|
@@ -102,17 +102,18 @@ const XrefInfo pin_xref[] PROGMEM = {
|
102
|
102
|
#define PIN_NUM_ALPHA_LEFT(P) (((P & 0x000F) < 10) ? ('0' + (P & 0x000F)) : '1')
|
103
|
103
|
#define PIN_NUM_ALPHA_RIGHT(P) (((P & 0x000F) > 9) ? ('0' + (P & 0x000F) - 10) : 0 )
|
104
|
104
|
#define PORT_NUM(P) ((P >> 4) & 0x0007)
|
105
|
|
-#define PORT_ALPHA(P) ('A' + (P >> 4))
|
|
105
|
+#define PORT_ALPHA(P) ('A' + (P >> 4))
|
106
|
106
|
|
107
|
107
|
/**
|
108
|
108
|
* Translation of routines & variables used by pinsDebug.h
|
109
|
109
|
*/
|
110
|
110
|
|
111
|
|
-#if PA0 >= NUM_DIGITAL_PINS
|
|
111
|
+#if NUM_ANALOG_FIRST >= NUM_DIGITAL_PINS
|
112
|
112
|
#define HAS_HIGH_ANALOG_PINS 1
|
113
|
113
|
#endif
|
114
|
|
-#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS)
|
115
|
|
-#define VALID_PIN(ANUM) ((ANUM) >= 0 && (ANUM) < NUMBER_PINS_TOTAL)
|
|
114
|
+#define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1)
|
|
115
|
+#define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS))
|
|
116
|
+#define VALID_PIN(P) (WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1) || TERN0(HAS_HIGH_ANALOG_PINS, WITHIN(P, NUM_ANALOG_FIRST, NUM_ANALOG_LAST)))
|
116
|
117
|
#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads
|
117
|
118
|
#define PRINT_PIN(Q)
|
118
|
119
|
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
|
@@ -168,7 +169,7 @@ bool GET_PINMODE(const pin_t Ard_num) {
|
168
|
169
|
}
|
169
|
170
|
|
170
|
171
|
int8_t digital_pin_to_analog_pin(const pin_t Ard_num) {
|
171
|
|
- if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_FIRST + NUM_ANALOG_INPUTS - 1))
|
|
172
|
+ if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))
|
172
|
173
|
return Ard_num - NUM_ANALOG_FIRST;
|
173
|
174
|
|
174
|
175
|
const uint32_t ind = digitalPinToAnalogInput(Ard_num);
|
|
@@ -206,8 +207,11 @@ void port_print(const pin_t Ard_num) {
|
206
|
207
|
SERIAL_ECHO_SP(7);
|
207
|
208
|
|
208
|
209
|
// Print number to be used with M42
|
209
|
|
- int calc_p = Ard_num % (NUM_DIGITAL_PINS + 1);
|
210
|
|
- if (Ard_num > NUM_DIGITAL_PINS && calc_p > 7) calc_p += 8;
|
|
210
|
+ int calc_p = Ard_num;
|
|
211
|
+ if (Ard_num > NUM_DIGITAL_PINS) {
|
|
212
|
+ calc_p -= NUM_ANALOG_FIRST;
|
|
213
|
+ if (calc_p > 7) calc_p += 8;
|
|
214
|
+ }
|
211
|
215
|
SERIAL_ECHOPGM(" M42 P", calc_p);
|
212
|
216
|
SERIAL_CHAR(' ');
|
213
|
217
|
if (calc_p < 100) {
|