From f329d3abad5e9c46284733a3abff329e9d344522 Mon Sep 17 00:00:00 2001 From: "Jason A. Cox" Date: Mon, 23 Aug 2021 21:25:29 -0700 Subject: [PATCH] Added dots parameter to showString() --- RELEASE.md | 9 ++++++ TM1637TinyDisplay.h | 2 +- TM1637TinyDisplay6.cpp | 10 ++++-- TM1637TinyDisplay6.h | 72 +++++++++++++++++++++++++++++------------- library.properties | 2 +- 5 files changed, 69 insertions(+), 26 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index c1ec73e..553f0ea 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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 ``` \ No newline at end of file diff --git a/TM1637TinyDisplay.h b/TM1637TinyDisplay.h index 46717d4..3ad33ee 100644 --- a/TM1637TinyDisplay.h +++ b/TM1637TinyDisplay.h @@ -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) //! diff --git a/TM1637TinyDisplay6.cpp b/TM1637TinyDisplay6.cpp index 981c534..1f5f96f 100644 --- a/TM1637TinyDisplay6.cpp +++ b/TM1637TinyDisplay6.cpp @@ -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)); @@ -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 @@ -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)); @@ -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 { diff --git a/TM1637TinyDisplay6.h b/TM1637TinyDisplay6.h index fc1a11d..cc99d1f 100644 --- a/TM1637TinyDisplay6.h +++ b/TM1637TinyDisplay6.h @@ -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 @@ -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 @@ -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) //! @@ -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) //! diff --git a/library.properties b/library.properties index 5b8b808..9f24c52 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TM1637TinyDisplay -version=1.4.1 +version=1.4.2 author=Jason Cox maintainer=Jason Cox sentence=A simple library to display numbers, text and animation on 4 and 6 digit 7-segment TM1637 based display modules.