@@ -112,21 +112,21 @@ bool Animation::changeBrightness() {
112
112
foregroundMinute = RgbColor (hsbColor);
113
113
RgbfColor **matrix[3 ] = {act, old, work};
114
114
for (uint8_t m = 0 ; m < 3 ; m++) {
115
- for (uint8_t r = 0 ; r < maxRows; r ++) {
116
- for (uint8_t c = 0 ; c < maxCols; c ++) {
115
+ for (uint8_t row = 0 ; row < maxRows; row ++) {
116
+ for (uint8_t col = 0 ; col < maxCols; col ++) {
117
117
if (adjustBg) {
118
- if (!matrix[m][r][c ].isForeground ()) {
119
- matrix[m][r][c ] = newBackground;
118
+ if (!matrix[m][row][col ].isForeground ()) {
119
+ matrix[m][row][col ] = newBackground;
120
120
}
121
121
}
122
122
if (adjustFg) {
123
- if (matrix[m][r][c ].isForeground ()) {
123
+ if (matrix[m][row][col ].isForeground ()) {
124
124
if (isColorization ()) {
125
- hsbColor = HsbColor (matrix[m][r][c ]);
125
+ hsbColor = HsbColor (matrix[m][row][col ]);
126
126
hsbColor.B = brightness;
127
- matrix[m][r][c ].changeRgb (hsbColor);
127
+ matrix[m][row][col ].changeRgb (hsbColor);
128
128
} else {
129
- matrix[m][r][c ].changeRgb (newForeground);
129
+ matrix[m][row][col ].changeRgb (newForeground);
130
130
}
131
131
}
132
132
}
@@ -198,14 +198,15 @@ void Animation::colorize(RgbfColor **dest) {
198
198
hsbColor.H = pseudoRandomHue ();
199
199
foregroundMinute = isColorization () ? RgbColor (hsbColor) : foreground;
200
200
hsbColor.H = pseudoRandomHue ();
201
- for (uint8_t r = 0 ; r < maxRows; r ++) {
202
- for (uint8_t c = 0 ; c < maxCols; c ++) {
203
- if (dest[r][c ].isForeground ()) {
201
+ for (uint8_t row = 0 ; row < maxRows; row ++) {
202
+ for (uint8_t col = 0 ; col < maxCols; col ++) {
203
+ if (dest[row][col ].isForeground ()) {
204
204
if ((G.animColorize == CHARACTERS) || changeColor) {
205
205
changeColor = false ;
206
206
hsbColor.H = pseudoRandomHue ();
207
207
}
208
- dest[r][c].changeRgb (isColorization () ? hsbColor : foreground);
208
+ dest[row][col].changeRgb (isColorization () ? hsbColor
209
+ : foreground);
209
210
} else {
210
211
changeColor = true ;
211
212
}
@@ -238,16 +239,16 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source,
238
239
RgbfColor &foreground, RgbfColor &background) {
239
240
RgbfColor color, color1 (0 ), color2 (0 );
240
241
uint32_t colorCounter1 = 0 , colorCounter2 = 0 ;
241
- for (uint8_t r = 0 ; r < maxRows; r ++) {
242
- for (uint8_t c = 0 ; c < maxCols; c ++) {
242
+ for (uint8_t row = 0 ; row < maxRows; row ++) {
243
+ for (uint8_t col = 0 ; col < maxCols; col ++) {
243
244
if (source == STRIPE) {
244
245
color = RgbfColor (led.getPixel (usedUhrType->getFrontMatrixIndex (
245
- r + rowStart, c + colStart)));
246
+ row + rowStart, col + colStart)));
246
247
} else {
247
- color = source[r][c ];
248
+ color = source[row][col ];
248
249
}
249
250
if (dest != NULL ) {
250
- dest[r][c ] = color;
251
+ dest[row][col ] = color;
251
252
}
252
253
if (color == color1) {
253
254
colorCounter1++;
@@ -279,47 +280,28 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source,
279
280
background.setForeground (false );
280
281
background.setOverlay (false );
281
282
if (dest != NULL ) {
282
- for (uint8_t r = 0 ; r < maxRows; r ++) {
283
- for (uint8_t c = 0 ; c < maxCols; c ++) {
284
- dest[r][c ].setForeground (dest[r][c ] == foreground);
283
+ for (uint8_t row = 0 ; row < maxRows; row ++) {
284
+ for (uint8_t col = 0 ; col < maxCols; col ++) {
285
+ dest[row][col ].setForeground (dest[row][col ] == foreground);
285
286
}
286
287
}
287
288
}
288
289
}
289
290
290
291
// ------------------------------------------------------------------------------
291
292
292
- uint8_t Animation::determineWhichMinuteVariant () {
293
- switch (G.minuteVariant ) {
294
- case MinuteVariant::LED4x:
295
- return 0 ;
296
- break ;
297
- case MinuteVariant::LED7x:
298
- return 1 ;
299
- break ;
300
- case MinuteVariant::Corners:
301
- return 2 ;
302
- break ;
303
- default :
304
- Serial.println (" [ERROR] G.minuteVariant undefined" );
305
- return 0 ;
306
- break ;
307
- }
308
- }
309
-
310
- // ------------------------------------------------------------------------------
311
-
312
- void Animation::set_minutes () {
293
+ void Animation::setMinute () {
313
294
if (G.minuteVariant != MinuteVariant::Off) {
314
295
uint8_t m = lastMinute % 5 ;
315
296
uint16_t minArray[4 ];
316
- usedUhrType->getMinuteArray (minArray, determineWhichMinuteVariant ());
297
+ usedUhrType->getMinuteArray (minArray,
298
+ clockWork.determineWhichMinuteVariant ());
317
299
if (G.layoutVariant [ReverseMinDirection]) {
318
300
std::reverse (std::begin (minArray), std::end (minArray));
319
301
}
320
302
for (uint8_t i = 0 ; i < 4 ; i++) {
321
303
led.setPixel (minArray[i],
322
- Color {m > i ? foregroundMinute : background});
304
+ HsbColor {m > i ? foregroundMinute : background});
323
305
}
324
306
}
325
307
}
@@ -330,29 +312,30 @@ void Animation::set_minutes() {
330
312
void Animation::copy2Stripe (RgbfColor **source) {
331
313
for (uint8_t row = 0 ; row < maxRows; row++) {
332
314
for (uint8_t col = 0 ; col < maxCols; col++) {
333
- led.setPixel (usedUhrType->getFrontMatrixIndex (row + rowStart,
334
- col + colStart),
335
- Color{RgbColor (source[row][col].R , source[row][col].G ,
336
- source[row][col].B )});
315
+ led.setPixel (
316
+ usedUhrType->getFrontMatrixIndex (row + rowStart,
317
+ col + colStart),
318
+ HsbColor{RgbColor (source[row][col].R , source[row][col].G ,
319
+ source[row][col].B )});
337
320
}
338
321
}
339
- set_minutes ();
322
+ setMinute ();
340
323
}
341
324
342
325
// ------------------------------------------------------------------------------
343
326
344
327
void Animation::copyMatrix (RgbfColor **dest, RgbfColor **source) {
345
- for (uint8_t r = 0 ; r < maxRows; r ++) {
346
- memcpy (dest[r ], source[r ], sizeofColumn);
328
+ for (uint8_t row = 0 ; row < maxRows; row ++) {
329
+ memcpy (dest[row ], source[row ], sizeofColumn);
347
330
}
348
331
}
349
332
350
333
// ------------------------------------------------------------------------------
351
334
352
335
void Animation::copyMatrixFlags (RgbfColor **dest, RgbfColor **source) {
353
- for (uint8_t r = 0 ; r < maxRows; r ++) {
354
- for (uint8_t c = 0 ; c < maxCols; c ++) {
355
- dest[r][c ].setFlags (source[r][c ].getFlags ());
336
+ for (uint8_t row = 0 ; row < maxRows; row ++) {
337
+ for (uint8_t col = 0 ; col < maxCols; col ++) {
338
+ dest[row][col ].setFlags (source[row][col ].getFlags ());
356
339
}
357
340
}
358
341
}
@@ -371,8 +354,8 @@ void Animation::fillMatrix(RgbfColor **matrix, RgbfColor color) {
371
354
372
355
// changed: 0 changes, e.g. color, no change of content
373
356
// changed: 1 content has changed
374
- bool Animation::led_show_notify (bool changed, uint8_t minute) {
375
- bool led_show = true ;
357
+ bool Animation::ledShowNotify (bool changed, uint8_t minute) {
358
+ bool ledShow = true ;
376
359
377
360
if (animType == KEINE) {
378
361
if (changed && (lastMinute != minute)) {
@@ -388,16 +371,16 @@ bool Animation::led_show_notify(bool changed, uint8_t minute) {
388
371
matrixChanged = true ;
389
372
nextActionTime = 0 ; // ###################
390
373
phase = 1 ; // -> start Animation
391
- led_show = false ; // ###################
374
+ ledShow = false ; // ###################
392
375
}
393
376
} else {
394
377
if (brightnessChanged) {
395
378
copy2Stripe (work);
396
379
}
397
- led_show = isIdle ();
380
+ ledShow = isIdle ();
398
381
}
399
382
}
400
- return led_show ;
383
+ return ledShow ;
401
384
}
402
385
403
386
// ------------------------------------------------------------------------------
@@ -661,16 +644,16 @@ uint16_t Animation::animScrollRight(bool dirRight) {
661
644
uint16_t Animation::animBalls () {
662
645
static uint32_t starttime;
663
646
static uint32_t numBalls;
664
- uint32_t oldR, r, c , ballsDown;
647
+ uint32_t oldR, row, col , ballsDown;
665
648
uint32_t timeDelta, now;
666
649
667
650
if (phase == 1 ) {
668
651
animationDelay = 50 ; // 20 Frames per second
669
652
numBalls = 0 ;
670
- for (c = 0 ; (c < maxCols) && (numBalls < maxCols); c ++) {
671
- for (r = 0 ; (r < maxRows) && (numBalls < maxCols); r ++) {
672
- if (work[r][c ].isForeground ()) {
673
- balls[numBalls].begin (r, c , work[r][c ], background,
653
+ for (col = 0 ; (col < maxCols) && (numBalls < maxCols); col ++) {
654
+ for (row = 0 ; (row < maxRows) && (numBalls < maxCols); row ++) {
655
+ if (work[row][col ].isForeground ()) {
656
+ balls[numBalls].begin (row, col , work[row][col ], background,
674
657
100 * numBalls);
675
658
numBalls++;
676
659
break ;
@@ -684,24 +667,24 @@ uint16_t Animation::animBalls() {
684
667
timeDelta = now - starttime;
685
668
starttime = now;
686
669
ballsDown = 0 ;
687
- for (uint8_t b = 0 ; b < numBalls; b ++) {
688
- oldR = balls[b]. r ;
689
- ballsDown += balls[b ].move (timeDelta);
690
- r = balls[b]. r ; // r, c new coordinates
691
- c = balls[b]. c ;
692
- if (r > oldR) { // down
693
- for (; r > oldR; oldR++) {
694
- work[oldR][c ] = background;
670
+ for (uint8_t i = 0 ; i < numBalls; i ++) {
671
+ oldR = balls[i]. row ;
672
+ ballsDown += balls[i ].move (timeDelta);
673
+ row = balls[i]. row ; // row, col new coordinates
674
+ col = balls[i]. col ;
675
+ if (row > oldR) { // down
676
+ for (; row > oldR; oldR++) {
677
+ work[oldR][col ] = background;
695
678
}
696
679
} else { // up
697
- for (; r < oldR; oldR--) {
698
- work[oldR][c ] = background;
680
+ for (; row < oldR; oldR--) {
681
+ work[oldR][col ] = background;
699
682
}
700
683
}
701
- work[r][c ] = balls[b ].color ;
684
+ work[row][col ] = balls[i ].color ;
702
685
}
703
686
if (ballsDown >= numBalls) {
704
- copyMatrix (work, act); // TODO(ATho95): shot Balls up
687
+ copyMatrix (work, act);
705
688
return 0 ;
706
689
}
707
690
return phase + 1 ;
0 commit comments