add text handler

This commit is contained in:
interfisch 2023-11-25 14:31:07 +01:00
parent eb1bbd6f74
commit 2c44f2aeb4
4 changed files with 156 additions and 372 deletions

View File

@ -65,14 +65,11 @@ public:
void addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset);
void setBuffer_Image1();
void setBuffer_Image2();
void setBuffer_Image3();
void setBuffer_Image4();
void setBuffer_Image5();
void setBuffer_Image6();
void setBuffer_Image7();
void setBuffer_Image8();
void setBuffer_Preset_Bumblebee();
void setBuffer_Preset_CTDO();
void setBuffer_Preset_Datamatrixctdo();
void setBuffer_Preset_1337();
void setBuffer_Preset_1359();
void loop_testDots();

View File

@ -54,7 +54,12 @@ void Image::addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset)
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);
uint16_t addBuffer;
if (currentchar==' ') { //space
addBuffer=0; //empty
}else{
addBuffer=( (uint16_t)( 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
@ -64,7 +69,7 @@ void Image::addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset)
}
void Image::setBuffer_Image1() //Bumblebee
void Image::setBuffer_Preset_Bumblebee() //Bumblebee
{
backBuffer[0]=0b1110000000000000;
backBuffer[1]=0b0000000000000000;
@ -147,7 +152,7 @@ backBuffer[74]=0b0000000000000000;
flag_updating=true; //make update run
}
void Image::setBuffer_Image2() //CTDO
void Image::setBuffer_Preset_CTDO() //CTDO
{
backBuffer[0]=0b0000000000000000;
backBuffer[1]=0b0000000000000000;
@ -156,54 +161,54 @@ backBuffer[3]=0b0000000000000000;
backBuffer[4]=0b0000000000000000;
backBuffer[5]=0b0000000000000000;
backBuffer[6]=0b0000000000000000;
backBuffer[7]=0b0000011110000000;
backBuffer[8]=0b0011111111000000;
backBuffer[9]=0b0111111111100000;
backBuffer[10]=0b1111110111110000;
backBuffer[11]=0b1110000000111000;
backBuffer[12]=0b1110000000111100;
backBuffer[13]=0b1110000000111100;
backBuffer[14]=0b1110000001111000;
backBuffer[15]=0b1111000000110000;
backBuffer[16]=0b0110000000000000;
backBuffer[7]=0b0000000111100000;
backBuffer[8]=0b0000001111111100;
backBuffer[9]=0b0000011111111110;
backBuffer[10]=0b0000111110111111;
backBuffer[11]=0b0001110000000111;
backBuffer[12]=0b0011110000000111;
backBuffer[13]=0b0011110000000111;
backBuffer[14]=0b0001111000000111;
backBuffer[15]=0b0000110000001111;
backBuffer[16]=0b0000000000000110;
backBuffer[17]=0b0000000000000000;
backBuffer[18]=0b0000000000000000;
backBuffer[19]=0b0000000000000000;
backBuffer[20]=0b0000000000000000;
backBuffer[21]=0b0110000000000000;
backBuffer[22]=0b1111000000000000;
backBuffer[23]=0b1110000000000000;
backBuffer[24]=0b1110000000001100;
backBuffer[25]=0b1110000011111110;
backBuffer[26]=0b1111111111111110;
backBuffer[27]=0b1111111111111100;
backBuffer[28]=0b1111111111000000;
backBuffer[29]=0b1110000000000000;
backBuffer[30]=0b1110000000000000;
backBuffer[31]=0b1110000000000000;
backBuffer[32]=0b1111000000000000;
backBuffer[33]=0b0110000000000000;
backBuffer[21]=0b0000000000000110;
backBuffer[22]=0b0000000000001111;
backBuffer[23]=0b0000000000000111;
backBuffer[24]=0b0011000000000111;
backBuffer[25]=0b0111111100000111;
backBuffer[26]=0b0111111111111111;
backBuffer[27]=0b0011111111111111;
backBuffer[28]=0b0000001111111111;
backBuffer[29]=0b0000000000000111;
backBuffer[30]=0b0000000000000111;
backBuffer[31]=0b0000000000000111;
backBuffer[32]=0b0000000000001111;
backBuffer[33]=0b0000000000000110;
backBuffer[34]=0b0000000000000000;
backBuffer[35]=0b0000000000000000;
backBuffer[36]=0b0000000000000000;
backBuffer[37]=0b0000000000000000;
backBuffer[38]=0b0000000000000000;
backBuffer[39]=0b0110000000000000;
backBuffer[40]=0b1111000000011000;
backBuffer[41]=0b1111111111111100;
backBuffer[42]=0b1111111111111110;
backBuffer[43]=0b1111111111111110;
backBuffer[44]=0b1111000011111111;
backBuffer[45]=0b1111000000000111;
backBuffer[46]=0b1111000000000111;
backBuffer[47]=0b0111000000000111;
backBuffer[48]=0b0111000000000011;
backBuffer[49]=0b0111100000000111;
backBuffer[50]=0b0011100000011111;
backBuffer[51]=0b0001111111111110;
backBuffer[52]=0b0000111111111100;
backBuffer[53]=0b0000011111110000;
backBuffer[54]=0b0000001110000000;
backBuffer[39]=0b0000000000000110;
backBuffer[40]=0b0001100000001111;
backBuffer[41]=0b0011111111111111;
backBuffer[42]=0b0111111111111111;
backBuffer[43]=0b0111111111111111;
backBuffer[44]=0b1111111100001111;
backBuffer[45]=0b1110000000001111;
backBuffer[46]=0b1110000000001111;
backBuffer[47]=0b1110000000001110;
backBuffer[48]=0b1100000000001110;
backBuffer[49]=0b1110000000011110;
backBuffer[50]=0b1111100000011100;
backBuffer[51]=0b0111111111111000;
backBuffer[52]=0b0011111111110000;
backBuffer[53]=0b0000111111100000;
backBuffer[54]=0b0000000111000000;
backBuffer[55]=0b0000000000000000;
backBuffer[56]=0b0000000000000000;
backBuffer[57]=0b0000000000000000;
@ -211,12 +216,12 @@ backBuffer[58]=0b0000000000000000;
backBuffer[59]=0b0000000000000000;
backBuffer[60]=0b0000000000000000;
backBuffer[61]=0b0000001111000000;
backBuffer[62]=0b0000111111100000;
backBuffer[63]=0b0001111111110000;
backBuffer[62]=0b0000011111110000;
backBuffer[63]=0b0000111111111000;
backBuffer[64]=0b0001111111111000;
backBuffer[65]=0b0011110000111100;
backBuffer[66]=0b0011100000011100;
backBuffer[67]=0b0111110000011100;
backBuffer[67]=0b0011100000111110;
backBuffer[68]=0b0111100000011110;
backBuffer[69]=0b0011111001111100;
backBuffer[70]=0b0001111111111000;
@ -226,182 +231,18 @@ backBuffer[73]=0b0000000000000000;
backBuffer[74]=0b0000000000000000;
flag_updating=true; //make update run
}
void Image::setBuffer_Image3() //23:24
{
backBuffer[0]=0b1111111111111111;
backBuffer[1]=0b1111111111111111;
backBuffer[2]=0b1111111111111111;
backBuffer[3]=0b1111111111111111;
backBuffer[4]=0b1111111111111111;
backBuffer[5]=0b1111111111111111;
backBuffer[6]=0b1111111111111111;
backBuffer[7]=0b1111111111111111;
backBuffer[8]=0b1111111111111111;
backBuffer[9]=0b1111111111111111;
backBuffer[10]=0b1111111111111111;
backBuffer[11]=0b1111111111111111;
backBuffer[12]=0b1111111111111111;
backBuffer[13]=0b1111111111111111;
backBuffer[14]=0b1101111111000111;
backBuffer[15]=0b1101111110000111;
backBuffer[16]=0b1001111100000111;
backBuffer[17]=0b1001111000100111;
backBuffer[18]=0b1000110001100111;
backBuffer[19]=0b1100000011100111;
backBuffer[20]=0b1100000111100111;
backBuffer[21]=0b1111111111111111;
backBuffer[22]=0b1111111111111111;
backBuffer[23]=0b1111111111111111;
backBuffer[24]=0b1111111111101111;
backBuffer[25]=0b1101111111101111;
backBuffer[26]=0b1101100111100111;
backBuffer[27]=0b1001100111100111;
backBuffer[28]=0b1001100111100111;
backBuffer[29]=0b1001100011000111;
backBuffer[30]=0b1100000000001111;
backBuffer[31]=0b1100011000001111;
backBuffer[32]=0b1111111100111111;
backBuffer[33]=0b1111111111111111;
backBuffer[34]=0b1111111111111111;
backBuffer[35]=0b1111111111111111;
backBuffer[36]=0b1111000111000111;
backBuffer[37]=0b1111000111000111;
backBuffer[38]=0b1111111111111111;
backBuffer[39]=0b1111111111111111;
backBuffer[40]=0b1111111111111111;
backBuffer[41]=0b1111111111111111;
backBuffer[42]=0b1101111111000111;
backBuffer[43]=0b1101111110000111;
backBuffer[44]=0b1001111100000111;
backBuffer[45]=0b1001111000100111;
backBuffer[46]=0b1000110001100111;
backBuffer[47]=0b1100000011100111;
backBuffer[48]=0b1100000111100111;
backBuffer[49]=0b1111111111111111;
backBuffer[50]=0b1111111111111111;
backBuffer[51]=0b1111111111111111;
backBuffer[52]=0b1111111100011111;
backBuffer[53]=0b1111110000011111;
backBuffer[54]=0b1111000110011111;
backBuffer[55]=0b1110011110011111;
backBuffer[56]=0b1000111110011111;
backBuffer[57]=0b1000000000000111;
backBuffer[58]=0b1000000000000111;
backBuffer[59]=0b1111111110011111;
backBuffer[60]=0b1111111110011111;
backBuffer[61]=0b1111111111111111;
backBuffer[62]=0b1111111111111111;
backBuffer[63]=0b1111111111111111;
backBuffer[64]=0b1111111111111111;
backBuffer[65]=0b1111111111111111;
backBuffer[66]=0b1111111111111111;
backBuffer[67]=0b1111111111111111;
backBuffer[68]=0b1111111111111111;
backBuffer[69]=0b1111111111111111;
backBuffer[70]=0b1111111111111111;
backBuffer[71]=0b1111111111111111;
backBuffer[72]=0b1111111111111111;
backBuffer[73]=0b1111111111111111;
backBuffer[74]=0b1111111111111111;
flag_updating=true; //make update run
}
void Image::setBuffer_Image4() //Linux
{
backBuffer[0]=0b0000000000000000;
backBuffer[1]=0b0000000000000000;
backBuffer[2]=0b0000000000000000;
backBuffer[3]=0b0000000000000000;
backBuffer[4]=0b0000000000000000;
backBuffer[5]=0b0000000000000000;
backBuffer[6]=0b0000000011000000;
backBuffer[7]=0b0000011111100000;
backBuffer[8]=0b0011111111110000;
backBuffer[9]=0b0111111111110000;
backBuffer[10]=0b0111110011110000;
backBuffer[11]=0b0011000011110000;
backBuffer[12]=0b0000000011110000;
backBuffer[13]=0b0000000011110000;
backBuffer[14]=0b0000000001110000;
backBuffer[15]=0b0000000000100000;
backBuffer[16]=0b0000000000000000;
backBuffer[17]=0b0000000000000000;
backBuffer[18]=0b0000000000000000;
backBuffer[19]=0b0000000000011000;
backBuffer[20]=0b0000000001111100;
backBuffer[21]=0b0001000011111000;
backBuffer[22]=0b0011100111110000;
backBuffer[23]=0b0011100011000000;
backBuffer[24]=0b0001000000000000;
backBuffer[25]=0b0000000000000000;
backBuffer[26]=0b0000000000000000;
backBuffer[27]=0b0000000000000000;
backBuffer[28]=0b0000000000011100;
backBuffer[29]=0b0000000111111110;
backBuffer[30]=0b0000001111111110;
backBuffer[31]=0b0000000111111100;
backBuffer[32]=0b0000000111100000;
backBuffer[33]=0b0000000111000000;
backBuffer[34]=0b0000000111000000;
backBuffer[35]=0b0000000111000000;
backBuffer[36]=0b0000000111111000;
backBuffer[37]=0b0000000011111100;
backBuffer[38]=0b0000000001111110;
backBuffer[39]=0b0000000000011100;
backBuffer[40]=0b0000000000000000;
backBuffer[41]=0b0000000000000000;
backBuffer[42]=0b0000000000000000;
backBuffer[43]=0b0000001111110000;
backBuffer[44]=0b0000011111111000;
backBuffer[45]=0b0000011111111100;
backBuffer[46]=0b0000001100111100;
backBuffer[47]=0b0000000000111000;
backBuffer[48]=0b0000000000111000;
backBuffer[49]=0b0000000000111000;
backBuffer[50]=0b0000000001110000;
backBuffer[51]=0b0000000011110000;
backBuffer[52]=0b0000001111100000;
backBuffer[53]=0b0000011111000000;
backBuffer[54]=0b0000001100000000;
backBuffer[55]=0b0000000000001000;
backBuffer[56]=0b0000011000011100;
backBuffer[57]=0b0000111100011100;
backBuffer[58]=0b0000111100011100;
backBuffer[59]=0b0000011110111000;
backBuffer[60]=0b0000001111111000;
backBuffer[61]=0b0000000011110000;
backBuffer[62]=0b0000000011110000;
backBuffer[63]=0b0000000111110000;
backBuffer[64]=0b0000001111111000;
backBuffer[65]=0b0000011110111100;
backBuffer[66]=0b0000011100011110;
backBuffer[67]=0b0000001000001110;
backBuffer[68]=0b0000000000000100;
backBuffer[69]=0b0000000000000000;
backBuffer[70]=0b0000000000000000;
backBuffer[71]=0b0000000000000000;
backBuffer[72]=0b0000000000000000;
backBuffer[73]=0b0000000000000000;
backBuffer[74]=0b0000000000000000;
flag_updating=true; //make update run
}
void Image::setBuffer_Image5() //Datamatrix ctdo.de
void Image::setBuffer_Preset_Datamatrixctdo() //Datamatrix ctdo.de
{
backBuffer[0]=0b1111111111111111;
@ -480,14 +321,12 @@ backBuffer[72]=0b1111111111111111;
backBuffer[73]=0b1111111111111111;
backBuffer[74]=0b1111111111111111;
flag_updating=true; //make update run
}
void Image::setBuffer_Image6() //13:37
void Image::setBuffer_Preset_1337() //13:37
{
backBuffer[0]=0b1111111111111111;
backBuffer[1]=0b1111111111111111;
@ -565,15 +404,13 @@ backBuffer[72]=0b1111111111111111;
backBuffer[73]=0b1111111111111111;
backBuffer[74]=0b1111111111111111;
flag_updating=true; //make update run
}
void Image::setBuffer_Image7() //13:59
void Image::setBuffer_Preset_1359() //13:59
{
backBuffer[0]=0b1111111111111111;
backBuffer[0]=0b1111111111111111;
backBuffer[1]=0b1111111111111111;
backBuffer[2]=0b1111111111111111;
backBuffer[3]=0b1111111111111111;
@ -585,54 +422,54 @@ backBuffer[8]=0b1111111111111111;
backBuffer[9]=0b1111111111111111;
backBuffer[10]=0b1111111111111111;
backBuffer[11]=0b1111111111111111;
backBuffer[12]=0b1110011111110011;
backBuffer[13]=0b1110111111110011;
backBuffer[12]=0b1100111111100111;
backBuffer[13]=0b1100111111110111;
backBuffer[14]=0b1100111111110011;
backBuffer[15]=0b1100000000000011;
backBuffer[16]=0b1100000000000011;
backBuffer[17]=0b1100000000000011;
backBuffer[18]=0b1111111111110011;
backBuffer[19]=0b1111111111110011;
backBuffer[18]=0b1100111111111111;
backBuffer[19]=0b1100111111111111;
backBuffer[20]=0b1111111111111111;
backBuffer[21]=0b1111111111111111;
backBuffer[22]=0b1111111111111111;
backBuffer[23]=0b1111111111110111;
backBuffer[23]=0b1110111111111111;
backBuffer[24]=0b1110111111110111;
backBuffer[25]=0b1110111111110011;
backBuffer[25]=0b1100111111110111;
backBuffer[26]=0b1100111001110011;
backBuffer[27]=0b1100111001110011;
backBuffer[28]=0b1100111001110011;
backBuffer[29]=0b1110000000000111;
backBuffer[30]=0b1110000100000111;
backBuffer[31]=0b1111001110001111;
backBuffer[30]=0b1110000010000111;
backBuffer[31]=0b1111000111001111;
backBuffer[32]=0b1111111111111111;
backBuffer[33]=0b1111111111111111;
backBuffer[34]=0b1111111111111111;
backBuffer[35]=0b1111111111111111;
backBuffer[36]=0b1111100011100011;
backBuffer[37]=0b1111100011100011;
backBuffer[38]=0b1111100011100011;
backBuffer[36]=0b1100011100011111;
backBuffer[37]=0b1100011100011111;
backBuffer[38]=0b1100011100011111;
backBuffer[39]=0b1111111111111111;
backBuffer[40]=0b1111111111111111;
backBuffer[41]=0b1111111111111111;
backBuffer[42]=0b1111111111111111;
backBuffer[43]=0b1100000011110111;
backBuffer[44]=0b1100000011110111;
backBuffer[45]=0b1100110011110011;
backBuffer[46]=0b1100110011110011;
backBuffer[47]=0b1100110011110011;
backBuffer[48]=0b1100110001100111;
backBuffer[49]=0b1100111000000111;
backBuffer[50]=0b1111111100001111;
backBuffer[43]=0b1110111100000011;
backBuffer[44]=0b1110111100000011;
backBuffer[45]=0b1100111100110011;
backBuffer[46]=0b1100111100110011;
backBuffer[47]=0b1100111100110011;
backBuffer[48]=0b1110011000110011;
backBuffer[49]=0b1110000001110011;
backBuffer[50]=0b1111000011111111;
backBuffer[51]=0b1111111111111111;
backBuffer[52]=0b1111111111111111;
backBuffer[53]=0b1111111111111111;
backBuffer[54]=0b1111100011111111;
backBuffer[55]=0b1110000001110111;
backBuffer[56]=0b1110000001110111;
backBuffer[57]=0b1100111100110011;
backBuffer[58]=0b1100111100110011;
backBuffer[59]=0b1100111101110011;
backBuffer[54]=0b1111111100011111;
backBuffer[55]=0b1110111000000111;
backBuffer[56]=0b1110111000000111;
backBuffer[57]=0b1100110011110011;
backBuffer[58]=0b1100110011110011;
backBuffer[59]=0b1100111011110011;
backBuffer[60]=0b1110011001100111;
backBuffer[61]=0b1110000000000111;
backBuffer[62]=0b1111000000001111;
@ -648,91 +485,6 @@ backBuffer[71]=0b1111111111111111;
backBuffer[72]=0b1111111111111111;
backBuffer[73]=0b1111111111111111;
backBuffer[74]=0b1111111111111111;
flag_updating=true; //make update run
}
void Image::setBuffer_Image8() //14:00
{
backBuffer[0]=0b1111111111111111;
backBuffer[1]=0b1111111111111111;
backBuffer[2]=0b1111111111111111;
backBuffer[3]=0b1111111111111111;
backBuffer[4]=0b1111111111111111;
backBuffer[5]=0b1111111111111111;
backBuffer[6]=0b1111111111111111;
backBuffer[7]=0b1111111111111111;
backBuffer[8]=0b1111111111111111;
backBuffer[9]=0b1111111111111111;
backBuffer[10]=0b1111111111111111;
backBuffer[11]=0b1111111111111111;
backBuffer[12]=0b1110011111110011;
backBuffer[13]=0b1110111111110011;
backBuffer[14]=0b1100111111110011;
backBuffer[15]=0b1100000000000011;
backBuffer[16]=0b1100000000000011;
backBuffer[17]=0b1100000000000011;
backBuffer[18]=0b1111111111110011;
backBuffer[19]=0b1111111111110011;
backBuffer[20]=0b1111111111111111;
backBuffer[21]=0b1111111111111111;
backBuffer[22]=0b1111111111111111;
backBuffer[23]=0b1111111100011111;
backBuffer[24]=0b1111111000011111;
backBuffer[25]=0b1111100010011111;
backBuffer[26]=0b1111001110011111;
backBuffer[27]=0b1110011110011111;
backBuffer[28]=0b1100011110011111;
backBuffer[29]=0b1100000000000011;
backBuffer[30]=0b1100000000000011;
backBuffer[31]=0b1111111110011111;
backBuffer[32]=0b1111111110011111;
backBuffer[33]=0b1111111111111111;
backBuffer[34]=0b1111111111111111;
backBuffer[35]=0b1111111111111111;
backBuffer[36]=0b1111100011100011;
backBuffer[37]=0b1111100011100011;
backBuffer[38]=0b1111100011100011;
backBuffer[39]=0b1111111111111111;
backBuffer[40]=0b1111111111111111;
backBuffer[41]=0b1111111111111111;
backBuffer[42]=0b1111100000011111;
backBuffer[43]=0b1111000000001111;
backBuffer[44]=0b1110000000000111;
backBuffer[45]=0b1100111111110011;
backBuffer[46]=0b1100111111110011;
backBuffer[47]=0b1100111111110011;
backBuffer[48]=0b1110011111100111;
backBuffer[49]=0b1110000000000111;
backBuffer[50]=0b1111000000001111;
backBuffer[51]=0b1111110000111111;
backBuffer[52]=0b1111111111111111;
backBuffer[53]=0b1111111111111111;
backBuffer[54]=0b1111100000011111;
backBuffer[55]=0b1111000000001111;
backBuffer[56]=0b1110000000000111;
backBuffer[57]=0b1100111111110011;
backBuffer[58]=0b1100111111110011;
backBuffer[59]=0b1100111111110011;
backBuffer[60]=0b1110011111100111;
backBuffer[61]=0b1110000000000111;
backBuffer[62]=0b1111000000001111;
backBuffer[63]=0b1111110000111111;
backBuffer[64]=0b1111111111111111;
backBuffer[65]=0b1111111111111111;
backBuffer[66]=0b1111111111111111;
backBuffer[67]=0b1111111111111111;
backBuffer[68]=0b1111111111111111;
backBuffer[69]=0b1111111111111111;
backBuffer[70]=0b1111111111111111;
backBuffer[71]=0b1111111111111111;
backBuffer[72]=0b1111111111111111;
backBuffer[73]=0b1111111111111111;
backBuffer[74]=0b1111111111111111;
flag_updating=true; //make update run
}

View File

@ -2,7 +2,7 @@
#include <Homie.h>
HomieNode flipdotNode("display", "Display", "display");
HomieNode displayNode("display", "Display", "display");
HomieNode settingsNode("settings", "Settings", "settings");
HomieNode resultNode("result", "Result", "result");
@ -27,6 +27,7 @@ bool presetHandler(const HomieRange& range, const String& value);
bool orderHandler(const HomieRange& range, const String& value);
bool dataHandler(const HomieRange& range, const String& value);
bool controlHandler(const HomieRange& range, const String& value);
bool textHandler(const HomieRange& range, const String& value) ;
bool clearFirstHandler(const HomieRange& range, const String& value);
bool optimizeClearHandler(const HomieRange& range, const String& value);
@ -47,10 +48,11 @@ void setup() {
//Setup Homie
Homie_setFirmware("flipdot", "0.1.0");
flipdotNode.advertise("preset").settable(presetHandler);
flipdotNode.advertise("data").settable(dataHandler);
flipdotNode.advertise("order").settable(orderHandler);
flipdotNode.advertise("control").settable(controlHandler);
displayNode.advertise("preset").settable(presetHandler);
displayNode.advertise("data").settable(dataHandler);
displayNode.advertise("order").settable(orderHandler);
displayNode.advertise("control").settable(controlHandler);
displayNode.advertise("text").settable(textHandler);
settingsNode.advertise("clearfirst").settable(clearFirstHandler);
settingsNode.advertise("optimizeclear").settable(optimizeClearHandler);
settingsNode.advertise("optimizeset").settable(optimizeSetHandler);
@ -181,7 +183,7 @@ bool orderHandler(const HomieRange& range, const String& value) {
}else{
return false;
}
flipdotNode.setProperty("order").send(value);
displayNode.setProperty("order").send(value);
return true;
}
@ -194,41 +196,32 @@ bool presetHandler(const HomieRange& range, const String& value) {
}else if(value == "black"){
flip.setBuffer_solid(0);
Homie.getLogger() << "Preset is Black" << endl;
}else if(value == "image1"){
flip.setBuffer_Image1();
Homie.getLogger() << "Preset is Image1" << endl;
}else if(value == "image2"){
flip.setBuffer_Image2();
Homie.getLogger() << "Preset is Image2" << endl;
}else if(value == "image3"){
flip.setBuffer_Image3();
Homie.getLogger() << "Preset is Image3" << endl;
}else if(value == "image4"){
flip.setBuffer_Image4();
Homie.getLogger() << "Preset is Image4" << endl;
}else if(value == "image5"){
flip.setBuffer_Image5();
Homie.getLogger() << "Preset is Image5" << endl;
}else if(value == "image6"){
flip.setBuffer_Image6();
Homie.getLogger() << "Preset is Image6" << endl;
}else if(value == "image7"){
flip.setBuffer_Image7();
Homie.getLogger() << "Preset is Image7" << endl;
}else if(value == "image8"){
flip.setBuffer_Image8();
Homie.getLogger() << "Preset is Image8" << endl;
}else if(value == "bumblebee"){
flip.setBuffer_Preset_Bumblebee();
Homie.getLogger() << "Preset is bumblebee" << endl;
}else if(value == "ctdo"){
flip.setBuffer_Preset_CTDO();
Homie.getLogger() << "Preset is ctdo" << endl;
}else if(value == "datamatrixctdo"){
flip.setBuffer_Preset_Datamatrixctdo();
Homie.getLogger() << "Preset is datamatrixctdo" << endl;
}else if(value == "1337"){
flip.setBuffer_Preset_1337();
Homie.getLogger() << "Preset is 1337" << endl;
}else if(value == "1359"){
flip.setBuffer_Preset_1359();
Homie.getLogger() << "Preset is 1359" << endl;
}else if(value == "random"){
flip.setBuffer_random(50);
}else if(value == "text") {
}else if(value == "uptime") {
flip.setBuffer_solid(0);
flip.addBuffer_text("Test",0,0);
flip.addBuffer_text((String)(millis()/1000),0,0);
}else{
error="preset \""+value+"\" not found";
return false;
}
flipdotNode.setProperty("preset").send(value);
displayNode.setProperty("preset").send(value);
return true;
}
@ -332,7 +325,47 @@ bool controlHandler(const HomieRange& range, const String& value) {
return false;
}
flipdotNode.setProperty("control").send(value);
displayNode.setProperty("control").send(value);
return true;
}
bool textHandler(const HomieRange& range, const String& value) {
Serial.print("Text payload="); Serial.println(value);
uint8_t linebreakindex=value.indexOf("\n"); //search for "\n" in string. 255 if not found
Serial.print("Linebreakindex="); Serial.println(linebreakindex);
String row1=value.substring(0,flip.getW()/6);
String row2=value.substring(flip.getW()/6);
row2.trim(); //remove leading and trailing whitespaces
String overflow=row2.substring(flip.getW()/6); //save text that did not fit
row2=row2.substring(0,flip.getW()/6);
if (overflow.length()>0) {
error="Text overflow:"+overflow;
Serial.println("Text overflow");
}
Serial.print("Row1="); Serial.println(row1);
Serial.print("Row2="); Serial.println(row2);
flip.setBuffer_solid(0); //clear
if (row2.length()<=0){
Serial.println("Only one row");
flip.addBuffer_text(row1,0,4);
}else{
Serial.println("Two rows");
flip.addBuffer_text(row1,0,0);
flip.addBuffer_text(row2,0,8);
}
return true;
}

View File

@ -22,10 +22,12 @@ fontname="font_minecraftia"
file = open("output.txt", "w") # write mode
file.write("uint8_t font_offset="+str(asciioffset)+";\n");
file.write("const uint8_t font_width="+str(pixelsW)+";\n");
file.write("const 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")
file.write("const uint8_t "+fontname+"["+str(asciiend-asciioffset+1)+"]["+str(pixelsW)+"]= {\n")
while not done:
for event in pygame.event.get():