Support for specifying dots on setDisplayToString

This commit is contained in:
rjbatista@gmail.com
2011-11-14 17:41:12 +00:00
parent 51c24bfaee
commit 8cd887a567
3 changed files with 31 additions and 27 deletions

View File

@@ -1,3 +1,7 @@
- ISSUE #6: Support for specifying dots on setDisplayToString
WARNING: setDisplayToString methods have changed prototype and are incompatible with code compiled for 1.3.x (if you specified a custom font)
Version 1.3.2 Version 1.3.2
- ISSUE #5: Correction of string library import - ISSUE #5: Correction of string library import

View File

@@ -115,20 +115,20 @@ void TM1638::clearDisplay()
} }
} }
void TM1638::setDisplayToString(const char* string, const byte font[]) void TM1638::setDisplayToString(const char* string, const byte dots, const byte font[])
{ {
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
sendData(i << 1, font[string[i] - 32]); sendData(i << 1, font[string[i] - 32] | ((dots & (1 << i)) != 0 ? 0b10000000 : 0));
} }
} }
void TM1638::setDisplayToString(const String string, const byte font[]) void TM1638::setDisplayToString(const String string, const byte dots, const byte font[])
{ {
int stringLength = string.length(); int stringLength = string.length();
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if (i < stringLength) { if (i < stringLength) {
sendData(i << 1, font[string.charAt(i) - 32]); sendData(i << 1, font[string.charAt(i) - 32] | ((dots & (1 << i)) != 0 ? 0b10000000 : 0));
} else { } else {
sendData(i << 1, 0); sendData(i << 1, 0);
} }

View File

@@ -51,9 +51,9 @@ class TM1638
/** Clear the display */ /** Clear the display */
void clearDisplay(); void clearDisplay();
/** Set the display to the string (defaults to built in font) */ /** Set the display to the string (defaults to built in font) */
void setDisplayToString(const char* string, const byte font[] = FONT_DEFAULT); void setDisplayToString(const char* string, const byte dots = 0, const byte font[] = FONT_DEFAULT);
/** Set the display to the String (defaults to built in font) */ /** Set the display to the String (defaults to built in font) */
void setDisplayToString(String string, const byte font[] = FONT_DEFAULT); void setDisplayToString(String string, const byte dots = 0, const byte font[] = FONT_DEFAULT);
/** Set the LED at pos to color (TM1638_COLOR_RED, TM1638_COLOR_GREEN or both) */ /** Set the LED at pos to color (TM1638_COLOR_RED, TM1638_COLOR_GREEN or both) */
void setLED(byte color, byte pos); void setLED(byte color, byte pos);