Browse Source

Fix pinsDebug compile errors

Scott Lahteine 8 years ago
parent
commit
ee7163fd3a
1 changed files with 21 additions and 17 deletions
  1. 21
    17
      Marlin/pinsDebug.h

+ 21
- 17
Marlin/pinsDebug.h View File

41
 
41
 
42
 // first pass - put the name strings into FLASH
42
 // first pass - put the name strings into FLASH
43
 
43
 
44
-#define _ADD_PIN_2(PIN_NAME, ENTRY_NAME) static const unsigned char ENTRY_NAME[] PROGMEM = { PIN_NAME };
44
+#define _ADD_PIN_2(PIN_NAME, ENTRY_NAME) static const char ENTRY_NAME[] PROGMEM = { PIN_NAME };
45
 #define _ADD_PIN(PIN_NAME, COUNTER) _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER)
45
 #define _ADD_PIN(PIN_NAME, COUNTER) _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER)
46
 #define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
46
 #define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
47
 #define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
47
 #define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
64
 #undef REPORT_NAME_DIGITAL
64
 #undef REPORT_NAME_DIGITAL
65
 #undef REPORT_NAME_ANALOG
65
 #undef REPORT_NAME_ANALOG
66
 
66
 
67
-#define _ADD_PIN_2(ENTRY_NAME, NAME, IS_DIGITAL) { (const char*)ENTRY_NAME, (const char*)NAME, (const char*)IS_DIGITAL },
67
+#define _ADD_PIN_2(ENTRY_NAME, NAME, IS_DIGITAL) { ENTRY_NAME, NAME, IS_DIGITAL },
68
 #define _ADD_PIN(NAME, COUNTER, IS_DIGITAL) _ADD_PIN_2(entry_NAME_##COUNTER, NAME, IS_DIGITAL)
68
 #define _ADD_PIN(NAME, COUNTER, IS_DIGITAL) _ADD_PIN_2(entry_NAME_##COUNTER, NAME, IS_DIGITAL)
69
-#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(NAME, COUNTER, (uint8_t)1)
70
-#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(analogInputToDigitalPin(NAME), COUNTER, 0)
69
+#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(NAME, COUNTER, true)
70
+#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(analogInputToDigitalPin(NAME), COUNTER, false)
71
 
71
 
72
-const char* const pin_array[][3] PROGMEM = {
72
+typedef struct {
73
+  const char * const name;
74
+  uint8_t pin;
75
+  bool is_digital;
76
+} PinInfo;
77
+
78
+const PinInfo pin_array[] PROGMEM = {
73
 
79
 
74
   /**
80
   /**
75
    *  [pin name]  [pin number]  [is digital or analog]  1 = digital, 0 = analog
81
    *  [pin name]  [pin number]  [is digital or analog]  1 = digital, 0 = analog
83
   // manually add pins ...
89
   // manually add pins ...
84
   #if SERIAL_PORT == 0
90
   #if SERIAL_PORT == 0
85
     #if AVR_ATmega2560_FAMILY
91
     #if AVR_ATmega2560_FAMILY
86
-      { RXD_NAME, 0, 1 },
87
-      { TXD_NAME, 1, 1 },
92
+      { RXD_NAME, 0, true },
93
+      { TXD_NAME, 1, true },
88
     #elif AVR_ATmega1284_FAMILY
94
     #elif AVR_ATmega1284_FAMILY
89
-      { RXD_NAME, 8, 1 },
90
-      { TXD_NAME, 9, 1 },
95
+      { RXD_NAME, 8, true },
96
+      { TXD_NAME, 9, true },
91
     #endif
97
     #endif
92
   #endif
98
   #endif
93
 
99
 
94
   #include "pinsDebug_list.h"
100
   #include "pinsDebug_list.h"
95
-  #line 96
101
+  #line 102
96
 
102
 
97
 };
103
 };
98
 
104
 
99
-#define n_array (sizeof(pin_array) / sizeof(char*)) / 3
100
-
101
 #define AVR_ATmega2560_FAMILY_PLUS_70 (MOTHERBOARD == BOARD_BQ_ZUM_MEGA_3D \
105
 #define AVR_ATmega2560_FAMILY_PLUS_70 (MOTHERBOARD == BOARD_BQ_ZUM_MEGA_3D \
102
 || MOTHERBOARD == BOARD_MIGHTYBOARD_REVE \
106
 || MOTHERBOARD == BOARD_MIGHTYBOARD_REVE \
103
 || MOTHERBOARD == BOARD_MINIRAMBO \
107
 || MOTHERBOARD == BOARD_MINIRAMBO \
439
 }
443
 }
440
 
444
 
441
 // pretty report with PWM info
445
 // pretty report with PWM info
442
-inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = false,const char *start_string = "") {
446
+inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = false, const char *start_string = "") {
443
   uint8_t temp_char;
447
   uint8_t temp_char;
444
   char *name_mem_pointer, buffer[30];   // for the sprintf statements
448
   char *name_mem_pointer, buffer[30];   // for the sprintf statements
445
   bool found = false, multi_name_pin = false;
449
   bool found = false, multi_name_pin = false;
446
-  for (uint8_t x = 0; x < n_array; x++)  {    // scan entire array and report all instances of this pin
447
-    if (pgm_read_byte(&pin_array[x][1]) == pin) {
450
+  for (uint8_t x = 0; x < COUNT(pin_array); x++)  {    // scan entire array and report all instances of this pin
451
+    if (pgm_read_byte(&pin_array[x].pin) == pin) {
448
       if (found) multi_name_pin = true;
452
       if (found) multi_name_pin = true;
449
       found = true;
453
       found = true;
450
       if (!multi_name_pin) {    // report digitial and analog pin number only on the first time through
454
       if (!multi_name_pin) {    // report digitial and analog pin number only on the first time through
461
         SERIAL_CHAR('.');
465
         SERIAL_CHAR('.');
462
         SERIAL_ECHO_SP(26 + strlen(start_string));  // add padding if not the first instance found
466
         SERIAL_ECHO_SP(26 + strlen(start_string));  // add padding if not the first instance found
463
       }
467
       }
464
-      name_mem_pointer = (char*)pgm_read_word(&pin_array[x][0]);
468
+      name_mem_pointer = (char*)pgm_read_word(&pin_array[x].name);
465
       for (uint8_t y = 0; y < 28; y++) {                   // always print pin name
469
       for (uint8_t y = 0; y < 28; y++) {                   // always print pin name
466
         temp_char = pgm_read_byte(name_mem_pointer + y);
470
         temp_char = pgm_read_byte(name_mem_pointer + y);
467
         if (temp_char != 0)
471
         if (temp_char != 0)
489
             else
493
             else
490
           #endif
494
           #endif
491
           {
495
           {
492
-            if (!(pgm_read_byte(&pin_array[x][2]))) {
496
+            if (!(pgm_read_byte(&pin_array[x].is_digital))) {
493
               sprintf_P(buffer, PSTR("Analog in = %5d"), analogRead(pin - analogInputToDigitalPin(0)));
497
               sprintf_P(buffer, PSTR("Analog in = %5d"), analogRead(pin - analogInputToDigitalPin(0)));
494
               SERIAL_ECHO(buffer);
498
               SERIAL_ECHO(buffer);
495
             }
499
             }

Loading…
Cancel
Save