diff --git a/examples/PinScan/src/digital.cpp b/examples/PinScan/src/digital.cpp index 1b01b85..4a3d022 100644 --- a/examples/PinScan/src/digital.cpp +++ b/examples/PinScan/src/digital.cpp @@ -56,17 +56,22 @@ static void irqHandler(void *ptr) { } static void digitalAllIrq() { +#if USE_WIFI + LT_I("Disabling logger"); + lt_log_disable(); + Serial.end(); +#endif for (pin_size_t i = 0; i < NUM_DIGITAL_PINS; i++) { if (pinSkip[0] == i || pinSkip[1] == i) { used[i] = false; continue; } pinMode(i, INPUT); - // choose interrupt level according to current state - PinStatus status = digitalRead(i) ? FALLING : RISING; - attachInterruptParam(i, irqHandler, status, pins + i); - used[i] = true; pins[i] = digitalRead(i); + used[i] = true; + // choose interrupt level according to current state + PinStatus status = pins[i] ? FALLING : RISING; + attachInterruptParam(i, irqHandler, status, pins + i); } active = true; } @@ -112,6 +117,11 @@ void digitalDetach() { } active = false; pin = -1; +#if USE_WIFI + lt_log_set_port(LT_UART_DEFAULT_LOGGER); + Serial.begin(115200); + LT_I("Logger enabled"); +#endif } void runDigital() { diff --git a/examples/PinScan/src/help.cpp b/examples/PinScan/src/help.cpp index 7d301e2..4c99bf9 100644 --- a/examples/PinScan/src/help.cpp +++ b/examples/PinScan/src/help.cpp @@ -32,7 +32,9 @@ void printHelp(uint8_t mode) { TAB "d - Check digital pins" EOL TAB "a - Check analog pins" EOL // TAB "p - Check PWM outputs" EOL +#if !USE_WIFI TAB "s - Select UART port" EOL +#endif TAB "t - Toggle ANSI control codes" EOL TAB "r - Reboot (for uploading)" EOL TAB "q - Go back to menu, at any time" EOL diff --git a/examples/PinScan/src/main.cpp b/examples/PinScan/src/main.cpp index cb7d503..cb2ae6a 100644 --- a/examples/PinScan/src/main.cpp +++ b/examples/PinScan/src/main.cpp @@ -11,10 +11,10 @@ static WiFiServer server(23); static WiFiClient client; #endif -Stream *stream = NULL; -uint8_t mode[] = {'q', '\0', '\0', '\0'}; -pin_size_t pinSkip[2]; -int output = -1; +Stream *stream = NULL; +uint8_t mode[] = {'?', '\0', '\0', '\0'}; +pin_size_t pinSkip[2] = {255, 255}; +int output = -1; static void parseMode(); @@ -54,7 +54,6 @@ void loop() { } if (!stream) { client = server.accept(); - delay(500); if (client) { stream = &client; printHelp(); @@ -105,7 +104,8 @@ void loop() { } } - parseMode(); + if (stream) + parseMode(); } static void parseMode() {