1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 13:56:24 +00:00

Apply coding standards to Max7219 code

This commit is contained in:
Scott Lahteine 2017-11-17 15:33:55 -06:00
parent aa612124f2
commit 8f57a3e28a

View File

@ -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) {
if (row > 7 || col > 7) {
int r,c;
r = row;
c = col;
SERIAL_ECHOPAIR("??? Max7219_LED_Set(",r);
SERIAL_ECHOPAIR(",",c);
SERIAL_ECHO(")\n");
SERIAL_ECHOPAIR("??? Max7219_LED_Set(", (int)row);
SERIAL_ECHOPAIR(",", (int)col);
SERIAL_ECHOLNPGM(")");
return;
}
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) {
if (row > 7 || col > 7) {
int r,c;
r = row;
c = col;
SERIAL_ECHOPAIR("??? Max7219_LED_On(",c);
SERIAL_ECHOPAIR(",",r);
SERIAL_ECHO(")\n");
SERIAL_ECHOPAIR("??? Max7219_LED_On(", (int)col);
SERIAL_ECHOPAIR(",", (int)row);
SERIAL_ECHOLNPGM(")");
return;
}
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) {
if (row > 7 || col > 7) {
int r,c;
r = row;
c = col;
SERIAL_ECHOPAIR("??? Max7219_LED_Off(",r);
SERIAL_ECHOPAIR(",",c);
SERIAL_ECHO(")\n");
SERIAL_ECHOPAIR("??? Max7219_LED_Off(", (int)row);
SERIAL_ECHOPAIR(",", (int)col);
SERIAL_ECHOLNPGM(")");
return;
}
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) {
if (row > 7 || col > 7) {
int r,c;
r = row;
c = col;
SERIAL_ECHOPAIR("??? Max7219_LED_Toggle(",r);
SERIAL_ECHOPAIR(",",c);
SERIAL_ECHO(")\n");
SERIAL_ECHOPAIR("??? Max7219_LED_Toggle(", (int)row);
SERIAL_ECHOPAIR(",", (int)col);
SERIAL_ECHOLNPGM(")");
return;
}
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) {
if (col > 7) {
int c;
c = col;
SERIAL_ECHOPAIR("??? Max7219_Clear_Column(",c);
SERIAL_ECHO(")\n");
SERIAL_ECHOPAIR("??? Max7219_Clear_Column(", (int)col);
SERIAL_ECHOLNPGM(")");
return;
}
LEDs[col] = 0;
@ -171,10 +157,8 @@ void Max7219_Clear_Column(const uint8_t col) {
void Max7219_Clear_Row(const uint8_t row) {
if (row > 7) {
int r;
r = row;
SERIAL_ECHOPAIR("??? Max7219_Clear_Row(",r);
SERIAL_ECHO(")\n");
SERIAL_ECHOPAIR("??? Max7219_Clear_Row(", (int)row);
SERIAL_ECHOLNPGM(")");
return;
}
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) {
if (row > 7 || val>255) {
int r, v;
r = row;
v = val;
SERIAL_ECHOPAIR("??? Max7219_Set_Row(",r);
SERIAL_ECHOPAIR(",",v);
SERIAL_ECHO(")\n");
if (row > 7) {
SERIAL_ECHOPAIR("??? Max7219_Set_Row(", (int)row);
SERIAL_ECHOPAIR(",", (int)val);
SERIAL_ECHOLNPGM(")");
return;
}
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) {
if (row > 6 || val>65535) {
int r, v;
r = row;
v = val;
SERIAL_ECHOPAIR("??? Max7219_Set_2_Rows(",r);
SERIAL_ECHOPAIR(",",v);
SERIAL_ECHO(")\n");
if (row > 6) {
SERIAL_ECHOPAIR("??? Max7219_Set_2_Rows(", (int)row);
SERIAL_ECHOPAIR(",", (int)val);
SERIAL_ECHOLNPGM(")");
return;
}
Max7219_Set_Row(row+1, (val & 0xff00) >> 8 );
Max7219_Set_Row(row+0, (val & 0xff));
Max7219_Set_Row(row + 1, (val >> 8) & 0xFF);
Max7219_Set_Row(row + 0, (val ) & 0xFF);
}
void Max7219_Set_4_Rows(const uint8_t row, const uint32_t val) {
if (row > 4 ) {
int r;
long v;
r = row;
v = val;
SERIAL_ECHOPAIR("??? Max7219_Set_4_Rows(",r);
SERIAL_ECHOPAIR(",",v);
SERIAL_ECHO(")\n");
if (row > 4) {
SERIAL_ECHOPAIR("??? Max7219_Set_4_Rows(", (int)row);
SERIAL_ECHOPAIR(",", (long)val);
SERIAL_ECHOLNPGM(")");
return;
}
Max7219_Set_Row(row+3, (val & 0xff000000) >> 24);
Max7219_Set_Row(row+2, (val & 0xff0000) >> 16);
Max7219_Set_Row(row+1, (val & 0xff00) >> 8);
Max7219_Set_Row(row+0, (val & 0xff));
Max7219_Set_Row(row + 3, (val >> 24) & 0xFF);
Max7219_Set_Row(row + 2, (val >> 16) & 0xFF);
Max7219_Set_Row(row + 1, (val >> 8) & 0xFF);
Max7219_Set_Row(row + 0, (val ) & 0xFF);
}
void Max7219_Set_Column(const uint8_t col, const uint8_t val) {
if (val > 255 || col > 7) {
int v,c;
v = val;
c = col;
SERIAL_ECHOPAIR("??? Max7219_Column(",c);
SERIAL_ECHOPAIR(",",v);
SERIAL_ECHO(")\n");
if (col > 7) {
SERIAL_ECHOPAIR("??? Max7219_Column(", (int)col);
SERIAL_ECHOPAIR(",", (int)val);
SERIAL_ECHOLNPGM(")");
return;
}
LEDs[col] = val;
@ -304,12 +275,10 @@ 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
uint8_t head;
head = planner.block_buffer_head;
const uint8_t head = planner.block_buffer_head;
#endif
#if MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
uint8_t tail;
tail = planner.block_buffer_tail;
const uint8_t tail = planner.block_buffer_tail;
#endif
CRITICAL_SECTION_END
#endif
@ -323,34 +292,34 @@ void Max7219_idle_tasks() {
#endif
#ifdef MAX7219_DEBUG_STEPPER_HEAD
static int16_t last_head_cnt=0;
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(last_head_cnt, MAX7219_DEBUG_STEPPER_HEAD);
else
Max7219_LED_Off( last_head_cnt-8, MAX7219_DEBUG_STEPPER_HEAD+1);
Max7219_LED_Off(last_head_cnt - 8, MAX7219_DEBUG_STEPPER_HEAD + 1);
last_head_cnt = head;
if (head < 8)
Max7219_LED_On(head, MAX7219_DEBUG_STEPPER_HEAD);
else
Max7219_LED_On(head-8, MAX7219_DEBUG_STEPPER_HEAD+1);
Max7219_LED_On(head - 8, MAX7219_DEBUG_STEPPER_HEAD + 1);
}
#endif
#ifdef MAX7219_DEBUG_STEPPER_TAIL
static int16_t last_tail_cnt=0;
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(last_tail_cnt, MAX7219_DEBUG_STEPPER_TAIL);
else
Max7219_LED_Off( last_tail_cnt-8, MAX7219_DEBUG_STEPPER_TAIL+1);
Max7219_LED_Off(last_tail_cnt - 8, MAX7219_DEBUG_STEPPER_TAIL + 1);
last_tail_cnt = tail;
if (tail < 8)
Max7219_LED_On(tail, MAX7219_DEBUG_STEPPER_TAIL);
else
Max7219_LED_On(tail-8, MAX7219_DEBUG_STEPPER_TAIL+1);
Max7219_LED_On(tail - 8, MAX7219_DEBUG_STEPPER_TAIL + 1);
}
#endif
@ -367,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(i / 2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
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(i / 2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
last_depth = current_depth;
}