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