From 583566f4870034b2e468f778d4784aed71fd23ca Mon Sep 17 00:00:00 2001 From: Dryw Wade Date: Thu, 14 Dec 2023 13:55:26 -0700 Subject: [PATCH 1/3] Bump version number to v2.2.10 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index efc1092..b0ebfbe 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun Qwiic Alphanumeric Display Arduino Library -version=2.2.9 +version=2.2.10 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=A library to drive the Holtek HT16K33 LED Driver with an Alphanumeric Display. From e29ef6125388cd6de7dc16f319458a30506c9529 Mon Sep 17 00:00:00 2001 From: Dryw Wade Date: Thu, 14 Dec 2023 13:56:40 -0700 Subject: [PATCH 2/3] Fix setColonOnOff() and setDecimalOnOff() Need to actually clear the bits to turn them off --- src/SparkFun_Alphanumeric_Display.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SparkFun_Alphanumeric_Display.cpp b/src/SparkFun_Alphanumeric_Display.cpp index 3aef7cb..9e8fcec 100644 --- a/src/SparkFun_Alphanumeric_Display.cpp +++ b/src/SparkFun_Alphanumeric_Display.cpp @@ -475,7 +475,8 @@ bool HT16K33::setDecimalOnOff(uint8_t displayNumber, bool turnOnDecimal, bool up dat = 0x00; } - displayRAM[adr + (displayNumber - 1) * 16] = displayRAM[adr + (displayNumber - 1) * 16] | dat; + displayRAM[adr + (displayNumber - 1) * 16] &= 0xFE; + displayRAM[adr + (displayNumber - 1) * 16] |= dat; if(updateNow) { @@ -547,7 +548,8 @@ bool HT16K33::setColonOnOff(uint8_t displayNumber, bool turnOnColon, bool update dat = 0x00; } - displayRAM[adr + (displayNumber - 1) * 16] = displayRAM[adr + (displayNumber - 1) * 16] | dat; + displayRAM[adr + (displayNumber - 1) * 16] &= 0xFE; + displayRAM[adr + (displayNumber - 1) * 16] |= dat; if(updateNow) { From 58e247feb91cf5bbb07e3ec0939698f0fda981c7 Mon Sep 17 00:00:00 2001 From: Dryw Wade Date: Thu, 14 Dec 2023 14:04:29 -0700 Subject: [PATCH 3/3] Ensure write() does not wrap with long inputs Eg. if only 1 display is available, shouldn't try to print more than 4 characters --- src/SparkFun_Alphanumeric_Display.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SparkFun_Alphanumeric_Display.cpp b/src/SparkFun_Alphanumeric_Display.cpp index 9e8fcec..22423bc 100644 --- a/src/SparkFun_Alphanumeric_Display.cpp +++ b/src/SparkFun_Alphanumeric_Display.cpp @@ -761,6 +761,10 @@ size_t HT16K33::write(uint8_t b) */ size_t HT16K33::write(const uint8_t *buffer, size_t size) { + // Do not exceed number of digits available + if(size > 4 * numberOfDisplays) + size = 4 * numberOfDisplays; + size_t n = size; uint8_t buff; @@ -784,7 +788,6 @@ size_t HT16K33::write(const uint8_t *buffer, size_t size) displayContent[digitPosition] = buff; // Record to internal array digitPosition++; - digitPosition %= (numberOfDisplays * 4); } }