|
@@ -207,17 +207,32 @@ static void print_input_or_output(const bool isout) {
|
207
|
207
|
}
|
208
|
208
|
|
209
|
209
|
// pretty report with PWM info
|
210
|
|
-inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = false, const char *start_string = "") {
|
|
210
|
+inline void report_pin_state_extended(const pin_t pin, const bool ignore, const bool extended=false, PGM_P const start_string=nullptr) {
|
211
|
211
|
char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements
|
212
|
212
|
bool found = false, multi_name_pin = false;
|
213
|
213
|
|
|
214
|
+ auto alt_pin_echo = [](const pin_t &pin) {
|
|
215
|
+ #if AVR_AT90USB1286_FAMILY
|
|
216
|
+ // Use FastIO for pins Teensy doesn't expose
|
|
217
|
+ if (pin == 46) {
|
|
218
|
+ print_input_or_output(IS_OUTPUT(46));
|
|
219
|
+ SERIAL_CHAR('0' + READ(46));
|
|
220
|
+ return false;
|
|
221
|
+ }
|
|
222
|
+ else if (pin == 47) {
|
|
223
|
+ print_input_or_output(IS_OUTPUT(47));
|
|
224
|
+ SERIAL_CHAR('0' + READ(47));
|
|
225
|
+ return false;
|
|
226
|
+ }
|
|
227
|
+ #endif
|
|
228
|
+ return true;
|
|
229
|
+ };
|
|
230
|
+
|
214
|
231
|
for (uint8_t x = 0; x < COUNT(pin_array); x++) { // scan entire array and report all instances of this pin
|
215
|
232
|
if (GET_ARRAY_PIN(x) == pin) {
|
216
|
|
- if (found) multi_name_pin = true;
|
217
|
|
- found = true;
|
218
|
|
- if (!multi_name_pin) { // report digital and analog pin number only on the first time through
|
219
|
|
- sprintf_P(buffer, PSTR("%sPIN: "), start_string); // digital pin number
|
220
|
|
- SERIAL_ECHO(buffer);
|
|
233
|
+ if (!found) { // report digital and analog pin number only on the first time through
|
|
234
|
+ if (start_string) serialprintPGM(start_string);
|
|
235
|
+ serialprintPGM(PSTR("PIN: "));
|
221
|
236
|
PRINT_PIN(pin);
|
222
|
237
|
PRINT_PORT(pin);
|
223
|
238
|
if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
|
|
@@ -228,27 +243,14 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
|
228
|
243
|
}
|
229
|
244
|
else {
|
230
|
245
|
SERIAL_CHAR('.');
|
231
|
|
- SERIAL_ECHO_SP(MULTI_NAME_PAD + strlen(start_string)); // add padding if not the first instance found
|
|
246
|
+ SERIAL_ECHO_SP(MULTI_NAME_PAD + (start_string ? strlen_P(start_string) : 0)); // add padding if not the first instance found
|
232
|
247
|
}
|
233
|
248
|
PRINT_ARRAY_NAME(x);
|
234
|
249
|
if (extended) {
|
235
|
250
|
if (pin_is_protected(pin) && !ignore)
|
236
|
251
|
SERIAL_ECHOPGM("protected ");
|
237
|
252
|
else {
|
238
|
|
- #if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
|
239
|
|
- if (pin == 46 || pin == 47) {
|
240
|
|
- if (pin == 46) {
|
241
|
|
- print_input_or_output(IS_OUTPUT(46));
|
242
|
|
- SERIAL_CHAR('0' + READ(46));
|
243
|
|
- }
|
244
|
|
- else if (pin == 47) {
|
245
|
|
- print_input_or_output(IS_OUTPUT(47));
|
246
|
|
- SERIAL_CHAR('0' + READ(47));
|
247
|
|
- }
|
248
|
|
- }
|
249
|
|
- else
|
250
|
|
- #endif
|
251
|
|
- {
|
|
253
|
+ if (alt_pin_echo(pin)) {
|
252
|
254
|
if (!GET_ARRAY_IS_DIGITAL(x)) {
|
253
|
255
|
sprintf_P(buffer, PSTR("Analog in = %5ld"), (long)analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)));
|
254
|
256
|
SERIAL_ECHO(buffer);
|
|
@@ -274,12 +276,14 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
|
274
|
276
|
}
|
275
|
277
|
}
|
276
|
278
|
SERIAL_EOL();
|
|
279
|
+ multi_name_pin = found;
|
|
280
|
+ found = true;
|
277
|
281
|
} // end of IF
|
278
|
282
|
} // end of for loop
|
279
|
283
|
|
280
|
284
|
if (!found) {
|
281
|
|
- sprintf_P(buffer, PSTR("%sPIN: "), start_string);
|
282
|
|
- SERIAL_ECHO(buffer);
|
|
285
|
+ if (start_string) serialprintPGM(start_string);
|
|
286
|
+ serialprintPGM(PSTR("PIN: "));
|
283
|
287
|
PRINT_PIN(pin);
|
284
|
288
|
PRINT_PORT(pin);
|
285
|
289
|
if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
|
|
@@ -290,21 +294,8 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
|
290
|
294
|
SERIAL_ECHO_SP(8); // add padding if not an analog pin
|
291
|
295
|
SERIAL_ECHOPGM("<unused/unknown>");
|
292
|
296
|
if (extended) {
|
293
|
|
- #if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
|
294
|
|
- if (pin == 46 || pin == 47) {
|
295
|
|
- SERIAL_ECHO_SP(12);
|
296
|
|
- if (pin == 46) {
|
297
|
|
- print_input_or_output(IS_OUTPUT(46));
|
298
|
|
- SERIAL_CHAR('0' + READ(46));
|
299
|
|
- }
|
300
|
|
- else {
|
301
|
|
- print_input_or_output(IS_OUTPUT(47));
|
302
|
|
- SERIAL_CHAR('0' + READ(47));
|
303
|
|
- }
|
304
|
|
- }
|
305
|
|
- else
|
306
|
|
- #endif
|
307
|
|
- {
|
|
297
|
+
|
|
298
|
+ if (alt_pin_echo(pin)) {
|
308
|
299
|
if (pwm_status(pin)) {
|
309
|
300
|
// do nothing
|
310
|
301
|
}
|