Skip to content

Commit 8491cf1

Browse files
committed
GoL - Removed pauseFrames
Uses .step now to pause.
1 parent 09dad1d commit 8491cf1

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

wled00/FX.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5178,8 +5178,7 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
51785178
uint16_t *oscillatorCRC = reinterpret_cast<uint16_t*>(SEGENV.data + dataSize*2 + sizeof(uint8_t));
51795179
uint16_t *spaceshipCRC = reinterpret_cast<uint16_t*>(SEGENV.data + dataSize*2 + sizeof(uint8_t) + sizeof(uint16_t));
51805180

5181-
uint16_t &generation = SEGENV.aux0; //rename aux0 and aux1 for readability (not needed)
5182-
uint16_t &pauseFrames = SEGENV.aux1;
5181+
uint16_t &generation = SEGENV.aux0; //rename aux0 readability (not needed)
51835182
CRGB bgColor = SEGCOLOR(1);
51845183
CRGB color;
51855184

@@ -5188,10 +5187,9 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
51885187
SEGMENT.fill(BLACK); // to make sure that segment buffer and physical leds are aligned initially
51895188
}
51905189
//start new game of life
5191-
if ((SEGENV.call == 0 || generation == 0) && pauseFrames == 0) {
5192-
SEGENV.step = strip.now; // .step = previous call time
5190+
if ((SEGENV.call == 0 || generation == 0) && SEGENV.step < strip.now) {
5191+
SEGENV.step = strip.now + 1500; // show initial state for 1.5 seconds
51935192
generation = 1;
5194-
pauseFrames = 75; // show initial state for longer
51955193
random16_set_seed(strip.now>>2); //seed the random generator
51965194
//Setup Grid
51975195
for (int x = 0; x < cols; x++) for (int y = 0; y < rows; y++) {
@@ -5235,8 +5233,7 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
52355233
}
52365234
}
52375235
}
5238-
if (pauseFrames || strip.now - SEGENV.step < FRAMETIME_FIXED * (uint32_t)map(SEGMENT.speed,0,255,64,2)) {
5239-
if(pauseFrames) pauseFrames--;
5236+
if (SEGENV.step > strip.now || strip.now - SEGENV.step < FRAMETIME_FIXED * (uint32_t)map(SEGMENT.speed,0,255,64,2)) {
52405237
return FRAMETIME; //skip if not enough time has passed
52415238
}
52425239
//Update Game of Life
@@ -5316,7 +5313,7 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
53165313
if (!cellChanged || crc == *oscillatorCRC || crc == *spaceshipCRC) repetition = true; //check if cell changed this gen and compare previous stored crc values
53175314
if (repetition) {
53185315
generation = 0; // reset on next call
5319-
pauseFrames = 50;
5316+
SEGENV.step += 1000; // pause final generation for 1 second
53205317
return FRAMETIME;
53215318
}
53225319
// Update CRC values

0 commit comments

Comments
 (0)