Patch Max7219 for parity with 2.0.x

This commit is contained in:
Scott Lahteine 2018-02-11 05:19:36 -06:00
parent 2e7a754ac1
commit 30b08e218d

View File

@ -100,7 +100,7 @@ void Max7219(const uint8_t reg, const uint8_t data) {
MS_DELAY();
}
void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) {
void Max7219_LED_Set(const uint8_t col, const uint8_t row, const bool on) {
if (row > 7 || col > 7) {
SERIAL_ECHOPAIR("??? Max7219_LED_Set(", (int)row);
SERIAL_ECHOPAIR(",", (int)col);
@ -237,13 +237,13 @@ void Max7219_init() {
for (x = 0; x <= 7; x++) // Do an aesthetically pleasing pattern to fully test
for (y = 0; y <= 7; y++) { // the Max7219 module and LEDs. First, turn them
Max7219_LED_On(x, y); // all on.
Max7219_LED_On(y, x); // all on.
delay(3);
}
for (x = 0; x <= 7; x++) // Now, turn them all off.
for (y = 0; y <= 7; y++) {
Max7219_LED_Off(x, y);
Max7219_LED_Off(y, x);
delay(3); // delay() is OK here. Max7219_init() is only called from
} // setup() and nothing is running yet.
@ -251,37 +251,37 @@ void Max7219_init() {
for (x = 8; x--;) // Now, do the same thing from the opposite direction
for (y = 0; y <= 7; y++) {
Max7219_LED_On(x, y);
Max7219_LED_On(y, x);
delay(2);
}
for (x = 8; x--;)
for (y = 0; y <= 7; y++) {
Max7219_LED_Off(x, y);
Max7219_LED_Off(y, x);
delay(2);
}
}
/**
* These are sample debug features to demonstrate the usage of the 8x8 LED Matrix for debug purposes.
* There is very little CPU burden added to the system by displaying information within the idle()
* task.
*
* But with that said, if your debugging can be facilitated by making calls into the library from
* other places in the code, feel free to do it. The CPU burden for a few calls to toggle an LED
* or clear a row is not very significant.
*/
* These are sample debug features to demonstrate the usage of the 8x8 LED Matrix for debug purposes.
* There is very little CPU burden added to the system by displaying information within the idle()
* task.
*
* But with that said, if your debugging can be facilitated by making calls into the library from
* other places in the code, feel free to do it. The CPU burden for a few calls to toggle an LED
* or clear a row is not very significant.
*/
void Max7219_idle_tasks() {
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
CRITICAL_SECTION_START
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_QUEUE
const uint8_t head = planner.block_buffer_head;
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
CRITICAL_SECTION_START
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_QUEUE
const uint8_t head = planner.block_buffer_head;
#endif
#if MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
const uint8_t tail = planner.block_buffer_tail;
#endif
CRITICAL_SECTION_END
#endif
#if MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
const uint8_t tail = planner.block_buffer_tail;
#endif
CRITICAL_SECTION_END
#endif
#if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE)
static millis_t next_blink = 0;
@ -295,15 +295,15 @@ void Max7219_idle_tasks() {
static int16_t last_head_cnt = 0;
if (last_head_cnt != head) {
if (last_head_cnt < 8)
Max7219_LED_Off(last_head_cnt, MAX7219_DEBUG_STEPPER_HEAD);
Max7219_LED_Off(MAX7219_DEBUG_STEPPER_HEAD, last_head_cnt);
else
Max7219_LED_Off(last_head_cnt - 8, MAX7219_DEBUG_STEPPER_HEAD + 1);
Max7219_LED_Off(MAX7219_DEBUG_STEPPER_HEAD + 1, last_head_cnt - 8);
last_head_cnt = head;
if (head < 8)
Max7219_LED_On(head, MAX7219_DEBUG_STEPPER_HEAD);
Max7219_LED_On(MAX7219_DEBUG_STEPPER_HEAD, head);
else
Max7219_LED_On(head - 8, MAX7219_DEBUG_STEPPER_HEAD + 1);
Max7219_LED_On(MAX7219_DEBUG_STEPPER_HEAD + 1, head - 8);
}
#endif
@ -311,15 +311,15 @@ void Max7219_idle_tasks() {
static int16_t last_tail_cnt = 0;
if (last_tail_cnt != tail) {
if (last_tail_cnt < 8)
Max7219_LED_Off(last_tail_cnt, MAX7219_DEBUG_STEPPER_TAIL);
Max7219_LED_Off(MAX7219_DEBUG_STEPPER_TAIL, last_tail_cnt);
else
Max7219_LED_Off(last_tail_cnt - 8, MAX7219_DEBUG_STEPPER_TAIL + 1);
Max7219_LED_Off(MAX7219_DEBUG_STEPPER_TAIL + 1, last_tail_cnt - 8);
last_tail_cnt = tail;
if (tail < 8)
Max7219_LED_On(tail, MAX7219_DEBUG_STEPPER_TAIL);
Max7219_LED_On(MAX7219_DEBUG_STEPPER_TAIL, tail);
else
Max7219_LED_On(tail - 8, MAX7219_DEBUG_STEPPER_TAIL + 1);
Max7219_LED_On(MAX7219_DEBUG_STEPPER_TAIL + 1, tail - 8);
}
#endif
@ -336,10 +336,10 @@ void Max7219_idle_tasks() {
en = max(current_depth, last_depth);
if (current_depth < last_depth)
for (uint8_t i = st; i <= en; i++) // clear the highest order LEDs
Max7219_LED_Off(i / 2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
Max7219_LED_Off(MAX7219_DEBUG_STEPPER_QUEUE + (i & 1), i / 2);
else
for (uint8_t i = st; i <= en; i++) // set the LEDs to current depth
Max7219_LED_On(i / 2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
Max7219_LED_On(MAX7219_DEBUG_STEPPER_QUEUE + (i & 1), i / 2);
last_depth = current_depth;
}