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

@@ -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);