|
|
|
@ -207,17 +207,32 @@ static void print_input_or_output(const bool isout) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// pretty report with PWM info
|
|
|
|
|
inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = false, const char *start_string = "") {
|
|
|
|
|
inline void report_pin_state_extended(const pin_t pin, const bool ignore, const bool extended=false, PGM_P const start_string=nullptr) {
|
|
|
|
|
char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements
|
|
|
|
|
bool found = false, multi_name_pin = false;
|
|
|
|
|
|
|
|
|
|
auto alt_pin_echo = [](const pin_t &pin) {
|
|
|
|
|
#if AVR_AT90USB1286_FAMILY
|
|
|
|
|
// Use FastIO for pins Teensy doesn't expose
|
|
|
|
|
if (pin == 46) {
|
|
|
|
|
print_input_or_output(IS_OUTPUT(46));
|
|
|
|
|
SERIAL_CHAR('0' + READ(46));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if (pin == 47) {
|
|
|
|
|
print_input_or_output(IS_OUTPUT(47));
|
|
|
|
|
SERIAL_CHAR('0' + READ(47));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (uint8_t x = 0; x < COUNT(pin_array); x++) { // scan entire array and report all instances of this pin
|
|
|
|
|
if (GET_ARRAY_PIN(x) == pin) {
|
|
|
|
|
if (found) multi_name_pin = true;
|
|
|
|
|
found = true;
|
|
|
|
|
if (!multi_name_pin) { // report digital and analog pin number only on the first time through
|
|
|
|
|
sprintf_P(buffer, PSTR("%sPIN: "), start_string); // digital pin number
|
|
|
|
|
SERIAL_ECHO(buffer);
|
|
|
|
|
if (!found) { // report digital and analog pin number only on the first time through
|
|
|
|
|
if (start_string) serialprintPGM(start_string);
|
|
|
|
|
serialprintPGM(PSTR("PIN: "));
|
|
|
|
|
PRINT_PIN(pin);
|
|
|
|
|
PRINT_PORT(pin);
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
SERIAL_CHAR('.');
|
|
|
|
|
SERIAL_ECHO_SP(MULTI_NAME_PAD + strlen(start_string)); // add padding if not the first instance found
|
|
|
|
|
SERIAL_ECHO_SP(MULTI_NAME_PAD + (start_string ? strlen_P(start_string) : 0)); // add padding if not the first instance found
|
|
|
|
|
}
|
|
|
|
|
PRINT_ARRAY_NAME(x);
|
|
|
|
|
if (extended) {
|
|
|
|
|
if (pin_is_protected(pin) && !ignore)
|
|
|
|
|
SERIAL_ECHOPGM("protected ");
|
|
|
|
|
else {
|
|
|
|
|
#if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
|
|
|
|
|
if (pin == 46 || pin == 47) {
|
|
|
|
|
if (pin == 46) {
|
|
|
|
|
print_input_or_output(IS_OUTPUT(46));
|
|
|
|
|
SERIAL_CHAR('0' + READ(46));
|
|
|
|
|
}
|
|
|
|
|
else if (pin == 47) {
|
|
|
|
|
print_input_or_output(IS_OUTPUT(47));
|
|
|
|
|
SERIAL_CHAR('0' + READ(47));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
if (alt_pin_echo(pin)) {
|
|
|
|
|
if (!GET_ARRAY_IS_DIGITAL(x)) {
|
|
|
|
|
sprintf_P(buffer, PSTR("Analog in = %5ld"), (long)analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)));
|
|
|
|
|
SERIAL_ECHO(buffer);
|
|
|
|
@ -274,12 +276,14 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
multi_name_pin = found;
|
|
|
|
|
found = true;
|
|
|
|
|
} // end of IF
|
|
|
|
|
} // end of for loop
|
|
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
|
sprintf_P(buffer, PSTR("%sPIN: "), start_string);
|
|
|
|
|
SERIAL_ECHO(buffer);
|
|
|
|
|
if (start_string) serialprintPGM(start_string);
|
|
|
|
|
serialprintPGM(PSTR("PIN: "));
|
|
|
|
|
PRINT_PIN(pin);
|
|
|
|
|
PRINT_PORT(pin);
|
|
|
|
|
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
|
|
|
|
|
SERIAL_ECHO_SP(8); // add padding if not an analog pin
|
|
|
|
|
SERIAL_ECHOPGM("<unused/unknown>");
|
|
|
|
|
if (extended) {
|
|
|
|
|
#if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
|
|
|
|
|
if (pin == 46 || pin == 47) {
|
|
|
|
|
SERIAL_ECHO_SP(12);
|
|
|
|
|
if (pin == 46) {
|
|
|
|
|
print_input_or_output(IS_OUTPUT(46));
|
|
|
|
|
SERIAL_CHAR('0' + READ(46));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
print_input_or_output(IS_OUTPUT(47));
|
|
|
|
|
SERIAL_CHAR('0' + READ(47));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (alt_pin_echo(pin)) {
|
|
|
|
|
if (pwm_status(pin)) {
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|