Compare commits
1 Commits
80f687aff6
...
v2.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
082d20c562 |
18
CHANGES.txt
18
CHANGES.txt
@@ -1,21 +1,3 @@
|
||||
Version 2.1.3
|
||||
|
||||
- ISSUE #26: Added a define TM1638_COLOR_NONE for clarity when clearing a single LED.
|
||||
|
||||
Version 2.1.2
|
||||
|
||||
- ISSUE #22: Corrected setDisplayDigit repeatedly with the dot set to true;
|
||||
- ISSUE #24: Correction on setDisplayToDecNumber bug (thanks to hbx3485).
|
||||
|
||||
Version 2.1.1
|
||||
|
||||
- ISSUE #21: Problems on clearDisplay and setupDisplay.
|
||||
|
||||
Version 2.1.0
|
||||
|
||||
- ISSUE #20: Support for negative decimal numbers;
|
||||
- ISSUE #19: Corrected setDisplayToString dot bug.
|
||||
|
||||
Version 2.0.1
|
||||
|
||||
- ISSUE #15: Backwards compatibility with previous Arduino IDE (pure virtual functions were not supported);
|
||||
|
||||
27
TM1638.cpp
27
TM1638.cpp
@@ -44,18 +44,18 @@ void TM1638::setDisplayToHexNumber(unsigned long number, byte dots, boolean lead
|
||||
}
|
||||
}
|
||||
|
||||
void TM1638::setDisplayToDecNumberAt(unsigned long number, byte dots, byte startingPos, boolean leadingZeros,
|
||||
void TM1638::setDisplayToDecNumber(unsigned long number, byte dots, boolean leadingZeros,
|
||||
const byte numberFont[])
|
||||
{
|
||||
if (number > 99999999L) {
|
||||
setDisplayToError();
|
||||
} else {
|
||||
for (int i = 0; i < displays - startingPos; i++) {
|
||||
for (int i = 0; i < displays; i++) {
|
||||
if (number != 0) {
|
||||
setDisplayDigit(number % 10, displays - i - 1, (dots & (1 << i)) != 0, numberFont);
|
||||
number /= 10;
|
||||
} else {
|
||||
if (leadingZeros) {
|
||||
if (leadingZeros) {
|
||||
setDisplayDigit(0, displays - i - 1, (dots & (1 << i)) != 0, numberFont);
|
||||
} else {
|
||||
clearDisplayDigit(displays - i - 1, (dots & (1 << i)) != 0);
|
||||
@@ -65,27 +65,6 @@ void TM1638::setDisplayToDecNumberAt(unsigned long number, byte dots, byte start
|
||||
}
|
||||
}
|
||||
|
||||
void TM1638::setDisplayToDecNumber(unsigned long number, byte dots, boolean leadingZeros,
|
||||
const byte numberFont[])
|
||||
{
|
||||
setDisplayToDecNumberAt(number, dots, 0, leadingZeros, numberFont);
|
||||
}
|
||||
|
||||
void TM1638::setDisplayToSignedDecNumber(signed long number, byte dots, boolean leadingZeros,
|
||||
const byte numberFont[])
|
||||
{
|
||||
if (number >= 0) {
|
||||
setDisplayToDecNumberAt(number, dots, 0, leadingZeros, numberFont);
|
||||
} else {
|
||||
if (-number > 9999999L) {
|
||||
setDisplayToError();
|
||||
} else {
|
||||
setDisplayToDecNumberAt(-number, dots, 1, leadingZeros, numberFont);
|
||||
sendChar(0, MINUS, (dots & (0x80)) != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TM1638::setDisplayToBinNumber(byte number, byte dots, const byte numberFont[])
|
||||
{
|
||||
for (int i = 0; i < displays; i++) {
|
||||
|
||||
6
TM1638.h
6
TM1638.h
@@ -28,7 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "TM16XX.h"
|
||||
#include "TM16XXFonts.h"
|
||||
|
||||
#define TM1638_COLOR_NONE 0
|
||||
#define TM1638_COLOR_RED 1
|
||||
#define TM1638_COLOR_GREEN 2
|
||||
|
||||
@@ -44,9 +43,6 @@ class TM1638 : public TM16XX
|
||||
/** Set the display to a unsigned decimal number (with or without leading zeros) */
|
||||
void setDisplayToDecNumber(unsigned long number, byte dots, boolean leadingZeros = true,
|
||||
const byte numberFont[] = NUMBER_FONT);
|
||||
/** Set the display to a signed decimal number (with or without leading zeros) */
|
||||
void setDisplayToSignedDecNumber(signed long number, byte dots, boolean leadingZeros = true,
|
||||
const byte numberFont[] = NUMBER_FONT);
|
||||
/** Set the display to a unsigned binary number */
|
||||
void setDisplayToBinNumber(byte number, byte dots,
|
||||
const byte numberFont[] = NUMBER_FONT);
|
||||
@@ -61,8 +57,6 @@ class TM1638 : public TM16XX
|
||||
|
||||
protected:
|
||||
virtual void sendChar(byte pos, byte data, boolean dot);
|
||||
void setDisplayToDecNumberAt(unsigned long number, byte dots, byte startingPos,
|
||||
boolean leadingZeros, const byte numberFont[]);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
16
TM1640.cpp
16
TM1640.cpp
@@ -35,20 +35,4 @@ TM1640::TM1640(byte dataPin, byte clockPin, boolean activateDisplay, byte intens
|
||||
void TM1640::sendChar(byte pos, byte data, boolean dot)
|
||||
{
|
||||
sendData(pos, data | (dot ? 0b10000000 : 0));
|
||||
|
||||
// necessary for the TM1640
|
||||
digitalWrite(strobePin, LOW);
|
||||
digitalWrite(clockPin, LOW);
|
||||
digitalWrite(clockPin, HIGH);
|
||||
digitalWrite(strobePin, HIGH);
|
||||
}
|
||||
|
||||
void TM1640::clearDisplay()
|
||||
{
|
||||
digitalWrite(strobePin, LOW);
|
||||
send(0xC0);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
send(0x00);
|
||||
}
|
||||
digitalWrite(strobePin, HIGH);
|
||||
}
|
||||
|
||||
2
TM1640.h
2
TM1640.h
@@ -33,8 +33,6 @@ class TM1640 : public TM16XX
|
||||
public:
|
||||
/** Instantiate a tm1640 module specifying the display state, the starting intensity (0-7) data and clock pins. */
|
||||
TM1640(byte dataPin, byte clockPin, boolean activateDisplay = true, byte intensity = 7);
|
||||
/** Clear the display */
|
||||
virtual void clearDisplay();
|
||||
|
||||
protected:
|
||||
virtual void sendChar(byte pos, byte data, boolean dot);
|
||||
|
||||
10
TM16XX.cpp
10
TM16XX.cpp
@@ -54,12 +54,6 @@ TM16XX::TM16XX(byte dataPin, byte clockPin, byte strobePin, byte displays, boole
|
||||
void TM16XX::setupDisplay(boolean active, byte intensity)
|
||||
{
|
||||
sendCommand(0x80 | (active ? 8 : 0) | min(7, intensity));
|
||||
|
||||
// necessary for the TM1640
|
||||
digitalWrite(strobePin, LOW);
|
||||
digitalWrite(clockPin, LOW);
|
||||
digitalWrite(clockPin, HIGH);
|
||||
digitalWrite(strobePin, HIGH);
|
||||
}
|
||||
|
||||
void TM16XX::setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[])
|
||||
@@ -99,7 +93,7 @@ void TM16XX::setDisplayToString(const char* string, const word dots, const byte
|
||||
{
|
||||
for (int i = 0; i < displays - pos; i++) {
|
||||
if (string[i] != '\0') {
|
||||
sendChar(i + pos, font[string[i] - 32], (dots & (1 << (displays - i - 1))) != 0);
|
||||
sendChar(i + pos, font[string[i] - 32], dots & (1 << (displays - i - 1)) != 0);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -112,7 +106,7 @@ void TM16XX::setDisplayToString(const String string, const word dots, const byte
|
||||
|
||||
for (int i = 0; i < displays - pos; i++) {
|
||||
if (i < stringLength) {
|
||||
sendChar(i + pos, font[string.charAt(i) - 32], (dots & (1 << (displays - i - 1))) != 0);
|
||||
sendChar(i + pos, font[string.charAt(i) - 32], dots & (1 << (displays - i - 1)) != 0);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -50,8 +50,6 @@ const byte NUMBER_FONT[] = {
|
||||
0b01110001 // F
|
||||
};
|
||||
|
||||
const byte MINUS = 0b01000000;
|
||||
|
||||
// definition for error
|
||||
const byte ERROR_DATA[] = {
|
||||
0b01111001, // E
|
||||
|
||||
Reference in New Issue
Block a user