Compare commits
No commits in common. "421b4e106800e98c9f55d04feee88500881be9db" and "ba3ccece6fe30eb131a132ea5a3bcf411c81325e" have entirely different histories.
421b4e1068
...
ba3ccece6f
|
@ -26,7 +26,7 @@ private:
|
||||||
|
|
||||||
//buffer is 16 bit because of 16 Rows
|
//buffer is 16 bit because of 16 Rows
|
||||||
uint16_t frontBuffer[COLUMNS]; //1 is bright dot / set dot. 0 is black / cleared
|
uint16_t frontBuffer[COLUMNS]; //1 is bright dot / set dot. 0 is black / cleared
|
||||||
uint16_t backBuffer[COLUMNS]; //least significant bit is bottom dot.
|
uint16_t backBuffer[COLUMNS];
|
||||||
|
|
||||||
bool flag_updating; //when true, display flip is in progress. frontBuffer does not match backBuffer
|
bool flag_updating; //when true, display flip is in progress. frontBuffer does not match backBuffer
|
||||||
bool flag_redraw; //when set true, settings for updating are overwritten such that all dots are cleared and set
|
bool flag_redraw; //when set true, settings for updating are overwritten such that all dots are cleared and set
|
||||||
|
@ -63,8 +63,6 @@ public:
|
||||||
void setBuffer_byString(String data,String& error);
|
void setBuffer_byString(String data,String& error);
|
||||||
void setBuffer_byInt(String data,String& error);
|
void setBuffer_byInt(String data,String& error);
|
||||||
|
|
||||||
void addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset);
|
|
||||||
|
|
||||||
void setBuffer_Image1();
|
void setBuffer_Image1();
|
||||||
void setBuffer_Image2();
|
void setBuffer_Image2();
|
||||||
void setBuffer_Image3();
|
void setBuffer_Image3();
|
||||||
|
|
|
@ -144,9 +144,8 @@ bool Flipdot::HBridgeOK() {
|
||||||
void Flipdot::shiftDataRow() { //send out all data to shift registers
|
void Flipdot::shiftDataRow() { //send out all data to shift registers
|
||||||
|
|
||||||
//select Rows via shift registers on own controller board
|
//select Rows via shift registers on own controller board
|
||||||
//LSBFIRST= LSB is QH, bit 8 is QA. //upper byte
|
shiftOutSlow(PIN_SR_DATA, PIN_SR_CLK, LSBFIRST, row&0xff); //lower byte
|
||||||
shiftOutSlow(PIN_SR_DATA, PIN_SR_CLK, MSBFIRST, row>>8); //MSBFIRST= LSB is QH, bit 8 is QA
|
shiftOutSlow(PIN_SR_DATA, PIN_SR_CLK, LSBFIRST, row>>8); //LSBFIRST= LSB is QH, bit 8 is QA. //upper byte
|
||||||
shiftOutSlow(PIN_SR_DATA, PIN_SR_CLK, MSBFIRST, row&0xff); //lower byte
|
|
||||||
digitalWrite(PIN_SR_LATCH, HIGH);
|
digitalWrite(PIN_SR_LATCH, HIGH);
|
||||||
delayMicroseconds(MICROS_SHIFT_LATCH);
|
delayMicroseconds(MICROS_SHIFT_LATCH);
|
||||||
digitalWrite(PIN_SR_LATCH, LOW);
|
digitalWrite(PIN_SR_LATCH, LOW);
|
||||||
|
@ -170,7 +169,7 @@ void Flipdot::resetColumns() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flipdot::setRow(uint16_t _row){
|
void Flipdot::setRow(uint16_t _row){
|
||||||
row=_row; //data for one column
|
row=_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Flipdot::getRow() {
|
uint16_t Flipdot::getRow() {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
|
||||||
#include "fonts.h"
|
|
||||||
|
|
||||||
Image::Image()
|
Image::Image()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::serialPrintInt(uint16_t source)
|
void Image::serialPrintInt(uint16_t source)
|
||||||
|
@ -45,24 +46,6 @@ void Image::setBuffer_solid(bool set)
|
||||||
flag_updating=true; //make update run
|
flag_updating=true; //make update run
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset)
|
|
||||||
{
|
|
||||||
uint8_t bufferxpos=xoffset;
|
|
||||||
for (uint8_t textpos=0;textpos<text.length();textpos++){
|
|
||||||
|
|
||||||
char currentchar=text.charAt(textpos);
|
|
||||||
Serial.print("Current Char "); Serial.print((uint8_t)currentchar); Serial.print(":"); Serial.println(currentchar);
|
|
||||||
|
|
||||||
for (uint8_t x=0;x<6;x++) {
|
|
||||||
uint16_t addBuffer=(font_minecraftia[(uint8_t)currentchar-font_offset][x]>>yoffset);
|
|
||||||
backBuffer[bufferxpos]|= addBuffer;
|
|
||||||
Serial.print("Buffer at "); Serial.print(bufferxpos); Serial.print(" add ");Serial.print(addBuffer,2); Serial.print(" result="); Serial.println(backBuffer[bufferxpos],2);
|
|
||||||
bufferxpos++; //TODO: do not increment when font column is empty
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Serial.println("Finished Text");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Image::setBuffer_Image1() //Bumblebee
|
void Image::setBuffer_Image1() //Bumblebee
|
||||||
{
|
{
|
||||||
|
@ -1056,6 +1039,9 @@ void Image::loop_drawClearTest() {
|
||||||
init=false;
|
init=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -220,9 +220,6 @@ bool presetHandler(const HomieRange& range, const String& value) {
|
||||||
Homie.getLogger() << "Preset is Image8" << endl;
|
Homie.getLogger() << "Preset is Image8" << endl;
|
||||||
}else if(value == "random"){
|
}else if(value == "random"){
|
||||||
flip.setBuffer_random(50);
|
flip.setBuffer_random(50);
|
||||||
}else if(value == "text") {
|
|
||||||
flip.setBuffer_solid(0);
|
|
||||||
flip.addBuffer_text("Test",0,0);
|
|
||||||
}else{
|
}else{
|
||||||
error="preset \""+value+"\" not found";
|
error="preset \""+value+"\" not found";
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
import pygame
|
|
||||||
|
|
||||||
pygame.init()
|
|
||||||
screen = pygame.display.set_mode((640, 480))
|
|
||||||
clock = pygame.time.Clock()
|
|
||||||
done = False
|
|
||||||
|
|
||||||
pixelsize=8
|
|
||||||
|
|
||||||
#font = pygame.font.SysFont("comicsansms", 72)
|
|
||||||
font = pygame.font.Font("Minecraftia-Regular.ttf", 8*pixelsize);
|
|
||||||
|
|
||||||
pixelsW=6
|
|
||||||
pixelsH=8
|
|
||||||
|
|
||||||
asciioffset=33
|
|
||||||
asciiend=126
|
|
||||||
ascii = asciioffset
|
|
||||||
|
|
||||||
fontname="font_minecraftia"
|
|
||||||
|
|
||||||
|
|
||||||
file = open("output.txt", "w") # write mode
|
|
||||||
|
|
||||||
file.write("uint8_t font_offset="+str(asciioffset)+";\n");
|
|
||||||
|
|
||||||
#file.write("uint8_t "+fontname+"["+str(asciiend-asciioffset+1)+"]["+str(pixelsW)+"];\n")
|
|
||||||
file.write("uint8_t "+fontname+"["+str(asciiend-asciioffset+1)+"]["+str(pixelsW)+"]= {\n")
|
|
||||||
|
|
||||||
while not done:
|
|
||||||
for event in pygame.event.get():
|
|
||||||
if event.type == pygame.QUIT:
|
|
||||||
done = True
|
|
||||||
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
|
||||||
done = True
|
|
||||||
|
|
||||||
screen.fill((255, 255, 255))
|
|
||||||
|
|
||||||
for y in range(pixelsH):
|
|
||||||
for x in range(pixelsW):
|
|
||||||
color=(250,250,250)
|
|
||||||
if (x+y)%2==0:
|
|
||||||
color=(200,200,200)
|
|
||||||
pygame.draw.rect(screen, color, pygame.Rect(pixelsize*x, pixelsize*y, pixelsize, pixelsize))
|
|
||||||
|
|
||||||
text = font.render(chr(ascii), True, (0, 0, 0))
|
|
||||||
screen.blit(text,(0,-pixelsize*2))
|
|
||||||
print("ascii="+str(ascii)+" char="+chr(ascii))
|
|
||||||
|
|
||||||
'''
|
|
||||||
uint16_t font[COLUMNS];
|
|
||||||
font[ascii][column]=0b00000000;
|
|
||||||
|
|
||||||
int a[2][3] = {
|
|
||||||
{0, 2, 1} , /* row at index 0 */
|
|
||||||
{4, 3, 7} , /* row at index 1 */
|
|
||||||
};
|
|
||||||
'''
|
|
||||||
|
|
||||||
file.write("{")
|
|
||||||
for x in range(pixelsW):
|
|
||||||
int8number=0
|
|
||||||
string8=""
|
|
||||||
for y in range(pixelsH):
|
|
||||||
readcolor = screen.get_at(((int)(pixelsize*x+pixelsize/2),(int)(pixelsize*y+pixelsize/2)))
|
|
||||||
if (readcolor==(0,0,0)):
|
|
||||||
int8number+=pow(2,y)
|
|
||||||
string8+='1'
|
|
||||||
else:
|
|
||||||
string8+='0'
|
|
||||||
|
|
||||||
#file.write(fontname+"["+str(ascii-asciioffset)+"]["+str(x)+"]=0b"+string8+";\n")
|
|
||||||
file.write(str(int8number))
|
|
||||||
if (x<pixelsW-1):
|
|
||||||
file.write(",")
|
|
||||||
|
|
||||||
|
|
||||||
comment_character=chr(ascii)
|
|
||||||
if comment_character=='\\':
|
|
||||||
comment_character="Backslash"
|
|
||||||
|
|
||||||
file.write("}, // "+str(ascii)+"="+comment_character+"\n")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ascii+=1
|
|
||||||
if (ascii>asciiend):
|
|
||||||
done=True
|
|
||||||
|
|
||||||
pygame.display.flip()
|
|
||||||
clock.tick(30)
|
|
||||||
|
|
||||||
file.write("};")
|
|
||||||
file.close()
|
|
Loading…
Reference in New Issue