Skip to content

fix(display): render WPM and handle sleep transitions - #1057

Draft
hitsmaxft wants to merge 1 commit into
rmk-rs:mainfrom
hitsmaxft:agent/rmk-display-reliability
Draft

fix(display): render WPM and handle sleep transitions#1057
hitsmaxft wants to merge 1 commit into
rmk-rs:mainfrom
hitsmaxft:agent/rmk-display-reliability

Conversation

@hitsmaxft

@hitsmaxft hitsmaxft commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

What changed

  • request a render when WpmUpdateEvent changes the display context
  • add a driver-selected sleep transition: render a final sleeping frame or enter sleep immediately
  • add a default no-op driver hook for entering and leaving the sleeping state
  • correct the documented default minimum render interval from 10 ms to 33 ms

Why

DisplayProcessor subscribed to WPM updates but only changed RenderContext::wpm. In event-driven mode, the displayed value could remain stale until an unrelated event arrived. WpmProcessor samples once per second and publishes only when the value changes, so this does not add per-key notifications; the existing 33 ms render coalescing still applies.

Displays also need different sleep transitions. E-paper or memory displays may render and flush a final special frame, while a power-managed OLED may turn off without transferring another framebuffer. DisplaySleepBehavior makes that choice explicit:

  • RenderThenSleep (default): render and flush the sleeping context, then call set_sleeping(true)
  • SleepImmediately: skip the final render and call set_sleeping(true) directly

On wake, set_sleeping(false) runs before the next render. This defines display preparation around RMK's existing sleep event without attempting to define platform deep-sleep policy.

The need was found while adapting an existing downstream OLED backend, which keeps its board-specific power, dirty-page, and error handling.

Compatibility

Both new DisplayDriver methods have defaults. Existing drivers and renderers require no changes, and the default preserves the current built-in renderer behavior.

Validation

  • 443 display-feature tests passed
  • Clippy with display and -D warnings
  • Rust custom-renderer example
  • both RP2040 OLED examples for thumbv6m-none-eabi
  • formatting and diff checks

@hitsmaxft
hitsmaxft force-pushed the agent/rmk-display-reliability branch from 2a7f0ad to 241b853 Compare August 16, 2026 04:22
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown

Size Report

Example main PR Diff .text .data .bss
use_config/nrf52832_ble 398.1 KiB 398.1 KiB +0.00% ⬇️ -4 0 0
use_config/nrf52840_ble 440.7 KiB 440.7 KiB +0.00% 0 0 0
use_config/nrf52840_ble_split (central) 502.2 KiB 502.2 KiB +0.00% 0 0 0
use_config/nrf52840_ble_split (peripheral) 317.5 KiB 317.5 KiB +0.00% 0 0 0
use_config/pi_pico_w_ble 673.3 KiB 673.3 KiB +0.00% ⬆️ +12 0 0
use_config/rp2040 146.0 KiB 146.0 KiB +0.00% 0 0 0
use_config/rp2040_split (central) 159.6 KiB 159.6 KiB +0.00% ⬇️ -4 0 0
use_config/rp2040_split (peripheral) 27.9 KiB 27.9 KiB +0.00% 0 0 0
use_config/stm32f1 62.7 KiB 62.7 KiB +0.00% 0 0 0
use_config/stm32h7 100.8 KiB 100.8 KiB +0.00% 0 0 0
use_rust/nrf52832_ble 386.0 KiB 386.0 KiB +0.00% 0 0 0
use_rust/nrf52840_ble 435.6 KiB 435.6 KiB +0.00% 0 0 0
use_rust/nrf52840_ble_split (central) 505.7 KiB 505.7 KiB +0.00% ⬇️ -8 0 0
use_rust/nrf52840_ble_split (peripheral) 315.3 KiB 315.3 KiB +0.00% ⬆️ +4 0 0
use_rust/pi_pico_w_ble 672.7 KiB 672.7 KiB +0.00% ⬇️ -4 0 0
use_rust/rp2040 145.5 KiB 145.5 KiB +0.00% 0 0 0
use_rust/rp2040_split (central) 158.3 KiB 158.3 KiB +0.00% 0 0 0
use_rust/rp2040_split (peripheral) 28.2 KiB 28.2 KiB +0.00% 0 0 0
use_rust/stm32f1 61.9 KiB 61.9 KiB +0.00% 0 0 0
use_rust/stm32h7 119.6 KiB 119.6 KiB +0.00% ⬆️ +8 0 0
use_config/nrf52832_ble — 398.1 KiB → 398.1 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 365360	   8620	  33672	 407652	  63864	rmk-nrf52832

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 365364	   8620	  33672	 407656	  63868	rmk-nrf52832

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +72  [ = ]       0    .debug_info
  +0.0%     +40  [ = ]       0    .debug_str
  +0.0%     +10  [ = ]       0    .debug_line
  +8.3%      +4  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  -0.0%     -30  [ = ]       0    .strtab
  +0.0%     +92  -0.0%      -4    TOTAL
use_config/nrf52840_ble — 440.7 KiB → 440.7 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 398952	   8628	  43704	 451284	  6e2d4	rmk-nrf52840

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 398952	   8628	  43704	 451284	  6e2d4	rmk-nrf52840

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +405  [ = ]       0    .debug_line
  +0.0%    +289  [ = ]       0    .debug_info
  +0.5%     +39  [ = ]       0    .debug_abbrev
  +0.0%     +26  [ = ]       0    .strtab
  +0.0%     +10  [ = ]       0    .debug_loc
  +5.9%      +3  [ = ]       0    [Unmapped]
  -0.0%     -52  [ = ]       0    .debug_str
  +0.0%    +720  [ = ]       0    TOTAL
use_config/nrf52840_ble_split (central) — 502.2 KiB → 502.2 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 456528	   8684	  49040	 514252	  7d8cc	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 456528	   8684	  49040	 514252	  7d8cc	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +240  [ = ]       0    .debug_line
  +0.0%    +216  [ = ]       0    .debug_info
  +0.0%     +10  [ = ]       0    .debug_loc
  +7.8%      +4  [ = ]       0    [Unmapped]
  -0.1%    -603  [ = ]       0    .strtab
  -0.1% -5.37Ki  [ = ]       0    .debug_str
  -0.1% -5.50Ki  [ = ]       0    TOTAL
use_config/nrf52840_ble_split (peripheral) — 317.5 KiB → 317.5 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 291464	   8500	  25184	 325148	  4f61c	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 291464	   8500	  25184	 325148	  4f61c	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +32  [ = ]       0    .debug_str
  +0.0%     +16  [ = ]       0    .strtab
  +0.0%     +10  [ = ]       0    .debug_loc
  +6.0%      +3  [ = ]       0    [Unmapped]
  +0.0%      +1  [ = ]       0    .debug_line
  -0.0%      -2  [ = ]       0    .debug_info
  +0.0%     +60  [ = ]       0    TOTAL
use_config/pi_pico_w_ble — 673.3 KiB → 673.3 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 635700	      0	  53736	 689436	  a851c	rmk-pi-pico-w

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 635688	      0	  53736	 689424	  a8510	rmk-pi-pico-w

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +8  +0.0%      +8    .text
  +0.0%      +4  +0.0%      +4    .rodata
  -0.0%      -4  [ = ]       0    .strtab
 -13.7%     -10  [ = ]       0    [Unmapped]
  -0.4%     -39  [ = ]       0    .debug_abbrev
  -0.0%     -97  [ = ]       0    .debug_line
  -0.0%    -137  [ = ]       0    .debug_str
  -0.0%    -213  [ = ]       0    .debug_info
  -0.0%    -488  +0.0%     +12    TOTAL
use_config/rp2040 — 146.0 KiB → 146.0 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 135656	      0	  13884	 149540	  24824	rmk-rp2040

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 135656	      0	  13884	 149540	  24824	rmk-rp2040

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +10  [ = ]       0    .debug_loc
  -4.7%      -2  [ = ]       0    [Unmapped]
  -0.0%     -44  [ = ]       0    .debug_line
  -0.0%     -36  [ = ]       0    TOTAL
use_config/rp2040_split (central) — 159.6 KiB → 159.6 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 148632	      0	  14836	 163468	  27e8c	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 148636	      0	  14836	 163472	  27e90	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +143  [ = ]       0    .debug_line
  +0.0%     +69  [ = ]       0    .debug_str
  +0.0%     +10  [ = ]       0    .debug_loc
   +16%      +8  [ = ]       0    [Unmapped]
  +0.0%      +1  [ = ]       0    .strtab
  -0.0%      -3  [ = ]       0    .debug_info
  -0.0%      -4  -0.0%      -4    .text
  +0.0%    +224  -0.0%      -4    TOTAL
use_config/rp2040_split (peripheral) — 27.9 KiB → 27.9 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  25696	     60	   2804	  28560	   6f90	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  25696	     60	   2804	  28560	   6f90	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_config/stm32f1 — 62.7 KiB → 62.7 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  57808	     28	   6344	  64180	   fab4	rmk-stm32f1

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  57808	     28	   6344	  64180	   fab4	rmk-stm32f1

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_config/stm32h7 — 100.8 KiB → 100.8 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  94804	    264	   8104	 103172	  19304	rmk-stm32h7

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  94804	    264	   8104	 103172	  19304	rmk-stm32h7

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_rust/nrf52832_ble — 386.0 KiB → 386.0 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 352992	   8620	  33608	 395220	  607d4	rmk-nrf52832

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 352992	   8620	  33608	 395220	  607d4	rmk-nrf52832

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +30  [ = ]       0    .strtab
  +0.0%     +10  [ = ]       0    .debug_loc
  -8.3%      -6  [ = ]       0    [Unmapped]
  -0.0%     -10  [ = ]       0    .debug_line
  -0.0%     -40  [ = ]       0    .debug_str
  -0.0%     -72  [ = ]       0    .debug_info
  -0.0%     -88  [ = ]       0    TOTAL
use_rust/nrf52840_ble — 435.6 KiB → 435.6 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 396464	   8628	  40944	 446036	  6ce54	rmk-nrf52840

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 396464	   8628	  40944	 446036	  6ce54	rmk-nrf52840

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +72  [ = ]       0    .debug_info
  +0.0%     +40  [ = ]       0    .debug_str
  -0.0%     -30  [ = ]       0    .strtab
  -0.1%    -230  [ = ]       0    .debug_line
  -0.0%    -148  [ = ]       0    TOTAL
use_rust/nrf52840_ble_split (central) — 505.7 KiB → 505.7 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 458152	   8684	  51008	 517844	  7e6d4	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 458160	   8684	  51008	 517852	  7e6dc	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +53  [ = ]       0    .debug_info
  +0.2%     +19  [ = ]       0    .debug_abbrev
   +15%      +8  [ = ]       0    [Unmapped]
  -0.0%      -8  -0.0%      -8    .text
  -0.0%     -23  [ = ]       0    .strtab
  -0.0%     -44  [ = ]       0    .debug_line
  -0.0%    -361  [ = ]       0    .debug_str
  -0.0%    -356  -0.0%      -8    TOTAL
use_rust/nrf52840_ble_split (peripheral) — 315.3 KiB → 315.3 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 289452	   8500	  24952	 322904	  4ed58	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 289448	   8500	  24952	 322900	  4ed54	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +12  [ = ]       0    .strtab
  +0.0%      +4  +0.0%      +4    .text
  -4.1%      -2  [ = ]       0    [Unmapped]
  -0.0%     -97  [ = ]       0    .debug_line
  -0.0%    -123  [ = ]       0    .debug_str
  -0.0%    -234  [ = ]       0    .debug_info
  -0.0%    -440  +0.0%      +4    TOTAL
use_rust/pi_pico_w_ble — 672.7 KiB → 672.7 KiB (+0.00% ⬇️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 635464	      0	  53416	 688880	  a82f0	rmk-pi-pico-w

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 635468	      0	  53416	 688884	  a82f4	rmk-pi-pico-w

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +5  [ = ]       0    .debug_info
  +2.9%      +2  [ = ]       0    [Unmapped]
  -0.0%      -4  -0.0%      -4    .text
  -0.0%      -5  [ = ]       0    .debug_line
  -0.2%    -678  [ = ]       0    .strtab
  -0.1% -4.99Ki  [ = ]       0    .debug_str
  -0.1% -5.66Ki  -0.0%      -4    TOTAL
use_rust/rp2040 — 145.5 KiB → 145.5 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 135276	      0	  13724	 149000	  24608	rmk-rp2040

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 135276	      0	  13724	 149000	  24608	rmk-rp2040

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +72  [ = ]       0    .debug_str
  +0.0%     +43  [ = ]       0    .debug_info
  +0.0%      +8  [ = ]       0    .strtab
  +2.7%      +1  [ = ]       0    [Unmapped]
  -0.0%     -10  [ = ]       0    .debug_loc
  -0.0%     -58  [ = ]       0    .debug_line
  +0.0%     +56  [ = ]       0    TOTAL
use_rust/rp2040_split (central) — 158.3 KiB → 158.3 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 147560	      0	  14580	 162140	  2795c	central

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 147560	      0	  14580	 162140	  2795c	central

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +143  [ = ]       0    .debug_line
  +0.0%     +69  [ = ]       0    .debug_str
   +11%      +4  [ = ]       0    [Unmapped]
  +0.0%      +1  [ = ]       0    .strtab
  -0.0%      -3  [ = ]       0    .debug_info
  -0.0%     -10  [ = ]       0    .debug_loc
  +0.0%    +204  [ = ]       0    TOTAL
use_rust/rp2040_split (peripheral) — 28.2 KiB → 28.2 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  25796	     60	   3068	  28924	   70fc	peripheral

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  25796	     60	   3068	  28924	   70fc	peripheral

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_rust/stm32f1 — 61.9 KiB → 61.9 KiB (+0.00%)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
  57128	     28	   6272	  63428	   f7c4	rmk-stm32f1

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
  57128	     28	   6272	  63428	   f7c4	rmk-stm32f1

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
use_rust/stm32h7 — 119.6 KiB → 119.6 KiB (+0.00% ⬆️)

cargo size (PR):

   text	   data	    bss	    dec	    hex	filename
 108148	    320	  14004	 122472	  1de68	rmk-stm32h7

cargo size (main):

   text	   data	    bss	    dec	    hex	filename
 108140	    320	  14004	 122464	  1de60	rmk-stm32h7

Bloaty diff (PR vs main):

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +63  [ = ]       0    .debug_str
  +0.0%     +43  [ = ]       0    .debug_info
   +54%     +20  [ = ]       0    [Unmapped]
  +0.0%     +10  [ = ]       0    .debug_loc
  +0.0%      +9  [ = ]       0    .strtab
  +0.0%      +8  +0.0%      +8    .text
  -0.0%     -13  [ = ]       0    .debug_line
  +0.0%    +140  +0.0%      +8    TOTAL

@hitsmaxft
hitsmaxft force-pushed the agent/rmk-display-reliability branch from 241b853 to 0d4eaff Compare August 16, 2026 05:50
@hitsmaxft hitsmaxft changed the title fix(display): reliably redraw state changes fix(display): render WPM and handle sleep transitions Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant