Max7219 Clean Up (#11563)
Some of the Rotations did not do the right thing with setting and clearing pixels. I think it is correct now. But if not... It is much closer to being correct.
This commit is contained in:
parent
9de730b2bf
commit
aae4c67e5d
|
@ -243,9 +243,9 @@ void Max7219_Set_Column(const uint8_t col, const uint32_t val) {
|
||||||
uint32_t mask = 0x0000001;
|
uint32_t mask = 0x0000001;
|
||||||
for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++) {
|
for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++) {
|
||||||
if (val & mask)
|
if (val & mask)
|
||||||
SET_PIXEL_7219(col, MAX7219_Y_LEDS-1-y);
|
SET_PIXEL_7219(col, MAX7219_Y_LEDS - y - 1);
|
||||||
else
|
else
|
||||||
CLEAR_PIXEL_7219(col, MAX7219_Y_LEDS-1-y);
|
CLEAR_PIXEL_7219(col, MAX7219_Y_LEDS - y - 1);
|
||||||
mask <<= 1;
|
mask <<= 1;
|
||||||
}
|
}
|
||||||
#if _ROT == 90 || _ROT == 270
|
#if _ROT == 90 || _ROT == 270
|
||||||
|
|
|
@ -116,19 +116,19 @@ void Max7219_idle_tasks();
|
||||||
#define MAX7219_UPDATE_AXIS x // Fast line update axis for this orientation of the matrix display
|
#define MAX7219_UPDATE_AXIS x // Fast line update axis for this orientation of the matrix display
|
||||||
#define MAX7219_X_LEDS 8
|
#define MAX7219_X_LEDS 8
|
||||||
#define MAX7219_Y_LEDS (MAX7219_X_LEDS * (MAX7219_NUMBER_UNITS))
|
#define MAX7219_Y_LEDS (MAX7219_X_LEDS * (MAX7219_NUMBER_UNITS))
|
||||||
#define XOR_7219(x, y) LEDs[x + ((MAX7219_Y_LEDS - 1 - y) & 0xF8)] ^= _BV((y & 0x7))
|
#define XOR_7219(x, y) LEDs[x + (y & 0xF8)] ^= _BV((y & 0x7))
|
||||||
#define SET_PIXEL_7219(x, y) LEDs[x + ((MAX7219_Y_LEDS - 1 - y) & 0xF8)] |= _BV((y & 0x7))
|
#define SET_PIXEL_7219(x, y) LEDs[x + (y & 0xF8)] |= _BV((y & 0x7))
|
||||||
#define CLEAR_PIXEL_7219(x, y) LEDs[x + ((MAX7219_Y_LEDS - 1 - y) & 0xF8)] &= (_BV((y & 0x7)) ^ 0xFF)
|
#define CLEAR_PIXEL_7219(x, y) LEDs[x + (y & 0xF8)] &= (_BV((y & 0x7)) ^ 0xFF)
|
||||||
#define BIT_7219(x, y) TEST(LEDs[x + ((MAX7219_Y_LEDS - 1 - y) & 0xF8)], (y & 0x7))
|
#define BIT_7219(x, y) TEST(LEDs[x + (y & 0xF8)], (y & 0x7))
|
||||||
#define SEND_7219(R) do {for(int8_t jj = 0; jj < MAX7219_NUMBER_UNITS; jj++) Max7219(max7219_reg_digit0 + (R & 0x7), LEDs[(R & 0x7) + jj * 8]); Max7219_pulse_load(); } while (0);
|
#define SEND_7219(R) do {for(int8_t jj = 0; jj < MAX7219_NUMBER_UNITS; jj++) Max7219(max7219_reg_digit0 + (R & 0x7), LEDs[(R & 0x7) + jj * 8]); Max7219_pulse_load(); } while (0);
|
||||||
#elif _ROT == 180
|
#elif _ROT == 180
|
||||||
#define MAX7219_UPDATE_AXIS y // Fast line update axis for this orientation of the matrix display
|
#define MAX7219_UPDATE_AXIS y // Fast line update axis for this orientation of the matrix display
|
||||||
#define MAX7219_Y_LEDS 8
|
#define MAX7219_Y_LEDS 8
|
||||||
#define MAX7219_X_LEDS (MAX7219_Y_LEDS * (MAX7219_NUMBER_UNITS))
|
#define MAX7219_X_LEDS (MAX7219_Y_LEDS * (MAX7219_NUMBER_UNITS))
|
||||||
#define XOR_7219(x, y) LEDs[y + (MAX7219_X_LEDS - 1 - (x)) & 0xF8] ^= _BV((x & 0x07))
|
#define XOR_7219(x, y) LEDs[x + (y & 0xF8)] ^= _BV((x & 0x07))
|
||||||
#define SET_PIXEL_7219(x, y) LEDs[y + (MAX7219_X_LEDS - 1 - (x)) & 0xF8] |= _BV((x & 0x07))
|
#define SET_PIXEL_7219(x, y) LEDs[x + (y & 0xF8)] |= _BV((x & 0x07))
|
||||||
#define CLEAR_PIXEL_7219(x, y) LEDs[y + (MAX7219_X_LEDS - 1 - (x)) & 0xF8] &= (_BV((x & 0x07)) ^ 0xFF)
|
#define CLEAR_PIXEL_7219(x, y) LEDs[x + (y & 0xF8)] &= (_BV((x & 0x07)) ^ 0xFF)
|
||||||
#define BIT_7219(x, y) TEST(LEDs[y + (MAX7219_X_LEDS - 1 - (x)) & 0xF8], ((x & 0x07)))
|
#define BIT_7219(x, y) TEST(LEDs[x + (y & 0xF8)], ((x & 0x07)))
|
||||||
#define SEND_7219(R) do {for(int8_t jj = 0; jj < MAX7219_NUMBER_UNITS; jj++) Max7219(max7219_reg_digit7 - (R & 0x7), LEDs[(R & 0x7) + jj * 8]); Max7219_pulse_load(); } while (0);
|
#define SEND_7219(R) do {for(int8_t jj = 0; jj < MAX7219_NUMBER_UNITS; jj++) Max7219(max7219_reg_digit7 - (R & 0x7), LEDs[(R & 0x7) + jj * 8]); Max7219_pulse_load(); } while (0);
|
||||||
#elif _ROT == 270
|
#elif _ROT == 270
|
||||||
#define MAX7219_UPDATE_AXIS x // Fast line update axis for this orientation of the matrix display
|
#define MAX7219_UPDATE_AXIS x // Fast line update axis for this orientation of the matrix display
|
||||||
|
|
|
@ -71,12 +71,18 @@ void GcodeSuite::M7219() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.seen('P')) {
|
if (parser.seen('P')) {
|
||||||
for (uint8_t x = 0; x < COUNT(LEDs); x++) {
|
for (int8_t x = 0; x < 8 * MAX7219_NUMBER_UNITS; x++) {
|
||||||
SERIAL_ECHOPAIR("LEDs[", x);
|
SERIAL_ECHOPAIR("LEDs[", x);
|
||||||
SERIAL_ECHOPAIR("]=", LEDs[x]);
|
SERIAL_ECHO("]=");
|
||||||
SERIAL_EOL();
|
for (int8_t j = 7; j >= 0; j--) {
|
||||||
|
if ( LEDs[x] & (0x01<<j) )
|
||||||
|
SERIAL_ECHO("1");
|
||||||
|
else
|
||||||
|
SERIAL_ECHO("0");
|
||||||
}
|
}
|
||||||
|
SERIAL_EOL();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue