Replaces the build-flag-driven #ifdef sprawl (~30 blocks across 6 files)
with a small HAL in firmware/src/hal/ and per-board folders under
firmware/src/boards/. Shared code (main.cpp, ui.cpp, splash.cpp) no
longer contains a single `#ifdef BOARD_*` — optional features are
guarded by BoardCaps (runtime) and BOARD_HAS_* macros (compile-time,
inside the board's own files).
Why: lets community contributors port to new ESP32 + AMOLED + touch
combos by dropping in a boards/<name>/ folder + a PlatformIO env,
without touching shared files. See docs/porting/adding-a-board.md.
Highlights:
- New HAL: display_hal, touch_hal, input_hal, power_hal, imu_hal,
board_caps. Each board provides display.cpp, touch.cpp, input.cpp,
power.cpp, imu.cpp, caps.cpp, board_init.cpp + private hardware
drivers (e.g. io_expander.{h,cpp} on AMOLED-1.8).
- PlatformIO build_src_filter selects each board's folder per env.
- ui.cpp picks fonts and layout from board_caps() via compute_layout()
with screen-height breakpoints (>= 460 → large, else compact).
- splash.cpp computes CELL = min(W,H)/20 — responsive instead of two
hardcoded values.
- idle.cpp (from #24) rewired through display_hal + power_hal — no
longer depends on the deleted display_cfg.h / power.h.
- power_hal gains power_hal_is_vbus_in() for idle's
IDLE_SLEEP_WHEN_CHARGING gate.
- boards/template/ + docs/porting/{adding-a-board,hal-contract,
capability-flags}.md to bootstrap new ports.
- display_cfg.h, power.{h,cpp}, imu.{h,cpp}, io_expander.{h,cpp}
deleted from src/ root (moved into boards/<name>/ or hal/).
Verification: both `pio run -e waveshare_amoled_216` and
`pio run -e waveshare_amoled_18` succeed unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
112 lines
3.4 KiB
INI
112 lines
3.4 KiB
INI
[env:waveshare_amoled_216]
|
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.38-1/platform-espressif32.zip
|
|
board = esp32-s3-devkitc-1
|
|
framework = arduino
|
|
board_build.arduino.memory_type = qio_opi
|
|
upload_speed = 921600
|
|
monitor_speed = 115200
|
|
|
|
; Compile shared code + this board's per-board folder; exclude all other
|
|
; boards. New ports add a `+<boards/<name>/>` line in their own env block.
|
|
build_src_filter =
|
|
+<*>
|
|
-<boards/>
|
|
+<boards/waveshare_amoled_216/>
|
|
|
|
build_flags =
|
|
-DBOARD_AMOLED_216
|
|
-DARDUINO_USB_CDC_ON_BOOT=1
|
|
-DBOARD_HAS_PSRAM
|
|
; AXP2101 PMU
|
|
-DXPOWERS_CHIP_AXP2101
|
|
; NimBLE config — peripheral, 2 simultaneous connections so the OS can
|
|
; hold the HID link (Space key from BOOT button) while the daemon holds
|
|
; its own connection for the custom data service.
|
|
-DCONFIG_BT_NIMBLE_ROLE_BROADCASTER=1
|
|
-DCONFIG_BT_NIMBLE_ROLE_PERIPHERAL=1
|
|
-DCONFIG_BT_NIMBLE_ROLE_CENTRAL=0
|
|
-DCONFIG_BT_NIMBLE_ROLE_OBSERVER=0
|
|
-DCONFIG_BT_NIMBLE_MAX_CONNECTIONS=2
|
|
; LVGL config via build flags
|
|
-DLV_CONF_SKIP
|
|
-DLV_COLOR_DEPTH=16
|
|
-DLV_USE_LOG=0
|
|
-DLV_USE_BAR=1
|
|
-DLV_USE_LABEL=1
|
|
-DLV_USE_ARC=1
|
|
-DLV_USE_BTN=1
|
|
-DLV_USE_LINE=1
|
|
-DLV_USE_OBJ=1
|
|
-DLV_USE_IMG=1
|
|
-DLV_USE_IMAGE=1
|
|
-DLV_USE_ANIMIMG=0
|
|
-DLV_TICK_CUSTOM=1
|
|
-DLV_USE_SNAPSHOT=1
|
|
|
|
lib_deps =
|
|
moononournation/GFX Library for Arduino@^1.5.6
|
|
lewisxhe/SensorLib@^0.2.6
|
|
lewisxhe/XPowersLib@^0.2.7
|
|
lvgl/lvgl@^9.2.0
|
|
bblanchon/ArduinoJson@^7.0.0
|
|
h2zero/NimBLE-Arduino@^2.1.1
|
|
|
|
|
|
[env:waveshare_amoled_18]
|
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.38-1/platform-espressif32.zip
|
|
board = esp32-s3-devkitc-1
|
|
framework = arduino
|
|
board_build.arduino.memory_type = qio_opi
|
|
board_upload.flash_size = 16MB
|
|
board_upload.maximum_size = 16777216
|
|
board_build.partitions = default_16MB.csv
|
|
upload_speed = 921600
|
|
monitor_speed = 115200
|
|
|
|
; Compile shared code + this board's per-board folder; exclude all other
|
|
; boards. New ports add a `+<boards/<name>/>` line in their own env block.
|
|
build_src_filter =
|
|
+<*>
|
|
-<boards/>
|
|
+<boards/waveshare_amoled_18/>
|
|
|
|
build_flags =
|
|
-DBOARD_AMOLED_18
|
|
-DARDUINO_USB_CDC_ON_BOOT=1
|
|
-DBOARD_HAS_PSRAM
|
|
; AXP2101 PMU is present on the AMOLED-1.8 board too (battery is optional kit add-on)
|
|
-DXPOWERS_CHIP_AXP2101
|
|
; NimBLE config — peripheral, 2 simultaneous connections so the OS can
|
|
; hold the HID link (Space key from BOOT button) while the daemon holds
|
|
; its own connection for the custom data service.
|
|
-DCONFIG_BT_NIMBLE_ROLE_BROADCASTER=1
|
|
-DCONFIG_BT_NIMBLE_ROLE_PERIPHERAL=1
|
|
-DCONFIG_BT_NIMBLE_ROLE_CENTRAL=0
|
|
-DCONFIG_BT_NIMBLE_ROLE_OBSERVER=0
|
|
-DCONFIG_BT_NIMBLE_MAX_CONNECTIONS=2
|
|
; LVGL config via build flags
|
|
-DLV_CONF_SKIP
|
|
-DLV_COLOR_DEPTH=16
|
|
-DLV_USE_LOG=0
|
|
-DLV_USE_BAR=1
|
|
-DLV_USE_LABEL=1
|
|
-DLV_USE_ARC=1
|
|
-DLV_USE_BTN=1
|
|
-DLV_USE_LINE=1
|
|
-DLV_USE_OBJ=1
|
|
-DLV_USE_IMG=1
|
|
-DLV_USE_IMAGE=1
|
|
-DLV_USE_ANIMIMG=0
|
|
-DLV_TICK_CUSTOM=1
|
|
-DLV_USE_SNAPSHOT=1
|
|
|
|
lib_deps =
|
|
; 1.6.4+ ships Arduino_SH8601 in mainline
|
|
moononournation/GFX Library for Arduino@^1.6.4
|
|
; SensorLib still used for QMI8658 IMU on AMOLED-1.8
|
|
lewisxhe/SensorLib@^0.2.6
|
|
lewisxhe/XPowersLib@^0.2.7
|
|
lvgl/lvgl@^9.2.0
|
|
bblanchon/ArduinoJson@^7.0.0
|
|
h2zero/NimBLE-Arduino@^2.1.1
|