Browse Source

Clean up some spacing and semantics

Scott Lahteine 8 years ago
parent
commit
af26d22741
1 changed files with 105 additions and 117 deletions
  1. 105
    117
      Marlin/pinsDebug.h

+ 105
- 117
Marlin/pinsDebug.h View File

21
  */
21
  */
22
 
22
 
23
 // How many DIO pins are defined?
23
 // How many DIO pins are defined?
24
-#if defined(DIO85_PIN)
24
+#ifdef DIO85_PIN
25
 //  #define DIO_COUNT 86
25
 //  #define DIO_COUNT 86
26
   #define DIO_COUNT 70  // digitalRead and other Arduino IDE routines only know about pins 0 through 69
26
   #define DIO_COUNT 70  // digitalRead and other Arduino IDE routines only know about pins 0 through 69
27
 #elif defined(DIO53_PIN)
27
 #elif defined(DIO53_PIN)
42
 #define _PIN_SAY(NAME) { sprintf(buffer, NAME_FORMAT, NAME); SERIAL_ECHO(buffer); return true; }
42
 #define _PIN_SAY(NAME) { sprintf(buffer, NAME_FORMAT, NAME); SERIAL_ECHO(buffer); return true; }
43
 #define PIN_SAY(NAME) if (pin == NAME) _PIN_SAY(#NAME);
43
 #define PIN_SAY(NAME) if (pin == NAME) _PIN_SAY(#NAME);
44
 
44
 
45
-#define _ANALOG_PIN_SAY(NAME)   { sprintf(buffer, NAME_FORMAT, NAME); SERIAL_ECHO(buffer); pin_is_analog = true; return true; }
45
+#define _ANALOG_PIN_SAY(NAME) { sprintf(buffer, NAME_FORMAT, NAME); SERIAL_ECHO(buffer); pin_is_analog = true; return true; }
46
 #define ANALOG_PIN_SAY(NAME) if (pin == analogInputToDigitalPin(NAME)) _ANALOG_PIN_SAY(#NAME);
46
 #define ANALOG_PIN_SAY(NAME) if (pin == analogInputToDigitalPin(NAME)) _ANALOG_PIN_SAY(#NAME);
47
 
47
 
48
 #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && ((P) <= analogInputToDigitalPin(15) || (P) <= analogInputToDigitalPin(5)))
48
 #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && ((P) <= analogInputToDigitalPin(15) || (P) <= analogInputToDigitalPin(5)))
49
 
49
 
50
-
51
-
52
-int digitalRead_mod(int8_t pin)  // same as digitalRead except the PWM stop section has been removed
53
-{
54
-	uint8_t bit = digitalPinToBitMask(pin);
55
-	uint8_t port = digitalPinToPort(pin);
56
-  
57
-	if (port == NOT_A_PIN) return LOW;
58
-
59
-	if (*portInputRegister(port) & bit) return HIGH;
60
-	return LOW;
61
-}
62
-
63
-bool get_pinMode(int8_t pin)
64
-{
65
-	uint8_t bit = digitalPinToBitMask(pin);
50
+int digitalRead_mod(int8_t pin) { // same as digitalRead except the PWM stop section has been removed
66
 	uint8_t port = digitalPinToPort(pin);
51
 	uint8_t port = digitalPinToPort(pin);
67
-	volatile uint8_t *reg;
68
-	reg = portModeRegister(port);
69
-  return   *reg & bit;
52
+	return (port != NOT_A_PIN) && (*portInputRegister(port) & digitalPinToBitMask(pin)) ? HIGH : LOW;
70
 }
53
 }
71
 
54
 
72
-// Report pin name for a given fastio digital pin index
55
+/**
56
+ * Report pin name for a given fastio digital pin index
57
+ */
58
+static bool report_pin_name(int8_t pin, bool &pin_is_analog) {
73
 
59
 
74
-static bool report_pin_name(int8_t pin,bool &pin_is_analog) {
75
-  
76
   char buffer[30];   // for the sprintf statements
60
   char buffer[30];   // for the sprintf statements
77
   pin_is_analog = false;   // default to digital pin
61
   pin_is_analog = false;   // default to digital pin
78
-  
62
+
79
   if (IS_ANALOG(pin)) {
63
   if (IS_ANALOG(pin)) {
80
     sprintf(buffer, "(A%2d)  ", int(pin - analogInputToDigitalPin(0)));
64
     sprintf(buffer, "(A%2d)  ", int(pin - analogInputToDigitalPin(0)));
81
-    SERIAL_ECHO(buffer);   
65
+    SERIAL_ECHO(buffer);
82
   }
66
   }
83
   else SERIAL_ECHOPGM("       ");
67
   else SERIAL_ECHOPGM("       ");
84
 
68
 
85
-  #if defined(RXD) && RXD > -1
69
+  #if defined(RXD) && RXD >= 0
86
     if (pin == 0) { sprintf(buffer, NAME_FORMAT, "RXD"); SERIAL_ECHO(buffer); return true; }
70
     if (pin == 0) { sprintf(buffer, NAME_FORMAT, "RXD"); SERIAL_ECHO(buffer); return true; }
87
   #endif
71
   #endif
88
-  #if defined(TXD) && TXD > -1
72
+
73
+  #if defined(TXD) && TXD >= 0
89
     if (pin == 1) { sprintf(buffer, NAME_FORMAT, "TXD"); SERIAL_ECHO(buffer); return true; }
74
     if (pin == 1) { sprintf(buffer, NAME_FORMAT, "TXD"); SERIAL_ECHO(buffer); return true; }
90
   #endif
75
   #endif
91
 
76
 
92
-  
93
   // Pin list updated from 7 OCT RCBugfix branch
77
   // Pin list updated from 7 OCT RCBugfix branch
94
-  #if defined(__FD) && __FD > -1   
78
+  #if defined(__FD) && __FD >= 0
95
     PIN_SAY(__FD)
79
     PIN_SAY(__FD)
96
   #endif
80
   #endif
97
-  #if defined(__FS) && __FS > -1
81
+  #if defined(__FS) && __FS >= 0
98
     PIN_SAY(__FS)
82
     PIN_SAY(__FS)
99
   #endif
83
   #endif
100
-  #if defined(__GD) && __GD > -1
84
+  #if defined(__GD) && __GD >= 0
101
     PIN_SAY(__GD)
85
     PIN_SAY(__GD)
102
   #endif
86
   #endif
103
-  #if defined(__GS) && __GS > -1
87
+  #if defined(__GS) && __GS >= 0
104
     PIN_SAY(__GS)
88
     PIN_SAY(__GS)
105
   #endif
89
   #endif
106
- 
90
+
107
   #if PIN_EXISTS(AVR_MISO)
91
   #if PIN_EXISTS(AVR_MISO)
108
     PIN_SAY(AVR_MISO_PIN);
92
     PIN_SAY(AVR_MISO_PIN);
109
   #endif
93
   #endif
119
   #if PIN_EXISTS(BEEPER)
103
   #if PIN_EXISTS(BEEPER)
120
     PIN_SAY(BEEPER_PIN);
104
     PIN_SAY(BEEPER_PIN);
121
   #endif
105
   #endif
122
-  #if defined(BTN_CENTER) && BTN_CENTER > -1
106
+  #if defined(BTN_CENTER) && BTN_CENTER >= 0
123
     PIN_SAY(BTN_CENTER);
107
     PIN_SAY(BTN_CENTER);
124
   #endif
108
   #endif
125
-  #if defined(BTN_DOWN) && BTN_DOWN > -1
109
+  #if defined(BTN_DOWN) && BTN_DOWN >= 0
126
     PIN_SAY(BTN_DOWN);
110
     PIN_SAY(BTN_DOWN);
127
   #endif
111
   #endif
128
-  #if defined(BTN_DWN) && BTN_DWN > -1
112
+  #if defined(BTN_DWN) && BTN_DWN >= 0
129
     PIN_SAY(BTN_DWN);
113
     PIN_SAY(BTN_DWN);
130
   #endif
114
   #endif
131
-  #if defined(BTN_EN1) && BTN_EN1 > -1
115
+  #if defined(BTN_EN1) && BTN_EN1 >= 0
132
     PIN_SAY(BTN_EN1);
116
     PIN_SAY(BTN_EN1);
133
   #endif
117
   #endif
134
-  #if defined(BTN_EN2) && BTN_EN2 > -1
118
+  #if defined(BTN_EN2) && BTN_EN2 >= 0
135
     PIN_SAY(BTN_EN2);
119
     PIN_SAY(BTN_EN2);
136
   #endif
120
   #endif
137
-  #if defined(BTN_ENC) && BTN_ENC > -1
121
+  #if defined(BTN_ENC) && BTN_ENC >= 0
138
     PIN_SAY(BTN_ENC);
122
     PIN_SAY(BTN_ENC);
139
   #endif
123
   #endif
140
-  #if defined(BTN_HOME) && BTN_HOME > -1
124
+  #if defined(BTN_HOME) && BTN_HOME >= 0
141
     PIN_SAY(BTN_HOME);
125
     PIN_SAY(BTN_HOME);
142
   #endif
126
   #endif
143
-  #if defined(BTN_LEFT) && BTN_LEFT > -1
127
+  #if defined(BTN_LEFT) && BTN_LEFT >= 0
144
     PIN_SAY(BTN_LEFT);
128
     PIN_SAY(BTN_LEFT);
145
   #endif
129
   #endif
146
-  #if defined(BTN_LFT) && BTN_LFT > -1
130
+  #if defined(BTN_LFT) && BTN_LFT >= 0
147
     PIN_SAY(BTN_LFT);
131
     PIN_SAY(BTN_LFT);
148
   #endif
132
   #endif
149
-  #if defined(BTN_RIGHT) && BTN_RIGHT > -1
133
+  #if defined(BTN_RIGHT) && BTN_RIGHT >= 0
150
     PIN_SAY(BTN_RIGHT);
134
     PIN_SAY(BTN_RIGHT);
151
   #endif
135
   #endif
152
-  #if defined(BTN_RT) && BTN_RT > -1
136
+  #if defined(BTN_RT) && BTN_RT >= 0
153
     PIN_SAY(BTN_RT);
137
     PIN_SAY(BTN_RT);
154
   #endif
138
   #endif
155
-  #if defined(BTN_UP) && BTN_UP > -1
139
+  #if defined(BTN_UP) && BTN_UP >= 0
156
     PIN_SAY(BTN_UP);
140
     PIN_SAY(BTN_UP);
157
   #endif
141
   #endif
158
   #if PIN_EXISTS(CONTROLLERFAN)
142
   #if PIN_EXISTS(CONTROLLERFAN)
161
   #if PIN_EXISTS(DAC_DISABLE)
145
   #if PIN_EXISTS(DAC_DISABLE)
162
     PIN_SAY(DAC_DISABLE_PIN);
146
     PIN_SAY(DAC_DISABLE_PIN);
163
   #endif
147
   #endif
164
-  #if defined(DAC_STEPPER_GAIN) && DAC_STEPPER_GAIN > -1
148
+  #if defined(DAC_STEPPER_GAIN) && DAC_STEPPER_GAIN >= 0
165
     PIN_SAY(DAC_STEPPER_GAIN);
149
     PIN_SAY(DAC_STEPPER_GAIN);
166
   #endif
150
   #endif
167
-  #if defined(DAC_STEPPER_VREF) && DAC_STEPPER_VREF > -1
151
+  #if defined(DAC_STEPPER_VREF) && DAC_STEPPER_VREF >= 0
168
     PIN_SAY(DAC_STEPPER_VREF);
152
     PIN_SAY(DAC_STEPPER_VREF);
169
   #endif
153
   #endif
170
   #if PIN_EXISTS(DEBUG)
154
   #if PIN_EXISTS(DEBUG)
173
   #if PIN_EXISTS(DIGIPOTSS)
157
   #if PIN_EXISTS(DIGIPOTSS)
174
     PIN_SAY(DIGIPOTSS_PIN);
158
     PIN_SAY(DIGIPOTSS_PIN);
175
   #endif
159
   #endif
176
-  #if defined(DIO_COUNT) && DIO_COUNT > -1
160
+  #if defined(DIO_COUNT) && DIO_COUNT >= 0
177
     PIN_SAY(DIO_COUNT);
161
     PIN_SAY(DIO_COUNT);
178
   #endif
162
   #endif
179
-  #if defined(DOGLCD_A0) && DOGLCD_A0 > -1
163
+  #if defined(DOGLCD_A0) && DOGLCD_A0 >= 0
180
     PIN_SAY(DOGLCD_A0);
164
     PIN_SAY(DOGLCD_A0);
181
   #endif
165
   #endif
182
-  #if defined(DOGLCD_CS) && DOGLCD_CS > -1
166
+  #if defined(DOGLCD_CS) && DOGLCD_CS >= 0
183
     PIN_SAY(DOGLCD_CS);
167
     PIN_SAY(DOGLCD_CS);
184
   #endif
168
   #endif
185
-  #if defined(DOGLCD_MOSI) && DOGLCD_MOSI > -1
169
+  #if defined(DOGLCD_MOSI) && DOGLCD_MOSI >= 0
186
     PIN_SAY(DOGLCD_MOSI);
170
     PIN_SAY(DOGLCD_MOSI);
187
   #endif
171
   #endif
188
-  #if defined(DOGLCD_SCK) && DOGLCD_SCK > -1
172
+  #if defined(DOGLCD_SCK) && DOGLCD_SCK >= 0
189
     PIN_SAY(DOGLCD_SCK);
173
     PIN_SAY(DOGLCD_SCK);
190
   #endif
174
   #endif
191
   #if PIN_EXISTS(E0_ATT)
175
   #if PIN_EXISTS(E0_ATT)
260
   #if PIN_EXISTS(E4_STEP)
244
   #if PIN_EXISTS(E4_STEP)
261
     PIN_SAY(E4_STEP_PIN);
245
     PIN_SAY(E4_STEP_PIN);
262
   #endif
246
   #endif
263
-  #if defined(encrot1) && encrot1 > -1
247
+  #if defined(encrot1) && encrot1 >= 0
264
     PIN_SAY(encrot1);
248
     PIN_SAY(encrot1);
265
   #endif
249
   #endif
266
-  #if defined(encrot2) && encrot2 > -1
250
+  #if defined(encrot2) && encrot2 >= 0
267
     PIN_SAY(encrot2);
251
     PIN_SAY(encrot2);
268
   #endif
252
   #endif
269
-  #if defined(encrot3) && encrot3 > -1
253
+  #if defined(encrot3) && encrot3 >= 0
270
     PIN_SAY(encrot3);
254
     PIN_SAY(encrot3);
271
   #endif
255
   #endif
272
-  #if defined(EXT_AUX_A0_IO) && EXT_AUX_A0_IO > -1
256
+  #if defined(EXT_AUX_A0_IO) && EXT_AUX_A0_IO >= 0
273
     PIN_SAY(EXT_AUX_A0_IO);
257
     PIN_SAY(EXT_AUX_A0_IO);
274
   #endif
258
   #endif
275
-  #if defined(EXT_AUX_A1) && EXT_AUX_A1 > -1
259
+  #if defined(EXT_AUX_A1) && EXT_AUX_A1 >= 0
276
     PIN_SAY(EXT_AUX_A1);
260
     PIN_SAY(EXT_AUX_A1);
277
   #endif
261
   #endif
278
-  #if defined(EXT_AUX_A1_IO) && EXT_AUX_A1_IO > -1
262
+  #if defined(EXT_AUX_A1_IO) && EXT_AUX_A1_IO >= 0
279
     PIN_SAY(EXT_AUX_A1_IO);
263
     PIN_SAY(EXT_AUX_A1_IO);
280
   #endif
264
   #endif
281
-  #if defined(EXT_AUX_A2) && EXT_AUX_A2 > -1
265
+  #if defined(EXT_AUX_A2) && EXT_AUX_A2 >= 0
282
     PIN_SAY(EXT_AUX_A2);
266
     PIN_SAY(EXT_AUX_A2);
283
   #endif
267
   #endif
284
-  #if defined(EXT_AUX_A2_IO) && EXT_AUX_A2_IO > -1
268
+  #if defined(EXT_AUX_A2_IO) && EXT_AUX_A2_IO >= 0
285
     PIN_SAY(EXT_AUX_A2_IO);
269
     PIN_SAY(EXT_AUX_A2_IO);
286
   #endif
270
   #endif
287
-  #if defined(EXT_AUX_A3) && EXT_AUX_A3 > -1
271
+  #if defined(EXT_AUX_A3) && EXT_AUX_A3 >= 0
288
     PIN_SAY(EXT_AUX_A3);
272
     PIN_SAY(EXT_AUX_A3);
289
   #endif
273
   #endif
290
-  #if defined(EXT_AUX_A3_IO) && EXT_AUX_A3_IO > -1
274
+  #if defined(EXT_AUX_A3_IO) && EXT_AUX_A3_IO >= 0
291
     PIN_SAY(EXT_AUX_A3_IO);
275
     PIN_SAY(EXT_AUX_A3_IO);
292
   #endif
276
   #endif
293
-  #if defined(EXT_AUX_A4) && EXT_AUX_A4 > -1
277
+  #if defined(EXT_AUX_A4) && EXT_AUX_A4 >= 0
294
     PIN_SAY(EXT_AUX_A4);
278
     PIN_SAY(EXT_AUX_A4);
295
   #endif
279
   #endif
296
-  #if defined(EXT_AUX_A4_IO) && EXT_AUX_A4_IO > -1
280
+  #if defined(EXT_AUX_A4_IO) && EXT_AUX_A4_IO >= 0
297
     PIN_SAY(EXT_AUX_A4_IO);
281
     PIN_SAY(EXT_AUX_A4_IO);
298
   #endif
282
   #endif
299
-  #if defined(EXT_AUX_PWM_D24) && EXT_AUX_PWM_D24 > -1
283
+  #if defined(EXT_AUX_PWM_D24) && EXT_AUX_PWM_D24 >= 0
300
     PIN_SAY(EXT_AUX_PWM_D24);
284
     PIN_SAY(EXT_AUX_PWM_D24);
301
   #endif
285
   #endif
302
-  #if defined(EXT_AUX_RX1_D2) && EXT_AUX_RX1_D2 > -1
286
+  #if defined(EXT_AUX_RX1_D2) && EXT_AUX_RX1_D2 >= 0
303
     PIN_SAY(EXT_AUX_RX1_D2);
287
     PIN_SAY(EXT_AUX_RX1_D2);
304
   #endif
288
   #endif
305
-  #if defined(EXT_AUX_SDA_D1) && EXT_AUX_SDA_D1 > -1
289
+  #if defined(EXT_AUX_SDA_D1) && EXT_AUX_SDA_D1 >= 0
306
     PIN_SAY(EXT_AUX_SDA_D1);
290
     PIN_SAY(EXT_AUX_SDA_D1);
307
   #endif
291
   #endif
308
-  #if defined(EXT_AUX_TX1_D3) && EXT_AUX_TX1_D3 > -1
292
+  #if defined(EXT_AUX_TX1_D3) && EXT_AUX_TX1_D3 >= 0
309
     PIN_SAY(EXT_AUX_TX1_D3);
293
     PIN_SAY(EXT_AUX_TX1_D3);
310
   #endif
294
   #endif
311
 
295
 
327
   #if PIN_EXISTS(FILWIDTH)
311
   #if PIN_EXISTS(FILWIDTH)
328
     ANALOG_PIN_SAY(FILWIDTH_PIN);
312
     ANALOG_PIN_SAY(FILWIDTH_PIN);
329
   #endif
313
   #endif
330
-  #if defined(GEN7_VERSION) && GEN7_VERSION > -1
314
+  #if defined(GEN7_VERSION) && GEN7_VERSION >= 0
331
     PIN_SAY(GEN7_VERSION);
315
     PIN_SAY(GEN7_VERSION);
332
   #endif
316
   #endif
333
   #if PIN_EXISTS(HEATER_0)
317
   #if PIN_EXISTS(HEATER_0)
357
   #if PIN_EXISTS(HEATER_BED)
341
   #if PIN_EXISTS(HEATER_BED)
358
     PIN_SAY(HEATER_BED_PIN);
342
     PIN_SAY(HEATER_BED_PIN);
359
   #endif
343
   #endif
360
-  #if defined(I2C_SCL) && I2C_SCL > -1
344
+  #if defined(I2C_SCL) && I2C_SCL >= 0
361
     PIN_SAY(I2C_SCL);
345
     PIN_SAY(I2C_SCL);
362
   #endif
346
   #endif
363
-  #if defined(I2C_SDA) && I2C_SDA > -1
347
+  #if defined(I2C_SDA) && I2C_SDA >= 0
364
     PIN_SAY(I2C_SDA);
348
     PIN_SAY(I2C_SDA);
365
   #endif
349
   #endif
366
   #if PIN_EXISTS(KILL)
350
   #if PIN_EXISTS(KILL)
369
   #if PIN_EXISTS(LCD_BACKLIGHT)
353
   #if PIN_EXISTS(LCD_BACKLIGHT)
370
     PIN_SAY(LCD_BACKLIGHT_PIN);
354
     PIN_SAY(LCD_BACKLIGHT_PIN);
371
   #endif
355
   #endif
372
-  #if defined(LCD_CONTRAST) && LCD_CONTRAST > -1
356
+  #if defined(LCD_CONTRAST) && LCD_CONTRAST >= 0
373
     PIN_SAY(LCD_CONTRAST);
357
     PIN_SAY(LCD_CONTRAST);
374
   #endif
358
   #endif
375
-  #if defined(LCD_PINS_D4) && LCD_PINS_D4 > -1
359
+  #if defined(LCD_PINS_D4) && LCD_PINS_D4 >= 0
376
     PIN_SAY(LCD_PINS_D4);
360
     PIN_SAY(LCD_PINS_D4);
377
   #endif
361
   #endif
378
-  #if defined(LCD_PINS_D5) && LCD_PINS_D5 > -1
362
+  #if defined(LCD_PINS_D5) && LCD_PINS_D5 >= 0
379
     PIN_SAY(LCD_PINS_D5);
363
     PIN_SAY(LCD_PINS_D5);
380
   #endif
364
   #endif
381
-  #if defined(LCD_PINS_D6) && LCD_PINS_D6 > -1
365
+  #if defined(LCD_PINS_D6) && LCD_PINS_D6 >= 0
382
     PIN_SAY(LCD_PINS_D6);
366
     PIN_SAY(LCD_PINS_D6);
383
   #endif
367
   #endif
384
-  #if defined(LCD_PINS_D7) && LCD_PINS_D7 > -1
368
+  #if defined(LCD_PINS_D7) && LCD_PINS_D7 >= 0
385
     PIN_SAY(LCD_PINS_D7);
369
     PIN_SAY(LCD_PINS_D7);
386
   #endif
370
   #endif
387
-  #if defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE > -1
371
+  #if defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE >= 0
388
     PIN_SAY(LCD_PINS_ENABLE);
372
     PIN_SAY(LCD_PINS_ENABLE);
389
   #endif
373
   #endif
390
-  #if defined(LCD_PINS_RS) && LCD_PINS_RS > -1
374
+  #if defined(LCD_PINS_RS) && LCD_PINS_RS >= 0
391
     PIN_SAY(LCD_PINS_RS);
375
     PIN_SAY(LCD_PINS_RS);
392
   #endif
376
   #endif
393
-  #if defined(LCD_SDSS) && LCD_SDSS > -1
377
+  #if defined(LCD_SDSS) && LCD_SDSS >= 0
394
     PIN_SAY(LCD_SDSS);
378
     PIN_SAY(LCD_SDSS);
395
   #endif
379
   #endif
396
   #if PIN_EXISTS(LED)
380
   #if PIN_EXISTS(LED)
399
   #if PIN_EXISTS(MAIN_VOLTAGE_MEASURE)
383
   #if PIN_EXISTS(MAIN_VOLTAGE_MEASURE)
400
     PIN_SAY(MAIN_VOLTAGE_MEASURE_PIN);
384
     PIN_SAY(MAIN_VOLTAGE_MEASURE_PIN);
401
   #endif
385
   #endif
402
-  #if defined(MAX6675_SS) && MAX6675_SS > -1
386
+  #if defined(MAX6675_SS) && MAX6675_SS >= 0
403
     PIN_SAY(MAX6675_SS);
387
     PIN_SAY(MAX6675_SS);
404
   #endif
388
   #endif
405
   #if PIN_EXISTS(MISO)
389
   #if PIN_EXISTS(MISO)
420
   #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
404
   #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
421
     PIN_SAY(MOTOR_CURRENT_PWM_Z_PIN);
405
     PIN_SAY(MOTOR_CURRENT_PWM_Z_PIN);
422
   #endif
406
   #endif
423
-  #if defined(NUM_TLCS) && NUM_TLCS > -1
407
+  #if defined(NUM_TLCS) && NUM_TLCS >= 0
424
     PIN_SAY(NUM_TLCS);
408
     PIN_SAY(NUM_TLCS);
425
   #endif
409
   #endif
426
   #if PIN_EXISTS(PHOTOGRAPH)
410
   #if PIN_EXISTS(PHOTOGRAPH)
447
   #if PIN_EXISTS(SCK)
431
   #if PIN_EXISTS(SCK)
448
     PIN_SAY(SCK_PIN);
432
     PIN_SAY(SCK_PIN);
449
   #endif
433
   #endif
450
-  #if defined(SCL) && SCL > -1
434
+  #if defined(SCL) && SCL >= 0
451
     PIN_SAY(SCL);
435
     PIN_SAY(SCL);
452
   #endif
436
   #endif
453
   #if PIN_EXISTS(SD_DETECT)
437
   #if PIN_EXISTS(SD_DETECT)
454
     PIN_SAY(SD_DETECT_PIN);
438
     PIN_SAY(SD_DETECT_PIN);
455
   #endif
439
   #endif
456
-  #if defined(SDA) && SDA > -1
440
+  #if defined(SDA) && SDA >= 0
457
     PIN_SAY(SDA);
441
     PIN_SAY(SDA);
458
   #endif
442
   #endif
459
-  #if defined(SDPOWER) && SDPOWER > -1
443
+  #if defined(SDPOWER) && SDPOWER >= 0
460
     PIN_SAY(SDPOWER);
444
     PIN_SAY(SDPOWER);
461
   #endif
445
   #endif
462
-  #if defined(SDSS) && SDSS > -1
446
+  #if defined(SDSS) && SDSS >= 0
463
     PIN_SAY(SDSS);
447
     PIN_SAY(SDSS);
464
   #endif
448
   #endif
465
   #if PIN_EXISTS(SERVO0)
449
   #if PIN_EXISTS(SERVO0)
474
   #if PIN_EXISTS(SERVO3)
458
   #if PIN_EXISTS(SERVO3)
475
     PIN_SAY(SERVO3_PIN);
459
     PIN_SAY(SERVO3_PIN);
476
   #endif
460
   #endif
477
-  #if defined(SHIFT_CLK) && SHIFT_CLK > -1
461
+  #if defined(SHIFT_CLK) && SHIFT_CLK >= 0
478
     PIN_SAY(SHIFT_CLK);
462
     PIN_SAY(SHIFT_CLK);
479
   #endif
463
   #endif
480
-  #if defined(SHIFT_EN) && SHIFT_EN > -1
464
+  #if defined(SHIFT_EN) && SHIFT_EN >= 0
481
     PIN_SAY(SHIFT_EN);
465
     PIN_SAY(SHIFT_EN);
482
   #endif
466
   #endif
483
-  #if defined(SHIFT_LD) && SHIFT_LD > -1
467
+  #if defined(SHIFT_LD) && SHIFT_LD >= 0
484
     PIN_SAY(SHIFT_LD);
468
     PIN_SAY(SHIFT_LD);
485
   #endif
469
   #endif
486
-  #if defined(SHIFT_OUT) && SHIFT_OUT > -1
470
+  #if defined(SHIFT_OUT) && SHIFT_OUT >= 0
487
     PIN_SAY(SHIFT_OUT);
471
     PIN_SAY(SHIFT_OUT);
488
   #endif
472
   #endif
489
   #if PIN_EXISTS(SLED)
473
   #if PIN_EXISTS(SLED)
519
   #if PIN_EXISTS(SUICIDE)
503
   #if PIN_EXISTS(SUICIDE)
520
     PIN_SAY(SUICIDE_PIN);
504
     PIN_SAY(SUICIDE_PIN);
521
   #endif
505
   #endif
522
-  #if defined(TC1) && TC1 > -1
506
+  #if defined(TC1) && TC1 >= 0
523
     ANALOG_PIN_SAY(TC1);
507
     ANALOG_PIN_SAY(TC1);
524
   #endif
508
   #endif
525
-  #if defined(TC2) && TC2 > -1
509
+  #if defined(TC2) && TC2 >= 0
526
     ANALOG_PIN_SAY(TC2);
510
     ANALOG_PIN_SAY(TC2);
527
   #endif
511
   #endif
528
   #if PIN_EXISTS(TEMP_0)
512
   #if PIN_EXISTS(TEMP_0)
546
   #if PIN_EXISTS(TEMP_X)
530
   #if PIN_EXISTS(TEMP_X)
547
     ANALOG_PIN_SAY(TEMP_X_PIN);
531
     ANALOG_PIN_SAY(TEMP_X_PIN);
548
   #endif
532
   #endif
549
-  #if defined(TLC_BLANK_BIT) && TLC_BLANK_BIT > -1
533
+  #if defined(TLC_BLANK_BIT) && TLC_BLANK_BIT >= 0
550
     PIN_SAY(TLC_BLANK_BIT);
534
     PIN_SAY(TLC_BLANK_BIT);
551
   #endif
535
   #endif
552
   #if PIN_EXISTS(TLC_BLANK)
536
   #if PIN_EXISTS(TLC_BLANK)
553
     PIN_SAY(TLC_BLANK_PIN);
537
     PIN_SAY(TLC_BLANK_PIN);
554
   #endif
538
   #endif
555
-  #if defined(TLC_CLOCK_BIT) && TLC_CLOCK_BIT > -1
539
+  #if defined(TLC_CLOCK_BIT) && TLC_CLOCK_BIT >= 0
556
     PIN_SAY(TLC_CLOCK_BIT);
540
     PIN_SAY(TLC_CLOCK_BIT);
557
   #endif
541
   #endif
558
   #if PIN_EXISTS(TLC_CLOCK)
542
   #if PIN_EXISTS(TLC_CLOCK)
559
     PIN_SAY(TLC_CLOCK_PIN);
543
     PIN_SAY(TLC_CLOCK_PIN);
560
   #endif
544
   #endif
561
-  #if defined(TLC_DATA_BIT) && TLC_DATA_BIT > -1
545
+  #if defined(TLC_DATA_BIT) && TLC_DATA_BIT >= 0
562
     PIN_SAY(TLC_DATA_BIT);
546
     PIN_SAY(TLC_DATA_BIT);
563
   #endif
547
   #endif
564
   #if PIN_EXISTS(TLC_DATA)
548
   #if PIN_EXISTS(TLC_DATA)
570
   #if PIN_EXISTS(TX_ENABLE)
554
   #if PIN_EXISTS(TX_ENABLE)
571
     PIN_SAY(TX_ENABLE_PIN);
555
     PIN_SAY(TX_ENABLE_PIN);
572
   #endif
556
   #endif
573
-  #if defined(UNUSED_PWM) && UNUSED_PWM > -1
557
+  #if defined(UNUSED_PWM) && UNUSED_PWM >= 0
574
     PIN_SAY(UNUSED_PWM);
558
     PIN_SAY(UNUSED_PWM);
575
   #endif
559
   #endif
576
   #if PIN_EXISTS(X_ATT)
560
   #if PIN_EXISTS(X_ATT)
687
 
671
 
688
   sprintf(buffer, NAME_FORMAT, "<unused> ");
672
   sprintf(buffer, NAME_FORMAT, "<unused> ");
689
   SERIAL_ECHO(buffer);
673
   SERIAL_ECHO(buffer);
690
-  
674
+
691
   return false;
675
   return false;
692
-}  //  report_pin_name
676
+} // report_pin_name
693
 
677
 
694
 //  True - currently a PWM pin
678
 //  True - currently a PWM pin
695
 static bool PWM_status(uint8_t pin) {
679
 static bool PWM_status(uint8_t pin) {
696
   char buffer[20];   // for the sprintf statements
680
   char buffer[20];   // for the sprintf statements
697
-  
681
+
698
   switch(digitalPinToTimer(pin)) {
682
   switch(digitalPinToTimer(pin)) {
699
 
683
 
700
     #if defined(TCCR0A) && defined(COM0A1)
684
     #if defined(TCCR0A) && defined(COM0A1)
789
         break;
773
         break;
790
     #endif
774
     #endif
791
 
775
 
792
-    #if defined(TCCR4A)
776
+    #ifdef TCCR4A
793
       case TIMER4A:
777
       case TIMER4A:
794
         if (TCCR4A & (_BV(COM4A1) | _BV(COM4A0))){
778
         if (TCCR4A & (_BV(COM4A1) | _BV(COM4A0))){
795
           sprintf(buffer, "PWM:  %4d",OCR4A); 
779
           sprintf(buffer, "PWM:  %4d",OCR4A); 
815
         else return false;
799
         else return false;
816
         break;
800
         break;
817
     #endif
801
     #endif
818
-          
802
+
819
     #if defined(TCCR5A) && defined(COM5A1)
803
     #if defined(TCCR5A) && defined(COM5A1)
820
       case TIMER5A:
804
       case TIMER5A:
821
         if (TCCR5A & (_BV(COM5A1) | _BV(COM5A0))){
805
         if (TCCR5A & (_BV(COM5A1) | _BV(COM5A0))){
1044
 	case NOT_ON_TIMER:
1028
 	case NOT_ON_TIMER:
1045
     break;
1029
     break;
1046
 	}
1030
 	}
1047
-  SERIAL_PROTOCOLPGM("  ");   
1031
+  SERIAL_PROTOCOLPGM("  ");
1048
 }  // PWM_details
1032
 }  // PWM_details
1049
 
1033
 
1050
 
1034
 
1070
   SERIAL_EOL;
1054
   SERIAL_EOL;
1071
 }
1055
 }
1072
 
1056
 
1057
+bool get_pinMode(int8_t pin) { return *portModeRegister(digitalPinToPort(pin)) & digitalPinToBitMask(pin); }
1058
+
1073
 // pretty report with PWM info
1059
 // pretty report with PWM info
1074
 inline void report_pin_state_extended(int8_t pin, bool ignore) {
1060
 inline void report_pin_state_extended(int8_t pin, bool ignore) {
1075
 
1061
 
1076
   char buffer[30];   // for the sprintf statements
1062
   char buffer[30];   // for the sprintf statements
1077
-    
1078
- // report pin number 
1063
+
1064
+  // report pin number
1079
   sprintf(buffer, "PIN:% 3d ", pin);
1065
   sprintf(buffer, "PIN:% 3d ", pin);
1080
-  SERIAL_ECHO(buffer);   
1066
+  SERIAL_ECHO(buffer);
1081
 
1067
 
1082
- // report pin name 
1068
+  // report pin name
1083
   bool analog_pin;
1069
   bool analog_pin;
1084
-  report_pin_name(pin, analog_pin); 
1085
-  
1086
-// report pin state
1087
-  if (pin_is_protected(pin) && ignore == false) 
1070
+  report_pin_name(pin, analog_pin);
1071
+
1072
+  // report pin state
1073
+  if (pin_is_protected(pin) && !ignore)
1088
     SERIAL_ECHOPGM("protected ");
1074
     SERIAL_ECHOPGM("protected ");
1089
   else {
1075
   else {
1090
     if (analog_pin) {
1076
     if (analog_pin) {
1091
-        sprintf(buffer, "Analog in =% 5d", analogRead(pin - analogInputToDigitalPin(0)));
1092
-        SERIAL_ECHO(buffer); 
1093
-       }
1077
+      sprintf(buffer, "Analog in =% 5d", analogRead(pin - analogInputToDigitalPin(0)));
1078
+      SERIAL_ECHO(buffer);
1079
+    }
1094
     else {
1080
     else {
1095
       if (!get_pinMode(pin)) {
1081
       if (!get_pinMode(pin)) {
1096
         pinMode(pin, INPUT_PULLUP);  // make sure input isn't floating
1082
         pinMode(pin, INPUT_PULLUP);  // make sure input isn't floating
1097
         SERIAL_PROTOCOLPAIR("Input  = ", digitalRead_mod(pin));
1083
         SERIAL_PROTOCOLPAIR("Input  = ", digitalRead_mod(pin));
1098
-      }  
1099
-      else if  (PWM_status(pin)) ;
1100
-      else SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));  
1084
+      }
1085
+      else if (PWM_status(pin)) {
1086
+        // do nothing
1087
+      }
1088
+      else SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));
1101
     }
1089
     }
1102
   }
1090
   }
1103
 
1091
 
1104
-// report PWM capabilities
1092
+  // report PWM capabilities
1105
   PWM_details(pin);
1093
   PWM_details(pin);
1106
   SERIAL_EOL;
1094
   SERIAL_EOL;
1107
 }
1095
 }

Loading…
Cancel
Save