Skip to content

Commit

Permalink
Add dots settings for showString()
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Aug 24, 2021
1 parent 0a4ae60 commit d91f9c2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
10 changes: 8 additions & 2 deletions TM1637TinyDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void TM1637TinyDisplay::showNumberBaseEx(int8_t base, uint16_t num, uint8_t dots
setSegments(digits, length, pos);
}

void TM1637TinyDisplay::showString(const char s[], uint8_t length, uint8_t pos)
void TM1637TinyDisplay::showString(const char s[], uint8_t length, uint8_t pos, uint8_t dots = 0)
{
// digits[MAXDIGITS] output array to render
memset(digits,0,sizeof(digits));
Expand All @@ -362,6 +362,9 @@ void TM1637TinyDisplay::showString(const char s[], uint8_t length, uint8_t pos)
for (int x = 0; x < strlen(s); x++) {
digits[x] = encodeASCII(s[x]);
}
if(dots != 0) {
showDots(dots, digits);
}
setSegments(digits, length, pos);
}
// Scrolling Display
Expand Down Expand Up @@ -400,7 +403,7 @@ void TM1637TinyDisplay::showString(const char s[], uint8_t length, uint8_t pos)
}
}

void TM1637TinyDisplay::showString_P(const char s[], uint8_t length, uint8_t pos)
void TM1637TinyDisplay::showString_P(const char s[], uint8_t length, uint8_t pos, uint8_t dots = 0)
{
// digits[MAXDIGITS] output array to render
memset(digits,0,sizeof(digits));
Expand All @@ -410,6 +413,9 @@ void TM1637TinyDisplay::showString_P(const char s[], uint8_t length, uint8_t pos
for (int x = 0; x < strlen_P(s); x++) {
digits[x] = encodeASCII(pgm_read_byte(&s[x]));
}
if(dots != 0) {
showDots(dots, digits);
}
setSegments(digits, length, pos);
}
else {
Expand Down
32 changes: 28 additions & 4 deletions TM1637TinyDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,20 @@ class TM1637TinyDisplay {
//! @param scrollDelay The delay, in microseconds to wait before scrolling to next frame
//! @param length The number of digits to set.
//! @param pos The position of the most significant digit (0 - leftmost, 3 - rightmost)
//! The _P function is for reading PROGMEM read-only flash memory space instead of RAM
void showString(const char s[], uint8_t length = MAXDIGITS, uint8_t pos = 0);
//! @param dots Dot/Colon enable. The argument is a bitmask, with each bit corresponding to a dot
//! between the digits (or colon mark, as implemented by each module). i.e.
//! For displays with dots between each digit:
//! * 0.000 (0b10000000)
//! * 00.00 (0b01000000)
//! * 000.0 (0b00100000)
//! * 0000. (0b00010000)
//! * 0.0.0.0 (0b11100000)
//! For displays with just a colon:
//! * 00:00 (0b01000000)
//! For displays with dots and colons colon:
//! * 0.0:0.0 (0b11100000)
//! See showString_P function for reading PROGMEM read-only flash memory space instead of RAM
void showString(const char s[], uint8_t length = MAXDIGITS, uint8_t pos = 0, uint8_t dots = 0);

//! Display a string (PROGMEM space)
//!
Expand All @@ -282,8 +294,20 @@ class TM1637TinyDisplay {
//! @param scrollDelay The delay, in microseconds to wait before scrolling to next frame
//! @param length The number of digits to set.
//! @param pos The position of the most significant digit (0 - leftmost, 3 - rightmost)
//! The _P function is for reading PROGMEM read-only flash memory space instead of RAM
void showString_P(const char s[], uint8_t length = MAXDIGITS, uint8_t pos = 0);
//! @param dots Dot/Colon enable. The argument is a bitmask, with each bit corresponding to a dot
//! between the digits (or colon mark, as implemented by each module). i.e.
//! For displays with dots between each digit:
//! * 0.000 (0b10000000)
//! * 00.00 (0b01000000)
//! * 000.0 (0b00100000)
//! * 0000. (0b00010000)
//! * 0.0.0.0 (0b11100000)
//! For displays with just a colon:
//! * 00:00 (0b01000000)
//! For displays with dots and colons colon:
//! * 0.0:0.0 (0b11100000)
//! This function is for reading PROGMEM read-only flash memory space instead of RAM
void showString_P(const char s[], uint8_t length = MAXDIGITS, uint8_t pos = 0, , uint8_t dots = 0);

//! Display a Level Indicator (both orientations)
//!
Expand Down

0 comments on commit d91f9c2

Please sign in to comment.