Browse Source

Apply coding standards to Max7219

pull/1/head
Scott Lahteine 7 years ago
parent
commit
d48cb6bf41
  1. 109
      Marlin/src/feature/Max7219_Debug_LEDs.cpp

109
Marlin/src/feature/Max7219_Debug_LEDs.cpp

@ -102,12 +102,9 @@ void Max7219(const uint8_t reg, const uint8_t data) {
void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) { void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) {
if (row > 7 || col > 7) { if (row > 7 || col > 7) {
int r,c; SERIAL_ECHOPAIR("??? Max7219_LED_Set(", (int)row);
r = row; SERIAL_ECHOPAIR(",", (int)col);
c = col; SERIAL_ECHOLNPGM(")");
SERIAL_ECHOPAIR("??? Max7219_LED_Set(",r);
SERIAL_ECHOPAIR(",",c);
SERIAL_ECHO(")\n");
return; return;
} }
if (TEST(LEDs[row], col) == on) return; // if LED is already on/off, leave alone if (TEST(LEDs[row], col) == on) return; // if LED is already on/off, leave alone
@ -117,12 +114,9 @@ void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) {
void Max7219_LED_On(const uint8_t col, const uint8_t row) { void Max7219_LED_On(const uint8_t col, const uint8_t row) {
if (row > 7 || col > 7) { if (row > 7 || col > 7) {
int r,c; SERIAL_ECHOPAIR("??? Max7219_LED_On(", (int)col);
r = row; SERIAL_ECHOPAIR(",", (int)row);
c = col; SERIAL_ECHOLNPGM(")");
SERIAL_ECHOPAIR("??? Max7219_LED_On(",c);
SERIAL_ECHOPAIR(",",r);
SERIAL_ECHO(")\n");
return; return;
} }
Max7219_LED_Set(col, row, true); Max7219_LED_Set(col, row, true);
@ -130,12 +124,9 @@ void Max7219_LED_On(const uint8_t col, const uint8_t row) {
void Max7219_LED_Off(const uint8_t col, const uint8_t row) { void Max7219_LED_Off(const uint8_t col, const uint8_t row) {
if (row > 7 || col > 7) { if (row > 7 || col > 7) {
int r,c; SERIAL_ECHOPAIR("??? Max7219_LED_Off(", (int)row);
r = row; SERIAL_ECHOPAIR(",", (int)col);
c = col; SERIAL_ECHOLNPGM(")");
SERIAL_ECHOPAIR("??? Max7219_LED_Off(",r);
SERIAL_ECHOPAIR(",",c);
SERIAL_ECHO(")\n");
return; return;
} }
Max7219_LED_Set(col, row, false); Max7219_LED_Set(col, row, false);
@ -143,12 +134,9 @@ void Max7219_LED_Off(const uint8_t col, const uint8_t row) {
void Max7219_LED_Toggle(const uint8_t col, const uint8_t row) { void Max7219_LED_Toggle(const uint8_t col, const uint8_t row) {
if (row > 7 || col > 7) { if (row > 7 || col > 7) {
int r,c; SERIAL_ECHOPAIR("??? Max7219_LED_Toggle(", (int)row);
r = row; SERIAL_ECHOPAIR(",", (int)col);
c = col; SERIAL_ECHOLNPGM(")");
SERIAL_ECHOPAIR("??? Max7219_LED_Toggle(",r);
SERIAL_ECHOPAIR(",",c);
SERIAL_ECHO(")\n");
return; return;
} }
if (TEST(LEDs[row], col)) if (TEST(LEDs[row], col))
@ -159,10 +147,8 @@ void Max7219_LED_Toggle(const uint8_t col, const uint8_t row) {
void Max7219_Clear_Column(const uint8_t col) { void Max7219_Clear_Column(const uint8_t col) {
if (col > 7) { if (col > 7) {
int c; SERIAL_ECHOPAIR("??? Max7219_Clear_Column(", (int)col);
c = col; SERIAL_ECHOLNPGM(")");
SERIAL_ECHOPAIR("??? Max7219_Clear_Column(",c);
SERIAL_ECHO(")\n");
return; return;
} }
LEDs[col] = 0; LEDs[col] = 0;
@ -171,10 +157,8 @@ void Max7219_Clear_Column(const uint8_t col) {
void Max7219_Clear_Row(const uint8_t row) { void Max7219_Clear_Row(const uint8_t row) {
if (row > 7) { if (row > 7) {
int r; SERIAL_ECHOPAIR("??? Max7219_Clear_Row(", (int)row);
r = row; SERIAL_ECHOLNPGM(")");
SERIAL_ECHOPAIR("??? Max7219_Clear_Row(",r);
SERIAL_ECHO(")\n");
return; return;
} }
for (uint8_t c = 0; c <= 7; c++) for (uint8_t c = 0; c <= 7; c++)
@ -182,13 +166,10 @@ void Max7219_Clear_Row(const uint8_t row) {
} }
void Max7219_Set_Row(const uint8_t row, const uint8_t val) { void Max7219_Set_Row(const uint8_t row, const uint8_t val) {
if (row > 7 || val>255) { if (row > 7) {
int r, v; SERIAL_ECHOPAIR("??? Max7219_Set_Row(", (int)row);
r = row; SERIAL_ECHOPAIR(",", (int)val);
v = val; SERIAL_ECHOLNPGM(")");
SERIAL_ECHOPAIR("??? Max7219_Set_Row(",r);
SERIAL_ECHOPAIR(",",v);
SERIAL_ECHO(")\n");
return; return;
} }
for (uint8_t b = 0; b <= 7; b++) for (uint8_t b = 0; b <= 7; b++)
@ -199,44 +180,34 @@ void Max7219_Set_Row(const uint8_t row, const uint8_t val) {
} }
void Max7219_Set_2_Rows(const uint8_t row, const uint16_t val) { void Max7219_Set_2_Rows(const uint8_t row, const uint16_t val) {
if (row > 6 || val>65535) { if (row > 6) {
int r, v; SERIAL_ECHOPAIR("??? Max7219_Set_2_Rows(", (int)row);
r = row; SERIAL_ECHOPAIR(",", (int)val);
v = val; SERIAL_ECHOLNPGM(")");
SERIAL_ECHOPAIR("??? Max7219_Set_2_Rows(",r);
SERIAL_ECHOPAIR(",",v);
SERIAL_ECHO(")\n");
return; return;
} }
Max7219_Set_Row(row+1, (val & 0xff00) >> 8 ); Max7219_Set_Row(row + 1, (val >> 8) & 0xFF);
Max7219_Set_Row(row+0, (val & 0xff)); Max7219_Set_Row(row + 0, (val ) & 0xFF);
} }
void Max7219_Set_4_Rows(const uint8_t row, const uint32_t val) { void Max7219_Set_4_Rows(const uint8_t row, const uint32_t val) {
if (row > 4) { if (row > 4) {
int r; SERIAL_ECHOPAIR("??? Max7219_Set_4_Rows(", (int)row);
long v; SERIAL_ECHOPAIR(",", (long)val);
r = row; SERIAL_ECHOLNPGM(")");
v = val;
SERIAL_ECHOPAIR("??? Max7219_Set_4_Rows(",r);
SERIAL_ECHOPAIR(",",v);
SERIAL_ECHO(")\n");
return; return;
} }
Max7219_Set_Row(row+3, (val & 0xff000000) >> 24); Max7219_Set_Row(row + 3, (val >> 24) & 0xFF);
Max7219_Set_Row(row+2, (val & 0xff0000) >> 16); Max7219_Set_Row(row + 2, (val >> 16) & 0xFF);
Max7219_Set_Row(row+1, (val & 0xff00) >> 8); Max7219_Set_Row(row + 1, (val >> 8) & 0xFF);
Max7219_Set_Row(row+0, (val & 0xff)); Max7219_Set_Row(row + 0, (val ) & 0xFF);
} }
void Max7219_Set_Column(const uint8_t col, const uint8_t val) { void Max7219_Set_Column(const uint8_t col, const uint8_t val) {
if (val > 255 || col > 7) { if (col > 7) {
int v,c; SERIAL_ECHOPAIR("??? Max7219_Column(", (int)col);
v = val; SERIAL_ECHOPAIR(",", (int)val);
c = col; SERIAL_ECHOLNPGM(")");
SERIAL_ECHOPAIR("??? Max7219_Column(",c);
SERIAL_ECHOPAIR(",",v);
SERIAL_ECHO(")\n");
return; return;
} }
LEDs[col] = val; LEDs[col] = val;
@ -304,12 +275,10 @@ void Max7219_idle_tasks() {
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE #if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
CRITICAL_SECTION_START CRITICAL_SECTION_START
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_QUEUE #if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_QUEUE
uint8_t head; const uint8_t head = planner.block_buffer_head;
head = planner.block_buffer_head;
#endif #endif
#if MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE #if MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
uint8_t tail; const uint8_t tail = planner.block_buffer_tail;
tail = planner.block_buffer_tail;
#endif #endif
CRITICAL_SECTION_END CRITICAL_SECTION_END
#endif #endif

Loading…
Cancel
Save