Kaynağa Gözat

Fix pinsDebug compile errors

Scott Lahteine 7 yıl önce
ebeveyn
işleme
ee7163fd3a
1 değiştirilmiş dosya ile 21 ekleme ve 17 silme
  1. 21
    17
      Marlin/pinsDebug.h

+ 21
- 17
Marlin/pinsDebug.h Dosyayı Görüntüle

@@ -41,7 +41,7 @@ bool endstop_monitor_flag = false;
41 41
 
42 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 45
 #define _ADD_PIN(PIN_NAME, COUNTER) _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER)
46 46
 #define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
47 47
 #define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
@@ -64,12 +64,18 @@ bool endstop_monitor_flag = false;
64 64
 #undef REPORT_NAME_DIGITAL
65 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 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 81
    *  [pin name]  [pin number]  [is digital or analog]  1 = digital, 0 = analog
@@ -83,21 +89,19 @@ const char* const pin_array[][3] PROGMEM = {
83 89
   // manually add pins ...
84 90
   #if SERIAL_PORT == 0
85 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 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 97
     #endif
92 98
   #endif
93 99
 
94 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 105
 #define AVR_ATmega2560_FAMILY_PLUS_70 (MOTHERBOARD == BOARD_BQ_ZUM_MEGA_3D \
102 106
 || MOTHERBOARD == BOARD_MIGHTYBOARD_REVE \
103 107
 || MOTHERBOARD == BOARD_MINIRAMBO \
@@ -439,12 +443,12 @@ static void print_input_or_output(const bool isout) {
439 443
 }
440 444
 
441 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 447
   uint8_t temp_char;
444 448
   char *name_mem_pointer, buffer[30];   // for the sprintf statements
445 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 452
       if (found) multi_name_pin = true;
449 453
       found = true;
450 454
       if (!multi_name_pin) {    // report digitial and analog pin number only on the first time through
@@ -461,7 +465,7 @@ inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = f
461 465
         SERIAL_CHAR('.');
462 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 469
       for (uint8_t y = 0; y < 28; y++) {                   // always print pin name
466 470
         temp_char = pgm_read_byte(name_mem_pointer + y);
467 471
         if (temp_char != 0)
@@ -489,7 +493,7 @@ inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = f
489 493
             else
490 494
           #endif
491 495
           {
492
-            if (!(pgm_read_byte(&pin_array[x][2]))) {
496
+            if (!(pgm_read_byte(&pin_array[x].is_digital))) {
493 497
               sprintf_P(buffer, PSTR("Analog in = %5d"), analogRead(pin - analogInputToDigitalPin(0)));
494 498
               SERIAL_ECHO(buffer);
495 499
             }

Loading…
İptal
Kaydet