Skip to content

Commit 0ea93a2

Browse files
authored
Merge pull request #581 from BastiMu/Improove-Demo-Mode
Improove demo mode
2 parents 812a140 + 2fe026c commit 0ea93a2

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

include/Transitiontypes/Transition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Transition {
198198
//------------------------------------------------------------------------------
199199
// Loop Helper Functions
200200
//------------------------------------------------------------------------------
201-
void demoMode(uint8_t &_minute, uint8_t _second);
201+
void demoMode(uint8_t &_hour, uint8_t &_minute, uint8_t _second);
202202
void initTransitionStart();
203203
bool hasMinuteChanged();
204204
bool isOverwrittenByTransition(WordclockChanges flag, uint8_t minute);

include/Transitiontypes/Transition.hpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,16 +1110,34 @@ uint16_t Transition::transitionSnake() {
11101110
// Loop Helper Functions
11111111
//------------------------------------------------------------------------------
11121112

1113-
void Transition::demoMode(uint8_t &_minute, uint8_t _second) {
1114-
static uint8_t test_second = 0;
1115-
static uint8_t test_minute = 45;
1113+
void Transition::demoMode(uint8_t &_hour, uint8_t &_minute, uint8_t _second) {
1114+
static uint8_t test_second = _second;
1115+
static uint8_t test_minute = _minute;
1116+
static uint8_t test_hour = _hour;
11161117
if (G.transitionDemo) {
1117-
if (isIdle() && ((_second % 10) == 0) && (test_second != _second)) {
1118-
test_minute += 5;
1118+
// increment every second
1119+
// by checking isIdle transitions are completely done
1120+
if (isIdle() && ((_second % 2) == 0) && (test_second != _second)) {
1121+
// select increment by clock type
1122+
if (usedUhrType != nullptr) {
1123+
if (usedUhrType->hasOnlyQuarterLayout()) {
1124+
test_minute += 15;
1125+
} else if (usedUhrType->has60MinuteLayout()) {
1126+
test_minute += 1;
1127+
} else {
1128+
test_minute += 5;
1129+
}
1130+
}
1131+
// add one hour every 60 minutes
11191132
if (test_minute >= 60) {
1120-
test_minute = _minute % 5;
1133+
test_minute %= 60;
1134+
test_hour = (test_hour + 1) % 24;
11211135
}
1136+
// log demo time
1137+
Serial.printf("Demo time: %02d:%02d\n", test_hour, test_minute);
11221138
}
1139+
// set to time variables
1140+
_hour = test_hour;
11231141
_minute = test_minute;
11241142
test_second = _second;
11251143
}

include/clockWork.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ void ClockWork::loop(struct tm &tm) {
11011101
previousMillis = currentMillis;
11021102

11031103
// Faster runtime for demo
1104-
transition->demoMode(_minute, _second);
1104+
transition->demoMode(_hour, _minute, _second);
11051105

11061106
//------------------------------------------------
11071107
// Secounds and LDR Routine

src/Wortuhr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ void loop() {
485485
transition->loop(tm); // must be called periodically
486486

487487
// make the time run faster in the demo mode of the transition
488-
transition->demoMode(_minute, _second);
488+
transition->demoMode(_hour, _minute, _second);
489489

490490
if (usedUhrType->numPixelsFrameMatrix() != 0) {
491491
secondsFrame->loop();

0 commit comments

Comments
 (0)