@@ -112,21 +112,21 @@ bool Animation::changeBrightness() {
112112 foregroundMinute = RgbColor (hsbColor);
113113 RgbfColor **matrix[3 ] = {act, old, work};
114114 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 ++) {
117117 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;
120120 }
121121 }
122122 if (adjustFg) {
123- if (matrix[m][r][c ].isForeground ()) {
123+ if (matrix[m][row][col ].isForeground ()) {
124124 if (isColorization ()) {
125- hsbColor = HsbColor (matrix[m][r][c ]);
125+ hsbColor = HsbColor (matrix[m][row][col ]);
126126 hsbColor.B = brightness;
127- matrix[m][r][c ].changeRgb (hsbColor);
127+ matrix[m][row][col ].changeRgb (hsbColor);
128128 } else {
129- matrix[m][r][c ].changeRgb (newForeground);
129+ matrix[m][row][col ].changeRgb (newForeground);
130130 }
131131 }
132132 }
@@ -198,14 +198,15 @@ void Animation::colorize(RgbfColor **dest) {
198198 hsbColor.H = pseudoRandomHue ();
199199 foregroundMinute = isColorization () ? RgbColor (hsbColor) : foreground;
200200 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 ()) {
204204 if ((G.animColorize == CHARACTERS) || changeColor) {
205205 changeColor = false ;
206206 hsbColor.H = pseudoRandomHue ();
207207 }
208- dest[r][c].changeRgb (isColorization () ? hsbColor : foreground);
208+ dest[row][col].changeRgb (isColorization () ? hsbColor
209+ : foreground);
209210 } else {
210211 changeColor = true ;
211212 }
@@ -238,16 +239,16 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source,
238239 RgbfColor &foreground, RgbfColor &background) {
239240 RgbfColor color, color1 (0 ), color2 (0 );
240241 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 ++) {
243244 if (source == STRIPE) {
244245 color = RgbfColor (led.getPixel (usedUhrType->getFrontMatrixIndex (
245- r + rowStart, c + colStart)));
246+ row + rowStart, col + colStart)));
246247 } else {
247- color = source[r][c ];
248+ color = source[row][col ];
248249 }
249250 if (dest != NULL ) {
250- dest[r][c ] = color;
251+ dest[row][col ] = color;
251252 }
252253 if (color == color1) {
253254 colorCounter1++;
@@ -279,47 +280,28 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source,
279280 background.setForeground (false );
280281 background.setOverlay (false );
281282 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);
285286 }
286287 }
287288 }
288289}
289290
290291// ------------------------------------------------------------------------------
291292
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 () {
313294 if (G.minuteVariant != MinuteVariant::Off) {
314295 uint8_t m = lastMinute % 5 ;
315296 uint16_t minArray[4 ];
316- usedUhrType->getMinuteArray (minArray, determineWhichMinuteVariant ());
297+ usedUhrType->getMinuteArray (minArray,
298+ clockWork.determineWhichMinuteVariant ());
317299 if (G.layoutVariant [ReverseMinDirection]) {
318300 std::reverse (std::begin (minArray), std::end (minArray));
319301 }
320302 for (uint8_t i = 0 ; i < 4 ; i++) {
321303 led.setPixel (minArray[i],
322- Color {m > i ? foregroundMinute : background});
304+ HsbColor {m > i ? foregroundMinute : background});
323305 }
324306 }
325307}
@@ -330,29 +312,30 @@ void Animation::set_minutes() {
330312void Animation::copy2Stripe (RgbfColor **source) {
331313 for (uint8_t row = 0 ; row < maxRows; row++) {
332314 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 )});
337320 }
338321 }
339- set_minutes ();
322+ setMinute ();
340323}
341324
342325// ------------------------------------------------------------------------------
343326
344327void 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);
347330 }
348331}
349332
350333// ------------------------------------------------------------------------------
351334
352335void 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 ());
356339 }
357340 }
358341}
@@ -371,8 +354,8 @@ void Animation::fillMatrix(RgbfColor **matrix, RgbfColor color) {
371354
372355// changed: 0 changes, e.g. color, no change of content
373356// 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 ;
376359
377360 if (animType == KEINE) {
378361 if (changed && (lastMinute != minute)) {
@@ -388,16 +371,16 @@ bool Animation::led_show_notify(bool changed, uint8_t minute) {
388371 matrixChanged = true ;
389372 nextActionTime = 0 ; // ###################
390373 phase = 1 ; // -> start Animation
391- led_show = false ; // ###################
374+ ledShow = false ; // ###################
392375 }
393376 } else {
394377 if (brightnessChanged) {
395378 copy2Stripe (work);
396379 }
397- led_show = isIdle ();
380+ ledShow = isIdle ();
398381 }
399382 }
400- return led_show ;
383+ return ledShow ;
401384}
402385
403386// ------------------------------------------------------------------------------
@@ -661,16 +644,16 @@ uint16_t Animation::animScrollRight(bool dirRight) {
661644uint16_t Animation::animBalls () {
662645 static uint32_t starttime;
663646 static uint32_t numBalls;
664- uint32_t oldR, r, c , ballsDown;
647+ uint32_t oldR, row, col , ballsDown;
665648 uint32_t timeDelta, now;
666649
667650 if (phase == 1 ) {
668651 animationDelay = 50 ; // 20 Frames per second
669652 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,
674657 100 * numBalls);
675658 numBalls++;
676659 break ;
@@ -684,24 +667,24 @@ uint16_t Animation::animBalls() {
684667 timeDelta = now - starttime;
685668 starttime = now;
686669 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;
695678 }
696679 } else { // up
697- for (; r < oldR; oldR--) {
698- work[oldR][c ] = background;
680+ for (; row < oldR; oldR--) {
681+ work[oldR][col ] = background;
699682 }
700683 }
701- work[r][c ] = balls[b ].color ;
684+ work[row][col ] = balls[i ].color ;
702685 }
703686 if (ballsDown >= numBalls) {
704- copyMatrix (work, act); // TODO(ATho95): shot Balls up
687+ copyMatrix (work, act);
705688 return 0 ;
706689 }
707690 return phase + 1 ;
0 commit comments