From cd72901fb7e27e14e9c920cbb574b702d6587347 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Apr 2017 16:10:02 -0500 Subject: [PATCH 1/9] Cleanups to UBL code --- Marlin/ubl_motion.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Marlin/ubl_motion.cpp b/Marlin/ubl_motion.cpp index 3bc74585a..0197f4d35 100755 --- a/Marlin/ubl_motion.cpp +++ b/Marlin/ubl_motion.cpp @@ -250,10 +250,8 @@ const float m = dy / dx, c = start[Y_AXIS] - m * start[X_AXIS]; - bool inf_normalized_flag, inf_m_flag; - - inf_normalized_flag = isinf(e_normalized_dist); - inf_m_flag = isinf(m); + const bool inf_normalized_flag = isinf(e_normalized_dist), + inf_m_flag = isinf(m); /** * This block handles vertical lines. These are lines that stay within the same From 42824b0e1f3747393c64b05ec7a186afec5bf82d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Apr 2017 18:36:40 -0500 Subject: [PATCH 2/9] Use new serial spacing function to save PROGMEM --- Marlin/pinsDebug.h | 32 ++++++++++++++++++++++---------- Marlin/ubl.cpp | 6 +++--- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Marlin/pinsDebug.h b/Marlin/pinsDebug.h index a40d1480d..0d73f95ba 100644 --- a/Marlin/pinsDebug.h +++ b/Marlin/pinsDebug.h @@ -409,11 +409,17 @@ static void pwm_details(uint8_t pin) { // looking for port B7 - PWMs 0A and 1C if ( ('B' == digitalPinToPort(pin) + 64) && (0x80 == digitalPinToBitMask(pin))) { #ifndef TEENSYDUINO_IDE - SERIAL_PROTOCOLPGM("\n . TIMER1C is also tied to this pin "); - timer_prefix(1,'C',4); + SERIAL_PROTOCOLPGM("\n ."); + SERIAL_PROTOCOL_SP(18); + SERIAL_PROTOCOLPGM("TIMER1C is also tied to this pin"); + SERIAL_PROTOCOL_SP(13); + timer_prefix(1, 'C', 4); #else - SERIAL_PROTOCOLPGM("\n . TIMER0A is also tied to this pin "); - timer_prefix(0,'A',3); + SERIAL_PROTOCOLPGM("\n ."); + SERIAL_PROTOCOL_SP(18); + SERIAL_PROTOCOLPGM("TIMER0A is also tied to this pin"); + SERIAL_PROTOCOL_SP(13); + timer_prefix(0, 'A', 3); #endif } #endif @@ -437,7 +443,7 @@ void print_port(int8_t pin) { // print port number for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1; SERIAL_CHAR(x); #else - SERIAL_PROTOCOLPGM(" "); + SERIAL_PROTOCOL_SP(10); #endif } @@ -460,7 +466,11 @@ inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = t sprintf(buffer, " (A%2d) ", int(pin - analogInputToDigitalPin(0))); // analog pin number SERIAL_ECHO(buffer); } - else SERIAL_ECHOPGM(" "); // add padding if not an analog pin + else SERIAL_ECHO_SP(8); // add padding if not an analog pin + } + else { + SERIAL_CHAR('.'); + SERIAL_ECHO_SP(25); // add padding if not the first instance found } else SERIAL_ECHOPGM(". "); // add padding if not the first instance found name_mem_pointer = (char*) pgm_read_word(&pin_array[x][0]); @@ -506,17 +516,19 @@ inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = t SERIAL_ECHO(buffer); } else - SERIAL_ECHOPGM(" "); // add padding if not an analog pin + SERIAL_ECHO_SP(8); // add padding if not an analog pin SERIAL_ECHOPGM(""); - if (get_pinMode(pin)) - SERIAL_PROTOCOLPAIR(" Output = ", digitalRead_mod(pin)); + if (get_pinMode(pin)) { + SERIAL_PROTOCOL_SP(12); + SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin)); + } else { if (IS_ANALOG(pin)) { sprintf(buffer, " Analog in = %5d", analogRead(pin - analogInputToDigitalPin(0))); SERIAL_ECHO(buffer); } else - SERIAL_ECHOPGM(" "); // add padding if not an analog pin + SERIAL_ECHO_SP(9); // add padding if not an analog pin SERIAL_PROTOCOLPAIR(" Input = ", digitalRead_mod(pin)); } diff --git a/Marlin/ubl.cpp b/Marlin/ubl.cpp index 8d8676bf7..c76aa80fe 100755 --- a/Marlin/ubl.cpp +++ b/Marlin/ubl.cpp @@ -52,7 +52,7 @@ static void serial_echo_12x_spaces() { for (uint8_t i = GRID_MAX_POINTS_X - 1; --i;) { - SERIAL_ECHOPGM(" "); + SERIAL_ECHO_SP(12); safe_delay(10); } } @@ -201,12 +201,12 @@ if (map0) { serial_echo_xy(UBL_MESH_MIN_X, UBL_MESH_MIN_Y); - SERIAL_ECHOPGM(" "); + SERIAL_ECHO_SP(4); serial_echo_12x_spaces(); serial_echo_xy(UBL_MESH_MAX_X, UBL_MESH_MIN_Y); SERIAL_EOL; serial_echo_xy(0, 0); - SERIAL_ECHOPGM(" "); + SERIAL_ECHO_SP(7); serial_echo_12x_spaces(); serial_echo_xy(GRID_MAX_POINTS_X - 1, 0); SERIAL_EOL; From 819df5e06d4412128e5f9067aaab54942decd2fc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Apr 2017 18:36:56 -0500 Subject: [PATCH 3/9] Cleanups to pins debugging --- Marlin/pinsDebug.h | 93 +++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 64 deletions(-) diff --git a/Marlin/pinsDebug.h b/Marlin/pinsDebug.h index 0d73f95ba..0f41864ee 100644 --- a/Marlin/pinsDebug.h +++ b/Marlin/pinsDebug.h @@ -72,7 +72,7 @@ bool endstop_monitor_flag = false; #undef REPORT_NAME_DIGITAL #undef REPORT_NAME_ANALOG -#define _ADD_PIN_2( ENTRY_NAME, NAME, IS_DIGITAL) {(const char*) ENTRY_NAME, (const char*)NAME, (const char*)IS_DIGITAL}, +#define _ADD_PIN_2( ENTRY_NAME, NAME, IS_DIGITAL) {(const char*)ENTRY_NAME, (const char*)NAME, (const char*)IS_DIGITAL}, #define _ADD_PIN( NAME, COUNTER, IS_DIGITAL) _ADD_PIN_2( entry_NAME_##COUNTER, NAME, IS_DIGITAL) #define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN( NAME, COUNTER, (uint8_t)1) #define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN( analogInputToDigitalPin(NAME), COUNTER, 0) @@ -208,9 +208,9 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = { #endif #if defined(COM1C1) && defined(TIMER1C) - { (const uint8_t*) &OCR1A, (const uint8_t*) &OCR1B, (const uint8_t*) &OCR1C}, + { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, (const uint8_t*)&OCR1C}, #else - { (const uint8_t*) &OCR1A, (const uint8_t*) &OCR1B,0}, + { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B,0}, #endif #if defined(TCCR2A) && defined(COM2A1) @@ -219,18 +219,18 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = { #if defined(TCCR3A) && defined(COM3A1) #ifdef COM3C1 - { (const uint8_t*) &OCR3A, (const uint8_t*) &OCR3B, (const uint8_t*) &OCR3C}, + { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C}, #else - { (const uint8_t*) &OCR3A, (const uint8_t*) &OCR3B,0}, + { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B,0}, #endif #endif #ifdef TCCR4A - { (const uint8_t*) &OCR4A, (const uint8_t*) &OCR4B, (const uint8_t*) &OCR4C}, + { (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C}, #endif #if defined(TCCR5A) && defined(COM5A1) - { (const uint8_t*) &OCR5A, (const uint8_t*) &OCR5B, (const uint8_t*) &OCR5C}, + { (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C}, #endif }; @@ -262,7 +262,7 @@ static void err_prob_interrupt() { } void com_print(uint8_t N, uint8_t Z) { - uint8_t *TCCRA = (uint8_t*) TCCR_A(N); + uint8_t *TCCRA = (uint8_t*)TCCR_A(N); SERIAL_PROTOCOLPGM(" COM"); SERIAL_PROTOCOLCHAR(N + '0'); switch(Z) { @@ -278,8 +278,7 @@ void com_print(uint8_t N, uint8_t Z) { } } - -void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm n - WGM bit layout +void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - WGM bit layout char buffer[20]; // for the sprintf statements uint8_t *TCCRB = (uint8_t*)TCCR_B(T); uint8_t *TCCRA = (uint8_t*)TCCR_A(T); @@ -292,11 +291,11 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm n - SERIAL_PROTOCOLPGM(" "); if (N == 3) { - uint8_t *OCRVAL8 = (uint8_t*) OCR_VAL(T, L - 'A'); + uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A'); PWM_PRINT(*OCRVAL8); } else { - uint16_t *OCRVAL16 = (uint16_t*) OCR_VAL(T, L - 'A'); + uint16_t *OCRVAL16 = (uint16_t*)OCR_VAL(T, L - 'A'); PWM_PRINT(*OCRVAL16); } SERIAL_PROTOCOLPAIR(" WGM: ", WGM); @@ -311,7 +310,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm n - SERIAL_PROTOCOLCHAR(T + '0'); SERIAL_PROTOCOLPAIR("B: ", *TCCRB); - uint8_t *TMSK = (uint8_t*) TIMSK(T); + uint8_t *TMSK = (uint8_t*)TIMSK(T); SERIAL_PROTOCOLPGM(" TIMSK"); SERIAL_PROTOCOLCHAR(T + '0'); SERIAL_PROTOCOLPAIR(": ", *TMSK); @@ -327,76 +326,43 @@ static void pwm_details(uint8_t pin) { switch(digitalPinToTimer(pin)) { #if defined(TCCR0A) && defined(COM0A1) - #ifdef TIMER0A - case TIMER0A: - timer_prefix(0,'A',3); - break; + case TIMER0A: timer_prefix(0, 'A', 3); break; #endif - case TIMER0B: - timer_prefix(0,'B',3); - break; + case TIMER0B: timer_prefix(0, 'B', 3); break; #endif #if defined(TCCR1A) && defined(COM1A1) - case TIMER1A: - timer_prefix(1,'A',4); - break; - case TIMER1B: - timer_prefix(1,'B',4); - break; + case TIMER1A: timer_prefix(1, 'A', 4); break; + case TIMER1B: timer_prefix(1, 'B', 4); break; #if defined(COM1C1) && defined(TIMER1C) - case TIMER1C: - timer_prefix(1,'C',4); - break; + case TIMER1C: timer_prefix(1, 'C', 4); break; #endif #endif #if defined(TCCR2A) && defined(COM2A1) - case TIMER2A: - timer_prefix(2,'A',3); - break; - case TIMER2B: - timer_prefix(2,'B',3); - break; + case TIMER2A: timer_prefix(2, 'A', 3); break; + case TIMER2B: timer_prefix(2, 'B', 3); break; #endif #if defined(TCCR3A) && defined(COM3A1) - case TIMER3A: - timer_prefix(3,'A',4); - break; - case TIMER3B: - timer_prefix(3,'B',4); - break; + case TIMER3A: timer_prefix(3, 'A', 4); break; + case TIMER3B: timer_prefix(3, 'B', 4); break; #ifdef COM3C1 - case TIMER3C: - timer_prefix(3,'C',4); - break; + case TIMER3C: timer_prefix(3, 'C', 4); break; #endif #endif #ifdef TCCR4A - case TIMER4A: - timer_prefix(4,'A',4); - break; - case TIMER4B: - timer_prefix(4,'B',4); - break; - case TIMER4C: - timer_prefix(4,'C',4); - break; + case TIMER4A: timer_prefix(4, 'A', 4); break; + case TIMER4B: timer_prefix(4, 'B', 4); break; + case TIMER4C: timer_prefix(4, 'C', 4); break; #endif #if defined(TCCR5A) && defined(COM5A1) - case TIMER5A: - timer_prefix(5,'A',4); - break; - case TIMER5B: - timer_prefix(5,'B',4); - break; - case TIMER5C: - timer_prefix(5,'C',4); - break; + case TIMER5A: timer_prefix(5, 'A', 4); break; + case TIMER5B: timer_prefix(5, 'B', 4); break; + case TIMER5C: timer_prefix(5, 'C', 4); break; #endif case NOT_ON_TIMER: break; @@ -472,8 +438,7 @@ inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = t SERIAL_CHAR('.'); SERIAL_ECHO_SP(25); // add padding if not the first instance found } - else SERIAL_ECHOPGM(". "); // add padding if not the first instance found - name_mem_pointer = (char*) pgm_read_word(&pin_array[x][0]); + name_mem_pointer = (char*)pgm_read_word(&pin_array[x][0]); for (uint8_t y = 0; y < 28; y++) { // always print pin name temp_char = pgm_read_byte(name_mem_pointer + y); if (temp_char != 0) MYSERIAL.write(temp_char); From c2c9f01c8e9c14272c2b4b15cad07880a3ef801e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Apr 2017 20:14:26 -0500 Subject: [PATCH 4/9] Patch newly-introduced bug in IS_Z2_OR_PROBE --- Marlin/Conditionals_post.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index 1d994ce1a..fae3d1b7f 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -406,9 +406,9 @@ #endif #endif - #define IS_Z2_OR_PROBE(P) (PIN_EXISTS(Z2_MIN_PIN) && (P == Z2_MIN_PIN) \ - || PIN_EXISTS(Z2_MAX_PIN) && (P == Z2_MAX_PIN) \ - || PIN_EXISTS(Z_MIN_PROBE_PIN) && (P == Z_MIN_PROBE_PIN)) + #define IS_Z2_OR_PROBE(P) ( (PIN_EXISTS(Z2_MIN) && (P) == Z2_MIN_PIN) \ + || (PIN_EXISTS(Z2_MAX) && (P) == Z2_MAX_PIN) \ + || (PIN_EXISTS(Z_MIN_PROBE) && (P) == Z_MIN_PROBE_PIN)) /** * Set ENDSTOPPULLUPS for active endstop switches From 0b421e97c910cb06adc267df08199e26e7d81551 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Apr 2017 22:16:44 -0500 Subject: [PATCH 5/9] Rename some (unused) OMCA pins --- Marlin/pinsDebug_list.h | 8 ++++---- Marlin/pins_OMCA.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/pinsDebug_list.h b/Marlin/pinsDebug_list.h index 54b7ae5d7..6fef84c59 100644 --- a/Marlin/pinsDebug_list.h +++ b/Marlin/pinsDebug_list.h @@ -350,11 +350,11 @@ #if PIN_EXISTS(HOME) REPORT_NAME_DIGITAL(HOME_PIN, __LINE__ ) #endif -#if defined(I2C_SCL) && I2C_SCL >= 0 - REPORT_NAME_DIGITAL(I2C_SCL, __LINE__ ) +#if PIN_EXISTS(I2C_SCL) + REPORT_NAME_DIGITAL(I2C_SCL_PIN, __LINE__ ) #endif -#if defined(I2C_SDA) && I2C_SDA >= 0 - REPORT_NAME_DIGITAL(I2C_SDA, __LINE__ ) +#if PIN_EXISTS(I2C_SDA) + REPORT_NAME_DIGITAL(I2C_SDA_PIN, __LINE__ ) #endif #if PIN_EXISTS(KILL) REPORT_NAME_DIGITAL(KILL_PIN, __LINE__ ) diff --git a/Marlin/pins_OMCA.h b/Marlin/pins_OMCA.h index a69d61ec7..545c8646f 100644 --- a/Marlin/pins_OMCA.h +++ b/Marlin/pins_OMCA.h @@ -111,8 +111,8 @@ // #define SDSS 11 -#define I2C_SCL 16 -#define I2C_SDA 17 +#define I2C_SCL_PIN 16 +#define I2C_SDA_PIN 17 // future proofing #define __FS 20 From ff35b11d08327bf8cd16e3db5824ed5c77cd4d19 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Apr 2017 22:24:03 -0500 Subject: [PATCH 6/9] Resolve compiler complaint about memset volatile * --- Marlin/stepper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 69ba984e1..ff6d85f84 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -1099,7 +1099,7 @@ void Stepper::init() { ENABLE_STEPPER_DRIVER_INTERRUPT(); #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE) - ZERO(e_steps); + for (uint8_t i = 0; i < COUNT(e_steps); i++) e_steps[i] = 0; #if ENABLED(LIN_ADVANCE) ZERO(current_adv_steps); #endif From 88141ca717ac0e8cbb449789c9def357da6399cb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Apr 2017 22:24:51 -0500 Subject: [PATCH 7/9] Remove things that aren't pins from pinsDebug_list.h --- Marlin/pinsDebug_list.h | 46 +++++++---------------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/Marlin/pinsDebug_list.h b/Marlin/pinsDebug_list.h index 6fef84c59..2fa23f62b 100644 --- a/Marlin/pinsDebug_list.h +++ b/Marlin/pinsDebug_list.h @@ -20,12 +20,15 @@ * */ - // Please update this list when adding new pins to Marlin. - // The order doesn't matter. - // Following this pattern is a must. - // If the new pin name is over 28 characters long then pinsDebug.h will need to be modified. +// Please update this list when adding new pins to Marlin. +// The order doesn't matter. +// Following this pattern is a must. +// If the new pin name is over 28 characters long then pinsDebug.h will need to be modified. + +// Pin list updated from 18 FEB 2017 RCBugfix branch - max length of pin name is 24 + +#line 0 // set __LINE__ to a known value for both passes - // Pin list updated from 18 FEB 2017 RCBugfix branch - max length of pin name is 24 #if defined(__FD) && __FD >= 0 REPORT_NAME_DIGITAL(__FD, __LINE__ ) #endif @@ -224,18 +227,6 @@ #if PIN_EXISTS(E4_STEP) REPORT_NAME_DIGITAL(E4_STEP_PIN, __LINE__ ) #endif -#if defined(encrot0) && encrot0 >= 0 - REPORT_NAME_DIGITAL(encrot0, __LINE__ ) -#endif -#if defined(encrot1) && encrot1 >= 0 - REPORT_NAME_DIGITAL(encrot1, __LINE__ ) -#endif -#if defined(encrot2) && encrot2 >= 0 - REPORT_NAME_DIGITAL(encrot2, __LINE__ ) -#endif -#if defined(encrot3) && encrot3 >= 0 - REPORT_NAME_DIGITAL(encrot3, __LINE__ ) -#endif #if defined(EXT_AUX_A0) && EXT_AUX_A0 >= 0 && EXT_AUX_A0 < NUM_ANALOG_INPUTS REPORT_NAME_ANALOG(EXT_AUX_A0, __LINE__ ) #endif @@ -317,9 +308,6 @@ #if PIN_EXISTS(FILWIDTH) && FILWIDTH_PIN < NUM_ANALOG_INPUTS REPORT_NAME_ANALOG(FILWIDTH_PIN, __LINE__ ) #endif -#if defined(GEN7_VERSION) && GEN7_VERSION >= 0 - REPORT_NAME_DIGITAL(GEN7_VERSION, __LINE__ ) -#endif #if PIN_EXISTS(HEATER_0) REPORT_NAME_DIGITAL(HEATER_0_PIN, __LINE__ ) #endif @@ -422,9 +410,6 @@ #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) REPORT_NAME_DIGITAL(MOTOR_CURRENT_PWM_Z_PIN, __LINE__ ) #endif -#if defined(NUM_TLCS) && NUM_TLCS >= 0 - REPORT_NAME_DIGITAL(NUM_TLCS, __LINE__ ) -#endif #if PIN_EXISTS(ORIG_E0_AUTO_FAN) REPORT_NAME_DIGITAL(ORIG_E0_AUTO_FAN_PIN, __LINE__ ) #endif @@ -545,15 +530,9 @@ #if PIN_EXISTS(SS) REPORT_NAME_DIGITAL(SS_PIN, __LINE__ ) #endif -#if defined(STAT_LED_BLUE) && STAT_LED_BLUE >= 0 - REPORT_NAME_DIGITAL(STAT_LED_BLUE, __LINE__ ) -#endif #if PIN_EXISTS(STAT_LED_BLUE) REPORT_NAME_DIGITAL(STAT_LED_BLUE_PIN, __LINE__ ) #endif -#if defined(STAT_LED_RED) && STAT_LED_RED >= 0 - REPORT_NAME_DIGITAL(STAT_LED_RED, __LINE__ ) -#endif #if PIN_EXISTS(STAT_LED_RED) REPORT_NAME_DIGITAL(STAT_LED_RED_PIN, __LINE__ ) #endif @@ -599,21 +578,12 @@ #if PIN_EXISTS(THERMO_SCK) REPORT_NAME_DIGITAL(THERMO_SCK_PIN, __LINE__ ) #endif -#if defined(TLC_BLANK_BIT) && TLC_BLANK_BIT >= 0 - REPORT_NAME_DIGITAL(TLC_BLANK_BIT, __LINE__ ) -#endif #if PIN_EXISTS(TLC_BLANK) REPORT_NAME_DIGITAL(TLC_BLANK_PIN, __LINE__ ) #endif -#if defined(TLC_CLOCK_BIT) && TLC_CLOCK_BIT >= 0 - REPORT_NAME_DIGITAL(TLC_CLOCK_BIT, __LINE__ ) -#endif #if PIN_EXISTS(TLC_CLOCK) REPORT_NAME_DIGITAL(TLC_CLOCK_PIN, __LINE__ ) #endif -#if defined(TLC_DATA_BIT) && TLC_DATA_BIT >= 0 - REPORT_NAME_DIGITAL(TLC_DATA_BIT, __LINE__ ) -#endif #if PIN_EXISTS(TLC_DATA) REPORT_NAME_DIGITAL(TLC_DATA_PIN, __LINE__ ) #endif From 46b714a52f38e28346a80df61e687d85673d20cf Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Apr 2017 22:27:26 -0500 Subject: [PATCH 8/9] Cleanup spacing in pinsDebug.h --- Marlin/pinsDebug.h | 148 ++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 82 deletions(-) diff --git a/Marlin/pinsDebug.h b/Marlin/pinsDebug.h index 0f41864ee..a14f2b519 100644 --- a/Marlin/pinsDebug.h +++ b/Marlin/pinsDebug.h @@ -46,21 +46,18 @@ bool endstop_monitor_flag = false; // first pass - put the name strings into FLASH -#define _ADD_PIN_2(PIN_NAME, ENTRY_NAME) static const unsigned char ENTRY_NAME[] PROGMEM = {PIN_NAME}; -#define _ADD_PIN(PIN_NAME, COUNTER) _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER) -#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER) -#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER) - -#line 0 // set __LINE__ to a known value for the first pass +#define _ADD_PIN_2(PIN_NAME, ENTRY_NAME) static const unsigned char ENTRY_NAME[] PROGMEM = { PIN_NAME }; +#define _ADD_PIN(PIN_NAME, COUNTER) _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER) +#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER) +#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER) #include "pinsDebug_list.h" - -#line 59 // set __LINE__ to the correct line number or else compiler error messages don't make sense +#line 56 // manually add pins that have names that are macros which don't play well with these macros #if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY) - static const char RXD_NAME[] PROGMEM = {"RXD"}; - static const char TXD_NAME[] PROGMEM = {"TXD"}; + static const char RXD_NAME[] PROGMEM = { "RXD" }; + static const char TXD_NAME[] PROGMEM = { "TXD" }; #endif ///////////////////////////////////////////////////////////////////////////// @@ -72,11 +69,10 @@ bool endstop_monitor_flag = false; #undef REPORT_NAME_DIGITAL #undef REPORT_NAME_ANALOG -#define _ADD_PIN_2( ENTRY_NAME, NAME, IS_DIGITAL) {(const char*)ENTRY_NAME, (const char*)NAME, (const char*)IS_DIGITAL}, -#define _ADD_PIN( NAME, COUNTER, IS_DIGITAL) _ADD_PIN_2( entry_NAME_##COUNTER, NAME, IS_DIGITAL) -#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN( NAME, COUNTER, (uint8_t)1) -#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN( analogInputToDigitalPin(NAME), COUNTER, 0) - +#define _ADD_PIN_2(ENTRY_NAME, NAME, IS_DIGITAL) { (const char*)ENTRY_NAME, (const char*)NAME, (const char*)IS_DIGITAL }, +#define _ADD_PIN(NAME, COUNTER, IS_DIGITAL) _ADD_PIN_2(entry_NAME_##COUNTER, NAME, IS_DIGITAL) +#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(NAME, COUNTER, (uint8_t)1) +#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(analogInputToDigitalPin(NAME), COUNTER, 0) const char* const pin_array[][3] PROGMEM = { @@ -92,35 +88,32 @@ const char* const pin_array[][3] PROGMEM = { // manually add pins ... #if SERIAL_PORT == 0 #if AVR_ATmega2560_FAMILY - {RXD_NAME, "0", "1"}, - {TXD_NAME, "1", "1"}, + { RXD_NAME, "0", "1" }, + { TXD_NAME, "1", "1" }, #elif AVR_ATmega1284_FAMILY - {RXD_NAME, "8", "1"}, - {TXD_NAME, "9", "1"}, + { RXD_NAME, "8", "1" }, + { TXD_NAME, "9", "1" }, #endif #endif - #line 0 // set __LINE__ to the SAME known value for the second pass #include "pinsDebug_list.h" + #line 101 -}; // done populating the array - -#line 109 // set __LINE__ to the correct line number or else compiler error messages don't make sense +}; -#define n_array (sizeof (pin_array) / sizeof (const char *))/3 +#define n_array (sizeof(pin_array) / sizeof(char*)) / 3 #ifndef TIMER1B // working with Teensyduino extension so need to re-define some things #include "pinsDebug_Teensyduino.h" #endif - #define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", V); SERIAL_ECHO(buffer); }while(0) -#define PWM_CASE(N,Z) \ - case TIMER##N##Z: \ +#define PWM_CASE(N,Z) \ + case TIMER##N##Z: \ if (TCCR##N##A & (_BV(COM##N##Z##1) | _BV(COM##N##Z##0))) { \ - PWM_PRINT(OCR##N##Z); \ - return true; \ + PWM_PRINT(OCR##N##Z); \ + return true; \ } else return false /** @@ -130,71 +123,70 @@ const char* const pin_array[][3] PROGMEM = { static bool pwm_status(uint8_t pin) { char buffer[20]; // for the sprintf statements - switch(digitalPinToTimer(pin)) { + switch (digitalPinToTimer(pin)) { #if defined(TCCR0A) && defined(COM0A1) #ifdef TIMER0A - PWM_CASE(0,A); + PWM_CASE(0, A); #endif - PWM_CASE(0,B); + PWM_CASE(0, B); #endif #if defined(TCCR1A) && defined(COM1A1) - PWM_CASE(1,A); - PWM_CASE(1,B); + PWM_CASE(1, A); + PWM_CASE(1, B); #if defined(COM1C1) && defined(TIMER1C) - PWM_CASE(1,C); + PWM_CASE(1, C); #endif #endif #if defined(TCCR2A) && defined(COM2A1) - PWM_CASE(2,A); - PWM_CASE(2,B); + PWM_CASE(2, A); + PWM_CASE(2, B); #endif #if defined(TCCR3A) && defined(COM3A1) - PWM_CASE(3,A); - PWM_CASE(3,B); + PWM_CASE(3, A); + PWM_CASE(3, B); #ifdef COM3C1 - PWM_CASE(3,C); + PWM_CASE(3, C); #endif #endif #ifdef TCCR4A - PWM_CASE(4,A); - PWM_CASE(4,B); - PWM_CASE(4,C); + PWM_CASE(4, A); + PWM_CASE(4, B); + PWM_CASE(4, C); #endif #if defined(TCCR5A) && defined(COM5A1) - PWM_CASE(5,A); - PWM_CASE(5,B); - PWM_CASE(5,C); + PWM_CASE(5, A); + PWM_CASE(5, B); + PWM_CASE(5, C); #endif case NOT_ON_TIMER: default: return false; } - SERIAL_PROTOCOLPGM(" "); + SERIAL_PROTOCOL_SP(2); } // pwm_status - const volatile uint8_t* const PWM_other[][3] PROGMEM = { - {&TCCR0A, &TCCR0B, &TIMSK0}, - {&TCCR1A, &TCCR1B, &TIMSK1}, + { &TCCR0A, &TCCR0B, &TIMSK0 }, + { &TCCR1A, &TCCR1B, &TIMSK1 }, #if defined(TCCR2A) && defined(COM2A1) - {&TCCR2A, &TCCR2B, &TIMSK2}, + { &TCCR2A, &TCCR2B, &TIMSK2 }, #endif #if defined(TCCR3A) && defined(COM3A1) - {&TCCR3A, &TCCR3B, &TIMSK3}, + { &TCCR3A, &TCCR3B, &TIMSK3 }, #endif #ifdef TCCR4A - {&TCCR4A, &TCCR4B, &TIMSK4}, + { &TCCR4A, &TCCR4B, &TIMSK4 }, #endif #if defined(TCCR5A) && defined(COM5A1) - {&TCCR5A, &TCCR5B, &TIMSK5}, + { &TCCR5A, &TCCR5B, &TIMSK5 }, #endif }; @@ -202,35 +194,35 @@ const volatile uint8_t* const PWM_other[][3] PROGMEM = { const volatile uint8_t* const PWM_OCR[][3] PROGMEM = { #ifdef TIMER0A - {&OCR0A,&OCR0B,0}, + { &OCR0A, &OCR0B, 0 }, #else - {0,&OCR0B,0}, + { 0, &OCR0B, 0 }, #endif #if defined(COM1C1) && defined(TIMER1C) - { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, (const uint8_t*)&OCR1C}, + { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, (const uint8_t*)&OCR1C }, #else - { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B,0}, + { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, 0 }, #endif #if defined(TCCR2A) && defined(COM2A1) - {&OCR2A,&OCR2B,0}, + { &OCR2A, &OCR2B, 0 }, #endif #if defined(TCCR3A) && defined(COM3A1) #ifdef COM3C1 - { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C}, + { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C }, #else - { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B,0}, + { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, 0 }, #endif #endif #ifdef TCCR4A - { (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C}, + { (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C }, #endif #if defined(TCCR5A) && defined(COM5A1) - { (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C}, + { (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C }, #endif }; @@ -247,32 +239,24 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = { #define WGM_3 4 #define TOIE 0 - #define OCR_VAL(T, L) pgm_read_word(&PWM_OCR[T][L]) - -static void err_is_counter() { - SERIAL_PROTOCOLPGM(" non-standard PWM mode"); -} -static void err_is_interrupt() { - SERIAL_PROTOCOLPGM(" compare interrupt enabled"); -} -static void err_prob_interrupt() { - SERIAL_PROTOCOLPGM(" overflow interrupt enabled"); -} +static void err_is_counter() { SERIAL_PROTOCOLPGM(" non-standard PWM mode"); } +static void err_is_interrupt() { SERIAL_PROTOCOLPGM(" compare interrupt enabled"); } +static void err_prob_interrupt() { SERIAL_PROTOCOLPGM(" overflow interrupt enabled"); } void com_print(uint8_t N, uint8_t Z) { uint8_t *TCCRA = (uint8_t*)TCCR_A(N); SERIAL_PROTOCOLPGM(" COM"); SERIAL_PROTOCOLCHAR(N + '0'); - switch(Z) { - case 'A' : + switch (Z) { + case 'A': SERIAL_PROTOCOLPAIR("A: ", ((*TCCRA & (_BV(7) | _BV(6))) >> 6)); break; - case 'B' : + case 'B': SERIAL_PROTOCOLPAIR("B: ", ((*TCCRA & (_BV(5) | _BV(4))) >> 4)); break; - case 'C' : + case 'C': SERIAL_PROTOCOLPAIR("C: ", ((*TCCRA & (_BV(3) | _BV(2))) >> 2)); break; } @@ -288,7 +272,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - SERIAL_PROTOCOLPGM(" TIMER"); SERIAL_PROTOCOLCHAR(T + '0'); SERIAL_PROTOCOLCHAR(L); - SERIAL_PROTOCOLPGM(" "); + SERIAL_PROTOCOL_SP(3); if (N == 3) { uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A'); @@ -316,14 +300,14 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - SERIAL_PROTOCOLPAIR(": ", *TMSK); uint8_t OCIE = L - 'A' + 1; - if (N == 3) {if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter();} - else {if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) err_is_counter();} + if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); } + else { if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) err_is_counter(); } if (TEST(*TMSK, OCIE)) err_is_interrupt(); if (TEST(*TMSK, TOIE)) err_prob_interrupt(); } static void pwm_details(uint8_t pin) { - switch(digitalPinToTimer(pin)) { + switch (digitalPinToTimer(pin)) { #if defined(TCCR0A) && defined(COM0A1) #ifdef TIMER0A From c12bc51a59d59855312b4956f3a88d9ba4482442 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Apr 2017 22:27:47 -0500 Subject: [PATCH 9/9] cardreader.cpp spacing tweak --- Marlin/cardreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index ff0b8a4cf..ab4b659da 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -233,7 +233,7 @@ void CardReader::initsd() { #define SPI_SPEED SPI_FULL_SPEED #endif - if (!card.init(SPI_SPEED,SDSS) + if (!card.init(SPI_SPEED, SDSS) #if defined(LCD_SDSS) && (LCD_SDSS != SDSS) && !card.init(SPI_SPEED, LCD_SDSS) #endif