Skip to content

feat: migrate to ZMK main (Zephyr 4.1 + LVGL 9) - #37

Open
tokyo2006 wants to merge 1 commit into
mctechnology17:mainfrom
tokyo2006:4.0
Open

feat: migrate to ZMK main (Zephyr 4.1 + LVGL 9)#37
tokyo2006 wants to merge 1 commit into
mctechnology17:mainfrom
tokyo2006:4.0

Conversation

@tokyo2006

Copy link
Copy Markdown

Summary

Migrate the nice_oled / nice_epaper / nice_custom shields from ZMK v0.3.0 (Zephyr 3.5 + LVGL 8.2) to ZMK main (Zephyr 4.1 + LVGL 9).

Changes

LVGL 8 → 9 migration

  • lv_canvas_transform() (removed in LVGL 9) → lv_draw_sw_rotate() with LV_DISPLAY_ROTATION_270
  • Canvas color format switched from true-color to LV_COLOR_FORMAT_L8 (the smallest format supported by lv_draw_sw_rotate), mirroring ZMK's own nice_view implementation
  • lv_canvas_draw_* (removed) → layer-based canvas_draw_* wrappers (lv_canvas_init_layerlv_draw_*lv_canvas_finish_layer)
  • Image assets: LV_IMG_CF_INDEXED_1BITLV_COLOR_FORMAT_I1; dropped the removed .header.always_zero / .header.reserved fields
  • lv_draw_img_dsc_t/_initlv_draw_image_dsc_t/_init, lv_anim_set_timelv_anim_set_duration, LV_LABEL_LONG_SCROLL_CIRCULARLV_LABEL_LONG_MODE_SCROLL_CIRCULAR

ZMK API changes

  • zmk_endpoints_selected()zmk_endpoint_get_selected()

Fixes

  • Bump ZMK_DISPLAY_DEDICATED_THREAD_STACK_SIZE from 2560 to 4096 — LVGL 9 rendering needs more stack; the old 2560 caused a hard fault on the split peripheral (broken display and unresponsive keyboard)
  • Drop the unused lv_color_t cbuf[] parameter from draw_canvas (type mismatch after the buffer became uint8_t[])

Cleanup

  • Removed redundant legacy widgets weather.c / media_player.c — they referenced the removed zmk/events/raw_hid.h API; weather and Spotify are already implemented via src/raw_hid + screen.c
  • Wired up the sleep_status_bootloader.c variant behind a new CONFIG_NICE_OLED_SLEEP_STATUS_BOOTLOADER flag, and fixed its periodic-timer leak (now one-shot)
  • Fixed a pre-existing Kconfig/CMake bug: SHOW_SLEEP_ART_ON_IDLE OR SHOW_SLEEP_ART_ON_IDLE..._ON_SLEEP (the _ON_SLEEP option never took effect)
  • Removed stale Zephyr 3.x in-tree LVGL include paths from CMakeLists.txt

Notes

  • ZMK main has no native Raw HID support; this module carries its own implementation, which is unchanged (the Zephyr 4.1 USB HID API is source-compatible with 3.5)
  • lv_img_dsc_t, LV_IMG_DECLARE, lv_img_set_src, lv_obj_del, lv_obj_clear_flag, lv_txt_get_size etc. are intentionally kept as-is — they are auto-mapped by LVGL 9's src/lv_api_map_v8.h (the same mechanism ZMK's own nice_view relies on)
  • Custom fonts are already LVGL 9-compatible (generated with version conditionals)

Testing

  • Migration verified against ZMK main nice_view (authoritative reference for the same 68×160 → 160×68 rotation)
  • Build + runtime verified on hardware (central + split peripheral)
  • Reviewer: confirm OLED (nice_oled) and nice!view (nice_epaper) both render correctly

@tokyo2006

Copy link
Copy Markdown
Author

I only test my nice_oled and passed

@ramb0t ramb0t left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this branch on a Sofle Choc RGB wireless (nice!nano v2, both halves nice!view,
sofle_left/right nice_view_adapter nice_epaper) against ZMK main
641514a9 / zephyr fork 10ba6d0c. It builds and renders correctly —
thanks for doing the LVGL 9 work.

It did not run, though, until I overrode two Kconfig values. Both halves
drew one correct frame and then froze about a second later, every boot.

The resolved .config from CI shows:

CONFIG_NICE_EPAPER_ON=y
CONFIG_LV_Z_VDB_SIZE=64
CONFIG_ZMK_DISPLAY_DEDICATED_THREAD_STACK_SIZE=3072

NICE_OLED_ON is unset in that same .config, so Kconfig.defconfig:23-26
should have selected default 100 if NICE_EPAPER_ON and :59-61 / :257-258
should have given 4096. Neither default took effect. LV_Z_MEM_POOL_SIZE is
unaffected and keeps the intended 8192 central / 4096 peripheral split.

Adding these two to my own .conf fixes it completely — no freezes since:

CONFIG_LV_Z_VDB_SIZE=100
CONFIG_ZMK_DISPLAY_DEDICATED_THREAD_STACK_SIZE=4096

4096 exactly, so this is the number the module already asks for rather than
me padding it.

Two things that may point at the cause:

nice_epaper.conf already carries both lines under the "modo dongle" TODO
block, but commented out:

# CONFIG_LV_Z_MEM_POOL_SIZE=8192
# CONFIG_ZMK_DISPLAY_DEDICATED_THREAD_STACK_SIZE=4096

And ZMK's own boards/shields/nice_view/nice_view.conf sets
CONFIG_ZMK_DISPLAY_DEDICATED_THREAD_STACK_SIZE=4096 as a .conf
assignment. Swapping nice_view for nice_epaper drops that, and the
Kconfig.defconfig default does not appear to replace it — ZMK declares an
unconditional default 3072 in app/src/display/Kconfig.

So the fix may be as simple as uncommenting those two lines in
nice_epaper.conf and adding CONFIG_LV_Z_VDB_SIZE=100 alongside them,
since a .conf assignment wins where the default did not.

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.

2 participants