Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cde2c670b | ||
|
|
b32993401f | ||
|
|
bb28428a44 | ||
|
|
cff5d047bf | ||
|
|
eb4538e162 |
@@ -1,3 +1,12 @@
|
|||||||
|
Version 1.6.0
|
||||||
|
|
||||||
|
- ISSUE #10: Support for starting position on setDisplayToString() methods.
|
||||||
|
WARNING: setDisplayToString methods have changed prototype and are incompatible with code compiled for 1.5.x (if you specified a custom font)
|
||||||
|
|
||||||
|
Version 1.5.2
|
||||||
|
|
||||||
|
- ISSUE #9: Backwards compatibility with previous Arduino IDE.
|
||||||
|
|
||||||
Version 1.5.1
|
Version 1.5.1
|
||||||
|
|
||||||
- ISSUE #7: New character data in default font for '*';
|
- ISSUE #7: New character data in default font for '*';
|
||||||
|
|||||||
23
TM1638.cpp
23
TM1638.cpp
@@ -49,11 +49,6 @@ TM1638::TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisp
|
|||||||
digitalWrite(strobePin, HIGH);
|
digitalWrite(strobePin, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
TM1638::~TM1638()
|
|
||||||
{
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
void TM1638::setupDisplay(boolean active, byte intensity)
|
void TM1638::setupDisplay(boolean active, byte intensity)
|
||||||
{
|
{
|
||||||
sendCommand(0x80 | (active ? 8 : 0) | min(7, intensity));
|
sendCommand(0x80 | (active ? 8 : 0) | min(7, intensity));
|
||||||
@@ -129,22 +124,26 @@ void TM1638::clearDisplay()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TM1638::setDisplayToString(const char* string, const byte dots, const byte font[])
|
void TM1638::setDisplayToString(const char* string, const byte dots, const byte pos, const byte font[])
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8 - pos; i++) {
|
||||||
sendChar(i, font[string[i] - 32], dots & (1 << (7 - i)));
|
if (string[i] != '\0') {
|
||||||
|
sendChar(i + pos, font[string[i] - 32], dots & (1 << (7 - i)));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TM1638::setDisplayToString(const String string, const byte dots, const byte font[])
|
void TM1638::setDisplayToString(const String string, const byte dots, const byte pos, const byte font[])
|
||||||
{
|
{
|
||||||
int stringLength = string.length();
|
int stringLength = string.length();
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8 - pos; i++) {
|
||||||
if (i < stringLength) {
|
if (i < stringLength) {
|
||||||
sendChar(i, font[string.charAt(i) - 32], dots & (1 << (7 - i)));
|
sendChar(i + pos, font[string.charAt(i) - 32], dots & (1 << (7 - i)));
|
||||||
} else {
|
} else {
|
||||||
sendChar(i, 0, dots & (1 << (7 - i)));
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
TM1638.h
7
TM1638.h
@@ -35,7 +35,6 @@ class TM1638
|
|||||||
public:
|
public:
|
||||||
/** Instantiate a tm1638 module specifying the display state, the starting intensity (0-7) data, clock and stobe pins. */
|
/** Instantiate a tm1638 module specifying the display state, the starting intensity (0-7) data, clock and stobe pins. */
|
||||||
TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay = true, byte intensity = 7);
|
TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay = true, byte intensity = 7);
|
||||||
virtual ~TM1638();
|
|
||||||
|
|
||||||
/** Set the display (segments and LEDs) active or off and intensity (range from 0-7). */
|
/** Set the display (segments and LEDs) active or off and intensity (range from 0-7). */
|
||||||
void setupDisplay(boolean active, byte intensity);
|
void setupDisplay(boolean active, byte intensity);
|
||||||
@@ -61,9 +60,11 @@ 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 dots = 0, const byte font[] = FONT_DEFAULT);
|
void setDisplayToString(const char* string, const byte dots = 0, const byte pos = 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 dots = 0, const byte font[] = FONT_DEFAULT);
|
void setDisplayToString(String string, const byte dots = 0, const byte pos = 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) */
|
||||||
virtual void setLED(byte color, byte pos);
|
virtual void setLED(byte color, byte pos);
|
||||||
|
|||||||
Reference in New Issue
Block a user