diff --git a/examples/TM1650_example01/TM1650_example01.ino b/examples/TM1650_example01/TM1650_example01.ino index 65ebc03..6ca0108 100644 --- a/examples/TM1650_example01/TM1650_example01.ino +++ b/examples/TM1650_example01/TM1650_example01.ino @@ -77,9 +77,37 @@ void loop() } } - + d.displayString(" A"); + d.setPosition(0, SEG_A); + delay(1000); + d.displayString(" B"); + d.setPosition(0, SEG_B); + delay(1000); + d.displayString(" C"); + d.setPosition(0, SEG_C); + delay(1000); + d.displayString(" D"); + d.setPosition(0, SEG_D); + delay(1000); + d.displayString(" E"); + d.setPosition(0, SEG_E); + delay(1000); + d.displayString(" F"); + d.setPosition(0, SEG_F); + delay(1000); + d.displayString(" G"); + d.setPosition(0, SEG_G); + delay(1000); + d.displayString(" DP"); + d.setPosition(0, SEG_DP); + delay(1000); + + if (d.displayRunning("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz")) { + while (d.displayRunningShift()) delay(500); + } + delay(2000); } - + diff --git a/keywords.txt b/keywords.txt index 60bd352..04392bf 100644 --- a/keywords.txt +++ b/keywords.txt @@ -28,6 +28,7 @@ setPosition KEYWORD2 setDot KEYWORD2 getPosition KEYWORD2 getNumPositions KEYWORD2 +displayChar KEYWORD2 ####################################### # Constants (LITERAL1) diff --git a/src/TM1650.h b/src/TM1650.h index f164fa9..36cf80f 100644 --- a/src/TM1650.h +++ b/src/TM1650.h @@ -27,6 +27,8 @@ //#define TM1650_USE_PROGMEM +#define REPLACE_NON_EXISTING_CHARACTERS + #ifdef TM1650_USE_PROGMEM #if (defined(__AVR__)) #include @@ -49,6 +51,22 @@ #define TM1650_MIN_BRIGHT 0 #define TM1650_MAX_BRIGHT 7 +#define SEG_A 0b00000001 +#define SEG_B 0b00000010 +#define SEG_C 0b00000100 +#define SEG_D 0b00001000 +#define SEG_E 0b00010000 +#define SEG_F 0b00100000 +#define SEG_G 0b01000000 +#define SEG_DP 0b10000000 +// A +// --- +// F | | B +// -G- +// E | | C +// --- +// D . DP + #ifndef TM1650_USE_PROGMEM const byte TM1650_CDigits[128] { #else @@ -80,6 +98,7 @@ class TM1650 { void setBrightness(unsigned int aValue = TM1650_MAX_BRIGHT); void setBrightnessGradually(unsigned int aValue = TM1650_MAX_BRIGHT); inline unsigned int getBrightness() { return iBrightness; }; + void displayChar(char aString, int pos); void controlPosition(unsigned int aPos, byte aValue); void setPosition(unsigned int aPos, byte aValue); @@ -263,6 +282,16 @@ void TM1650::displayString(char *aString) iBuffer[i] = TM1650_CDigits[a]; #else iBuffer[i] = pgm_read_byte_near(TM1650_CDigits + a); +#endif +#ifdef REPLACE_NON_EXISTING_CHARACTERS + if(a=='m'||a=='M'){ + setPosition(i,SEG_E|SEG_F|SEG_A|SEG_B|SEG_C); + } else if(a=='k'||a=='K'){ + setPosition(i,SEG_E|SEG_F|SEG_G); + } else if(a=='i') { + setPosition(i,SEG_C); + } + else #endif if (a) { Wire.beginTransmission(TM1650_DISPLAY_BASE+i); @@ -275,6 +304,34 @@ void TM1650::displayString(char *aString) } } +/** Display a single character on the display + * aString = character array to be displayed + * i = digit position + * + * Internal buffer is updated as well + * Only first N positions of the string are displayed if + * the string is longer than the number of digits + @new + */ +void TM1650::displayChar(char aString, int i) +{ + if (!iActive) return; + if(i