From c2c35978b946406529cefa573915ec9496415ca2 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Thu, 12 Nov 2026 16:32:29 +0100 Subject: [PATCH] ui off: an unplugged USB cable gives the UI back, also in an output mode (Ultra) On the bench unplugging the generator left the UI off until the jog was pressed. The USB state check was right (an ST-Link monitor showed USB_SUSPENDED for the whole unplug), but an output mode repeats its sweep until an operation is requested, so the sweep loop never got to the check. The USB suspend event now requests one (OP_CONSOLE) while the UI is off. --- main.c | 4 +++- usbcfg.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 0767e9c..6a725bc 100644 --- a/main.c +++ b/main.c @@ -337,7 +337,9 @@ static THD_FUNCTION(Thread1, arg) } #endif #ifdef __UI_OFF__ - if (ui_off && !shell_check_connect()) { // an unplugged tinySA must not stay blind + // An unplugged tinySA must not stay blind. The USB suspend also stops the endless sweep of + // an output mode (usbcfg.c), else this would only run after the next touch or command. + if (ui_off && !shell_check_connect()) { set_ui(true); ui_on_notice = false; // no PC to tell } diff --git a/usbcfg.c b/usbcfg.c index 7333816..b5f4387 100644 --- a/usbcfg.c +++ b/usbcfg.c @@ -422,6 +422,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { /* Disconnection event on suspend.*/ sduDisconnectI(&SDU1); +#ifdef __UI_OFF__ + /* ui off: the sweep loop gives the UI back without the PC, but an output mode + keeps sweeping until an operation is requested.*/ + if (ui_off) + operation_requested |= OP_CONSOLE; +#endif chSysUnlockFromISR(); return;