Browse Source

Send slightly less data to Max7219

Scott Lahteine 6 years ago
parent
commit
601b2d9f51
1 changed files with 36 additions and 20 deletions
  1. 36
    20
      Marlin/src/feature/Max7219_Debug_LEDs.cpp

+ 36
- 20
Marlin/src/feature/Max7219_Debug_LEDs.cpp View File

210
   CRITICAL_SECTION_END;
210
   CRITICAL_SECTION_END;
211
 }
211
 }
212
 
212
 
213
-// Send out a single native row of bits to all units
214
-void Max7219::refresh_line(const uint8_t line) {
215
-  for (uint8_t u = MAX7219_NUMBER_UNITS; u--;)
216
-    send(LINE_REG(line), led_line[(u << 3) | (line & 0x7)]);
213
+// Send out a single native row of bits to just one unit
214
+void Max7219::refresh_unit_line(const uint8_t line) {
215
+  #if MAX7219_NUMBER_UNITS == 1
216
+    send(LINE_REG(line), led_line[line]);
217
+  #else
218
+    for (uint8_t u = MAX7219_NUMBER_UNITS; u--;)
219
+      if (u == (line >> 3)) send(LINE_REG(line), led_line[line]); else noop();
220
+  #endif
217
   pulse_load();
221
   pulse_load();
218
 }
222
 }
219
 
223
 
220
-// Send out a single native row of bits to just one unit
221
-void Max7219::refresh_unit_line(const uint8_t line) {
222
-  for (uint8_t u = MAX7219_NUMBER_UNITS; u--;)
223
-    if (u == (line >> 3)) send(LINE_REG(line), led_line[line]); else noop();
224
+// Send out a single native row of bits to all units
225
+void Max7219::refresh_line(const uint8_t line) {
226
+  #if MAX7219_NUMBER_UNITS == 1
227
+    refresh_unit_line(line);
228
+  #else
229
+    for (uint8_t u = MAX7219_NUMBER_UNITS; u--;)
230
+      send(LINE_REG(line), led_line[(u << 3) | (line & 0x7)]);
231
+  #endif
224
   pulse_load();
232
   pulse_load();
225
 }
233
 }
226
 
234
 
227
 void Max7219::set(const uint8_t line, const uint8_t bits) {
235
 void Max7219::set(const uint8_t line, const uint8_t bits) {
228
   led_line[line] = bits;
236
   led_line[line] = bits;
229
-  refresh_line(line);
237
+  refresh_unit_line(line);
230
 }
238
 }
231
 
239
 
232
 #if ENABLED(MAX7219_NUMERIC)
240
 #if ENABLED(MAX7219_NUMERIC)
268
   if (x > MAX7219_X_LEDS - 1 || y > MAX7219_Y_LEDS - 1) return error(PSTR("led_set"), x, y);
276
   if (x > MAX7219_X_LEDS - 1 || y > MAX7219_Y_LEDS - 1) return error(PSTR("led_set"), x, y);
269
   if (BIT_7219(x, y) == on) return;
277
   if (BIT_7219(x, y) == on) return;
270
   XOR_7219(x, y);
278
   XOR_7219(x, y);
271
-  refresh_line(LED_IND(x, y));
279
+  refresh_unit_line(LED_IND(x, y));
272
 }
280
 }
273
 
281
 
274
 void Max7219::led_on(const uint8_t x, const uint8_t y) {
282
 void Max7219::led_on(const uint8_t x, const uint8_t y) {
287
 }
295
 }
288
 
296
 
289
 void Max7219::send_row(const uint8_t row) {
297
 void Max7219::send_row(const uint8_t row) {
290
-  #if _ROT == 0 || _ROT == 180
291
-    refresh_line(LED_IND(0, row));
292
-  #else
298
+  #if _ROT == 0 || _ROT == 180            // Native Lines are horizontal too
299
+    #if MAX7219_X_LEDS <= 8
300
+      refresh_unit_line(LED_IND(0, row)); // A single unit line
301
+    #else
302
+      refresh_line(LED_IND(0, row));      // Same line, all units
303
+    #endif
304
+  #else                                   // Native lines are vertical
293
     UNUSED(row);
305
     UNUSED(row);
294
-    refresh();
306
+    refresh();                            // Actually a column
295
   #endif
307
   #endif
296
 }
308
 }
297
 
309
 
298
 void Max7219::send_column(const uint8_t col) {
310
 void Max7219::send_column(const uint8_t col) {
299
-  #if _ROT == 90 || _ROT == 270
300
-    refresh_line(LED_IND(col, 0));
301
-  #else
311
+  #if _ROT == 90 || _ROT == 270           // Native Lines are vertical too
312
+    #if MAX7219_Y_LEDS <= 8
313
+      refresh_unit_line(LED_IND(col, 0)); // A single unit line
314
+    #else
315
+      refresh_line(LED_IND(col, 0));      // Same line, all units
316
+    #endif
317
+  #else                                   // Native lines are horizontal
302
     UNUSED(col);
318
     UNUSED(col);
303
-    refresh();
319
+    refresh();                            // Actually a row
304
   #endif
320
   #endif
305
 }
321
 }
306
 
322
 
544
   for (uint8_t i = _MIN(nv, ov); i < _MAX(nv, ov); i++)
560
   for (uint8_t i = _MIN(nv, ov); i < _MAX(nv, ov); i++)
545
     #if MAX7219_X_LEDS == 8
561
     #if MAX7219_X_LEDS == 8
546
       #if MAX7219_Y_LEDS == 8
562
       #if MAX7219_Y_LEDS == 8
547
-        led_set(i >> 1, pos + (i & 1), nv >= ov); // single 8x8 LED matrix.  Use two lines to get 16 LED's
563
+        led_set(i >> 1, pos + (i & 1), nv >= ov); // Single 8x8 LED matrix.  Use two lines to get 16 LED's
548
       #else
564
       #else
549
         led_set(pos, i, nv >= ov);                // The Max7219 Y-Axis has at least 16 LED's.  So use a single column
565
         led_set(pos, i, nv >= ov);                // The Max7219 Y-Axis has at least 16 LED's.  So use a single column
550
       #endif
566
       #endif
551
     #else
567
     #else
552
-      led_set(i, pos, nv >= ov);                // LED matrix has at least 16 LED's on the X-Axis.  Use single line of LED's
568
+      led_set(i, pos, nv >= ov);                  // LED matrix has at least 16 LED's on the X-Axis.  Use single line of LED's
553
     #endif
569
     #endif
554
 }
570
 }
555
 
571
 

Loading…
Cancel
Save