|
@@ -455,15 +455,19 @@ void Max7219::register_setup() {
|
455
|
455
|
#ifdef MAX7219_INIT_TEST
|
456
|
456
|
#if MAX7219_INIT_TEST == 2
|
457
|
457
|
|
|
458
|
+ #define MAX7219_LEDS (MAX7219_X_LEDS * MAX7219_Y_LEDS)
|
|
459
|
+
|
458
|
460
|
void Max7219::spiral(const bool on, const uint16_t del) {
|
459
|
|
- constexpr int8_t way[] = { 1, 0, 0, 1, -1, 0, 0, -1 };
|
|
461
|
+ constexpr int8_t way[][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
|
460
|
462
|
int8_t px = 0, py = 0, dir = 0;
|
461
|
|
- for (uint8_t i = MAX7219_X_LEDS * MAX7219_Y_LEDS; i--;) {
|
|
463
|
+ for (IF<(MAX7219_LEDS > 255), uint16_t, uint8_t>::type i = MAX7219_LEDS; i--;) {
|
462
|
464
|
led_set(px, py, on);
|
463
|
465
|
delay(del);
|
464
|
|
- const int8_t x = px + way[dir], y = py + way[dir + 1];
|
465
|
|
- if (!WITHIN(x, 0, MAX7219_X_LEDS - 1) || !WITHIN(y, 0, MAX7219_Y_LEDS - 1) || BIT_7219(x, y) == on) dir = (dir + 2) & 0x7;
|
466
|
|
- px += way[dir]; py += way[dir + 1];
|
|
466
|
+ const int8_t x = px + way[dir][0], y = py + way[dir][1];
|
|
467
|
+ if (!WITHIN(x, 0, MAX7219_X_LEDS - 1) || !WITHIN(y, 0, MAX7219_Y_LEDS - 1) || BIT_7219(x, y) == on)
|
|
468
|
+ dir = (dir + 1) & 0x3;
|
|
469
|
+ px += way[dir][0];
|
|
470
|
+ py += way[dir][1];
|
467
|
471
|
}
|
468
|
472
|
}
|
469
|
473
|
|