Tiny improvement to M7219
The registers within the Max7219 can get corrupted a number of ways. This allows the Max7219 to be reset and fully initialized. And... it also allows the user to see the initialization pattern.
This commit is contained in:
parent
888d319145
commit
7d491aa015
5 changed files with 22 additions and 22 deletions
|
|
@ -48,7 +48,7 @@
|
|||
#include "Marlin.h"
|
||||
#include "delay.h"
|
||||
|
||||
uint8_t LEDs[8*MAX7219_NUMBER_UNITS] = { 0 };
|
||||
uint8_t LEDs[8 * MAX7219_NUMBER_UNITS] = { 0 };
|
||||
|
||||
// Delay for 0.1875µs (16MHz AVR) or 0.15µs (20MHz AVR)
|
||||
#define SIG_DELAY() DELAY_NS(188)
|
||||
|
|
@ -191,7 +191,7 @@ inline void _Max7219_Set_Digit_Segments(const uint8_t digit, const uint8_t val)
|
|||
void Max7219_Set_Row(const uint8_t row, const uint32_t val) {
|
||||
if (row >= MAX7219_Y_LEDS) return Max7219_Error(PSTR("Max7219_Set_Row"), row);
|
||||
uint32_t mask = 0x0000001;
|
||||
for(uint8_t x = 0; x < MAX7219_X_LEDS; x++) {
|
||||
for (uint8_t x = 0; x < MAX7219_X_LEDS; x++) {
|
||||
if (val & mask)
|
||||
SET_PIXEL_7219(MAX7219_X_LEDS-1-x, row);
|
||||
else
|
||||
|
|
@ -199,7 +199,7 @@ void Max7219_Set_Row(const uint8_t row, const uint32_t val) {
|
|||
mask <<= 1;
|
||||
}
|
||||
#if _ROT == 90 || _ROT == 270
|
||||
for(uint8_t x = 0; x < 8; x++)
|
||||
for (uint8_t x = 0; x < 8; x++)
|
||||
SEND_7219(x); // force all columns out to the Max7219 chips and strobe them
|
||||
#else
|
||||
SEND_7219(row); // force the single column out to the Max7219 chips and strobe them
|
||||
|
|
@ -225,7 +225,7 @@ void Max7219_Clear_Row(const uint8_t row) {
|
|||
void Max7219_Set_Column(const uint8_t col, const uint32_t val) {
|
||||
if (col >= MAX7219_X_LEDS) return Max7219_Error(PSTR("Max7219_Set_Column"), col);
|
||||
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)
|
||||
SET_PIXEL_7219(col, MAX7219_Y_LEDS-1-y);
|
||||
else
|
||||
|
|
@ -235,7 +235,7 @@ void Max7219_Set_Column(const uint8_t col, const uint32_t val) {
|
|||
#if _ROT == 90 || _ROT == 270
|
||||
SEND_7219(col); // force the column out to the Max7219 chips and strobe them
|
||||
#else
|
||||
for(uint8_t yy = 0; yy < 8; yy++)
|
||||
for (uint8_t yy = 0; yy < 8; yy++)
|
||||
SEND_7219(yy); // force all columns out to the Max7219 chips and strobe them
|
||||
#endif
|
||||
return;
|
||||
|
|
@ -244,13 +244,13 @@ void Max7219_Set_Column(const uint8_t col, const uint32_t val) {
|
|||
void Max7219_Clear_Column(const uint8_t col) {
|
||||
if (col >= MAX7219_X_LEDS) return Max7219_Error(PSTR("Max7219_Clear_Column"), col);
|
||||
|
||||
for(uint8_t yy = 0; yy < MAX7219_Y_LEDS; yy++)
|
||||
for (uint8_t yy = 0; yy < MAX7219_Y_LEDS; yy++)
|
||||
CLEAR_PIXEL_7219(col, yy);
|
||||
|
||||
#if _ROT == 90 || _ROT == 270
|
||||
SEND_7219(col); // force the column out to the Max7219 chips and strobe them
|
||||
#else
|
||||
for(uint8_t y = 0; y < 8; y++)
|
||||
for (uint8_t y = 0; y < 8; y++)
|
||||
SEND_7219(y); // force all columns out to the Max7219 chips and strobe them
|
||||
#endif
|
||||
return;
|
||||
|
|
@ -322,22 +322,22 @@ void Max7219_Set_Columns_32bits(const uint8_t x, uint32_t val) {
|
|||
|
||||
void Max7219_register_setup() {
|
||||
// Initialize the Max7219
|
||||
for(int i=0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
Max7219(max7219_reg_scanLimit, 0x07);
|
||||
Max7219_pulse_load(); // tell the chips to load the clocked out data
|
||||
|
||||
for(int i=0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
Max7219(max7219_reg_decodeMode, 0x00); // using an led matrix (not digits)
|
||||
Max7219_pulse_load(); // tell the chips to load the clocked out data
|
||||
|
||||
for(int i=0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
Max7219(max7219_reg_shutdown, 0x01); // not in shutdown mode
|
||||
Max7219_pulse_load(); // tell the chips to load the clocked out data
|
||||
for(int i=0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
Max7219(max7219_reg_displayTest, 0x00); // no display test
|
||||
Max7219_pulse_load(); // tell the chips to load the clocked out data
|
||||
|
||||
for(int i=0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
Max7219(max7219_reg_intensity, 0x01 & 0x0F); // the first 0x0F is the value you can set
|
||||
// range: 0x00 to 0x0F
|
||||
Max7219_pulse_load(); // tell the chips to load the clocked out data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue