Show a progress bar while the update command runs - #287
Conversation
…ommands The update, switch-to-stock and shutdown-host handlers ran their command synchronously on the LVGL thread from inside the click dispatch and only created the "Initiated" dialog after the command returned. Commands that end in a reboot never return, so the screen showed nothing at all until the printer restarted, not even the button's pressed state. Factory reset already avoids this by creating the dialog first and deferring the command to a one-shot lv_timer. Generalise that into run_command_deferred() and use it for all four commands. Factory reset keeps its 5 s delay; the others wait 500 ms, enough for LVGL to render the dialog before the command blocks the thread. Failure handling is unchanged: a non-zero exit replaces the dialog with the "Failed" one. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
So Update is basically only for COSMOS now, the Simple AF project never used Update, and I have stopped supporting helper script. So really the question becomes, will the cosmos project actually use this? Are they going to change their update script to publish progress, cos if they are not, this seems pointless. If they are committing to it, then I am all for this. |
| #include "logger.h" | ||
| #include "subprocess.hpp" | ||
| #include "simple_dialog.h" | ||
| #include "update_progress.h" |
There was a problem hiding this comment.
I think this should be guarded with UPDATE_BUTTON_STATUS_FILE too.
|
Let me be really blunt, if Cosmos commit to the update status file, then there is no point in making this optional, where the UPDATE button is enabled in the Makefile, its expected that an update will proceed this way with progress, no need to add more options. If they are not going to do the update status file then I wont merge this, I will merge your other PR though as that is good for everyone :-) |
When the update button is enabled (UPDATE_CMD) the update command is now spawned detached with sp::Popen instead of blocking the UI thread, and the dialog shows a bar fed by the "<state>|<percent>" line the command publishes to UPDATE_STATUS_FILE (default /run/cosmos-update.status): downloading, flashing, rebooting, failed. The file is polled every 500 ms from an lv_timer; the command's exit status stays authoritative, so exiting before it reports "rebooting" shows the "Failed" dialog. The dialog uses the multiline_message variant because the default no-button dialog on a 272 px high screen is 95 px tall and clips the bar. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
b76e932 to
4bd84fe
Compare
|
Makes sense. I've reworked it so there's no separate switch: when UPDATE_CMD is set the update always goes through the progress dialog, and the status file path is just a Makefile default ( |
|
Closing in favour of #289: instead of parsing update-cosmos output on the screen, grumpyscreen now shows Moonraker's update_manager messages, following the cosmos discussion in OpenCentauri/cosmos#308. |
Builds on #286.
What
When the update button is enabled (
UPDATE_CMD), pressing it now spawns the update command detached withsp::Popeninstead of blocking the UI thread, and shows a dialog with anlv_barfed by a status file the command writes: a single<state>|<percent>line, with state one ofdownloading,flashing,rebooting,failed. The dialog polls the file every 500 ms from anlv_timer. The command's exit status stays authoritative: if it exits before reportingrebooting, the "Failed" dialog is shown, same as today.The file path defaults to
/run/cosmos-update.status(UPDATE_STATUS_FILEin the Makefile, right next toUPDATE_CMD; nothing needs to set it). Builds withoutUPDATE_CMDare untouched: the include and the header are guarded and compile to nothing.Notes on the implementation:
src/update_progress.h), following thesimple_dialog.hpattern in the tree.multiline_messagevariant ofcreate_configurable_dialog(). The default no-button dialog on a 272 px high screen is 95 px tall and the bar would be clipped; the taller variant leaves about 30 px spare.call_command()runs it (split on whitespace, executed directly), just without waiting.The producer side for COSMOS is OpenCentauri/cosmos#308.
Tested
GUPPY_SMALL_SCREEN) on COSMOS 26.08.0 with the cosmos script change: the dialog appears immediately, percentage and bar track the real 124 MB download, "Installing update, do not power off!" during the flash, then "Your printer will restart shortly!" until the reboot.UPDATE_CMD(COSMOS's variables) and without it (default configuration), both without warnings.