Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make setting the colon on optional for printDualCounter #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/SevenSegmentExtended.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void SevenSegmentExtended::printNumber(int16_t number, bool zeroPadding, bool ro
};

// positive counter 0..99, negative counter 0..-9
void SevenSegmentExtended::printDualCounter(int8_t leftCounter, int8_t rightCounter, bool zeroPadding) {
void SevenSegmentExtended::printDualCounter(int8_t leftCounter, int8_t rightCounter, bool zeroPadding, bool setColonOn) {

int8_t max = 99;
int8_t min = -9;
Expand All @@ -109,7 +109,8 @@ void SevenSegmentExtended::printDualCounter(int8_t leftCounter, int8_t rightCoun
rightCounter = (rightCounter < min)?min:rightCounter;

bool colonWasOn = getColonOn(); // get current state
setColonOn(true); // turn on the colon
if (setColonOn)
SevenSegmentTM1637::setColonOn(true); // turn on the colon
home(); // set cursor to zero

if ( leftCounter < 10 && leftCounter >= 0) {
Expand All @@ -136,5 +137,5 @@ void SevenSegmentExtended::printDualCounter(int8_t leftCounter, int8_t rightCoun
print(rightCounter);

// set to previous state
setColonOn(colonWasOn);
SevenSegmentTM1637::setColonOn(colonWasOn);
};
3 changes: 2 additions & 1 deletion src/SevenSegmentExtended.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ void printNumber(int16_t number, bool zeroPadding = false, bool rollOver = fa
@param [in] leftCounter the number on the left side of the display
@param [in] rightcounter the numnber on the right side of the display
@param [in] zeroPadding optional: pad counters with zero
@param [in] setColonOn optional: set to false to leave colon alone
*/
void printDualCounter(int8_t leftCounter, int8_t rightCounter, bool zeroPadding = false);
void printDualCounter(int8_t leftCounter, int8_t rightCounter, bool zeroPadding = false, bool setColonOn = true);

};
#endif