added support for String Object
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
Version 1.3.0
|
Version 1.3.0
|
||||||
|
|
||||||
|
- added support for String Object;
|
||||||
- added support for removing leading zeros in displaying numbers.
|
- added support for removing leading zeros in displaying numbers.
|
||||||
|
|
||||||
Version 1.2.0
|
Version 1.2.0
|
||||||
@@ -12,4 +13,4 @@ Version 1.1.0
|
|||||||
|
|
||||||
Version 1.0.0
|
Version 1.0.0
|
||||||
|
|
||||||
- initial Release.
|
- initial release.
|
||||||
|
|||||||
14
TM1638.cpp
14
TM1638.cpp
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#include "WProgram.h"
|
#include "WProgram.h"
|
||||||
#include "TM1638.h"
|
#include "TM1638.h"
|
||||||
|
#include "String.h"
|
||||||
|
|
||||||
TM1638::TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay, byte intensity)
|
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)
|
void TM1638::setLED(byte color, byte pos)
|
||||||
{
|
{
|
||||||
sendData((pos << 1) + 1, color);
|
sendData((pos << 1) + 1, color);
|
||||||
|
|||||||
2
TM1638.h
2
TM1638.h
@@ -52,6 +52,8 @@ class TM1638
|
|||||||
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 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) */
|
/** 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);
|
||||||
|
|||||||
Reference in New Issue
Block a user