Sfoglia il codice sorgente

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.
Roxy-3D 6 anni fa
parent
commit
aae4c67e5d
Nessun account collegato all'indirizzo email del committer

+ 2
- 2
Marlin/src/feature/Max7219_Debug_LEDs.cpp Vedi File

243
   uint32_t mask = 0x0000001;
243
   uint32_t mask = 0x0000001;
244
   for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++) {
244
   for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++) {
245
     if (val & mask)
245
     if (val & mask)
246
-      SET_PIXEL_7219(col, MAX7219_Y_LEDS-1-y);
246
+      SET_PIXEL_7219(col, MAX7219_Y_LEDS - y - 1);
247
     else
247
     else
248
-      CLEAR_PIXEL_7219(col, MAX7219_Y_LEDS-1-y);
248
+      CLEAR_PIXEL_7219(col, MAX7219_Y_LEDS - y - 1);
249
     mask <<= 1;
249
     mask <<= 1;
250
   }
250
   }
251
   #if _ROT == 90 || _ROT == 270
251
   #if _ROT == 90 || _ROT == 270

+ 8
- 8
Marlin/src/feature/Max7219_Debug_LEDs.h Vedi File

116
   #define MAX7219_UPDATE_AXIS     x   // Fast line update axis for this orientation of the matrix display
116
   #define MAX7219_UPDATE_AXIS     x   // Fast line update axis for this orientation of the matrix display
117
   #define MAX7219_X_LEDS          8
117
   #define MAX7219_X_LEDS          8
118
   #define MAX7219_Y_LEDS          (MAX7219_X_LEDS * (MAX7219_NUMBER_UNITS))
118
   #define MAX7219_Y_LEDS          (MAX7219_X_LEDS * (MAX7219_NUMBER_UNITS))
119
-  #define XOR_7219(x, y)          LEDs[x + ((MAX7219_Y_LEDS - 1 - y) & 0xF8)] ^= _BV((y & 0x7))
120
-  #define SET_PIXEL_7219(x, y)    LEDs[x + ((MAX7219_Y_LEDS - 1 - y) & 0xF8)] |= _BV((y & 0x7))
121
-  #define CLEAR_PIXEL_7219(x, y)  LEDs[x + ((MAX7219_Y_LEDS - 1 - y) & 0xF8)] &= (_BV((y & 0x7)) ^ 0xFF)
122
-  #define BIT_7219(x, y)          TEST(LEDs[x + ((MAX7219_Y_LEDS - 1 - y) & 0xF8)], (y & 0x7))
119
+  #define XOR_7219(x, y)          LEDs[x + (y & 0xF8)] ^= _BV((y & 0x7))
120
+  #define SET_PIXEL_7219(x, y)    LEDs[x + (y & 0xF8)] |= _BV((y & 0x7))
121
+  #define CLEAR_PIXEL_7219(x, y)  LEDs[x + (y & 0xF8)] &= (_BV((y & 0x7)) ^ 0xFF)
122
+  #define BIT_7219(x, y)          TEST(LEDs[x + (y & 0xF8)], (y & 0x7))
123
   #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);
123
   #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);
124
 #elif _ROT == 180
124
 #elif _ROT == 180
125
   #define MAX7219_UPDATE_AXIS     y   // Fast line update axis for this orientation of the matrix display
125
   #define MAX7219_UPDATE_AXIS     y   // Fast line update axis for this orientation of the matrix display
126
   #define MAX7219_Y_LEDS          8
126
   #define MAX7219_Y_LEDS          8
127
   #define MAX7219_X_LEDS          (MAX7219_Y_LEDS * (MAX7219_NUMBER_UNITS))
127
   #define MAX7219_X_LEDS          (MAX7219_Y_LEDS * (MAX7219_NUMBER_UNITS))
128
-  #define XOR_7219(x, y)          LEDs[y + (MAX7219_X_LEDS - 1 - (x)) & 0xF8] ^= _BV((x & 0x07))
129
-  #define SET_PIXEL_7219(x, y)    LEDs[y + (MAX7219_X_LEDS - 1 - (x)) & 0xF8] |= _BV((x & 0x07))
130
-  #define CLEAR_PIXEL_7219(x, y)  LEDs[y + (MAX7219_X_LEDS - 1 - (x)) & 0xF8] &= (_BV((x & 0x07)) ^ 0xFF)
131
-  #define BIT_7219(x, y)          TEST(LEDs[y + (MAX7219_X_LEDS - 1 - (x)) & 0xF8], ((x & 0x07)))
128
+  #define XOR_7219(x, y)          LEDs[x + (y & 0xF8)] ^= _BV((x & 0x07))
129
+  #define SET_PIXEL_7219(x, y)    LEDs[x + (y & 0xF8)] |= _BV((x & 0x07))
130
+  #define CLEAR_PIXEL_7219(x, y)  LEDs[x + (y & 0xF8)] &= (_BV((x & 0x07)) ^ 0xFF)
131
+  #define BIT_7219(x, y)          TEST(LEDs[x + (y & 0xF8)], ((x & 0x07)))
132
   #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);
132
   #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);
133
 #elif _ROT == 270
133
 #elif _ROT == 270
134
   #define MAX7219_UPDATE_AXIS     x   // Fast line update axis for this orientation of the matrix display
134
   #define MAX7219_UPDATE_AXIS     x   // Fast line update axis for this orientation of the matrix display

+ 9
- 3
Marlin/src/gcode/feature/leds/M7219.cpp Vedi File

71
   }
71
   }
72
 
72
 
73
   if (parser.seen('P')) {
73
   if (parser.seen('P')) {
74
-    for (uint8_t x = 0; x < COUNT(LEDs); x++) {
74
+    for (int8_t x = 0; x < 8 * MAX7219_NUMBER_UNITS; x++) {
75
       SERIAL_ECHOPAIR("LEDs[", x);
75
       SERIAL_ECHOPAIR("LEDs[", x);
76
-      SERIAL_ECHOPAIR("]=", LEDs[x]);
77
-      SERIAL_EOL();
76
+    SERIAL_ECHO("]=");
77
+    for (int8_t j = 7; j >= 0; j--) {
78
+      if ( LEDs[x] & (0x01<<j) )
79
+        SERIAL_ECHO("1");
80
+      else
81
+        SERIAL_ECHO("0");
78
     }
82
     }
83
+    SERIAL_EOL();
79
     return;
84
     return;
85
+    }
80
   }
86
   }
81
 }
87
 }
82
 
88
 

Loading…
Annulla
Salva