|
@@ -31,7 +31,7 @@
|
31
|
31
|
* #define MAX7219_DIN_PIN 78
|
32
|
32
|
* #define MAX7219_LOAD_PIN 79
|
33
|
33
|
*
|
34
|
|
- * Max7219_init() is called automatically at startup, and then there are a number of
|
|
34
|
+ * send() is called automatically at startup, and then there are a number of
|
35
|
35
|
* support functions available to control the LEDs in the 8x8 grid.
|
36
|
36
|
*/
|
37
|
37
|
|
|
@@ -48,24 +48,96 @@
|
48
|
48
|
#include "../Marlin.h"
|
49
|
49
|
#include "../HAL/shared/Delay.h"
|
50
|
50
|
|
51
|
|
-uint8_t LEDs[8 * (MAX7219_NUMBER_UNITS)] = { 0 };
|
|
51
|
+Max7219 max7219;
|
52
|
52
|
|
53
|
|
-#ifndef MAX7219_ROTATE
|
54
|
|
- #define MAX7219_ROTATE 0
|
|
53
|
+uint8_t Max7219::led_line[MAX7219_ROWS]; // = { 0 };
|
|
54
|
+
|
|
55
|
+#if _ROT == 0 || _ROT == 270
|
|
56
|
+ #define _LED_BIT(Q) (7 - ((Q) & 0x07))
|
|
57
|
+#else
|
|
58
|
+ #define _LED_BIT(Q) ((Q) & 0x07)
|
|
59
|
+#endif
|
|
60
|
+#if _ROT >= 180
|
|
61
|
+ #define _LED_IND(P,Q) (P + ((Q) & ~0x07))
|
|
62
|
+ #define _ROW_REG(Q) (max7219_reg_digit7 - ((Q) & 0x7))
|
|
63
|
+#else
|
|
64
|
+ #define _LED_IND(P,Q) (P + ((Q) & ~0x07))
|
|
65
|
+ #define _ROW_REG(Q) (max7219_reg_digit0 + ((Q) & 0x7))
|
|
66
|
+#endif
|
|
67
|
+#if _ROT == 0 || _ROT == 180
|
|
68
|
+ #define MAX7219_LINE_AXIS y
|
|
69
|
+ #define LED_IND(X,Y) _LED_IND(Y,X)
|
|
70
|
+ #define LED_BIT(X,Y) _LED_BIT(X)
|
|
71
|
+#elif _ROT == 90 || _ROT == 270
|
|
72
|
+ #define MAX7219_LINE_AXIS x
|
|
73
|
+ #define LED_IND(X,Y) _LED_IND(X,Y)
|
|
74
|
+ #define LED_BIT(X,Y) _LED_BIT(Y)
|
|
75
|
+#else
|
|
76
|
+ #error "MAX7219_ROTATE must be a multiple of +/- 90°."
|
55
|
77
|
#endif
|
56
|
78
|
|
|
79
|
+#define XOR_7219(X,Y) led_line[LED_IND(X,Y)] ^= _BV(LED_BIT(X,Y))
|
|
80
|
+#define SET_LED_7219(X,Y) led_line[LED_IND(X,Y)] |= _BV(LED_BIT(X,Y))
|
|
81
|
+#define CLR_LED_7219(X,Y) led_line[LED_IND(X,Y)] &= ~_BV(LED_BIT(X,Y))
|
|
82
|
+#define BIT_7219(X,Y) TEST(led_line[LED_IND(X,Y)], LED_BIT(X,Y))
|
|
83
|
+
|
57
|
84
|
#ifdef CPU_32_BIT
|
58
|
|
- // Approximate a 1µs delay on 32-bit ARM
|
59
|
|
- #define SIG_DELAY() DELAY_US(1)
|
|
85
|
+ #define SIG_DELAY() DELAY_US(1) // Approximate a 1µs delay on 32-bit ARM
|
|
86
|
+ #undef CRITICAL_SECTION_START
|
|
87
|
+ #undef CRITICAL_SECTION_END
|
|
88
|
+ #define CRITICAL_SECTION_START NOOP
|
|
89
|
+ #define CRITICAL_SECTION_END NOOP
|
60
|
90
|
#else
|
61
|
|
- // Delay for 0.1875µs (16MHz AVR) or 0.15µs (20MHz AVR)
|
62
|
|
- #define SIG_DELAY() DELAY_NS(188)
|
|
91
|
+ #define SIG_DELAY() DELAY_NS(188) // Delay for 0.1875µs (16MHz AVR) or 0.15µs (20MHz AVR)
|
63
|
92
|
#endif
|
64
|
93
|
|
65
|
|
-void Max7219_PutByte(uint8_t data) {
|
66
|
|
- #ifndef CPU_32_BIT
|
67
|
|
- CRITICAL_SECTION_START;
|
|
94
|
+void Max7219::error(const char * const func, const int32_t v1, const int32_t v2/*=-1*/) {
|
|
95
|
+ #if ENABLED(MAX7219_ERRORS)
|
|
96
|
+ SERIAL_ECHOPGM("??? Max7219");
|
|
97
|
+ serialprintPGM(func);
|
|
98
|
+ SERIAL_CHAR('(');
|
|
99
|
+ SERIAL_ECHO(v1);
|
|
100
|
+ if (v2 > 0) SERIAL_ECHOPAIR(", ", v2);
|
|
101
|
+ SERIAL_CHAR(')');
|
|
102
|
+ SERIAL_EOL();
|
|
103
|
+ #else
|
|
104
|
+ UNUSED(func); UNUSED(v1); UNUSED(v2);
|
68
|
105
|
#endif
|
|
106
|
+}
|
|
107
|
+
|
|
108
|
+/**
|
|
109
|
+ * Flip the lowest n_bytes of the supplied bits:
|
|
110
|
+ * flipped(x, 1) flips the low 8 bits of x.
|
|
111
|
+ * flipped(x, 2) flips the low 16 bits of x.
|
|
112
|
+ * flipped(x, 3) flips the low 24 bits of x.
|
|
113
|
+ * flipped(x, 4) flips the low 32 bits of x.
|
|
114
|
+ */
|
|
115
|
+inline uint32_t flipped(const uint32_t bits, const uint8_t n_bytes) {
|
|
116
|
+ uint32_t mask = 1, outbits = 0;
|
|
117
|
+ for (uint8_t b = 0; b < n_bytes * 8; b++) {
|
|
118
|
+ outbits <<= 1;
|
|
119
|
+ if (bits & mask) outbits |= 1;
|
|
120
|
+ mask <<= 1;
|
|
121
|
+ }
|
|
122
|
+ return outbits;
|
|
123
|
+}
|
|
124
|
+
|
|
125
|
+void Max7219::noop() {
|
|
126
|
+ CRITICAL_SECTION_START;
|
|
127
|
+ SIG_DELAY();
|
|
128
|
+ WRITE(MAX7219_DIN_PIN, LOW);
|
|
129
|
+ for (uint8_t i = 16; i--;) {
|
|
130
|
+ SIG_DELAY();
|
|
131
|
+ WRITE(MAX7219_CLK_PIN, LOW);
|
|
132
|
+ SIG_DELAY();
|
|
133
|
+ WRITE(MAX7219_CLK_PIN, HIGH);
|
|
134
|
+ SIG_DELAY();
|
|
135
|
+ }
|
|
136
|
+ CRITICAL_SECTION_END;
|
|
137
|
+}
|
|
138
|
+
|
|
139
|
+void Max7219::putbyte(uint8_t data) {
|
|
140
|
+ CRITICAL_SECTION_START;
|
69
|
141
|
for (uint8_t i = 8; i--;) {
|
70
|
142
|
SIG_DELAY();
|
71
|
143
|
WRITE(MAX7219_CLK_PIN, LOW); // tick
|
|
@@ -76,11 +148,10 @@ void Max7219_PutByte(uint8_t data) {
|
76
|
148
|
SIG_DELAY();
|
77
|
149
|
data <<= 1;
|
78
|
150
|
}
|
79
|
|
- #ifndef CPU_32_BIT
|
80
|
|
- CRITICAL_SECTION_END;
|
81
|
|
- #endif
|
|
151
|
+ CRITICAL_SECTION_END;
|
82
|
152
|
}
|
83
|
|
-void Max7219_pulse_load() {
|
|
153
|
+
|
|
154
|
+void Max7219::pulse_load() {
|
84
|
155
|
SIG_DELAY();
|
85
|
156
|
WRITE(MAX7219_LOAD_PIN, LOW); // tell the chip to load the data
|
86
|
157
|
SIG_DELAY();
|
|
@@ -88,24 +159,43 @@ void Max7219_pulse_load() {
|
88
|
159
|
SIG_DELAY();
|
89
|
160
|
}
|
90
|
161
|
|
91
|
|
-void Max7219(const uint8_t reg, const uint8_t data) {
|
|
162
|
+void Max7219::send(const uint8_t reg, const uint8_t data) {
|
92
|
163
|
SIG_DELAY();
|
93
|
|
- #ifndef CPU_32_BIT
|
94
|
|
- CRITICAL_SECTION_START;
|
95
|
|
- #endif
|
|
164
|
+ CRITICAL_SECTION_START;
|
96
|
165
|
SIG_DELAY();
|
97
|
|
- Max7219_PutByte(reg); // specify register
|
|
166
|
+ putbyte(reg); // specify register
|
98
|
167
|
SIG_DELAY();
|
99
|
|
- Max7219_PutByte(data); // put data
|
100
|
|
- #ifndef CPU_32_BIT
|
101
|
|
- CRITICAL_SECTION_END;
|
102
|
|
- #endif
|
|
168
|
+ putbyte(data); // put data
|
|
169
|
+ CRITICAL_SECTION_END;
|
|
170
|
+}
|
|
171
|
+
|
|
172
|
+// Send out a single native row of bits to all units
|
|
173
|
+void Max7219::all(const uint8_t line) {
|
|
174
|
+ for (uint8_t u = 0; u < MAX7219_ROWS; u += 8)
|
|
175
|
+ send(_ROW_REG(line), led_line[u + (line & 0x7)]);
|
|
176
|
+ pulse_load();
|
|
177
|
+}
|
|
178
|
+
|
|
179
|
+// Send out a single native row of bits to just one unit
|
|
180
|
+void Max7219::one(const uint8_t line) {
|
|
181
|
+ for (uint8_t u = MAX7219_NUMBER_UNITS; u--;) {
|
|
182
|
+ if (u == (line >> 3))
|
|
183
|
+ send(_ROW_REG(line), led_line[line]);
|
|
184
|
+ else
|
|
185
|
+ noop();
|
|
186
|
+ }
|
|
187
|
+ pulse_load();
|
|
188
|
+}
|
|
189
|
+
|
|
190
|
+void Max7219::set(const uint8_t line, const uint8_t bits) {
|
|
191
|
+ led_line[line] = bits;
|
|
192
|
+ all(line);
|
103
|
193
|
}
|
104
|
194
|
|
105
|
195
|
#if ENABLED(MAX7219_NUMERIC)
|
106
|
196
|
|
107
|
197
|
// Draw an integer with optional leading zeros and optional decimal point
|
108
|
|
- void Max7219_Print(const uint8_t start, int16_t value, uint8_t size, const bool leadzero=false, bool dec=false) {
|
|
198
|
+ void Max7219::print(const uint8_t start, int16_t value, uint8_t size, const bool leadzero=false, bool dec=false) {
|
109
|
199
|
constexpr uint8_t led_numeral[10] = { 0x7E, 0x60, 0x6D, 0x79, 0x63, 0x5B, 0x5F, 0x70, 0x7F, 0x7A },
|
110
|
200
|
led_decimal = 0x80, led_minus = 0x01;
|
111
|
201
|
|
|
@@ -114,11 +204,11 @@ void Max7219(const uint8_t reg, const uint8_t data) {
|
114
|
204
|
while (size--) {
|
115
|
205
|
const bool minus = neg && blank;
|
116
|
206
|
if (minus) neg = false;
|
117
|
|
- Max7219(
|
|
207
|
+ send(
|
118
|
208
|
max7219_reg_digit0 + start + size,
|
119
|
209
|
minus ? led_minus : blank ? 0x00 : led_numeral[value % 10] | (dec ? led_decimal : 0x00)
|
120
|
210
|
);
|
121
|
|
- Max7219_pulse_load(); // tell the chips to load the clocked out data
|
|
211
|
+ pulse_load(); // tell the chips to load the clocked out data
|
122
|
212
|
value /= 10;
|
123
|
213
|
if (!value && !leadzero) blank = true;
|
124
|
214
|
dec = false;
|
|
@@ -126,247 +216,200 @@ void Max7219(const uint8_t reg, const uint8_t data) {
|
126
|
216
|
}
|
127
|
217
|
|
128
|
218
|
// Draw a float with a decimal point and optional digits
|
129
|
|
- void Max7219_Print(const uint8_t start, const float value, const uint8_t pre_size, const uint8_t post_size, const bool leadzero=false) {
|
130
|
|
- if (pre_size) Max7219_Print(start, value, pre_size, leadzero, !!post_size);
|
|
219
|
+ void Max7219::print(const uint8_t start, const float value, const uint8_t pre_size, const uint8_t post_size, const bool leadzero=false) {
|
|
220
|
+ if (pre_size) print(start, value, pre_size, leadzero, !!post_size);
|
131
|
221
|
if (post_size) {
|
132
|
222
|
const int16_t after = ABS(value) * (10 ^ post_size);
|
133
|
|
- Max7219_Print(start + pre_size, after, post_size, true);
|
|
223
|
+ print(start + pre_size, after, post_size, true);
|
134
|
224
|
}
|
135
|
225
|
}
|
136
|
226
|
|
137
|
227
|
#endif // MAX7219_NUMERIC
|
138
|
228
|
|
139
|
|
-inline void Max7219_Error(const char * const func, const int32_t v1, const int32_t v2=-1) {
|
140
|
|
- #if ENABLED(MAX7219_ERRORS)
|
141
|
|
- SERIAL_ECHOPGM("??? ");
|
142
|
|
- serialprintPGM(func);
|
143
|
|
- SERIAL_CHAR('(');
|
144
|
|
- SERIAL_ECHO(v1);
|
145
|
|
- if (v2 > 0) SERIAL_ECHOPAIR(", ", v2);
|
146
|
|
- SERIAL_CHAR(')');
|
147
|
|
- SERIAL_EOL();
|
148
|
|
- #else
|
149
|
|
- UNUSED(func); UNUSED(v1); UNUSED(v2);
|
150
|
|
- #endif
|
|
229
|
+// Modify a single LED bit and send the changed line
|
|
230
|
+void Max7219::led_set(const uint8_t x, const uint8_t y, const bool on) {
|
|
231
|
+ if (x > MAX7219_X_LEDS - 1 || y > MAX7219_Y_LEDS - 1) return error(PSTR("led_set"), x, y);
|
|
232
|
+ if (BIT_7219(x, y) == on) return;
|
|
233
|
+ XOR_7219(x, y);
|
|
234
|
+ all(MAX7219_LINE_AXIS);
|
151
|
235
|
}
|
152
|
236
|
|
153
|
|
-/**
|
154
|
|
- * uint32_t flipped(const uint32_t bits, const uint8_t n_bytes) operates on the number
|
155
|
|
- * of bytes specified in n_bytes. The lower order bits of the supplied bits are flipped.
|
156
|
|
- * flipped( x, 1) flips the low 8 bits of x.
|
157
|
|
- * flipped( x, 2) flips the low 16 bits of x.
|
158
|
|
- * flipped( x, 3) flips the low 24 bits of x.
|
159
|
|
- * flipped( x, 4) flips the low 32 bits of x.
|
160
|
|
- */
|
|
237
|
+void Max7219::led_on(const uint8_t x, const uint8_t y) {
|
|
238
|
+ if (x > MAX7219_X_LEDS - 1 || y > MAX7219_Y_LEDS - 1) return error(PSTR("led_on"), x, y);
|
|
239
|
+ led_set(x, y, true);
|
|
240
|
+}
|
161
|
241
|
|
162
|
|
-inline uint32_t flipped(const uint32_t bits, const uint8_t n_bytes) {
|
163
|
|
- uint32_t mask = 1, outbits = 0;
|
164
|
|
- for (uint8_t b = 0; b < n_bytes * 8; b++) {
|
165
|
|
- outbits = (outbits << 1);
|
166
|
|
- if (bits & mask)
|
167
|
|
- outbits |= 1;
|
168
|
|
- mask <<= 1;
|
169
|
|
- }
|
170
|
|
- return outbits;
|
|
242
|
+void Max7219::led_off(const uint8_t x, const uint8_t y) {
|
|
243
|
+ if (x > MAX7219_X_LEDS - 1 || y > MAX7219_Y_LEDS - 1) return error(PSTR("led_off"), x, y);
|
|
244
|
+ led_set(x, y, false);
|
171
|
245
|
}
|
172
|
246
|
|
173
|
|
-// Modify a single LED bit and send the changed line
|
174
|
|
-void Max7219_LED_Set(const uint8_t x, const uint8_t y, const bool on) {
|
175
|
|
- if (x > (MAX7219_X_LEDS - 1) || y > (MAX7219_Y_LEDS - 1)) return Max7219_Error(PSTR("Max7219_LED_Set"), x, y);
|
176
|
|
- if (BIT_7219(x, y) == on) return;
|
177
|
|
- XOR_7219(x, y);
|
178
|
|
- SEND_7219(MAX7219_UPDATE_AXIS);
|
|
247
|
+void Max7219::led_toggle(const uint8_t x, const uint8_t y) {
|
|
248
|
+ if (x > MAX7219_X_LEDS - 1 || y > MAX7219_Y_LEDS - 1) return error(PSTR("led_toggle"), x, y);
|
|
249
|
+ led_set(x, y, !BIT_7219(x, y));
|
|
250
|
+}
|
|
251
|
+
|
|
252
|
+void Max7219::send_row(const uint8_t row) {
|
|
253
|
+ #if _ROT == 90 || _ROT == 270
|
|
254
|
+ all(row);
|
|
255
|
+ #else
|
|
256
|
+ UNUSED(row);
|
|
257
|
+ refresh();
|
|
258
|
+ #endif
|
179
|
259
|
}
|
180
|
260
|
|
181
|
|
-void Max7219_LED_On(const uint8_t x, const uint8_t y) {
|
182
|
|
- if (x > (MAX7219_X_LEDS - 1) || y > (MAX7219_Y_LEDS - 1)) return Max7219_Error(PSTR("Max7219_LED_On"), x, y);
|
183
|
|
- Max7219_LED_Set(x, y, true);
|
|
261
|
+void Max7219::send_column(const uint8_t col) {
|
|
262
|
+ #if _ROT == 90 || _ROT == 270
|
|
263
|
+ all(col); // Send the "column" out and strobe
|
|
264
|
+ #else
|
|
265
|
+ UNUSED(col);
|
|
266
|
+ refresh();
|
|
267
|
+ #endif
|
184
|
268
|
}
|
185
|
269
|
|
186
|
|
-void Max7219_LED_Off(const uint8_t x, const uint8_t y) {
|
187
|
|
- if (x > (MAX7219_X_LEDS - 1) || y > (MAX7219_Y_LEDS - 1)) return Max7219_Error(PSTR("Max7219_LED_Off"), x, y);
|
188
|
|
- Max7219_LED_Set(x, y, false);
|
|
270
|
+void Max7219::clear() {
|
|
271
|
+ ZERO(led_line);
|
|
272
|
+ refresh();
|
189
|
273
|
}
|
190
|
274
|
|
191
|
|
-void Max7219_LED_Toggle(const uint8_t x, const uint8_t y) {
|
192
|
|
- if (x > (MAX7219_X_LEDS - 1) || y > (MAX7219_Y_LEDS - 1)) return Max7219_Error(PSTR("Max7219_LED_Toggle"), x, y);
|
193
|
|
- Max7219_LED_Set(x, y, !BIT_7219(x, y));
|
|
275
|
+void Max7219::clear_row(const uint8_t row) {
|
|
276
|
+ if (row >= MAX7219_Y_LEDS) return error(PSTR("clear_row"), row);
|
|
277
|
+ for (uint8_t x = 0; x < MAX7219_X_LEDS; x++)
|
|
278
|
+ CLR_LED_7219(MAX7219_X_LEDS - 1 - x, row);
|
|
279
|
+ send_row(row);
|
194
|
280
|
}
|
195
|
281
|
|
196
|
|
-inline void _Max7219_Set_Digit_Segments(const uint8_t digit, const uint8_t val) {
|
197
|
|
- LEDs[digit] = val;
|
198
|
|
- SEND_7219(digit);
|
|
282
|
+void Max7219::clear_column(const uint8_t col) {
|
|
283
|
+ if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col);
|
|
284
|
+ for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++)
|
|
285
|
+ CLR_LED_7219(col, MAX7219_Y_LEDS - y - 1);
|
|
286
|
+ send_column(col);
|
199
|
287
|
}
|
200
|
288
|
|
201
|
289
|
/**
|
202
|
|
- * void Max7219_Set_Row( const uint8_t col, const uint32_t val) plots the low order bits of
|
203
|
|
- * val to the specified row of the Max7219 matrix. With 4 Max7219 units in the chain, it
|
204
|
|
- * is possible to display an entire 32-bit number with one call to the function (if appropriately
|
205
|
|
- * orientated).
|
|
290
|
+ * Plot the low order bits of val to the specified row of the matrix.
|
|
291
|
+ * With 4 Max7219 units in the chain, it's possible to set 32 bits at once with
|
|
292
|
+ * one call to the function (if rotated 90° or 180°).
|
206
|
293
|
*/
|
207
|
|
-void Max7219_Set_Row(const uint8_t row, const uint32_t val) {
|
208
|
|
- if (row >= MAX7219_Y_LEDS) return Max7219_Error(PSTR("Max7219_Set_Row"), row);
|
|
294
|
+void Max7219::set_row(const uint8_t row, const uint32_t val) {
|
|
295
|
+ if (row >= MAX7219_Y_LEDS) return error(PSTR("set_row"), row);
|
209
|
296
|
uint32_t mask = 0x0000001;
|
210
|
297
|
for (uint8_t x = 0; x < MAX7219_X_LEDS; x++) {
|
211
|
298
|
if (val & mask)
|
212
|
|
- SET_PIXEL_7219((MAX7219_X_LEDS-1-x), row);
|
|
299
|
+ SET_LED_7219(MAX7219_X_LEDS - 1 - x, row);
|
213
|
300
|
else
|
214
|
|
- CLEAR_PIXEL_7219((MAX7219_X_LEDS-1-x), row);
|
|
301
|
+ CLR_LED_7219(MAX7219_X_LEDS - 1 - x, row);
|
215
|
302
|
mask <<= 1;
|
216
|
303
|
}
|
217
|
|
-
|
218
|
|
- #if _ROT == 90 || _ROT == 270
|
219
|
|
- for (uint8_t x = 0; x < 8; x++)
|
220
|
|
- SEND_7219(x); // force all columns out to the Max7219 chips and strobe them
|
221
|
|
- #else
|
222
|
|
- SEND_7219(row); // force the single column out to the Max7219 chips and strobe them
|
223
|
|
- #endif
|
224
|
|
-}
|
225
|
|
-
|
226
|
|
-void Max7219_Clear_Row(const uint8_t row) {
|
227
|
|
- if (row > 7) return Max7219_Error(PSTR("Max7219_Clear_Row"), row);
|
228
|
|
- #if _ROT == 90 || _ROT == 270
|
229
|
|
- for (uint8_t col = 0; col < 8; col++) Max7219_LED_Off(col, row);
|
230
|
|
- #else
|
231
|
|
- _Max7219_Set_Digit_Segments(row, 0);
|
232
|
|
- #endif
|
|
304
|
+ send_row(row);
|
233
|
305
|
}
|
234
|
306
|
|
235
|
307
|
/**
|
236
|
|
- * void Max7219_Set_Column( const uint8_t col, const uint32_t val) plots the low order bits of
|
237
|
|
- * val to the specified column of the Max7219 matrix. With 4 Max7219 units in the chain, it
|
238
|
|
- * is possible to display an entire 32-bit number with one call to the function (if appropriately
|
239
|
|
- * orientated).
|
|
308
|
+ * Plot the low order bits of val to the specified column of the matrix.
|
|
309
|
+ * With 4 Max7219 units in the chain, it's possible to set 32 bits at once with
|
|
310
|
+ * one call to the function (if rotated 90° or 180°).
|
240
|
311
|
*/
|
241
|
|
-void Max7219_Set_Column(const uint8_t col, const uint32_t val) {
|
242
|
|
- if (col >= MAX7219_X_LEDS) return Max7219_Error(PSTR("Max7219_Set_Column"), col);
|
|
312
|
+void Max7219::set_column(const uint8_t col, const uint32_t val) {
|
|
313
|
+ if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col);
|
243
|
314
|
uint32_t mask = 0x0000001;
|
244
|
315
|
for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++) {
|
245
|
316
|
if (val & mask)
|
246
|
|
- SET_PIXEL_7219(col, MAX7219_Y_LEDS - y - 1);
|
|
317
|
+ SET_LED_7219(col, MAX7219_Y_LEDS - y - 1);
|
247
|
318
|
else
|
248
|
|
- CLEAR_PIXEL_7219(col, MAX7219_Y_LEDS - y - 1);
|
|
319
|
+ CLR_LED_7219(col, MAX7219_Y_LEDS - y - 1);
|
249
|
320
|
mask <<= 1;
|
250
|
321
|
}
|
251
|
|
- #if _ROT == 90 || _ROT == 270
|
252
|
|
- SEND_7219(col); // force the column out to the Max7219 chips and strobe them
|
253
|
|
- #else
|
254
|
|
- for (uint8_t yy = 0; yy < 8; yy++)
|
255
|
|
- SEND_7219(yy); // force all columns out to the Max7219 chips and strobe them
|
256
|
|
- #endif
|
257
|
|
-}
|
258
|
|
-
|
259
|
|
-void Max7219_Clear_Column(const uint8_t col) {
|
260
|
|
- if (col >= MAX7219_X_LEDS) return Max7219_Error(PSTR("Max7219_Clear_Column"), col);
|
261
|
|
-
|
262
|
|
- for (uint8_t yy = 0; yy < MAX7219_Y_LEDS; yy++)
|
263
|
|
- CLEAR_PIXEL_7219(col, yy);
|
264
|
|
-
|
265
|
|
- #if _ROT == 90 || _ROT == 270
|
266
|
|
- SEND_7219(col); // force the column out to the Max7219 chips and strobe them
|
267
|
|
- #else
|
268
|
|
- for (uint8_t y = 0; y < 8; y++)
|
269
|
|
- SEND_7219(y); // force all columns out to the Max7219 chips and strobe them
|
270
|
|
- #endif
|
271
|
|
-}
|
272
|
|
-
|
273
|
|
-void Max7219_Clear() {
|
274
|
|
- for (uint8_t i = 0; i <= 7; i++) { // Clear LED bitmap
|
275
|
|
- for (uint8_t j = 0; j < MAX7219_NUMBER_UNITS; j++)
|
276
|
|
- LEDs[i + j * 8] = 0x00;
|
277
|
|
- SEND_7219(i);
|
278
|
|
- }
|
279
|
|
-
|
|
322
|
+ send_column(col);
|
280
|
323
|
}
|
281
|
324
|
|
282
|
|
-void Max7219_Set_Rows_16bits(const uint8_t y, uint32_t val) {
|
|
325
|
+void Max7219::set_rows_16bits(const uint8_t y, uint32_t val) {
|
283
|
326
|
#if MAX7219_X_LEDS == 8
|
284
|
|
- if (y > MAX7219_Y_LEDS - 2) return Max7219_Error(PSTR("Max7219_Set_Rows_16bits"), y, val);
|
285
|
|
- Max7219_Set_Row(y + 1, val); val >>= 8;
|
286
|
|
- Max7219_Set_Row(y + 0, val);
|
|
327
|
+ if (y > MAX7219_Y_LEDS - 2) return error(PSTR("set_rows_16bits"), y, val);
|
|
328
|
+ set_row(y + 1, val); val >>= 8;
|
|
329
|
+ set_row(y + 0, val);
|
287
|
330
|
#else // at least 16 bits on each row
|
288
|
|
- if (y > MAX7219_Y_LEDS - 1) return Max7219_Error(PSTR("Max7219_Set_Rows_16bits"), y, val);
|
289
|
|
- Max7219_Set_Row(y, val);
|
|
331
|
+ if (y > MAX7219_Y_LEDS - 1) return error(PSTR("set_rows_16bits"), y, val);
|
|
332
|
+ set_row(y, val);
|
290
|
333
|
#endif
|
291
|
334
|
}
|
292
|
335
|
|
293
|
|
-void Max7219_Set_Rows_32bits(const uint8_t y, uint32_t val) {
|
|
336
|
+void Max7219::set_rows_32bits(const uint8_t y, uint32_t val) {
|
294
|
337
|
#if MAX7219_X_LEDS == 8
|
295
|
|
- if (y > MAX7219_Y_LEDS - 4) return Max7219_Error(PSTR("Max7219_Set_Rows_32bits"), y, val);
|
296
|
|
- Max7219_Set_Row(y + 3, val); val >>= 8;
|
297
|
|
- Max7219_Set_Row(y + 2, val); val >>= 8;
|
298
|
|
- Max7219_Set_Row(y + 1, val); val >>= 8;
|
299
|
|
- Max7219_Set_Row(y + 0, val);
|
|
338
|
+ if (y > MAX7219_Y_LEDS - 4) return error(PSTR("set_rows_32bits"), y, val);
|
|
339
|
+ set_row(y + 3, val); val >>= 8;
|
|
340
|
+ set_row(y + 2, val); val >>= 8;
|
|
341
|
+ set_row(y + 1, val); val >>= 8;
|
|
342
|
+ set_row(y + 0, val);
|
300
|
343
|
#elif MAX7219_X_LEDS == 16
|
301
|
|
- if (y > MAX7219_Y_LEDS - 2) return Max7219_Error(PSTR("Max7219_Set_Rows_32bits"), y, val);
|
302
|
|
- Max7219_Set_Row(y + 1, val); val >>= 16;
|
303
|
|
- Max7219_Set_Row(y + 0, val);
|
|
344
|
+ if (y > MAX7219_Y_LEDS - 2) return error(PSTR("set_rows_32bits"), y, val);
|
|
345
|
+ set_row(y + 1, val); val >>= 16;
|
|
346
|
+ set_row(y + 0, val);
|
304
|
347
|
#else // at least 24 bits on each row. In the 3 matrix case, just display the low 24 bits
|
305
|
|
- if (y > MAX7219_Y_LEDS - 1) return Max7219_Error(PSTR("Max7219_Set_Rows_32bits"), y, val);
|
306
|
|
- Max7219_Set_Row(y, val);
|
|
348
|
+ if (y > MAX7219_Y_LEDS - 1) return error(PSTR("set_rows_32bits"), y, val);
|
|
349
|
+ set_row(y, val);
|
307
|
350
|
#endif
|
308
|
351
|
}
|
309
|
352
|
|
310
|
|
-void Max7219_Set_Columns_16bits(const uint8_t x, uint32_t val) {
|
|
353
|
+void Max7219::set_columns_16bits(const uint8_t x, uint32_t val) {
|
311
|
354
|
#if MAX7219_Y_LEDS == 8
|
312
|
|
- if (x > MAX7219_X_LEDS - 2) return Max7219_Error(PSTR("Max7219_Set_Columns_16bits"), x, val);
|
313
|
|
- Max7219_Set_Column(x + 0, val); val >>= 8;
|
314
|
|
- Max7219_Set_Column(x + 1, val);
|
|
355
|
+ if (x > MAX7219_X_LEDS - 2) return error(PSTR("set_columns_16bits"), x, val);
|
|
356
|
+ set_column(x + 0, val); val >>= 8;
|
|
357
|
+ set_column(x + 1, val);
|
315
|
358
|
#else // at least 16 bits in each column
|
316
|
|
- if (x > MAX7219_X_LEDS - 1) return Max7219_Error(PSTR("Max7219_Set_Columns_16bits"), x, val);
|
317
|
|
- Max7219_Set_Column(x, val);
|
|
359
|
+ if (x > MAX7219_X_LEDS - 1) return error(PSTR("set_columns_16bits"), x, val);
|
|
360
|
+ set_column(x, val);
|
318
|
361
|
#endif
|
319
|
362
|
}
|
320
|
363
|
|
321
|
|
-void Max7219_Set_Columns_32bits(const uint8_t x, uint32_t val) {
|
|
364
|
+void Max7219::set_columns_32bits(const uint8_t x, uint32_t val) {
|
322
|
365
|
#if MAX7219_Y_LEDS == 8
|
323
|
|
- if (x > MAX7219_X_LEDS - 4) return Max7219_Error(PSTR("Max7219_Set_Rows_32bits"), x, val);
|
324
|
|
- Max7219_Set_Column(x + 3, val); val >>= 8;
|
325
|
|
- Max7219_Set_Column(x + 2, val); val >>= 8;
|
326
|
|
- Max7219_Set_Column(x + 1, val); val >>= 8;
|
327
|
|
- Max7219_Set_Column(x + 0, val);
|
|
366
|
+ if (x > MAX7219_X_LEDS - 4) return error(PSTR("set_rows_32bits"), x, val);
|
|
367
|
+ set_column(x + 3, val); val >>= 8;
|
|
368
|
+ set_column(x + 2, val); val >>= 8;
|
|
369
|
+ set_column(x + 1, val); val >>= 8;
|
|
370
|
+ set_column(x + 0, val);
|
328
|
371
|
#elif MAX7219_Y_LEDS == 16
|
329
|
|
- if (x > MAX7219_X_LEDS - 2) return Max7219_Error(PSTR("Max7219_Set_Rows_32bits"), x, val);
|
330
|
|
- Max7219_Set_Column(x + 1, val); val >>= 16;
|
331
|
|
- Max7219_Set_Column(x + 0, val);
|
|
372
|
+ if (x > MAX7219_X_LEDS - 2) return error(PSTR("set_rows_32bits"), x, val);
|
|
373
|
+ set_column(x + 1, val); val >>= 16;
|
|
374
|
+ set_column(x + 0, val);
|
332
|
375
|
#else // at least 24 bits on each row. In the 3 matrix case, just display the low 24 bits
|
333
|
|
- if (x > MAX7219_X_LEDS - 1) return Max7219_Error(PSTR("Max7219_Set_Rows_32bits"), x, val);
|
334
|
|
- Max7219_Set_Column(x, val);
|
|
376
|
+ if (x > MAX7219_X_LEDS - 1) return error(PSTR("set_rows_32bits"), x, val);
|
|
377
|
+ set_column(x, val);
|
335
|
378
|
#endif
|
336
|
379
|
}
|
337
|
380
|
|
338
|
|
-void Max7219_register_setup() {
|
|
381
|
+void Max7219::register_setup() {
|
339
|
382
|
// Initialize the Max7219
|
340
|
383
|
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
341
|
|
- Max7219(max7219_reg_scanLimit, 0x07);
|
342
|
|
- Max7219_pulse_load(); // tell the chips to load the clocked out data
|
|
384
|
+ send(max7219_reg_scanLimit, 0x07);
|
|
385
|
+ pulse_load(); // tell the chips to load the clocked out data
|
343
|
386
|
|
344
|
387
|
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
345
|
|
- Max7219(max7219_reg_decodeMode, 0x00); // using an led matrix (not digits)
|
346
|
|
- Max7219_pulse_load(); // tell the chips to load the clocked out data
|
|
388
|
+ send(max7219_reg_decodeMode, 0x00); // using an led matrix (not digits)
|
|
389
|
+ pulse_load(); // tell the chips to load the clocked out data
|
347
|
390
|
|
348
|
391
|
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
349
|
|
- Max7219(max7219_reg_shutdown, 0x01); // not in shutdown mode
|
350
|
|
- Max7219_pulse_load(); // tell the chips to load the clocked out data
|
|
392
|
+ send(max7219_reg_shutdown, 0x01); // not in shutdown mode
|
|
393
|
+ pulse_load(); // tell the chips to load the clocked out data
|
351
|
394
|
|
352
|
395
|
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
353
|
|
- Max7219(max7219_reg_displayTest, 0x00); // no display test
|
354
|
|
- Max7219_pulse_load(); // tell the chips to load the clocked out data
|
|
396
|
+ send(max7219_reg_displayTest, 0x00); // no display test
|
|
397
|
+ pulse_load(); // tell the chips to load the clocked out data
|
355
|
398
|
|
356
|
399
|
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
357
|
|
- Max7219(max7219_reg_intensity, 0x01 & 0x0F); // the first 0x0F is the value you can set
|
358
|
|
- // range: 0x00 to 0x0F
|
359
|
|
- Max7219_pulse_load(); // tell the chips to load the clocked out data
|
|
400
|
+ send(max7219_reg_intensity, 0x01 & 0x0F); // the first 0x0F is the value you can set
|
|
401
|
+ // range: 0x00 to 0x0F
|
|
402
|
+ pulse_load(); // tell the chips to load the clocked out data
|
360
|
403
|
}
|
361
|
404
|
|
362
|
405
|
#ifdef MAX7219_INIT_TEST
|
363
|
|
-#if (MAX7219_INIT_TEST + 0) == 2
|
|
406
|
+#if MAX7219_INIT_TEST == 2
|
364
|
407
|
|
365
|
|
- inline void Max7219_spiral(const bool on, const uint16_t del) {
|
|
408
|
+ void Max7219::spiral(const bool on, const uint16_t del) {
|
366
|
409
|
constexpr int8_t way[] = { 1, 0, 0, 1, -1, 0, 0, -1 };
|
367
|
410
|
int8_t px = 0, py = 0, dir = 0;
|
368
|
411
|
for (uint8_t i = MAX7219_X_LEDS * MAX7219_Y_LEDS; i--;) {
|
369
|
|
- Max7219_LED_Set(px, py, on);
|
|
412
|
+ led_set(px, py, on);
|
370
|
413
|
delay(del);
|
371
|
414
|
const int8_t x = px + way[dir], y = py + way[dir + 1];
|
372
|
415
|
if (!WITHIN(x, 0, MAX7219_X_LEDS-1) || !WITHIN(y, 0, MAX7219_Y_LEDS-1) || BIT_7219(x, y) == on) dir = (dir + 2) & 0x7;
|
|
@@ -376,10 +419,10 @@ void Max7219_register_setup() {
|
376
|
419
|
|
377
|
420
|
#else
|
378
|
421
|
|
379
|
|
- inline void Max7219_sweep(const int8_t dir, const uint16_t ms, const bool on) {
|
|
422
|
+ void Max7219::sweep(const int8_t dir, const uint16_t ms, const bool on) {
|
380
|
423
|
uint8_t x = dir > 0 ? 0 : MAX7219_X_LEDS-1;
|
381
|
424
|
for (uint8_t i = MAX7219_X_LEDS; i--; x += dir) {
|
382
|
|
- Max7219_Set_Column(x, on ? 0xFFFFFFFF : 0x00000000);
|
|
425
|
+ set_column(x, on ? 0xFFFFFFFF : 0x00000000);
|
383
|
426
|
delay(ms);
|
384
|
427
|
}
|
385
|
428
|
}
|
|
@@ -387,33 +430,33 @@ void Max7219_register_setup() {
|
387
|
430
|
#endif
|
388
|
431
|
#endif // MAX7219_INIT_TEST
|
389
|
432
|
|
390
|
|
-void Max7219_init() {
|
|
433
|
+void Max7219::init() {
|
391
|
434
|
SET_OUTPUT(MAX7219_DIN_PIN);
|
392
|
435
|
SET_OUTPUT(MAX7219_CLK_PIN);
|
393
|
436
|
OUT_WRITE(MAX7219_LOAD_PIN, HIGH);
|
394
|
437
|
delay(1);
|
395
|
438
|
|
396
|
|
- Max7219_register_setup();
|
|
439
|
+ register_setup();
|
397
|
440
|
|
398
|
441
|
for (uint8_t i = 0; i <= 7; i++) { // Empty registers to turn all LEDs off
|
399
|
|
- LEDs[i] = 0x00;
|
400
|
|
- Max7219(max7219_reg_digit0 + i, 0);
|
401
|
|
- Max7219_pulse_load(); // tell the chips to load the clocked out data
|
|
442
|
+ led_line[i] = 0x00;
|
|
443
|
+ send(max7219_reg_digit0 + i, 0);
|
|
444
|
+ pulse_load(); // tell the chips to load the clocked out data
|
402
|
445
|
}
|
403
|
446
|
|
404
|
447
|
#ifdef MAX7219_INIT_TEST
|
405
|
|
- #if (MAX7219_INIT_TEST + 0) == 2
|
406
|
|
- Max7219_spiral(true, 8);
|
|
448
|
+ #if MAX7219_INIT_TEST == 2
|
|
449
|
+ spiral(true, 8);
|
407
|
450
|
delay(150);
|
408
|
|
- Max7219_spiral(false, 8);
|
|
451
|
+ spiral(false, 8);
|
409
|
452
|
#else
|
410
|
453
|
// Do an aesthetically-pleasing pattern to fully test the Max7219 module and LEDs.
|
411
|
454
|
// Light up and turn off columns, both forward and backward.
|
412
|
|
- Max7219_sweep(1, 20, true);
|
413
|
|
- Max7219_sweep(1, 20, false);
|
|
455
|
+ sweep(1, 20, true);
|
|
456
|
+ sweep(1, 20, false);
|
414
|
457
|
delay(150);
|
415
|
|
- Max7219_sweep(-1, 20, true);
|
416
|
|
- Max7219_sweep(-1, 20, false);
|
|
458
|
+ sweep(-1, 20, true);
|
|
459
|
+ sweep(-1, 20, false);
|
417
|
460
|
#endif
|
418
|
461
|
#endif
|
419
|
462
|
}
|
|
@@ -425,73 +468,69 @@ void Max7219_init() {
|
425
|
468
|
*/
|
426
|
469
|
|
427
|
470
|
// Apply changes to update a marker
|
428
|
|
-inline void Max7219_Mark16(const uint8_t y, const uint8_t v1, const uint8_t v2) {
|
|
471
|
+void Max7219::mark16(const uint8_t y, const uint8_t v1, const uint8_t v2) {
|
429
|
472
|
#if MAX7219_X_LEDS == 8
|
430
|
473
|
#if MAX7219_Y_LEDS == 8
|
431
|
|
- Max7219_LED_Off(v1 & 0x7, y + (v1 >= 8));
|
432
|
|
- Max7219_LED_On(v2 & 0x7, y + (v2 >= 8));
|
|
474
|
+ led_off(v1 & 0x7, y + (v1 >= 8));
|
|
475
|
+ led_on(v2 & 0x7, y + (v2 >= 8));
|
433
|
476
|
#else
|
434
|
|
- Max7219_LED_Off(y, v1 & 0xF); // The Max7219 Y-Axis has at least 16 LED's. So use a single column
|
435
|
|
- Max7219_LED_On(y, v2 & 0xF);
|
|
477
|
+ led_off(y, v1 & 0xF); // At least 16 LEDs down. Use a single column.
|
|
478
|
+ led_on(y, v2 & 0xF);
|
436
|
479
|
#endif
|
437
|
|
- #else // LED matrix has at least 16 LED's on the X-Axis. Use single line of LED's
|
438
|
|
- Max7219_LED_Off(v1 & 0xf, y);
|
439
|
|
- Max7219_LED_On(v2 & 0xf, y);
|
|
480
|
+ #else
|
|
481
|
+ led_off(v1 & 0xF, y); // At least 16 LEDs across. Use a single row.
|
|
482
|
+ led_on(v2 & 0xF, y);
|
440
|
483
|
#endif
|
441
|
484
|
}
|
442
|
485
|
|
443
|
486
|
// Apply changes to update a tail-to-head range
|
444
|
|
-inline void Max7219_Range16(const uint8_t y, const uint8_t ot, const uint8_t nt, const uint8_t oh, const uint8_t nh) {
|
|
487
|
+void Max7219::range16(const uint8_t y, const uint8_t ot, const uint8_t nt, const uint8_t oh, const uint8_t nh) {
|
445
|
488
|
#if MAX7219_X_LEDS == 8
|
446
|
489
|
#if MAX7219_Y_LEDS == 8
|
447
|
490
|
if (ot != nt) for (uint8_t n = ot & 0xF; n != (nt & 0xF) && n != (nh & 0xF); n = (n + 1) & 0xF)
|
448
|
|
- Max7219_LED_Off(n & 0x7, y + (n >= 8));
|
|
491
|
+ led_off(n & 0x7, y + (n >= 8));
|
449
|
492
|
if (oh != nh) for (uint8_t n = (oh + 1) & 0xF; n != ((nh + 1) & 0xF); n = (n + 1) & 0xF)
|
450
|
|
- Max7219_LED_On(n & 0x7, y + (n >= 8));
|
|
493
|
+ led_on(n & 0x7, y + (n >= 8));
|
451
|
494
|
#else // The Max7219 Y-Axis has at least 16 LED's. So use a single column
|
452
|
495
|
if (ot != nt) for (uint8_t n = ot & 0xF; n != (nt & 0xF) && n != (nh & 0xF); n = (n + 1) & 0xF)
|
453
|
|
- Max7219_LED_Off(y, n & 0xF);
|
|
496
|
+ led_off(y, n & 0xF);
|
454
|
497
|
if (oh != nh) for (uint8_t n = (oh + 1) & 0xF; n != ((nh + 1) & 0xF); n = (n + 1) & 0xF)
|
455
|
|
- Max7219_LED_On(y, n & 0xF);
|
|
498
|
+ led_on(y, n & 0xF);
|
456
|
499
|
#endif
|
457
|
500
|
#else // LED matrix has at least 16 LED's on the X-Axis. Use single line of LED's
|
458
|
501
|
if (ot != nt) for (uint8_t n = ot & 0xF; n != (nt & 0xF) && n != (nh & 0xF); n = (n + 1) & 0xF)
|
459
|
|
- Max7219_LED_Off(n & 0xf, y);
|
|
502
|
+ led_off(n & 0xF, y);
|
460
|
503
|
if (oh != nh) for (uint8_t n = (oh + 1) & 0xF; n != ((nh + 1) & 0xF); n = (n + 1) & 0xF)
|
461
|
|
- Max7219_LED_On(n & 0xf, y);
|
|
504
|
+ led_on(n & 0xF, y);
|
462
|
505
|
#endif
|
463
|
506
|
}
|
464
|
507
|
|
465
|
508
|
// Apply changes to update a quantity
|
466
|
|
-inline void Max7219_Quantity16(const uint8_t y, const uint8_t ov, const uint8_t nv) {
|
|
509
|
+void Max7219::quantity16(const uint8_t y, const uint8_t ov, const uint8_t nv) {
|
467
|
510
|
for (uint8_t i = MIN(nv, ov); i < MAX(nv, ov); i++)
|
468
|
511
|
#if MAX7219_X_LEDS == 8
|
469
|
512
|
#if MAX7219_Y_LEDS == 8
|
470
|
|
- Max7219_LED_Set(i >> 1, y + (i & 1), nv >= ov); // single 8x8 LED matrix. Use two lines to get 16 LED's
|
|
513
|
+ led_set(i >> 1, y + (i & 1), nv >= ov); // single 8x8 LED matrix. Use two lines to get 16 LED's
|
471
|
514
|
#else
|
472
|
|
- Max7219_LED_Set(y, i, nv >= ov); // The Max7219 Y-Axis has at least 16 LED's. So use a single column
|
|
515
|
+ led_set(y, i, nv >= ov); // The Max7219 Y-Axis has at least 16 LED's. So use a single column
|
473
|
516
|
#endif
|
474
|
517
|
#else
|
475
|
|
- Max7219_LED_Set(i, y, nv >= ov); // LED matrix has at least 16 LED's on the X-Axis. Use single line of LED's
|
|
518
|
+ led_set(i, y, nv >= ov); // LED matrix has at least 16 LED's on the X-Axis. Use single line of LED's
|
476
|
519
|
#endif
|
477
|
520
|
}
|
478
|
521
|
|
479
|
|
-void Max7219_idle_tasks() {
|
|
522
|
+void Max7219::idle_tasks() {
|
480
|
523
|
#define MAX7219_USE_HEAD (defined(MAX7219_DEBUG_PLANNER_HEAD) || defined(MAX7219_DEBUG_PLANNER_QUEUE))
|
481
|
524
|
#define MAX7219_USE_TAIL (defined(MAX7219_DEBUG_PLANNER_TAIL) || defined(MAX7219_DEBUG_PLANNER_QUEUE))
|
482
|
525
|
#if MAX7219_USE_HEAD || MAX7219_USE_TAIL
|
483
|
|
- #ifndef CPU_32_BIT
|
484
|
|
- CRITICAL_SECTION_START;
|
485
|
|
- #endif
|
|
526
|
+ CRITICAL_SECTION_START;
|
486
|
527
|
#if MAX7219_USE_HEAD
|
487
|
528
|
const uint8_t head = planner.block_buffer_head;
|
488
|
529
|
#endif
|
489
|
530
|
#if MAX7219_USE_TAIL
|
490
|
531
|
const uint8_t tail = planner.block_buffer_tail;
|
491
|
532
|
#endif
|
492
|
|
- #ifndef CPU_32_BIT
|
493
|
|
- CRITICAL_SECTION_END;
|
494
|
|
- #endif
|
|
533
|
+ CRITICAL_SECTION_END;
|
495
|
534
|
#endif
|
496
|
535
|
|
497
|
536
|
#if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE)
|
|
@@ -511,12 +550,12 @@ void Max7219_idle_tasks() {
|
511
|
550
|
// corrupted, this will fix it within a couple seconds.
|
512
|
551
|
if (do_blink && ++refresh_cnt >= refresh_limit) {
|
513
|
552
|
refresh_cnt = 0;
|
514
|
|
- Max7219_register_setup();
|
|
553
|
+ register_setup();
|
515
|
554
|
}
|
516
|
555
|
|
517
|
556
|
#if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE)
|
518
|
557
|
if (do_blink) {
|
519
|
|
- Max7219_LED_Toggle(MAX7219_X_LEDS - 1, MAX7219_Y_LEDS - 1);
|
|
558
|
+ led_toggle(MAX7219_X_LEDS - 1, MAX7219_Y_LEDS - 1);
|
520
|
559
|
next_blink = ms + 1000;
|
521
|
560
|
}
|
522
|
561
|
#endif
|
|
@@ -526,7 +565,7 @@ void Max7219_idle_tasks() {
|
526
|
565
|
static int16_t last_head_cnt = 0xF, last_tail_cnt = 0xF;
|
527
|
566
|
|
528
|
567
|
if (last_head_cnt != head || last_tail_cnt != tail) {
|
529
|
|
- Max7219_Range16(MAX7219_DEBUG_PLANNER_HEAD, last_tail_cnt, tail, last_head_cnt, head);
|
|
568
|
+ range16(MAX7219_DEBUG_PLANNER_HEAD, last_tail_cnt, tail, last_head_cnt, head);
|
530
|
569
|
last_head_cnt = head;
|
531
|
570
|
last_tail_cnt = tail;
|
532
|
571
|
}
|
|
@@ -536,7 +575,7 @@ void Max7219_idle_tasks() {
|
536
|
575
|
#ifdef MAX7219_DEBUG_PLANNER_HEAD
|
537
|
576
|
static int16_t last_head_cnt = 0x1;
|
538
|
577
|
if (last_head_cnt != head) {
|
539
|
|
- Max7219_Mark16(MAX7219_DEBUG_PLANNER_HEAD, last_head_cnt, head);
|
|
578
|
+ mark16(MAX7219_DEBUG_PLANNER_HEAD, last_head_cnt, head);
|
540
|
579
|
last_head_cnt = head;
|
541
|
580
|
}
|
542
|
581
|
#endif
|
|
@@ -544,7 +583,7 @@ void Max7219_idle_tasks() {
|
544
|
583
|
#ifdef MAX7219_DEBUG_PLANNER_TAIL
|
545
|
584
|
static int16_t last_tail_cnt = 0x1;
|
546
|
585
|
if (last_tail_cnt != tail) {
|
547
|
|
- Max7219_Mark16(MAX7219_DEBUG_PLANNER_TAIL, last_tail_cnt, tail);
|
|
586
|
+ mark16(MAX7219_DEBUG_PLANNER_TAIL, last_tail_cnt, tail);
|
548
|
587
|
last_tail_cnt = tail;
|
549
|
588
|
}
|
550
|
589
|
#endif
|
|
@@ -555,7 +594,7 @@ void Max7219_idle_tasks() {
|
555
|
594
|
static int16_t last_depth = 0;
|
556
|
595
|
const int16_t current_depth = (head - tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1) & 0xF;
|
557
|
596
|
if (current_depth != last_depth) {
|
558
|
|
- Max7219_Quantity16(MAX7219_DEBUG_PLANNER_QUEUE, last_depth, current_depth);
|
|
597
|
+ quantity16(MAX7219_DEBUG_PLANNER_QUEUE, last_depth, current_depth);
|
559
|
598
|
last_depth = current_depth;
|
560
|
599
|
}
|
561
|
600
|
#endif
|