-
-
Notifications
You must be signed in to change notification settings - Fork 94
Show a confirmed shutdown screen before cutting power #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
KenVanHoeylandt
merged 7 commits into
TactilityProject:main
from
Crazypedia:display-wait-for-flush-on-poweroff
Jul 10, 2026
+122
−13
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ababcf7
feat(display): confirm shutdown visually with a wait-for-flush hook
Crazypedia 291019e
feat(launcher): confirm before powering off
Crazypedia 5e2062a
fix(launcher): acquire the LVGL lock before drawing the shutdown screen
Crazypedia badf62c
feat(app): move power-off confirmation into its own fullscreen app
Crazypedia 0d54177
fix(app): set dark text color on the powered-off screen
Crazypedia 1b1f64c
refactor(app): move PowerOff out of Launcher into Settings
Crazypedia 944689e
fix(launcher): restore the power button as a link to the PowerOff app
Crazypedia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| #include <Tactility/app/AppContext.h> | ||
| #include <Tactility/app/AppRegistration.h> | ||
| #include <Tactility/hal/display/DisplayDevice.h> | ||
| #include <Tactility/hal/power/PowerDevice.h> | ||
| #include <Tactility/service/loader/Loader.h> | ||
|
|
||
| #include <lvgl.h> | ||
| #include <tactility/hal/Device.h> | ||
| #include <tactility/lvgl_fonts.h> | ||
| #include <tactility/lvgl_icon_shared.h> | ||
|
|
||
| namespace tt::app::poweroff { | ||
|
|
||
| extern const AppManifest manifest; | ||
|
|
||
| class PowerOffApp final : public App { | ||
|
|
||
| /** Replaces the screen with a plain "powered off" message, forces it to draw | ||
| * synchronously, and waits for the display to confirm the draw physically | ||
| * finished. On e-paper this is what's left showing once power cuts, so it | ||
| * doubles as visual confirmation that the device shut down cleanly rather | ||
| * than crashed or hung. Called from an LVGL button click callback, so it's | ||
| * already running on the LVGL thread. */ | ||
| static void showPoweredOffScreenAndWait(hal::display::DisplayDevice* display) { | ||
| auto* screen = lv_obj_create(nullptr); | ||
| lv_obj_set_style_bg_color(screen, lv_color_white(), 0); | ||
| lv_obj_set_flex_flow(screen, LV_FLEX_FLOW_COLUMN); | ||
| lv_obj_set_flex_align(screen, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); | ||
|
|
||
| auto* title = lv_label_create(screen); | ||
| lv_label_set_text(title, "Tactility OS"); | ||
| lv_obj_set_style_text_font(title, lvgl_get_text_font(FONT_SIZE_LARGE), 0); | ||
| lv_obj_set_style_text_color(title, lv_color_black(), 0); | ||
|
|
||
| auto* subtitle = lv_label_create(screen); | ||
| lv_label_set_text(subtitle, "Powered off"); | ||
| lv_obj_set_style_text_color(subtitle, lv_color_black(), 0); | ||
|
|
||
| lv_screen_load(screen); | ||
|
|
||
| if (display != nullptr) { | ||
| auto* lvgl_display = display->getLvglDisplay(); | ||
| if (lvgl_display != nullptr) { | ||
| lv_refr_now(lvgl_display); | ||
| } | ||
| display->waitForFlushComplete(); | ||
| } | ||
| } | ||
|
|
||
| static void onYesPressed(lv_event_t* /*event*/) { | ||
| auto power = hal::findFirstDevice<hal::power::PowerDevice>(hal::Device::Type::Power); | ||
| if (power == nullptr || !power->supportsPowerOff()) { | ||
| return; | ||
| } | ||
|
|
||
| auto display = hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display); | ||
| showPoweredOffScreenAndWait(display.get()); | ||
|
|
||
| power->powerOff(); | ||
| } | ||
|
|
||
| static void onNoPressed(lv_event_t* /*event*/) { | ||
| stop(manifest.appId); | ||
| } | ||
|
|
||
| public: | ||
|
|
||
| void onShow(AppContext& /*app*/, lv_obj_t* parent) override { | ||
| lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); | ||
| lv_obj_set_flex_align(parent, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); | ||
|
|
||
| auto* label = lv_label_create(parent); | ||
| lv_label_set_text(label, "Power off?"); | ||
| lv_obj_set_style_text_font(label, lvgl_get_text_font(FONT_SIZE_LARGE), 0); | ||
|
|
||
| auto* button_wrapper = lv_obj_create(parent); | ||
| lv_obj_set_flex_flow(button_wrapper, LV_FLEX_FLOW_ROW); | ||
| lv_obj_set_size(button_wrapper, LV_SIZE_CONTENT, LV_SIZE_CONTENT); | ||
| lv_obj_set_style_pad_all(button_wrapper, 0, 0); | ||
| lv_obj_set_style_border_width(button_wrapper, 0, 0); | ||
| lv_obj_set_flex_align(button_wrapper, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); | ||
|
|
||
| auto* yes_button = lv_button_create(button_wrapper); | ||
| auto* yes_label = lv_label_create(yes_button); | ||
| lv_label_set_text(yes_label, "Yes"); | ||
| lv_obj_add_event_cb(yes_button, onYesPressed, LV_EVENT_SHORT_CLICKED, nullptr); | ||
|
|
||
| auto* no_button = lv_button_create(button_wrapper); | ||
| auto* no_label = lv_label_create(no_button); | ||
| lv_label_set_text(no_label, "No"); | ||
| lv_obj_add_event_cb(no_button, onNoPressed, LV_EVENT_SHORT_CLICKED, nullptr); | ||
| } | ||
| }; | ||
|
|
||
| extern const AppManifest manifest = { | ||
| .appId = "PowerOff", | ||
| .appName = "Power Off", | ||
| .appIcon = LVGL_ICON_SHARED_POWER_SETTINGS_NEW, | ||
| .appCategory = Category::Settings, | ||
| .appFlags = AppManifest::Flags::HideStatusBar, | ||
| .createApp = create<PowerOffApp> | ||
| }; | ||
|
|
||
| } // namespace |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not link to the PowerOff app from here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The app looks fine by the way!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 944689e — the button now just calls
start("PowerOff")via the same handler the other launcher buttons use, so the confirmation and shutdown-screen flow lives only in the app. Re-tested on my T-Deck Max: launcher button opens the confirmation, power-off leaves the "Powered off" screen on the e-paper.