added support for String Object

This commit is contained in:
rjbatista@gmail.com
2011-10-19 23:57:43 +00:00
parent e3075c02e2
commit 320ef7d54d
3 changed files with 18 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
Version 1.3.0
- added support for String Object;
- added support for removing leading zeros in displaying numbers.
Version 1.2.0
@@ -12,4 +13,4 @@ Version 1.1.0
Version 1.0.0
- initial Release.
- initial release.

View File

@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "WProgram.h"
#include "TM1638.h"
#include "String.h"
TM1638::TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay, byte intensity)
{
@@ -121,6 +122,19 @@ void TM1638::setDisplayToString(const char* string, const byte font[])
}
}
void TM1638::setDisplayToString(const String string, const byte font[])
{
int stringLength = string.length();
for (int i = 0; i < 8; i++) {
if (i < stringLength) {
sendData(i << 1, font[string.charAt(i) - 32]);
} else {
sendData(i << 1, 0);
}
}
}
void TM1638::setLED(byte color, byte pos)
{
sendData((pos << 1) + 1, color);

View File

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