From e27fa152e8f4ee92086db38563208e02a5f0be3c Mon Sep 17 00:00:00 2001 From: tofof Date: Tue, 10 May 2022 10:45:05 -0500 Subject: [PATCH 1/2] Bump version to 1.1.2 in library.properties Reflect version change in library.properties so PlatformIO's crawler will update this library. --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 3e93214..b34a359 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SevenSegmentTM1637 -version=1.1.0 +version=1.1.2 author=Bram Harmsen maintainer=Bram Harmsen sentence=Library for using a 4 digit seven segment display with TM1636 or TM1637 driver IC From 95ca401c30e6905761eb757d837e83598ee5aaa2 Mon Sep 17 00:00:00 2001 From: tofof Date: Tue, 10 May 2022 11:29:08 -0500 Subject: [PATCH 2/2] Simplify and correct bar logic Logic is intended to check how many bars to draw by examining 2 bar positions at a time. Previous version the second conditional was always false (because if barsOn-2*i+1 is not >=0 in the first conditional it certainly won't be >=1 in the second. Instead of >=1, the second conditional needed to be >=-1 in the prior logic. Simplifying the logic so that the value being checked in the conditional corresponds directly to the number of bars to light solves the problem and makes the flow much more directly understandable. --- src/SevenSegmentFun.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SevenSegmentFun.cpp b/src/SevenSegmentFun.cpp index c5a2640..711dbc5 100644 --- a/src/SevenSegmentFun.cpp +++ b/src/SevenSegmentFun.cpp @@ -24,9 +24,9 @@ void SevenSegmentFun::printLevelVertical(uint8_t level, bool leftToRight) { uint8_t d = leftToRight == true?0:TM1637_MAX_COLOM-1; for (uint8_t i=0; i < TM1637_MAX_COLOM; i++) { - if (barsOn - (2 * (i + 1)) >= 0) { + if (barsOn - (2 * i) >= 2) { _rawBuffer[d] = TM1637_CHAR_VERT_LEVEL_II; - } else if (barsOn - (2 * (i + 1)) >= 1) { + } else if (barsOn - (2 * i) >= 1) { _rawBuffer[d] = (leftToRight == true)?TM1637_CHAR_VERT_LEVEL_I0:TM1637_CHAR_VERT_LEVEL_0I; } else { _rawBuffer[d] = 0;