Skip to content

Commit

Permalink
Added dots parameter to showString()
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Aug 24, 2021
1 parent d91f9c2 commit f329d3a
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 26 deletions.
9 changes: 9 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@
```python
display.showNumberDec(987654, 0b10101000, false); // Expect: 3.03.03.
display.showNumberDec(123456, 0b11111100, false); // Expect: 1.2.3.4.5.6.
```

## v.1.4.2
- Added dots parameter to showString() and showString_P() functions.
```python
// void showString(const char s[], uint8_t length = MAXDIGITS, uint8_t pos = 0, uint8_t dots = 0);

display.showString("HHSS",4,0,0b01000000); // Expect: HH:SS or HH.SS
display.showString("1234",4,0,0b01000000); // Expect: 12:34 or 12.34
```
2 changes: 1 addition & 1 deletion TM1637TinyDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class TM1637TinyDisplay {
//! 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);
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
10 changes: 8 additions & 2 deletions TM1637TinyDisplay6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void TM1637TinyDisplay6::showNumberBaseEx(int8_t base, uint32_t num, uint8_t dot
setSegments(digits, length, pos);
}

void TM1637TinyDisplay6::showString(const char s[], uint8_t length, uint8_t pos)
void TM1637TinyDisplay6::showString(const char s[], uint8_t length, uint8_t pos, uint8_t dots)
{
// digits[MAXDIGITS] output array to render
memset(digits,0,sizeof(digits));
Expand All @@ -372,6 +372,9 @@ void TM1637TinyDisplay6::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 @@ -410,7 +413,7 @@ void TM1637TinyDisplay6::showString(const char s[], uint8_t length, uint8_t pos)
}
}

void TM1637TinyDisplay6::showString_P(const char s[], uint8_t length, uint8_t pos)
void TM1637TinyDisplay6::showString_P(const char s[], uint8_t length, uint8_t pos, uint8_t dots)
{
// digits[MAXDIGITS] output array to render
memset(digits,0,sizeof(digits));
Expand All @@ -420,6 +423,9 @@ void TM1637TinyDisplay6::showString_P(const char s[], uint8_t length, uint8_t po
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
72 changes: 50 additions & 22 deletions TM1637TinyDisplay6.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,16 @@ class TM1637TinyDisplay6 {
//! @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)
//! * 00.0000 (0b01000000)
//! * 0.00000 (0b10000000)
//! * 00.0000 (0b01000000)
//! * 000.000 (0b00100000)
//! * 0000.00 (0b00010000)
//! * 00000.0 (0b00001000)
//! * 000000. (0b00000100)
//! * 00.00.00 (0b01010000)
//! For displays with just a colons:
//! * 00:00:00 (0b01010000)
//! @param leading_zero When true, leading zeros are displayed. Otherwise unnecessary digits are
//! blank. NOTE: leading zero is not supported with negative numbers.
//! @param length The number of digits to set. The user must ensure that the number to be shown
Expand All @@ -236,15 +237,16 @@ class TM1637TinyDisplay6 {
//! @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)
//! * 00.0000 (0b01000000)
//! * 0.00000 (0b10000000)
//! * 00.0000 (0b01000000)
//! * 000.000 (0b00100000)
//! * 0000.00 (0b00010000)
//! * 00000.0 (0b00001000)
//! * 000000. (0b00000100)
//! * 00.00.00 (0b01010000)
//! For displays with just a colons:
//! * 00:00:00 (0b01010000)
//! @param leading_zero When true, leading zeros are displayed. Otherwise unnecessary digits are
//! blank
//! @param length The number of digits to set. The user must ensure that the number to be shown
Expand Down Expand Up @@ -272,8 +274,21 @@ class TM1637TinyDisplay6 {
//! @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:
//! * 00.0000 (0b01000000)
//! * 0.00000 (0b10000000)
//! * 00.0000 (0b01000000)
//! * 000.000 (0b00100000)
//! * 0000.00 (0b00010000)
//! * 00000.0 (0b00001000)
//! * 000000. (0b00000100)
//! * 00.00.00 (0b01010000)
//! For displays with just a colons:
//! * 00:00:00 (0b01010000)
//! Use 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 @@ -284,8 +299,21 @@ class TM1637TinyDisplay6 {
//! @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:
//! * 00.0000 (0b01000000)
//! * 0.00000 (0b10000000)
//! * 00.0000 (0b01000000)
//! * 000.000 (0b00100000)
//! * 0000.00 (0b00010000)
//! * 00000.0 (0b00001000)
//! * 000000. (0b00000100)
//! * 00.00.00 (0b01010000)
//! For displays with just a colons:
//! * 00:00:00 (0b01010000)
//! 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
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TM1637TinyDisplay
version=1.4.1
version=1.4.2
author=Jason Cox <[email protected]>
maintainer=Jason Cox <[email protected]>
sentence=A simple library to display numbers, text and animation on 4 and 6 digit 7-segment TM1637 based display modules.
Expand Down

0 comments on commit f329d3a

Please sign in to comment.