Skip to content

Commit ce3305c

Browse files
authored
Merge pull request #295 from dbambus/main
Commits for Release 3.1.0 Bug Tested
2 parents 7afe87a + e40448e commit ce3305c

31 files changed

+755
-509
lines changed

include/Animation.h

+14-15
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class Animation {
117117

118118
void begin();
119119
void loop(struct tm &tm);
120-
bool led_show_notify(bool flag, uint8_t minute);
120+
bool ledShowNotify(bool flag, uint8_t minute);
121121
void demoMode(uint8_t &_minute, uint8_t _second);
122122
//------------------------------------------------------------------------------
123123
protected:
@@ -167,8 +167,7 @@ class Animation {
167167
void saveMatrix();
168168
void analyzeColors(RgbfColor **dest, RgbfColor **source,
169169
RgbfColor &foreground, RgbfColor &background);
170-
uint8_t determineWhichMinuteVariant();
171-
void set_minutes(void);
170+
void setMinute(void);
172171
void copy2Stripe(RgbfColor **source);
173172
void copyMatrix(RgbfColor **dest, RgbfColor **source);
174173
void copyMatrixFlags(RgbfColor **dest, RgbfColor **source);
@@ -219,8 +218,8 @@ class Rain {
219218
stopPhase = frames - speedlimit * maxRows;
220219
}
221220

222-
RgbaColor get(int32_t r) {
223-
int32_t row = (maxRows - 1 - r);
221+
RgbaColor get(int32_t _row) {
222+
int32_t row = (maxRows - 1 - _row);
224223
// per image row runs from (maxRows - 1) down to 0
225224

226225
int32_t pos = (row + offset) % (deadtime + lifetime);
@@ -284,12 +283,12 @@ class Ball {
284283
}
285284
virtual ~Ball(){};
286285

287-
void begin(int32_t row, int32_t column, RgbfColor foreground,
286+
void begin(int32_t _row, int32_t _col, RgbfColor foreground,
288287
RgbfColor background, int32_t delay) {
289288
this->delay = delay;
290-
y = row << 8; // increase precision
291-
r = row;
292-
c = column;
289+
y = _row << 8; // increase precision
290+
row = _row;
291+
col = _col;
293292
vy = 0;
294293
colorForeground = foreground;
295294
colorBackground = background;
@@ -319,15 +318,15 @@ class Ball {
319318
}
320319
lastDown |= (_vy < 0) && (vy >= 0) &&
321320
(y > lastPos); // upper turning point
322-
r = y >> 8;
321+
row = y >> 8;
323322
}
324323
color = end ? colorBackground : colorForeground;
325324
}
326325
return end;
327326
}
328327

329328
public:
330-
int32_t r, c; // after calling move() r and c contain new actual values
329+
int32_t row, col; // after calling move() row & col contain new actual val
331330
RgbfColor color;
332331

333332
protected:
@@ -508,19 +507,19 @@ class Firework {
508507
maxLayer = layer;
509508
}
510509

511-
bool getPixel(uint8_t r, uint8_t c, RgbColor &color) {
510+
bool getPixel(uint8_t row, uint8_t col, RgbColor &color) {
512511
// void Animation::copyBlock(RgbfColor color, uint32_t block, bool fgbg,
513512
// bool mirrored,
514513
// bool init) {
515514

516-
if ((r < 10) && (r < maxRows) && (c < 11) && (c < maxCols)) {
515+
if ((row < 10) && (row < maxRows) && (col < 11) && (col < maxCols)) {
517516
uint16_t pixels = 0;
518517
for (int32_t layer = 0; layer <= maxLayer; layer++) {
519518
if (icons[layer] != static_cast<Icons>(0)) {
520519
pixels = animation->reverse(
521-
pgm_read_word(&(grafik_11x10[icons[layer]][r])),
520+
pgm_read_word(&(grafik_11x10[icons[layer]][row])),
522521
mirrored);
523-
if (pixels & (1 << c)) {
522+
if (pixels & (1 << col)) {
524523
color = colors[layer];
525524
return true;
526525
}

include/Animation.hpp

+58-75
Original file line numberDiff line numberDiff line change
@@ -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() {
330312
void 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

344327
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);
347330
}
348331
}
349332

350333
//------------------------------------------------------------------------------
351334

352335
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());
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) {
661644
uint16_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;

include/EEPROMAnything.h

+9-12
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,15 @@ void read() {
3939
Serial.printf("Sernr : %u\n", G.sernr);
4040
Serial.printf("Programm : %u\n", G.prog);
4141
Serial.printf("Conf : %u\n", G.conf);
42-
Serial.printf("FgCol.H : %f\n", G.color[Foreground].hsb.H);
43-
Serial.printf("FgCol.S : %f\n", G.color[Foreground].hsb.S);
44-
Serial.printf("FgCol.V : %f\n", G.color[Foreground].hsb.B);
45-
Serial.printf("FgCol.A : %u\n", G.color[Foreground].alpha);
46-
Serial.printf("BgCol.H : %f\n", G.color[Background].hsb.H);
47-
Serial.printf("BgCol.S : %f\n", G.color[Background].hsb.S);
48-
Serial.printf("BgCol.V : %f\n", G.color[Background].hsb.B);
49-
Serial.printf("BgCol.A : %u\n", G.color[Background].alpha);
50-
Serial.printf("EfCol.H : %f\n", G.color[Effect].hsb.H);
51-
Serial.printf("EfCol.S : %f\n", G.color[Effect].hsb.S);
52-
Serial.printf("EfCol.V : %f\n", G.color[Effect].hsb.B);
53-
Serial.printf("EfCol.A : %u\n", G.color[Effect].alpha);
42+
Serial.printf("FgCol.H : %f\n", G.color[Foreground].H);
43+
Serial.printf("FgCol.S : %f\n", G.color[Foreground].S);
44+
Serial.printf("FgCol.V : %f\n", G.color[Foreground].B);
45+
Serial.printf("BgCol.H : %f\n", G.color[Background].H);
46+
Serial.printf("BgCol.S : %f\n", G.color[Background].S);
47+
Serial.printf("BgCol.V : %f\n", G.color[Background].B);
48+
Serial.printf("EfCol.H : %f\n", G.color[Effect].H);
49+
Serial.printf("EfCol.S : %f\n", G.color[Effect].S);
50+
Serial.printf("EfCol.V : %f\n", G.color[Effect].B);
5451
Serial.printf("Zeitserver: %s\n", G.timeserver);
5552
Serial.printf("Lauftext : %s\n", G.scrollingText);
5653
Serial.printf("H6 : %u\n", G.h6);

0 commit comments

Comments
 (0)