Fixed led flickering on update -- configurable time between updates

This commit is contained in:
Dirk Jahnke 2019-05-30 20:41:01 +02:00
parent 831b514c0a
commit 196d504fa7
1 changed files with 21 additions and 14 deletions

View File

@ -181,8 +181,12 @@ void SevenSegmentClock::displaySeperator(char seperatorCharacter) {
} }
} }
static uint32_t lastUpdate_ms = 0;
void SevenSegmentClock::displayTime(int hour, int minute) { void SevenSegmentClock::displayTime(int hour, int minute) {
char displayText[4]; char displayText[4];
if (clockHour != hour || clockMinute != minute || millis()-lastUpdate_ms > TIME_BETWEEN_DISPLAY_UPDATES_ms) {
clockHour = hour; clockHour = hour;
clockMinute = minute; clockMinute = minute;
Serial.print("SevenSegmentClock: new time "); Serial.print(clockHour); Serial.print(":"); Serial.println(clockMinute); Serial.print("SevenSegmentClock: new time "); Serial.print(clockHour); Serial.print(":"); Serial.println(clockMinute);
@ -196,7 +200,10 @@ void SevenSegmentClock::displayTime(int hour, int minute) {
displayDigit(3, displayText[3]); displayDigit(3, displayText[3]);
displaySeperator(':'); displaySeperator(':');
strip->show(); strip->show();
Serial.print("Shown: "); Serial.print(displayText[0]); Serial.print(displayText[1]); Serial.print(':'); Serial.print(displayText[2]); Serial.println(displayText[3]); Serial.print("Shown: "); Serial.print(displayText[0]); Serial.print(displayText[1]);
Serial.print(':'); Serial.print(displayText[2]); Serial.println(displayText[3]);
lastUpdate_ms = millis();
}
}; };
uint32_t SevenSegmentClock::red, SevenSegmentClock::green, SevenSegmentClock::blue, SevenSegmentClock::white, SevenSegmentClock::black; uint32_t SevenSegmentClock::red, SevenSegmentClock::green, SevenSegmentClock::blue, SevenSegmentClock::white, SevenSegmentClock::black;