Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ecec847
New shellui utility with persistence.
nchapman Dec 5, 2025
b76f409
Minimize duplicate code between shellui screens.
nchapman Dec 5, 2025
d9f1001
Update keyboard layout to fill the screen.
nchapman Dec 5, 2025
e362d65
Add missing features to shellui and integrate into Wifi pak.
nchapman Dec 5, 2025
0407bdc
Keyboard upgrade and UI fixes.
nchapman Dec 6, 2025
f54c346
Preemptively launch shellui for faster pak boot.
nchapman Dec 6, 2025
da8dc75
Fallback to discover frequencies by probing.
nchapman Dec 6, 2025
859d9e2
Add proper frequencies for trimuismart.
nchapman Dec 6, 2025
b58e2e3
Add progress support to shellui.
nchapman Dec 6, 2025
f500e7e
Clean up unused shellui options.
nchapman Dec 6, 2025
33c9d18
Improve warning checks in all makefiles.
nchapman Dec 6, 2025
25b2be7
Upgrade paks to use shellui and improve UX.
nchapman Dec 6, 2025
176d6fd
Rename shellui to shui.
nchapman Dec 6, 2025
af30e80
Fix shui confirmation screens.
nchapman Dec 6, 2025
503df07
Improve action buttons in shui and paks.
nchapman Dec 6, 2025
b28f0db
Make auto-sleep stateful and introduce restart to shui.
nchapman Dec 6, 2025
aaf6b5c
Clean up file server pak and rename.
nchapman Dec 6, 2025
f102e27
Make dev-deploy sync everything.
nchapman Dec 6, 2025
7a8106b
Rework shutdown system to work with paks.
nchapman Dec 6, 2025
7b8d0b6
Improve shui boot and resilience.
nchapman Dec 6, 2025
7e6eb15
Fix native paks and simplify makefiles.
nchapman Dec 6, 2025
8782a14
Add subtext to shui and update paks.
nchapman Dec 6, 2025
6c17202
Review fixes.
nchapman Dec 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
417 changes: 417 additions & 0 deletions docs/pak-ux-guide.md

Large diffs are not rendered by default.

146 changes: 146 additions & 0 deletions docs/shutdown-architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Shutdown Architecture

How device shutdown works in LessUI.

## Shutdown Triggers

### 1. keymon (MENU+POWER)

keymon daemon monitors for MENU+POWER combo and calls shutdown directly:

```c
// workspace/*/keymon/keymon.c
system("shutdown");
while (1) pause();
```

Works regardless of what app is running.

### 2. Power Button Hold (1 second)

Applications call `PWR_update()` each frame, which detects power held for 1 second:

```c
// workspace/all/common/api.c - PWR_update()
if (power_pressed_at && now - power_pressed_at >= 1000) {
if (before_sleep) before_sleep();
PWR_powerOff();
}
```

`PWR_powerOff()` shows "Powering off" message and calls `PLAT_powerOff()`:

```c
void PWR_powerOff(void) {
if (pwr.can_poweroff) {
// ... show message ...
PLAT_powerOff();
}
}
```

### 3. Auto-shutdown (after 2 min sleep)

If device is sleeping for 2 minutes and not charging:

```c
// workspace/all/common/api.c - PWR_waitForWake()
if (pwr.can_poweroff && SDL_GetTicks() - sleep_ticks >= 120000) {
if (pwr.is_charging)
sleep_ticks += 60000; // check again in a minute
else
PWR_powerOff();
}
```

### 4. Launcher Script Fallback

MinUI.pak/launch.sh has shutdown at the end as a safety net:

```sh
while [ -f "$EXEC_PATH" ]; do
# ... main loop ...
done

shutdown # just in case
```

## PLAT_powerOff() Implementation

All platforms (except physical switch devices) call `system("shutdown")` directly:

```c
void PLAT_powerOff(void) {
sleep(2);
// ... cleanup (mute, backlight off, quit subsystems) ...
system("shutdown");
while (1) pause();
}
```

This ensures shutdown works consistently regardless of which process triggers it
(minui, minarch, shui daemon, or tool paks).

### Physical Power Switch Platforms

trimuismart and m17 have physical power switches and can't actually power off.
They enter a low-power mode instead:

```c
void PLAT_powerOff(void) {
// ... cleanup ...
touch("/tmp/poweroff");
exit(0);
}
```

The launcher script checks for this marker and handles low-power mode:

```sh
if [ -f "/tmp/poweroff" ]; then
rm -f "/tmp/poweroff"
killall keymon.elf
# ... enter low power mode ...
fi
```

## Shutdown Scripts

Each platform has a `shutdown` script in `skeleton/SYSTEM/<platform>/bin/`:

| Platform | Method |
|----------|--------|
| miyoomini | Plus: `sync && poweroff`; Non-plus: `sync && reboot` |
| tg5040 | AXP register writes for hardware power-off |
| rg35xxplus | `reboot -f` |
| rg35xx | `sync && poweroff` |
| rgb30 | `poweroff` |
| zero28 | Clear framebuffer, `poweroff` |
| my282 | `poweroff` |
| my355 | `poweroff` |
| magicmini | `poweroff` |
| trimuismart | Just saves datetime (physical switch) |
| m17 | Just saves datetime (physical switch) |

## Who Calls PWR_update()

| Context | Calls PWR_update()? |
|---------|---------------------|
| minui main loop | Yes |
| minarch game loop | Yes |
| minarch in-game menu | Yes |
| shui ui_list | Yes |
| shui ui_message | Yes |
| shui ui_keyboard | Yes |
| shui daemon idle loop | No |
| Tool pak shell scripts | No (they're shell, not C) |

## Summary

| Trigger | Path | Works everywhere? |
|---------|------|-------------------|
| MENU+POWER | keymon → system("shutdown") | Yes |
| Power hold in minui | PWR_powerOff() → PLAT_powerOff() | Yes |
| Power hold in minarch | PWR_powerOff() → PLAT_powerOff() | Yes |
| Power hold in shui | PWR_powerOff() → PLAT_powerOff() | Yes |
| 2 min sleep timeout | PWR_powerOff() → PLAT_powerOff() | Yes |
3 changes: 3 additions & 0 deletions makefile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ LOG_FLAGS ?= -DENABLE_INFO_LOGS -DENABLE_DEBUG_LOGS
CFLAGS = -fomit-frame-pointer -DPLATFORM=\"$(PLATFORM)\" -DUSE_SDL2 $(LOG_FLAGS) -Ofast -std=gnu99
CFLAGS += -DDEV_SCREEN_WIDTH=$(SCREEN_WIDTH) -DDEV_SCREEN_HEIGHT=$(SCREEN_HEIGHT)
CFLAGS += -fsanitize=address -fno-common
CFLAGS += -Wall -Wextra -Wsign-compare -Wshadow -Wnull-dereference -Wundef \
-Wno-unused-variable -Wno-unused-function -Wno-unused-parameter \
-Wno-cast-align -Wno-missing-field-initializers -Wno-format -Werror
CFLAGS += -Wno-tautological-constant-out-of-range-compare -Wno-asm-operand-widths
LDFLAGS = -ldl -flto $(SDL_LIBS) -lSDL2 -lSDL2_image -lSDL2_ttf -lpthread -lm -lz -fsanitize=address

Expand Down
22 changes: 19 additions & 3 deletions scripts/analyze-cpu-bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@
1100: 182700,
1600: 232600,
},
"trimuismart": {
60: 8900,
240: 38300,
312: 50100,
408: 65400,
480: 77600,
600: 97200,
720: 116900,
816: 131800,
912: 147400,
1008: 163900,
1104: 179600,
1200: 195300,
1344: 218900,
1440: 229800,
},
"my355": {
408: 67400,
600: 99300,
Expand Down Expand Up @@ -112,9 +128,9 @@
"PERFORMANCE": 2016,
},
"trimuismart": {
"POWERSAVE": 1104,
"NORMAL": 1344,
"PERFORMANCE": 1536,
"POWERSAVE": 816,
"NORMAL": 1104,
"PERFORMANCE": 1440,
},
"rg35xx": {
"POWERSAVE": 1104,
Expand Down
Loading