@geastack/targets 0.1.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +83 -0
- package/package.json +50 -0
- package/targets/cmake/geatsc-generated-archive-build.mjs +614 -0
- package/targets/cmake/geatsc_generated_archive.cmake +116 -0
- package/targets/cmake/geatsc_generated_archive_build.cmake +50 -0
- package/targets/esp32/app_project.cmake +33 -0
- package/targets/esp32/apps/app_manager.cpp +188 -0
- package/targets/esp32/apps/app_manager.h +10 -0
- package/targets/esp32/chip_bindings/README.md +58 -0
- package/targets/esp32/chip_bindings/audio/es8311.cpp +556 -0
- package/targets/esp32/chip_bindings/displays/co5300.cpp +510 -0
- package/targets/esp32/chip_bindings/displays/co5300.h +47 -0
- package/targets/esp32/chip_bindings/displays/co5300_async_stream.inc +79 -0
- package/targets/esp32/chip_bindings/displays/qspi_panel.h +65 -0
- package/targets/esp32/chip_bindings/displays/sh8601.cpp +583 -0
- package/targets/esp32/chip_bindings/displays/sh8601.h +36 -0
- package/targets/esp32/chip_bindings/gps/lc76g.cpp +296 -0
- package/targets/esp32/chip_bindings/gps/lc76g.h +7 -0
- package/targets/esp32/chip_bindings/imu/bmi270.cpp +299 -0
- package/targets/esp32/chip_bindings/imu/bmi270_config.inl +439 -0
- package/targets/esp32/chip_bindings/imu/qmi8658.cpp +213 -0
- package/targets/esp32/chip_bindings/power/axp2101.cpp +185 -0
- package/targets/esp32/chip_bindings/touch/cst9217.cpp +229 -0
- package/targets/esp32/chip_bindings/touch/cst9217_controller.h +78 -0
- package/targets/esp32/chip_bindings/touch/ft3168.cpp +340 -0
- package/targets/esp32/chip_bindings/touch/ft3168_controller.h +103 -0
- package/targets/esp32/chip_bindings/touch/ft6336.cpp +310 -0
- package/targets/esp32/chip_bindings/touch/ft6336_controller.h +90 -0
- package/targets/esp32/components/gea_framework/CMakeLists.txt +62 -0
- package/targets/esp32/connectivity/ble_hid.cpp +2916 -0
- package/targets/esp32/connectivity/ble_hid.h +8 -0
- package/targets/esp32/connectivity/diagnostics_transport.cpp +523 -0
- package/targets/esp32/connectivity/diagnostics_transport_offline.cpp +108 -0
- package/targets/esp32/connectivity/wifi.cpp +615 -0
- package/targets/esp32/connectivity/wifi_debug_offline.cpp +37 -0
- package/targets/esp32/connectivity/wifi_task_stack.h +119 -0
- package/targets/esp32/display.cpp +6010 -0
- package/targets/esp32/display_headless.cpp +468 -0
- package/targets/esp32/gea/platform_random.h +11 -0
- package/targets/esp32/gea_framework.cmake +382 -0
- package/targets/esp32/gpio.cpp +229 -0
- package/targets/esp32/host_sources.cmake +35 -0
- package/targets/esp32/imu_absent.cpp +36 -0
- package/targets/esp32/ldfragments/gea_ui_state_external.lf +35 -0
- package/targets/esp32/memory_config.h +64 -0
- package/targets/esp32/power_absent.cpp +22 -0
- package/targets/esp32/sdk-patches/0001-esp_ptr_dma_capable-accept-PSRAM.patch +70 -0
- package/targets/esp32/sdk-patches/0002-gdma-access_ext_mem-spi_master.patch +59 -0
- package/targets/esp32/sdk-patches/README.md +127 -0
- package/targets/esp32/services/app_runner.cpp +248 -0
- package/targets/esp32/services/app_state.cpp +56 -0
- package/targets/esp32/services/audio_runtime_stub.cpp +86 -0
- package/targets/esp32/services/battery_service.cpp +31 -0
- package/targets/esp32/services/device_control.cpp +1896 -0
- package/targets/esp32/services/device_control.h +31 -0
- package/targets/esp32/services/frame_scheduler.cpp +1571 -0
- package/targets/esp32/services/heap.cpp +129 -0
- package/targets/esp32/services/memory.cpp +103 -0
- package/targets/esp32/services/ota.cpp +840 -0
- package/targets/esp32/services/ota_image.cpp +162 -0
- package/targets/esp32/services/ota_image.h +16 -0
- package/targets/esp32/services/storage_service.cpp +159 -0
- package/targets/esp32/touch_absent.cpp +44 -0
- package/targets/esp32-m5stack-m5paper/CMakeLists.txt +10 -0
- package/targets/esp32-m5stack-m5paper/README.md +55 -0
- package/targets/esp32-m5stack-m5paper/dependencies.lock +76 -0
- package/targets/esp32-m5stack-m5paper/main/CMakeLists.txt +46 -0
- package/targets/esp32-m5stack-m5paper/main/Kconfig.projbuild +10 -0
- package/targets/esp32-m5stack-m5paper/main/app_main.cpp +114 -0
- package/targets/esp32-m5stack-m5paper/main/audio_stub.cpp +27 -0
- package/targets/esp32-m5stack-m5paper/main/buttons.cpp +111 -0
- package/targets/esp32-m5stack-m5paper/main/display.cpp +1074 -0
- package/targets/esp32-m5stack-m5paper/main/i2c.cpp +36 -0
- package/targets/esp32-m5stack-m5paper/main/idf_component.yml +7 -0
- package/targets/esp32-m5stack-m5paper/main/imu_stub.cpp +20 -0
- package/targets/esp32-m5stack-m5paper/main/include/board.h +100 -0
- package/targets/esp32-m5stack-m5paper/main/include/buttons.h +8 -0
- package/targets/esp32-m5stack-m5paper/main/launcher_button.cpp +82 -0
- package/targets/esp32-m5stack-m5paper/main/m5paper_psram.lf +20 -0
- package/targets/esp32-m5stack-m5paper/main/power.cpp +73 -0
- package/targets/esp32-m5stack-m5paper/main/sdcard_mount.cpp +82 -0
- package/targets/esp32-m5stack-m5paper/main/touch.cpp +279 -0
- package/targets/esp32-m5stack-m5paper/partitions.csv +9 -0
- package/targets/esp32-m5stack-m5paper/sdkconfig.defaults +84 -0
- package/targets/esp32-p4-m5stack-tab5/CMakeLists.txt +10 -0
- package/targets/esp32-p4-m5stack-tab5/dependencies.lock +276 -0
- package/targets/esp32-p4-m5stack-tab5/main/CMakeLists.txt +586 -0
- package/targets/esp32-p4-m5stack-tab5/main/Kconfig.projbuild +12 -0
- package/targets/esp32-p4-m5stack-tab5/main/app_main.cpp +177 -0
- package/targets/esp32-p4-m5stack-tab5/main/camera.cpp +2025 -0
- package/targets/esp32-p4-m5stack-tab5/main/display.cpp +4033 -0
- package/targets/esp32-p4-m5stack-tab5/main/fatfs_ffconf.h +383 -0
- package/targets/esp32-p4-m5stack-tab5/main/i2c.cpp +39 -0
- package/targets/esp32-p4-m5stack-tab5/main/idf_component.yml +21 -0
- package/targets/esp32-p4-m5stack-tab5/main/include/board.h +130 -0
- package/targets/esp32-p4-m5stack-tab5/main/include/tab5_drivers.h +68 -0
- package/targets/esp32-p4-m5stack-tab5/main/include/wifi_config.h.example +5 -0
- package/targets/esp32-p4-m5stack-tab5/main/launcher_button.cpp +188 -0
- package/targets/esp32-p4-m5stack-tab5/main/power.cpp +22 -0
- package/targets/esp32-p4-m5stack-tab5/main/sdcard_mount.cpp +125 -0
- package/targets/esp32-p4-m5stack-tab5/main/tab5_audio.cpp +345 -0
- package/targets/esp32-p4-m5stack-tab5/main/tab5_drivers.cpp +871 -0
- package/targets/esp32-p4-m5stack-tab5/main/tab5_imu.cpp +246 -0
- package/targets/esp32-p4-m5stack-tab5/main/touch.cpp +206 -0
- package/targets/esp32-p4-m5stack-tab5/partitions.csv +12 -0
- package/targets/esp32-p4-m5stack-tab5/sdkconfig.defaults +128 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/CMakeLists.txt +19 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/0001-esp_video-csi-raw-passthrough-p4-rev-lt-v3.patch +28 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/README.md +45 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/apply.sh +37 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/dependencies.lock +196 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/CMakeLists.txt +562 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/Kconfig.projbuild +12 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/app_main.cpp +166 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/camera.cpp +2105 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/display.cpp +1730 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/fatfs_ffconf.h +383 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/i2c.cpp +39 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/idf_component.yml +11 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/board.h +87 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/panel_native.h +59 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/wifi_config.h.example +5 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/launcher_button.cpp +191 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/power.cpp +15 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/touch.cpp +306 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/partitions.csv +13 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/patches/README.md +22 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/patches/espressif__esp_video-csi-bypass.patch +28 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/sdkconfig.defaults +109 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/tools/README-camera-capture.md +84 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/tools/capture-camera.py +369 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/CMakeLists.txt +10 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/dependencies.lock +258 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/CMakeLists.txt +577 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/Kconfig.projbuild +12 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/app_main.cpp +177 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/camera.cpp +1935 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/display.cpp +2832 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/fatfs_ffconf.h +383 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/i2c.cpp +39 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/idf_component.yml +23 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/include/board.h +68 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/include/wifi_config.h.example +5 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/launcher_button.cpp +191 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/power.cpp +15 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/sdcard_mount.cpp +125 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/touch.cpp +332 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/partitions.csv +12 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/sdkconfig.defaults +122 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/tools/README-camera-capture.md +84 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/tools/capture-camera.py +369 -0
- package/targets/esp32-s3-devkit-n16r8.json +31 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/CMakeLists.txt +10 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/dependencies.lock +40 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/CMakeLists.txt +549 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/Kconfig.projbuild +12 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/app_main.cpp +187 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/display_rgb.cpp +1338 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/i2c.cpp +39 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/idf_component.yml +5 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/include/board.h +142 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/include/pcf8574.h +16 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/include/rotary_encoder.h +7 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/launcher_button.cpp +191 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/pcf8574.cpp +86 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/platform_stubs.cpp +47 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/rotary_encoder.cpp +135 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/touch.cpp +250 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/partitions.csv +8 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/sdkconfig.defaults +116 -0
- package/targets/esp32-s3-epaper-1.54/CMakeLists.txt +10 -0
- package/targets/esp32-s3-epaper-1.54/dependencies.lock +76 -0
- package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +691 -0
- package/targets/esp32-s3-epaper-1.54/main/Kconfig.projbuild +12 -0
- package/targets/esp32-s3-epaper-1.54/main/app_main.cpp +181 -0
- package/targets/esp32-s3-epaper-1.54/main/buttons.cpp +144 -0
- package/targets/esp32-s3-epaper-1.54/main/display.cpp +1281 -0
- package/targets/esp32-s3-epaper-1.54/main/fatfs_ffconf.h +377 -0
- package/targets/esp32-s3-epaper-1.54/main/i2c.cpp +39 -0
- package/targets/esp32-s3-epaper-1.54/main/idf_component.yml +7 -0
- package/targets/esp32-s3-epaper-1.54/main/imu_stub.cpp +21 -0
- package/targets/esp32-s3-epaper-1.54/main/include/board.h +119 -0
- package/targets/esp32-s3-epaper-1.54/main/include/buttons.h +9 -0
- package/targets/esp32-s3-epaper-1.54/main/include/wifi_config.h.example +5 -0
- package/targets/esp32-s3-epaper-1.54/main/launcher_button.cpp +191 -0
- package/targets/esp32-s3-epaper-1.54/main/power.cpp +15 -0
- package/targets/esp32-s3-epaper-1.54/main/sdcard_mount.cpp +89 -0
- package/targets/esp32-s3-epaper-1.54/main/touch.cpp +299 -0
- package/targets/esp32-s3-epaper-1.54/partitions.csv +8 -0
- package/targets/esp32-s3-epaper-1.54/sdkconfig.defaults +217 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/CMakeLists.txt +10 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/README.md +29 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/dependencies.lock +116 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/main/CMakeLists.txt +90 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/main/idf_component.yml +7 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/main/include/board.h +61 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/main/touch.cpp +299 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/partitions.csv +7 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/sdkconfig.defaults +50 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/CMakeLists.txt +12 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/CMakeLists.txt +17 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/ed047tc1.c +269 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/ed047tc1.h +142 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/epd_driver.c +1114 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/epd_driver.h +410 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/gea_epd.c +989 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/i2s_data_bus.c +489 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/i2s_data_bus.h +104 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/rmt_pulse.c +136 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/rmt_pulse.h +78 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/utilities.h +49 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/dependencies.lock +35 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/CMakeLists.txt +30 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/Kconfig.projbuild +10 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/app_main.cpp +95 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/audio_stub.cpp +27 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/buttons.cpp +40 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/display.cpp +627 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/i2c.cpp +36 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/idf_component.yml +4 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/imu_stub.cpp +20 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/include/board.h +85 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/include/buttons.h +8 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/launcher_button.cpp +82 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/power.cpp +36 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/sdcard_mount.cpp +90 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/touch.cpp +293 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/partitions.csv +9 -0
- package/targets/esp32-s3-lilygo-t5-epaper-4.7/sdkconfig.defaults +217 -0
- package/targets/esp32-s3-m5stack-papers3/CMakeLists.txt +13 -0
- package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/CMakeLists.txt +5 -0
- package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/include/papers3_epd.h +74 -0
- package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/papers3_epd.c +671 -0
- package/targets/esp32-s3-m5stack-papers3/dependencies.lock +76 -0
- package/targets/esp32-s3-m5stack-papers3/main/CMakeLists.txt +64 -0
- package/targets/esp32-s3-m5stack-papers3/main/Kconfig.projbuild +10 -0
- package/targets/esp32-s3-m5stack-papers3/main/app_main.cpp +96 -0
- package/targets/esp32-s3-m5stack-papers3/main/audio_stub.cpp +27 -0
- package/targets/esp32-s3-m5stack-papers3/main/buttons.cpp +49 -0
- package/targets/esp32-s3-m5stack-papers3/main/display.cpp +706 -0
- package/targets/esp32-s3-m5stack-papers3/main/i2c.cpp +36 -0
- package/targets/esp32-s3-m5stack-papers3/main/idf_component.yml +14 -0
- package/targets/esp32-s3-m5stack-papers3/main/imu.cpp +351 -0
- package/targets/esp32-s3-m5stack-papers3/main/include/board.h +101 -0
- package/targets/esp32-s3-m5stack-papers3/main/include/buttons.h +8 -0
- package/targets/esp32-s3-m5stack-papers3/main/launcher_button.cpp +96 -0
- package/targets/esp32-s3-m5stack-papers3/main/power.cpp +102 -0
- package/targets/esp32-s3-m5stack-papers3/main/sdcard_mount.cpp +88 -0
- package/targets/esp32-s3-m5stack-papers3/main/touch.cpp +287 -0
- package/targets/esp32-s3-m5stack-papers3/partitions.csv +9 -0
- package/targets/esp32-s3-m5stack-papers3/sdkconfig.defaults +232 -0
- package/targets/esp32-s3-m5stack-sticks3/CMakeLists.txt +10 -0
- package/targets/esp32-s3-m5stack-sticks3/dependencies.lock +51 -0
- package/targets/esp32-s3-m5stack-sticks3/main/CMakeLists.txt +51 -0
- package/targets/esp32-s3-m5stack-sticks3/main/Kconfig.projbuild +12 -0
- package/targets/esp32-s3-m5stack-sticks3/main/app_main.cpp +130 -0
- package/targets/esp32-s3-m5stack-sticks3/main/buttons.cpp +101 -0
- package/targets/esp32-s3-m5stack-sticks3/main/display.cpp +1391 -0
- package/targets/esp32-s3-m5stack-sticks3/main/i2c.cpp +39 -0
- package/targets/esp32-s3-m5stack-sticks3/main/idf_component.yml +8 -0
- package/targets/esp32-s3-m5stack-sticks3/main/imu_stub.cpp +9 -0
- package/targets/esp32-s3-m5stack-sticks3/main/include/board.h +89 -0
- package/targets/esp32-s3-m5stack-sticks3/main/include/buttons.h +9 -0
- package/targets/esp32-s3-m5stack-sticks3/main/launcher_button.cpp +191 -0
- package/targets/esp32-s3-m5stack-sticks3/main/power.cpp +15 -0
- package/targets/esp32-s3-m5stack-sticks3/main/sdcard_mount.cpp +8 -0
- package/targets/esp32-s3-m5stack-sticks3/main/touch.cpp +65 -0
- package/targets/esp32-s3-m5stack-sticks3/partitions.csv +8 -0
- package/targets/esp32-s3-m5stack-sticks3/sdkconfig.defaults +130 -0
- package/targets/esp32-s3-touch-amoled-1.75/CMakeLists.txt +10 -0
- package/targets/esp32-s3-touch-amoled-1.75/dependencies.lock +130 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/CMakeLists.txt +589 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/Kconfig.projbuild +12 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/app_main.cpp +153 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/i2c.cpp +39 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/idf_component.yml +9 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/include/board.h +110 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/include/wifi_config.h.example +5 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/launcher_button.cpp +191 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/touch.cpp +45 -0
- package/targets/esp32-s3-touch-amoled-1.75/partitions.csv +8 -0
- package/targets/esp32-s3-touch-amoled-1.75/sdkconfig.defaults +179 -0
- package/targets/esp32-s3-touch-amoled-1.8/CMakeLists.txt +10 -0
- package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +105 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +768 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/Kconfig.projbuild +12 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/app_main.cpp +172 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/i2c.cpp +39 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +8 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/include/board.h +83 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/include/wifi_config.h.example +5 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/launcher_button.cpp +191 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/touch.cpp +41 -0
- package/targets/esp32-s3-touch-amoled-1.8/partitions.csv +8 -0
- package/targets/esp32-s3-touch-amoled-1.8/sdkconfig.defaults +179 -0
- package/targets/esp32-s3-touch-amoled-2.06/CMakeLists.txt +10 -0
- package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +64 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +1121 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/Kconfig.projbuild +12 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/app_main.cpp +333 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/i2c.cpp +39 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +27 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +114 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/include/wifi_config.h.example +5 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/launcher_button.cpp +199 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/sdcard_mount.cpp +105 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/touch.cpp +49 -0
- package/targets/esp32-s3-touch-amoled-2.06/partitions.csv +14 -0
- package/targets/esp32-s3-touch-amoled-2.06/sdkconfig.defaults +273 -0
- package/targets/esp32-s3-touch-amoled-2.41/CMakeLists.txt +10 -0
- package/targets/esp32-s3-touch-amoled-2.41/main/CMakeLists.txt +71 -0
- package/targets/esp32-s3-touch-amoled-2.41/main/Kconfig.projbuild +12 -0
- package/targets/esp32-s3-touch-amoled-2.41/main/idf_component.yml +27 -0
- package/targets/esp32-s3-touch-amoled-2.41/main/include/board.h +108 -0
- package/targets/esp32-s3-touch-amoled-2.41/main/include/wifi_config.h.example +5 -0
- package/targets/esp32-s3-touch-amoled-2.41/main/panel_reset.cpp +82 -0
- package/targets/esp32-s3-touch-amoled-2.41/main/touch.cpp +49 -0
- package/targets/esp32-s3-touch-amoled-2.41/partitions.csv +8 -0
- package/targets/esp32-s3-touch-amoled-2.41/sdkconfig.defaults +273 -0
- package/targets/rp2350-tufty-2350/CMakeLists.txt +348 -0
- package/targets/rp2350-tufty-2350/README.md +53 -0
- package/targets/rp2350-tufty-2350/boards/pimoroni_tufty2350.h +87 -0
- package/targets/rp2350-tufty-2350/main/bringup.cpp +187 -0
- package/targets/rp2350-tufty-2350/main/include/board.h +124 -0
- package/targets/rp2350-tufty-2350/main/rp2350_panel.cpp +428 -0
- package/targets/rp2350-tufty-2350/main/rp2350_panel.h +46 -0
- package/targets/rp2350-tufty-2350/main/st7789_parallel.pio +7 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/CMakeLists.txt +345 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/README.md +153 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/boards/waveshare_rp2350_touch_amoled_2_41.h +59 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/app.cpp +984 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/bringup.cpp +222 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/include/board.h +138 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.cpp +2553 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.h +18 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_host_fetch_stub.cpp +64 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.cpp +677 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.h +48 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/rp_pico_alloc.c +354 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/rp_pico_alloc.h +56 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf.c +1284 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf.h +95 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf_block_functions.h +123 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf_common.h +127 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/tools/rp2350-scroll-bench.py +162 -0
- package/targets/rp2350-waveshare-touch-amoled-2.41/tools/rp2350-scroll-parity.py +198 -0
- package/targets.json +154 -0
|
@@ -0,0 +1,1338 @@
|
|
|
1
|
+
#include "display.h"
|
|
2
|
+
|
|
3
|
+
#include "board.h"
|
|
4
|
+
#include "canvas.h"
|
|
5
|
+
#include "display_present.h"
|
|
6
|
+
#include "pcf8574.h"
|
|
7
|
+
|
|
8
|
+
#ifndef GEA_EMBEDDED_DISPLAY_RGB_STRIP_RASTER
|
|
9
|
+
// Strip-raster fused present: compose each horizontal strip in INTERNAL SRAM
|
|
10
|
+
// (fast, cached, no contention with the RGB panel's continuous PSRAM scanout),
|
|
11
|
+
// then bulk-copy the finished strip straight to the live scanout framebuffer.
|
|
12
|
+
// Replaces the slow "raster 1000 scattered circles directly into the PSRAM back
|
|
13
|
+
// buffer (75ms under scanout contention) + memcpy back->scanout (36ms)" path for
|
|
14
|
+
// full-screen-redraw frames. Still composes each strip fully off-screen, so it is
|
|
15
|
+
// tear-equivalent to the double buffer (never exposes clear-then-draw intermediates).
|
|
16
|
+
#define GEA_EMBEDDED_DISPLAY_RGB_STRIP_RASTER 1
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
#include "driver/gpio.h"
|
|
20
|
+
#include "driver/ledc.h"
|
|
21
|
+
#include "esp_cache.h"
|
|
22
|
+
#include "esp_heap_caps.h"
|
|
23
|
+
#include "esp_lcd_panel_ops.h"
|
|
24
|
+
#include "esp_lcd_panel_rgb.h"
|
|
25
|
+
#include "esp_log.h"
|
|
26
|
+
#include "esp_rom_sys.h"
|
|
27
|
+
#include "esp_timer.h"
|
|
28
|
+
#include "freertos/FreeRTOS.h"
|
|
29
|
+
#include "freertos/task.h"
|
|
30
|
+
#include "soc/clk_tree_defs.h"
|
|
31
|
+
|
|
32
|
+
#include <algorithm>
|
|
33
|
+
#include <atomic>
|
|
34
|
+
#include <cstdint>
|
|
35
|
+
#include <cstdio>
|
|
36
|
+
#include <cstring>
|
|
37
|
+
|
|
38
|
+
// Second-core worker (defined later in this file). Used by the strip-raster path to
|
|
39
|
+
// copy a finished strip to the PSRAM scanout buffer on the other core while this
|
|
40
|
+
// core rasters the next strip into SRAM.
|
|
41
|
+
extern "C" bool gea_render_parallel_rows_submit(void (*fn)(void *, int, int), void *ctx, int y0, int y1);
|
|
42
|
+
extern "C" void gea_render_parallel_wait();
|
|
43
|
+
|
|
44
|
+
namespace {
|
|
45
|
+
|
|
46
|
+
constexpr const char *kTag = "elecrow_rgb";
|
|
47
|
+
constexpr int kWidth = gea::platform::display::kWidth;
|
|
48
|
+
constexpr int kHeight = gea::platform::display::kHeight;
|
|
49
|
+
constexpr std::size_t kPixelCount = static_cast<std::size_t>(kWidth) * static_cast<std::size_t>(kHeight);
|
|
50
|
+
constexpr std::size_t kFramebufferBytes = kPixelCount * sizeof(std::uint16_t);
|
|
51
|
+
constexpr int kRgbBounceRows = 20;
|
|
52
|
+
constexpr std::size_t kRgbBounceBufferPixels = static_cast<std::size_t>(kWidth) * kRgbBounceRows;
|
|
53
|
+
static_assert(kPixelCount % kRgbBounceBufferPixels == 0, "RGB bounce buffer must divide the framebuffer evenly");
|
|
54
|
+
constexpr ledc_mode_t kBacklightLedcMode = LEDC_LOW_SPEED_MODE;
|
|
55
|
+
constexpr ledc_channel_t kBacklightLedcChannel = LEDC_CHANNEL_0;
|
|
56
|
+
constexpr ledc_timer_t kBacklightLedcTimer = LEDC_TIMER_0;
|
|
57
|
+
constexpr ledc_timer_bit_t kBacklightLedcDutyResolution = LEDC_TIMER_10_BIT;
|
|
58
|
+
constexpr std::uint32_t kBacklightLedcMaxDuty = (1u << 10) - 1u;
|
|
59
|
+
|
|
60
|
+
namespace present = gea::framework::display_present;
|
|
61
|
+
|
|
62
|
+
// Internal-SRAM scratch strips that the fused present path composes into before
|
|
63
|
+
// copying to the PSRAM scanout buffer. Double-buffered: while core0 rasters strip
|
|
64
|
+
// N+1 into one half (SRAM), the worker core copies strip N from the other half to
|
|
65
|
+
// scanout (PSRAM) — different buffers, different buses, so they overlap with no
|
|
66
|
+
// contention. Two 24-row strips fit the same 46KB block one 48-row strip used.
|
|
67
|
+
constexpr int kStripRows = 24;
|
|
68
|
+
constexpr int kStripBufferRows = kStripRows * 2;
|
|
69
|
+
constexpr std::size_t kStripBufferPixels = static_cast<std::size_t>(kWidth) * kStripBufferRows;
|
|
70
|
+
|
|
71
|
+
gea::framework::graphics::Canvas g_canvas;
|
|
72
|
+
// Band canvas for the renderer's coarse 2-core replay split: bound to the SAME
|
|
73
|
+
// back buffer as g_canvas but with a private clip stack + dirty accumulator, so
|
|
74
|
+
// the worker core's band replay never races the main core on clip/dirty state.
|
|
75
|
+
// g_renderCoreId is the core the renderer submits from (recorded per
|
|
76
|
+
// gea_render_parallel_submit); Display draw calls on any OTHER core are the
|
|
77
|
+
// worker's band replay and route here via replayCanvas().
|
|
78
|
+
gea::framework::graphics::Canvas g_workerCanvas;
|
|
79
|
+
int g_renderCoreId = -1;
|
|
80
|
+
|
|
81
|
+
bool onWorkerCore()
|
|
82
|
+
{
|
|
83
|
+
return g_renderCoreId >= 0 && static_cast<int>(xPortGetCoreID()) != g_renderCoreId;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
gea::framework::graphics::Canvas &replayCanvas()
|
|
87
|
+
{
|
|
88
|
+
return onWorkerCore() ? g_workerCanvas : g_canvas;
|
|
89
|
+
}
|
|
90
|
+
esp_lcd_panel_handle_t g_panel = nullptr;
|
|
91
|
+
std::uint16_t *g_framebuffer = nullptr;
|
|
92
|
+
std::uint16_t *g_drawFramebuffer = nullptr;
|
|
93
|
+
std::uint16_t *g_stripBuffer = nullptr;
|
|
94
|
+
// The strip path publishes straight to scanout and leaves g_drawFramebuffer
|
|
95
|
+
// untouched. If a later frame falls back to the per-command path (partial
|
|
96
|
+
// present with no full-screen base), re-sync the back buffer once first.
|
|
97
|
+
bool g_drawBufferStale = false;
|
|
98
|
+
bool g_initialized = false;
|
|
99
|
+
bool g_backlightPwmInitialized = false;
|
|
100
|
+
int g_brightness = 100;
|
|
101
|
+
int g_flushRows = kHeight;
|
|
102
|
+
int g_flushDepth = 1;
|
|
103
|
+
gea::platform::display::DisplayFlushPerfStats g_stats = {};
|
|
104
|
+
|
|
105
|
+
bool clipRect(int *x0, int *y0, int *x1, int *y1);
|
|
106
|
+
|
|
107
|
+
struct InitCommand {
|
|
108
|
+
std::uint8_t command;
|
|
109
|
+
std::uint8_t data[16];
|
|
110
|
+
std::uint8_t length;
|
|
111
|
+
std::uint16_t delayMs;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
constexpr InitCommand kSt7701Init[] = {
|
|
115
|
+
{0x01, {}, 0, 120},
|
|
116
|
+
{0xff, {0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
|
|
117
|
+
{0xc0, {0x3b, 0x00}, 2, 0},
|
|
118
|
+
{0xc1, {0x0b, 0x02}, 2, 0},
|
|
119
|
+
{0xc2, {0x00, 0x02}, 2, 0},
|
|
120
|
+
{0xcc, {0x10}, 1, 0},
|
|
121
|
+
{0xcd, {0x08}, 1, 0},
|
|
122
|
+
{0xb0, {0x02, 0x13, 0x1b, 0x0d, 0x10, 0x05, 0x08, 0x07, 0x07, 0x24, 0x04, 0x11, 0x0e, 0x2c, 0x33, 0x1d}, 16, 0},
|
|
123
|
+
{0xb1, {0x05, 0x13, 0x1b, 0x0d, 0x11, 0x05, 0x08, 0x07, 0x07, 0x24, 0x04, 0x11, 0x0e, 0x2c, 0x33, 0x1d}, 16, 0},
|
|
124
|
+
{0xff, {0x77, 0x01, 0x00, 0x00, 0x11}, 5, 0},
|
|
125
|
+
{0xb0, {0x5d}, 1, 0},
|
|
126
|
+
{0xb1, {0x43}, 1, 0},
|
|
127
|
+
{0xb2, {0x81}, 1, 0},
|
|
128
|
+
{0xb3, {0x80}, 1, 0},
|
|
129
|
+
{0xb5, {0x43}, 1, 0},
|
|
130
|
+
{0xb7, {0x85}, 1, 0},
|
|
131
|
+
{0xb8, {0x20}, 1, 0},
|
|
132
|
+
{0xc1, {0x78}, 1, 0},
|
|
133
|
+
{0xc2, {0x78}, 1, 0},
|
|
134
|
+
{0xd0, {0x88}, 1, 0},
|
|
135
|
+
{0xe0, {0x00, 0x00, 0x02}, 3, 0},
|
|
136
|
+
{0xe1, {0x03, 0xa0, 0x00, 0x00, 0x04, 0xa0, 0x00, 0x00, 0x00, 0x20, 0x20}, 11, 0},
|
|
137
|
+
{0xe2, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 13, 0},
|
|
138
|
+
{0xe3, {0x00, 0x00, 0x11, 0x00}, 4, 0},
|
|
139
|
+
{0xe4, {0x22, 0x00}, 2, 0},
|
|
140
|
+
{0xe5, {0x05, 0xec, 0xa0, 0xa0, 0x07, 0xee, 0xa0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 16, 0},
|
|
141
|
+
{0xe6, {0x00, 0x00, 0x11, 0x00}, 4, 0},
|
|
142
|
+
{0xe7, {0x22, 0x00}, 2, 0},
|
|
143
|
+
{0xe8, {0x06, 0xed, 0xa0, 0xa0, 0x08, 0xef, 0xa0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 16, 0},
|
|
144
|
+
{0xeb, {0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00}, 7, 0},
|
|
145
|
+
{0xed, {0xff, 0xff, 0xff, 0xba, 0x0a, 0xbf, 0x45, 0xff, 0xff, 0x54, 0xfb, 0xa0, 0xab, 0xff, 0xff, 0xff}, 16, 0},
|
|
146
|
+
{0xef, {0x10, 0x0d, 0x04, 0x08, 0x3f, 0x1f}, 6, 0},
|
|
147
|
+
{0xff, {0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0},
|
|
148
|
+
{0xef, {0x08}, 1, 0},
|
|
149
|
+
{0xff, {0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0},
|
|
150
|
+
{0x36, {0x00}, 1, 0},
|
|
151
|
+
{0x3a, {0x60}, 1, 0},
|
|
152
|
+
{0x11, {}, 0, 120},
|
|
153
|
+
{0x29, {}, 0, 50},
|
|
154
|
+
{0x20, {}, 0, 0},
|
|
155
|
+
{0xff, {0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
|
|
156
|
+
{0xc7, {0x00}, 1, 0},
|
|
157
|
+
{0xff, {0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0},
|
|
158
|
+
{0x36, {0x00}, 1, 0},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
void cacheWritebackAll()
|
|
162
|
+
{
|
|
163
|
+
if (!g_framebuffer) return;
|
|
164
|
+
esp_cache_msync(g_framebuffer,
|
|
165
|
+
kFramebufferBytes,
|
|
166
|
+
ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
void cacheWritebackRect(int x0, int y0, int x1, int y1)
|
|
170
|
+
{
|
|
171
|
+
if (!g_framebuffer || !clipRect(&x0, &y0, &x1, &y1)) return;
|
|
172
|
+
const std::size_t begin = static_cast<std::size_t>(y0) * kWidth + static_cast<std::size_t>(x0);
|
|
173
|
+
const std::size_t end = static_cast<std::size_t>(y1) * kWidth + static_cast<std::size_t>(x1) + 1;
|
|
174
|
+
if (end <= begin || end > kPixelCount) return;
|
|
175
|
+
esp_cache_msync(&g_framebuffer[begin],
|
|
176
|
+
(end - begin) * sizeof(std::uint16_t),
|
|
177
|
+
ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
void addFlushStats(int64_t totalUs, int pixelCount)
|
|
181
|
+
{
|
|
182
|
+
g_stats.totalUs += totalUs;
|
|
183
|
+
g_stats.callCount += 1;
|
|
184
|
+
g_stats.pixelCount += pixelCount;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
void addFlushStageStats(int64_t copyUs, int64_t cacheUs)
|
|
188
|
+
{
|
|
189
|
+
g_stats.copyUs += copyUs;
|
|
190
|
+
g_stats.completeWaitUs += cacheUs;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
void configureGpioOutput(gpio_num_t pin, int level)
|
|
194
|
+
{
|
|
195
|
+
gpio_reset_pin(pin);
|
|
196
|
+
gpio_config_t config = {};
|
|
197
|
+
config.pin_bit_mask = 1ULL << pin;
|
|
198
|
+
config.mode = GPIO_MODE_OUTPUT;
|
|
199
|
+
config.pull_up_en = GPIO_PULLUP_DISABLE;
|
|
200
|
+
config.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
|
201
|
+
config.intr_type = GPIO_INTR_DISABLE;
|
|
202
|
+
gpio_config(&config);
|
|
203
|
+
gpio_set_level(pin, level);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
void configureControlPins()
|
|
207
|
+
{
|
|
208
|
+
const auto &display = gea::platform::board::display;
|
|
209
|
+
configureGpioOutput(display.spiCs, 1);
|
|
210
|
+
configureGpioOutput(display.spiSck, 0);
|
|
211
|
+
configureGpioOutput(display.spiSda, 0);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
void writeControlBit(bool value)
|
|
215
|
+
{
|
|
216
|
+
const auto &display = gea::platform::board::display;
|
|
217
|
+
gpio_set_level(display.spiSda, value ? 1 : 0);
|
|
218
|
+
gpio_set_level(display.spiSck, 1);
|
|
219
|
+
esp_rom_delay_us(1);
|
|
220
|
+
gpio_set_level(display.spiSck, 0);
|
|
221
|
+
esp_rom_delay_us(1);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
void writeControlWord(bool dataWord, std::uint8_t value)
|
|
225
|
+
{
|
|
226
|
+
writeControlBit(dataWord);
|
|
227
|
+
for (int bit = 7; bit >= 0; --bit) {
|
|
228
|
+
writeControlBit((value >> bit) & 1);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
void sendInitCommandsBatched()
|
|
233
|
+
{
|
|
234
|
+
const auto &display = gea::platform::board::display;
|
|
235
|
+
gpio_set_level(display.spiCs, 0);
|
|
236
|
+
bool selected = true;
|
|
237
|
+
for (const auto &cmd : kSt7701Init) {
|
|
238
|
+
if (!selected) {
|
|
239
|
+
gpio_set_level(display.spiCs, 0);
|
|
240
|
+
selected = true;
|
|
241
|
+
}
|
|
242
|
+
writeControlWord(false, cmd.command);
|
|
243
|
+
for (int i = 0; i < cmd.length; ++i) {
|
|
244
|
+
writeControlWord(true, cmd.data[i]);
|
|
245
|
+
}
|
|
246
|
+
if (cmd.delayMs > 0) {
|
|
247
|
+
gpio_set_level(display.spiCs, 1);
|
|
248
|
+
selected = false;
|
|
249
|
+
vTaskDelay(pdMS_TO_TICKS(cmd.delayMs));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (selected) gpio_set_level(display.spiCs, 1);
|
|
253
|
+
esp_rom_delay_us(5);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
esp_err_t powerAndResetPanel()
|
|
257
|
+
{
|
|
258
|
+
esp_err_t err = gea::platform::elecrow::Pcf8574::init();
|
|
259
|
+
if (err != ESP_OK) return err;
|
|
260
|
+
|
|
261
|
+
err = gea::platform::elecrow::Pcf8574::writePin(gea::platform::board::expander.lcdPowerBit, true);
|
|
262
|
+
if (err != ESP_OK) return err;
|
|
263
|
+
vTaskDelay(pdMS_TO_TICKS(100));
|
|
264
|
+
|
|
265
|
+
err = gea::platform::elecrow::Pcf8574::writePin(gea::platform::board::expander.lcdResetBit, true);
|
|
266
|
+
if (err != ESP_OK) return err;
|
|
267
|
+
vTaskDelay(pdMS_TO_TICKS(100));
|
|
268
|
+
err = gea::platform::elecrow::Pcf8574::writePin(gea::platform::board::expander.lcdResetBit, false);
|
|
269
|
+
if (err != ESP_OK) return err;
|
|
270
|
+
vTaskDelay(pdMS_TO_TICKS(120));
|
|
271
|
+
err = gea::platform::elecrow::Pcf8574::writePin(gea::platform::board::expander.lcdResetBit, true);
|
|
272
|
+
if (err != ESP_OK) return err;
|
|
273
|
+
vTaskDelay(pdMS_TO_TICKS(120));
|
|
274
|
+
|
|
275
|
+
err = gea::platform::elecrow::Pcf8574::writePin(gea::platform::board::expander.touchResetBit, true);
|
|
276
|
+
if (err != ESP_OK) return err;
|
|
277
|
+
vTaskDelay(pdMS_TO_TICKS(100));
|
|
278
|
+
err = gea::platform::elecrow::Pcf8574::writePin(gea::platform::board::expander.touchResetBit, false);
|
|
279
|
+
if (err != ESP_OK) return err;
|
|
280
|
+
vTaskDelay(pdMS_TO_TICKS(120));
|
|
281
|
+
err = gea::platform::elecrow::Pcf8574::writePin(gea::platform::board::expander.touchResetBit, true);
|
|
282
|
+
if (err != ESP_OK) return err;
|
|
283
|
+
vTaskDelay(pdMS_TO_TICKS(120));
|
|
284
|
+
err = gea::platform::elecrow::Pcf8574::writePin(gea::platform::board::expander.touchInterruptBit, true);
|
|
285
|
+
if (err != ESP_OK) return err;
|
|
286
|
+
vTaskDelay(pdMS_TO_TICKS(120));
|
|
287
|
+
return ESP_OK;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
esp_err_t initSt7701()
|
|
291
|
+
{
|
|
292
|
+
configureControlPins();
|
|
293
|
+
esp_err_t err = powerAndResetPanel();
|
|
294
|
+
if (err != ESP_OK) return err;
|
|
295
|
+
|
|
296
|
+
sendInitCommandsBatched();
|
|
297
|
+
return ESP_OK;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
esp_err_t updateBacklightDuty()
|
|
301
|
+
{
|
|
302
|
+
if (!g_backlightPwmInitialized) return ESP_OK;
|
|
303
|
+
const std::uint32_t duty = (kBacklightLedcMaxDuty * static_cast<std::uint32_t>(g_brightness)) / 100u;
|
|
304
|
+
esp_err_t err = ledc_set_duty(kBacklightLedcMode, kBacklightLedcChannel, duty);
|
|
305
|
+
if (err != ESP_OK) {
|
|
306
|
+
ESP_LOGE(kTag, "failed to set backlight duty: %s", esp_err_to_name(err));
|
|
307
|
+
return err;
|
|
308
|
+
}
|
|
309
|
+
err = ledc_update_duty(kBacklightLedcMode, kBacklightLedcChannel);
|
|
310
|
+
if (err != ESP_OK) {
|
|
311
|
+
ESP_LOGE(kTag, "failed to update backlight duty: %s", esp_err_to_name(err));
|
|
312
|
+
return err;
|
|
313
|
+
}
|
|
314
|
+
return ESP_OK;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
esp_err_t initBacklight()
|
|
318
|
+
{
|
|
319
|
+
ledc_timer_config_t timerConfig = {};
|
|
320
|
+
timerConfig.speed_mode = kBacklightLedcMode;
|
|
321
|
+
timerConfig.timer_num = kBacklightLedcTimer;
|
|
322
|
+
timerConfig.duty_resolution = kBacklightLedcDutyResolution;
|
|
323
|
+
timerConfig.freq_hz = 5000;
|
|
324
|
+
timerConfig.clk_cfg = LEDC_AUTO_CLK;
|
|
325
|
+
esp_err_t err = ledc_timer_config(&timerConfig);
|
|
326
|
+
if (err != ESP_OK) {
|
|
327
|
+
ESP_LOGE(kTag, "failed to configure backlight LEDC timer: %s", esp_err_to_name(err));
|
|
328
|
+
return err;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
ledc_channel_config_t channelConfig = {};
|
|
332
|
+
channelConfig.gpio_num = gea::platform::board::display.backlight;
|
|
333
|
+
channelConfig.speed_mode = kBacklightLedcMode;
|
|
334
|
+
channelConfig.channel = kBacklightLedcChannel;
|
|
335
|
+
channelConfig.timer_sel = kBacklightLedcTimer;
|
|
336
|
+
channelConfig.duty = kBacklightLedcMaxDuty;
|
|
337
|
+
channelConfig.hpoint = 0;
|
|
338
|
+
err = ledc_channel_config(&channelConfig);
|
|
339
|
+
if (err != ESP_OK) {
|
|
340
|
+
ESP_LOGE(kTag, "failed to configure backlight LEDC channel: %s", esp_err_to_name(err));
|
|
341
|
+
return err;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
g_backlightPwmInitialized = true;
|
|
345
|
+
return updateBacklightDuty();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
esp_err_t initRgbPanel()
|
|
349
|
+
{
|
|
350
|
+
const auto &display = gea::platform::board::display;
|
|
351
|
+
esp_lcd_rgb_panel_config_t config = {};
|
|
352
|
+
config.clk_src = LCD_CLK_SRC_PLL160M;
|
|
353
|
+
config.timings.pclk_hz = display.pclkHz;
|
|
354
|
+
config.timings.h_res = kWidth;
|
|
355
|
+
config.timings.v_res = kHeight;
|
|
356
|
+
config.timings.hsync_pulse_width = display.hsyncPulseWidth;
|
|
357
|
+
config.timings.hsync_back_porch = display.hsyncBackPorch;
|
|
358
|
+
config.timings.hsync_front_porch = display.hsyncFrontPorch;
|
|
359
|
+
config.timings.vsync_pulse_width = display.vsyncPulseWidth;
|
|
360
|
+
config.timings.vsync_back_porch = display.vsyncBackPorch;
|
|
361
|
+
config.timings.vsync_front_porch = display.vsyncFrontPorch;
|
|
362
|
+
config.timings.flags.pclk_active_neg = display.pclkActiveNeg ? 1 : 0;
|
|
363
|
+
config.data_width = 16;
|
|
364
|
+
config.in_color_format = LCD_COLOR_FMT_RGB565;
|
|
365
|
+
config.out_color_format = LCD_COLOR_FMT_RGB565;
|
|
366
|
+
config.num_fbs = 1;
|
|
367
|
+
// Bounce buffers vs direct PSRAM scanout: with bounce, a core-0 ISR memcpys
|
|
368
|
+
// every scanline batch from PSRAM into internal SRAM (~27.6MB/s at 12MHz pclk)
|
|
369
|
+
// — a standing ~30% CPU tax on the render core. With 0 the GDMA reads the
|
|
370
|
+
// PSRAM framebuffer directly (no CPU in the scanout path); risk is scanout
|
|
371
|
+
// underrun (visible drift) when CPU PSRAM traffic starves the DMA.
|
|
372
|
+
#ifndef GEA_EMBEDDED_DISPLAY_RGB_BOUNCE
|
|
373
|
+
#define GEA_EMBEDDED_DISPLAY_RGB_BOUNCE 1
|
|
374
|
+
#endif
|
|
375
|
+
#if GEA_EMBEDDED_DISPLAY_RGB_BOUNCE
|
|
376
|
+
config.bounce_buffer_size_px = kRgbBounceBufferPixels;
|
|
377
|
+
#else
|
|
378
|
+
config.bounce_buffer_size_px = 0;
|
|
379
|
+
#endif
|
|
380
|
+
config.dma_burst_size = 64;
|
|
381
|
+
config.hsync_gpio_num = display.hsync;
|
|
382
|
+
config.vsync_gpio_num = display.vsync;
|
|
383
|
+
config.de_gpio_num = display.de;
|
|
384
|
+
config.pclk_gpio_num = display.pclk;
|
|
385
|
+
config.disp_gpio_num = GPIO_NUM_NC;
|
|
386
|
+
config.data_gpio_nums[0] = display.b0;
|
|
387
|
+
config.data_gpio_nums[1] = display.b1;
|
|
388
|
+
config.data_gpio_nums[2] = display.b2;
|
|
389
|
+
config.data_gpio_nums[3] = display.b3;
|
|
390
|
+
config.data_gpio_nums[4] = display.b4;
|
|
391
|
+
config.data_gpio_nums[5] = display.g0;
|
|
392
|
+
config.data_gpio_nums[6] = display.g1;
|
|
393
|
+
config.data_gpio_nums[7] = display.g2;
|
|
394
|
+
config.data_gpio_nums[8] = display.g3;
|
|
395
|
+
config.data_gpio_nums[9] = display.g4;
|
|
396
|
+
config.data_gpio_nums[10] = display.g5;
|
|
397
|
+
config.data_gpio_nums[11] = display.r0;
|
|
398
|
+
config.data_gpio_nums[12] = display.r1;
|
|
399
|
+
config.data_gpio_nums[13] = display.r2;
|
|
400
|
+
config.data_gpio_nums[14] = display.r3;
|
|
401
|
+
config.data_gpio_nums[15] = display.r4;
|
|
402
|
+
config.flags.fb_in_psram = 1;
|
|
403
|
+
|
|
404
|
+
esp_err_t err = esp_lcd_new_rgb_panel(&config, &g_panel);
|
|
405
|
+
if (err != ESP_OK) {
|
|
406
|
+
ESP_LOGE(kTag, "failed to create RGB panel: %s", esp_err_to_name(err));
|
|
407
|
+
return err;
|
|
408
|
+
}
|
|
409
|
+
err = esp_lcd_panel_reset(g_panel);
|
|
410
|
+
if (err != ESP_OK) return err;
|
|
411
|
+
err = esp_lcd_panel_init(g_panel);
|
|
412
|
+
if (err != ESP_OK) return err;
|
|
413
|
+
|
|
414
|
+
void *fb = nullptr;
|
|
415
|
+
err = esp_lcd_rgb_panel_get_frame_buffer(g_panel, 1, &fb);
|
|
416
|
+
if (err != ESP_OK) {
|
|
417
|
+
ESP_LOGE(kTag, "failed to get RGB framebuffer: %s", esp_err_to_name(err));
|
|
418
|
+
return err;
|
|
419
|
+
}
|
|
420
|
+
g_framebuffer = static_cast<std::uint16_t *>(fb);
|
|
421
|
+
if (!g_framebuffer) return ESP_ERR_NO_MEM;
|
|
422
|
+
|
|
423
|
+
// Double buffer: the panel framebuffer (g_framebuffer) is continuously scanned out,
|
|
424
|
+
// so drawing directly into it exposes every intermediate step (e.g. a tick's
|
|
425
|
+
// background clears, THEN the tick paints — a visible flash). Render into a separate
|
|
426
|
+
// PSRAM back buffer instead; publishDrawRect() copies the fully-composited dirty
|
|
427
|
+
// region into the scanout framebuffer in one shot, so the panel only ever sees
|
|
428
|
+
// finished pixels. Falls back to single-buffered direct draw if PSRAM is exhausted.
|
|
429
|
+
g_drawFramebuffer = static_cast<std::uint16_t *>(
|
|
430
|
+
heap_caps_malloc(kFramebufferBytes, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT));
|
|
431
|
+
if (!g_drawFramebuffer) {
|
|
432
|
+
ESP_LOGW(kTag, "no PSRAM for back buffer; falling back to single-buffered draw");
|
|
433
|
+
g_drawFramebuffer = g_framebuffer;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
std::memset(g_framebuffer, 0, kFramebufferBytes);
|
|
437
|
+
if (g_drawFramebuffer != g_framebuffer) std::memset(g_drawFramebuffer, 0, kFramebufferBytes);
|
|
438
|
+
cacheWritebackAll();
|
|
439
|
+
g_canvas.bindPixels(g_drawFramebuffer, kWidth, kHeight);
|
|
440
|
+
g_workerCanvas.bindPixels(g_drawFramebuffer, kWidth, kHeight);
|
|
441
|
+
|
|
442
|
+
#if GEA_EMBEDDED_DISPLAY_RGB_STRIP_RASTER
|
|
443
|
+
// Internal SRAM (not PSRAM): the whole point is to raster off the scanout bus.
|
|
444
|
+
// 16-byte aligned: rows are 960B (16-multiple), so an aligned base keeps every
|
|
445
|
+
// staged-replay row 16-aligned — maximal PIE-SIMD span coverage per scanline.
|
|
446
|
+
g_stripBuffer = static_cast<std::uint16_t *>(
|
|
447
|
+
heap_caps_aligned_alloc(16, kStripBufferPixels * sizeof(std::uint16_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT));
|
|
448
|
+
ESP_LOGI(kTag, "strip-raster %s strip_buf=%p rows=%d",
|
|
449
|
+
g_stripBuffer ? "ON" : "OFF (no internal SRAM)", g_stripBuffer, kStripRows);
|
|
450
|
+
#endif
|
|
451
|
+
ESP_LOGI(kTag, "RGB panel ready %dx%d pclk=%d bounce_rows=%d fb=%p draw_fb=%p single_fb=%d",
|
|
452
|
+
kWidth,
|
|
453
|
+
kHeight,
|
|
454
|
+
display.pclkHz,
|
|
455
|
+
kRgbBounceRows,
|
|
456
|
+
g_framebuffer,
|
|
457
|
+
g_drawFramebuffer,
|
|
458
|
+
g_framebuffer == g_drawFramebuffer ? 1 : 0);
|
|
459
|
+
return ESP_OK;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
void replayPresentCommand(const gea::platform::display::DisplayPresentCommand &command)
|
|
463
|
+
{
|
|
464
|
+
using Type = gea::platform::display::DisplayPresentCommandType;
|
|
465
|
+
switch (command.type) {
|
|
466
|
+
case Type::Clear:
|
|
467
|
+
g_canvas.clear(command.clear.color);
|
|
468
|
+
break;
|
|
469
|
+
case Type::FillRectRgb565:
|
|
470
|
+
g_canvas.setGlobalAlpha(command.fillRectRgb565.alpha);
|
|
471
|
+
g_canvas.fillRect(command.fillRectRgb565.x,
|
|
472
|
+
command.fillRectRgb565.y,
|
|
473
|
+
command.fillRectRgb565.w,
|
|
474
|
+
command.fillRectRgb565.h,
|
|
475
|
+
command.fillRectRgb565.color);
|
|
476
|
+
break;
|
|
477
|
+
case Type::StrokeRectRgb565:
|
|
478
|
+
g_canvas.setGlobalAlpha(command.strokeRectRgb565.alpha);
|
|
479
|
+
g_canvas.strokeRect(command.strokeRectRgb565.x,
|
|
480
|
+
command.strokeRectRgb565.y,
|
|
481
|
+
command.strokeRectRgb565.w,
|
|
482
|
+
command.strokeRectRgb565.h,
|
|
483
|
+
command.strokeRectRgb565.color);
|
|
484
|
+
break;
|
|
485
|
+
case Type::FillTriangleRgb565:
|
|
486
|
+
g_canvas.setGlobalAlpha(command.fillTriangleRgb565.alpha);
|
|
487
|
+
g_canvas.fillTriangle(command.fillTriangleRgb565.x0,
|
|
488
|
+
command.fillTriangleRgb565.y0,
|
|
489
|
+
command.fillTriangleRgb565.x1,
|
|
490
|
+
command.fillTriangleRgb565.y1,
|
|
491
|
+
command.fillTriangleRgb565.x2,
|
|
492
|
+
command.fillTriangleRgb565.y2,
|
|
493
|
+
command.fillTriangleRgb565.color);
|
|
494
|
+
break;
|
|
495
|
+
case Type::FillCircleRgb565:
|
|
496
|
+
g_canvas.setGlobalAlpha(command.fillCircleRgb565.alpha);
|
|
497
|
+
g_canvas.fillCircle(command.fillCircleRgb565.x,
|
|
498
|
+
command.fillCircleRgb565.y,
|
|
499
|
+
command.fillCircleRgb565.radius,
|
|
500
|
+
command.fillCircleRgb565.color);
|
|
501
|
+
break;
|
|
502
|
+
case Type::StrokeCircleRgb565:
|
|
503
|
+
g_canvas.setGlobalAlpha(command.strokeCircleRgb565.alpha);
|
|
504
|
+
g_canvas.strokeCircle(command.strokeCircleRgb565.x,
|
|
505
|
+
command.strokeCircleRgb565.y,
|
|
506
|
+
command.strokeCircleRgb565.radius,
|
|
507
|
+
command.strokeCircleRgb565.color);
|
|
508
|
+
break;
|
|
509
|
+
case Type::FillCirclesRgb565:
|
|
510
|
+
g_canvas.setGlobalAlpha(command.fillCirclesRgb565.alpha);
|
|
511
|
+
g_canvas.fillCirclesRgb565(command.fillCirclesRgb565.xs,
|
|
512
|
+
command.fillCirclesRgb565.ys,
|
|
513
|
+
command.fillCirclesRgb565.count,
|
|
514
|
+
command.fillCirclesRgb565.radius,
|
|
515
|
+
command.fillCirclesRgb565.colors);
|
|
516
|
+
break;
|
|
517
|
+
case Type::DrawImage:
|
|
518
|
+
g_canvas.setGlobalAlpha(command.drawImage.alpha);
|
|
519
|
+
g_canvas.drawImage(command.drawImage.pixels,
|
|
520
|
+
command.drawImage.alphaPixels,
|
|
521
|
+
command.drawImage.srcWidth,
|
|
522
|
+
command.drawImage.srcHeight,
|
|
523
|
+
command.drawImage.x,
|
|
524
|
+
command.drawImage.y);
|
|
525
|
+
break;
|
|
526
|
+
case Type::DrawImageScaled:
|
|
527
|
+
g_canvas.setGlobalAlpha(command.drawImageScaled.alpha);
|
|
528
|
+
g_canvas.drawImage(command.drawImageScaled.pixels,
|
|
529
|
+
command.drawImageScaled.alphaPixels,
|
|
530
|
+
command.drawImageScaled.srcWidth,
|
|
531
|
+
command.drawImageScaled.srcHeight,
|
|
532
|
+
command.drawImageScaled.x,
|
|
533
|
+
command.drawImageScaled.y,
|
|
534
|
+
command.drawImageScaled.w,
|
|
535
|
+
command.drawImageScaled.h);
|
|
536
|
+
break;
|
|
537
|
+
case Type::DrawImageRotated90CW:
|
|
538
|
+
g_canvas.setGlobalAlpha(command.drawImageRotated90CW.alpha);
|
|
539
|
+
g_canvas.drawImageRotated90CW(command.drawImageRotated90CW.pixels,
|
|
540
|
+
command.drawImageRotated90CW.alphaPixels,
|
|
541
|
+
command.drawImageRotated90CW.srcWidth,
|
|
542
|
+
command.drawImageRotated90CW.srcHeight,
|
|
543
|
+
command.drawImageRotated90CW.x,
|
|
544
|
+
command.drawImageRotated90CW.y,
|
|
545
|
+
command.drawImageRotated90CW.w,
|
|
546
|
+
command.drawImageRotated90CW.h);
|
|
547
|
+
break;
|
|
548
|
+
case Type::DrawImageTiledX:
|
|
549
|
+
g_canvas.setGlobalAlpha(command.drawImageTiledX.alpha);
|
|
550
|
+
g_canvas.drawImageTiledX(command.drawImageTiledX.pixels,
|
|
551
|
+
command.drawImageTiledX.alphaPixels,
|
|
552
|
+
command.drawImageTiledX.srcWidth,
|
|
553
|
+
command.drawImageTiledX.srcHeight,
|
|
554
|
+
command.drawImageTiledX.x,
|
|
555
|
+
command.drawImageTiledX.y,
|
|
556
|
+
command.drawImageTiledX.w);
|
|
557
|
+
break;
|
|
558
|
+
case Type::FillText:
|
|
559
|
+
g_canvas.setGlobalAlpha(command.fillText.alpha);
|
|
560
|
+
g_canvas.drawText(command.fillText.text,
|
|
561
|
+
command.fillText.x,
|
|
562
|
+
command.fillText.y,
|
|
563
|
+
command.fillText.color,
|
|
564
|
+
command.fillText.scale);
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
bool clipRect(int *x0, int *y0, int *x1, int *y1)
|
|
570
|
+
{
|
|
571
|
+
if (!x0 || !y0 || !x1 || !y1) return false;
|
|
572
|
+
if (*x0 < 0) *x0 = 0;
|
|
573
|
+
if (*y0 < 0) *y0 = 0;
|
|
574
|
+
if (*x1 >= kWidth) *x1 = kWidth - 1;
|
|
575
|
+
if (*y1 >= kHeight) *y1 = kHeight - 1;
|
|
576
|
+
return *x0 <= *x1 && *y0 <= *y1;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
int publishDrawRect(int x0, int y0, int x1, int y1, int *outX0 = nullptr, int *outY0 = nullptr, int *outX1 = nullptr, int *outY1 = nullptr)
|
|
580
|
+
{
|
|
581
|
+
if (!g_framebuffer || !g_drawFramebuffer || !clipRect(&x0, &y0, &x1, &y1)) return 0;
|
|
582
|
+
if (outX0) *outX0 = x0;
|
|
583
|
+
if (outY0) *outY0 = y0;
|
|
584
|
+
if (outX1) *outX1 = x1;
|
|
585
|
+
if (outY1) *outY1 = y1;
|
|
586
|
+
const int width = x1 - x0 + 1;
|
|
587
|
+
if (g_framebuffer == g_drawFramebuffer) return width * (y1 - y0 + 1);
|
|
588
|
+
for (int y = y0; y <= y1; ++y) {
|
|
589
|
+
const std::size_t offset = static_cast<std::size_t>(y) * kWidth + static_cast<std::size_t>(x0);
|
|
590
|
+
std::memcpy(&g_framebuffer[offset], &g_drawFramebuffer[offset], static_cast<std::size_t>(width) * sizeof(std::uint16_t));
|
|
591
|
+
}
|
|
592
|
+
return width * (y1 - y0 + 1);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
struct RenderRowWorker {
|
|
596
|
+
TaskHandle_t task = nullptr;
|
|
597
|
+
void (*volatile fn)(void *, int, int) = nullptr;
|
|
598
|
+
void *volatile ctx = nullptr;
|
|
599
|
+
volatile int y0 = 0;
|
|
600
|
+
volatile int y1 = 0;
|
|
601
|
+
std::atomic<std::uint32_t> jobSeq{0};
|
|
602
|
+
std::atomic<bool> done{true};
|
|
603
|
+
// DIAG: cumulative on-worker band execution time (read by the wait-side print;
|
|
604
|
+
// only ever written between done=false and done=true, so the read is stable).
|
|
605
|
+
std::int64_t bandUs = 0;
|
|
606
|
+
bool attempted = false;
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
RenderRowWorker g_renderRowWorker;
|
|
610
|
+
// 12KB (was 8KB for the memcpy-only strip copies): the worker now also runs the
|
|
611
|
+
// renderer's full band replay (gradient projection math + rounded-rect batch +
|
|
612
|
+
// command handlers), which is much deeper than a strip copy.
|
|
613
|
+
constexpr std::uint32_t kRenderRowWorkerStackBytes = 12288;
|
|
614
|
+
|
|
615
|
+
void renderRowWorkerTask(void *)
|
|
616
|
+
{
|
|
617
|
+
// MUST start at 0 (jobSeq's initial value), NOT jobSeq.load(): submit() creates
|
|
618
|
+
// this task and increments jobSeq immediately after, so by the time this task
|
|
619
|
+
// gets its first instructions in, jobSeq is usually already 1 — loading it here
|
|
620
|
+
// would swallow job 1 (the caller times out and the first parallel band is
|
|
621
|
+
// silently dropped; for the in-place recolor that band then stays stale forever,
|
|
622
|
+
// since later recolors only match the CURRENT oldColor).
|
|
623
|
+
std::uint32_t seen = 0;
|
|
624
|
+
std::int64_t idleSince = esp_timer_get_time();
|
|
625
|
+
for (;;) {
|
|
626
|
+
while (g_renderRowWorker.jobSeq.load(std::memory_order_acquire) == seen) {
|
|
627
|
+
if (esp_timer_get_time() - idleSince > 4000) {
|
|
628
|
+
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(100));
|
|
629
|
+
idleSince = esp_timer_get_time();
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
seen = g_renderRowWorker.jobSeq.load(std::memory_order_acquire);
|
|
633
|
+
void (*fn)(void *, int, int) = g_renderRowWorker.fn;
|
|
634
|
+
const std::int64_t b0 = esp_timer_get_time();
|
|
635
|
+
if (fn) fn(g_renderRowWorker.ctx, g_renderRowWorker.y0, g_renderRowWorker.y1);
|
|
636
|
+
g_renderRowWorker.bandUs += esp_timer_get_time() - b0;
|
|
637
|
+
g_renderRowWorker.done.store(true, std::memory_order_release);
|
|
638
|
+
idleSince = esp_timer_get_time();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
#if GEA_EMBEDDED_DISPLAY_RGB_STRIP_RASTER
|
|
643
|
+
// Runs on the worker core: copy a finished SRAM strip (ctx) to PSRAM scanout rows
|
|
644
|
+
// [y0,y1] and write it back so the panel's scanout DMA sees it.
|
|
645
|
+
void copyStripToScanoutThunk(void *ctx, int y0, int y1)
|
|
646
|
+
{
|
|
647
|
+
const std::uint16_t *src = static_cast<const std::uint16_t *>(ctx);
|
|
648
|
+
const int rows = y1 - y0 + 1;
|
|
649
|
+
std::memcpy(&g_framebuffer[static_cast<std::size_t>(y0) * kWidth],
|
|
650
|
+
src,
|
|
651
|
+
static_cast<std::size_t>(rows) * kWidth * sizeof(std::uint16_t));
|
|
652
|
+
cacheWritebackRect(0, y0, kWidth - 1, y1);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// Compose the whole frame strip-by-strip in internal SRAM, copying each finished
|
|
656
|
+
// strip to the live scanout buffer. Used only for full-screen-redraw frames
|
|
657
|
+
// (frameHasOpaqueBase), so each strip is fully composited before it is published —
|
|
658
|
+
// tear-equivalent to the PSRAM double buffer, but the 1000-circle raster runs in
|
|
659
|
+
// SRAM instead of fighting the panel's continuous scanout for PSRAM bandwidth.
|
|
660
|
+
//
|
|
661
|
+
// Pipelined across cores: this core rasters strip N+1 into one SRAM half while the
|
|
662
|
+
// worker core copies strip N out of the other half to scanout. Raster (SRAM-only)
|
|
663
|
+
// and copy (PSRAM) hit different buses, so the ~6.5ms raster hides under the ~20ms
|
|
664
|
+
// copy instead of adding to it.
|
|
665
|
+
bool presentStripFused(const present::Frame &frame)
|
|
666
|
+
{
|
|
667
|
+
if (!g_framebuffer || !g_stripBuffer) return false;
|
|
668
|
+
int stripRows = g_flushRows > 0 ? g_flushRows : kStripRows;
|
|
669
|
+
if (stripRows > kStripRows) stripRows = kStripRows;
|
|
670
|
+
const std::int64_t start = esp_timer_get_time();
|
|
671
|
+
bool inFlight = false;
|
|
672
|
+
int idx = 0;
|
|
673
|
+
for (int row = 0; row < kHeight; row += stripRows, ++idx) {
|
|
674
|
+
int rows = stripRows;
|
|
675
|
+
if (row + rows > kHeight) rows = kHeight - row;
|
|
676
|
+
std::uint16_t *buf = g_stripBuffer + static_cast<std::size_t>(idx & 1) * kStripRows * kWidth;
|
|
677
|
+
// Raster strip `idx` into its SRAM half — overlaps the worker copying the
|
|
678
|
+
// previous strip out of the OTHER half (different buffer + bus, no contention).
|
|
679
|
+
present::rasterFrameRowsStrided(buf, kWidth, 0, kWidth, row, rows, kHeight, frame);
|
|
680
|
+
// The single worker handles one copy at a time. Waiting here also guarantees
|
|
681
|
+
// the half we'll reuse two strips from now is free before we raster into it.
|
|
682
|
+
if (inFlight) { gea_render_parallel_wait(); inFlight = false; }
|
|
683
|
+
if (gea_render_parallel_rows_submit(copyStripToScanoutThunk, buf, row, row + rows - 1)) {
|
|
684
|
+
inFlight = true;
|
|
685
|
+
} else {
|
|
686
|
+
copyStripToScanoutThunk(buf, row, row + rows - 1); // no worker: inline copy
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
if (inFlight) gea_render_parallel_wait();
|
|
690
|
+
g_drawBufferStale = (g_drawFramebuffer != g_framebuffer);
|
|
691
|
+
addFlushStats(esp_timer_get_time() - start, kWidth * kHeight);
|
|
692
|
+
return true;
|
|
693
|
+
}
|
|
694
|
+
#endif
|
|
695
|
+
|
|
696
|
+
} // namespace
|
|
697
|
+
|
|
698
|
+
namespace {
|
|
699
|
+
|
|
700
|
+
// DIAG: band-replay split engagement — submit count + the main core's join-wait
|
|
701
|
+
// time, printed every 300 draw-band jobs (mirrors the esp32 backend's [worker]
|
|
702
|
+
// line). Tells "split never engages" apart from "split engages but doesn't help".
|
|
703
|
+
int g_drawBandJobs = 0;
|
|
704
|
+
std::int64_t g_drawBandWaitUs = 0;
|
|
705
|
+
bool g_lastSubmitWasDrawBand = false;
|
|
706
|
+
|
|
707
|
+
// Shared single-job submit behind both worker entry points: the strip-copy path
|
|
708
|
+
// (gea_render_parallel_rows_submit) and the renderer's coarse band replay
|
|
709
|
+
// (gea_render_parallel_submit). One job in flight at a time — both producers run
|
|
710
|
+
// on the frame task and join via gea_render_parallel_wait before resubmitting.
|
|
711
|
+
bool submitRenderWorkerJob(void (*fn)(void *, int, int), void *ctx, int y0, int y1)
|
|
712
|
+
{
|
|
713
|
+
if (!g_renderRowWorker.attempted) {
|
|
714
|
+
g_renderRowWorker.attempted = true;
|
|
715
|
+
const BaseType_t renderCore = xPortGetCoreID();
|
|
716
|
+
const BaseType_t workerCore = renderCore == 0 ? 1 : 0;
|
|
717
|
+
const UBaseType_t priority = uxTaskPriorityGet(nullptr);
|
|
718
|
+
const BaseType_t created = xTaskCreatePinnedToCore(renderRowWorkerTask,
|
|
719
|
+
"gea_rowwrk",
|
|
720
|
+
kRenderRowWorkerStackBytes,
|
|
721
|
+
nullptr,
|
|
722
|
+
priority,
|
|
723
|
+
&g_renderRowWorker.task,
|
|
724
|
+
workerCore);
|
|
725
|
+
if (created != pdPASS || !g_renderRowWorker.task) {
|
|
726
|
+
ESP_LOGW(kTag, "row worker create failed: create=%d stack=%u",
|
|
727
|
+
static_cast<int>(created),
|
|
728
|
+
static_cast<unsigned>(kRenderRowWorkerStackBytes));
|
|
729
|
+
} else {
|
|
730
|
+
std::printf("[render-worker] task=%p renderCore=%d workerCore=%d prio=%u stack=%u\n",
|
|
731
|
+
static_cast<void *>(g_renderRowWorker.task), static_cast<int>(renderCore),
|
|
732
|
+
static_cast<int>(workerCore), static_cast<unsigned>(priority),
|
|
733
|
+
static_cast<unsigned>(kRenderRowWorkerStackBytes));
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (!g_renderRowWorker.task) return false;
|
|
737
|
+
g_renderRowWorker.fn = fn;
|
|
738
|
+
g_renderRowWorker.ctx = ctx;
|
|
739
|
+
g_renderRowWorker.y0 = y0;
|
|
740
|
+
g_renderRowWorker.y1 = y1;
|
|
741
|
+
g_renderRowWorker.done.store(false, std::memory_order_release);
|
|
742
|
+
g_renderRowWorker.jobSeq.fetch_add(1, std::memory_order_release);
|
|
743
|
+
xTaskNotifyGive(g_renderRowWorker.task);
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
} // namespace
|
|
748
|
+
|
|
749
|
+
extern "C" bool gea_render_parallel_rows_submit(void (*fn)(void *, int, int), void *ctx, int y0, int y1)
|
|
750
|
+
{
|
|
751
|
+
g_lastSubmitWasDrawBand = false;
|
|
752
|
+
return submitRenderWorkerJob(fn, ctx, y0, y1);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// NOTE: a 410-permille biased split (worker takes more rows; both bands finish
|
|
756
|
+
// together) was measured and REVERTED: with the cores fully overlapped the pair
|
|
757
|
+
// is bus-limited, so rebalancing rows doesn't shorten the wall — it only deepens
|
|
758
|
+
// the PSRAM saturation window, and the bounce-fill ISR (which keeps the panel
|
|
759
|
+
// synced) starts missing its deadline → dropped/restarted frames. Even split
|
|
760
|
+
// (the weak default 500) leaves the main core a solo tail that the ISR rides.
|
|
761
|
+
|
|
762
|
+
extern "C" bool gea_render_parallel_submit(void (*fn)(void *, int, int), void *ctx, int y0, int y1)
|
|
763
|
+
{
|
|
764
|
+
// Record the render core so Display draw calls on the OTHER core (the worker's
|
|
765
|
+
// band replay) route to the band canvas. Re-set each submit in case the frame
|
|
766
|
+
// task ever migrates cores.
|
|
767
|
+
g_renderCoreId = static_cast<int>(xPortGetCoreID());
|
|
768
|
+
const bool ok = submitRenderWorkerJob(fn, ctx, y0, y1);
|
|
769
|
+
g_lastSubmitWasDrawBand = ok;
|
|
770
|
+
return ok;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// After a coarse band-replay joins, fold the worker canvas's dirty bbox into the
|
|
774
|
+
// primary so the publish copy (which reads g_canvas.dirty()) transmits both bands.
|
|
775
|
+
extern "C" void gea_render_parallel_merge_dirty()
|
|
776
|
+
{
|
|
777
|
+
int x0, y0, x1, y1;
|
|
778
|
+
if (g_workerCanvas.dirty(&x0, &y0, &x1, &y1)) g_canvas.markDirty(x0, y0, x1, y1);
|
|
779
|
+
g_workerCanvas.resetDirty();
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
namespace {
|
|
783
|
+
|
|
784
|
+
// SRAM-staged dirty-region replay (gea_replay_stage_* hooks): the region replay
|
|
785
|
+
// rasters into a per-core half of g_stripBuffer instead of read-modify-writing the
|
|
786
|
+
// PSRAM back buffer under the RGB panel's continuous scanout. Measured before this:
|
|
787
|
+
// a HALF-band replay cost the same ~20ms as the full region — the PSRAM bus, not
|
|
788
|
+
// the CPU, was the limit, so the 2-core split alone bought nothing. Per-core halves:
|
|
789
|
+
// with the band split each core stages its own (disjoint) band rows, so the halves
|
|
790
|
+
// never overlap; presentStripFused also uses both halves but only on canvas-present
|
|
791
|
+
// frames, never concurrently with a region replay.
|
|
792
|
+
struct ReplayStageState {
|
|
793
|
+
bool active = false;
|
|
794
|
+
int x0 = 0, y0 = 0, x1 = -1, y1 = -1; // staged window (screen coords)
|
|
795
|
+
bool hadDirty = false; // canvas dirty union accumulated before the
|
|
796
|
+
int dx0 = 0, dy0 = 0, dx1 = -1, dy1 = -1; // rebind (bindPixels resets it)
|
|
797
|
+
std::uint8_t alpha = 255;
|
|
798
|
+
// DIAG: per-strip cost decomposition (seed copy-in / replay body / copy-back),
|
|
799
|
+
// printed every kStageDiagStrips strips per core.
|
|
800
|
+
std::int64_t beginDoneUs = 0;
|
|
801
|
+
std::int64_t seedUs = 0, bodyUs = 0, cbUs = 0;
|
|
802
|
+
int strips = 0, px = 0;
|
|
803
|
+
};
|
|
804
|
+
ReplayStageState g_replayStage[2];
|
|
805
|
+
constexpr int kStageDiagStrips = 600;
|
|
806
|
+
// DIAG: PIE SIMD blend engagement (calls + 8-px groups), printed with [stage].
|
|
807
|
+
volatile int g_pieCalls = 0;
|
|
808
|
+
volatile int g_pieCount8 = 0;
|
|
809
|
+
|
|
810
|
+
} // namespace
|
|
811
|
+
|
|
812
|
+
// Staged-replay gate. Measured on css-3d-cube: staging the replay through SRAM
|
|
813
|
+
// strips LOST ~6fps — the per-strip re-replay multiplies commands whose raster
|
|
814
|
+
// cost is NOT row-proportional (the transformed face-label text re-rasters its
|
|
815
|
+
// full quad in every overlapping 24-row strip; rUs text went to ~10ms/frame),
|
|
816
|
+
// and the per-pixel blend turned out compute-bound, not PSRAM-bound, so the
|
|
817
|
+
// SRAM dst saved nothing. Keep the machinery (hooks + per-core windows) gated
|
|
818
|
+
// off for A/B; flip to 1 to re-measure.
|
|
819
|
+
#ifndef GEA_EMBEDDED_DISPLAY_REPLAY_SRAM_STAGE
|
|
820
|
+
#define GEA_EMBEDDED_DISPLAY_REPLAY_SRAM_STAGE 0
|
|
821
|
+
#endif
|
|
822
|
+
|
|
823
|
+
extern "C" int gea_replay_stage_rows()
|
|
824
|
+
{
|
|
825
|
+
#if GEA_EMBEDDED_DISPLAY_REPLAY_SRAM_STAGE
|
|
826
|
+
return g_stripBuffer ? kStripRows : 0;
|
|
827
|
+
#else
|
|
828
|
+
return 0;
|
|
829
|
+
#endif
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
extern "C" bool gea_replay_stage_begin(int x0, int y0, int x1, int y1)
|
|
833
|
+
{
|
|
834
|
+
if (!g_stripBuffer || !g_drawFramebuffer) return false;
|
|
835
|
+
if (x0 < 0) x0 = 0;
|
|
836
|
+
if (y0 < 0) y0 = 0;
|
|
837
|
+
if (x1 >= kWidth) x1 = kWidth - 1;
|
|
838
|
+
if (y1 >= kHeight) y1 = kHeight - 1;
|
|
839
|
+
const int rows = y1 - y0 + 1;
|
|
840
|
+
if (x0 > x1 || rows <= 0 || rows > kStripRows) return false;
|
|
841
|
+
const int core = xPortGetCoreID() & 1;
|
|
842
|
+
ReplayStageState &st = g_replayStage[core];
|
|
843
|
+
if (st.active) return false; // staging never nests; fall back to direct if it ever would
|
|
844
|
+
std::uint16_t *strip = g_stripBuffer + static_cast<std::size_t>(core) * kStripRows * kWidth;
|
|
845
|
+
// Seed the window from the back buffer so alpha blends and partial paints meet
|
|
846
|
+
// the same dst bytes the direct path would have.
|
|
847
|
+
const std::int64_t s0 = esp_timer_get_time();
|
|
848
|
+
const int width = x1 - x0 + 1;
|
|
849
|
+
for (int y = y0; y <= y1; ++y) {
|
|
850
|
+
std::memcpy(&strip[static_cast<std::size_t>(y - y0) * kWidth + x0],
|
|
851
|
+
&g_drawFramebuffer[static_cast<std::size_t>(y) * kWidth + x0],
|
|
852
|
+
static_cast<std::size_t>(width) * sizeof(std::uint16_t));
|
|
853
|
+
}
|
|
854
|
+
st.seedUs += esp_timer_get_time() - s0;
|
|
855
|
+
st.px += width * rows;
|
|
856
|
+
auto &canvas = replayCanvas();
|
|
857
|
+
st.hadDirty = canvas.dirty(&st.dx0, &st.dy0, &st.dx1, &st.dy1);
|
|
858
|
+
st.alpha = canvas.globalAlpha();
|
|
859
|
+
// Window binding: claim rows [0..y1] with the pixel base rewound by y0 rows, so
|
|
860
|
+
// screen row y lands at strip row (y - y0) — the replay keeps drawing in screen
|
|
861
|
+
// coordinates. Rows above the window are unbacked memory; the guard clip below
|
|
862
|
+
// keeps every drawer inside the window (all drawers clamp to the clip, and the
|
|
863
|
+
// replay never reads outside it).
|
|
864
|
+
canvas.bindPixels(strip - static_cast<std::size_t>(y0) * kWidth, kWidth, y1 + 1, kWidth);
|
|
865
|
+
canvas.setGlobalAlpha(st.alpha);
|
|
866
|
+
canvas.pushClip(x0, y0, width, rows);
|
|
867
|
+
st.active = true;
|
|
868
|
+
st.x0 = x0;
|
|
869
|
+
st.y0 = y0;
|
|
870
|
+
st.x1 = x1;
|
|
871
|
+
st.y1 = y1;
|
|
872
|
+
st.beginDoneUs = esp_timer_get_time();
|
|
873
|
+
return true;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
extern "C" void gea_replay_stage_end()
|
|
877
|
+
{
|
|
878
|
+
const int core = xPortGetCoreID() & 1;
|
|
879
|
+
ReplayStageState &st = g_replayStage[core];
|
|
880
|
+
if (!st.active) return;
|
|
881
|
+
st.active = false;
|
|
882
|
+
const std::int64_t e0 = esp_timer_get_time();
|
|
883
|
+
st.bodyUs += e0 - st.beginDoneUs;
|
|
884
|
+
auto &canvas = replayCanvas();
|
|
885
|
+
int dx0, dy0, dx1, dy1;
|
|
886
|
+
bool dirty = canvas.dirty(&dx0, &dy0, &dx1, &dy1);
|
|
887
|
+
if (dirty) {
|
|
888
|
+
// Copy back only the painted bbox (clamped to the window) — unpainted strip
|
|
889
|
+
// pixels are seed-identical, so skipping them saves PSRAM write traffic.
|
|
890
|
+
if (dx0 < st.x0) dx0 = st.x0;
|
|
891
|
+
if (dy0 < st.y0) dy0 = st.y0;
|
|
892
|
+
if (dx1 > st.x1) dx1 = st.x1;
|
|
893
|
+
if (dy1 > st.y1) dy1 = st.y1;
|
|
894
|
+
dirty = dx0 <= dx1 && dy0 <= dy1;
|
|
895
|
+
}
|
|
896
|
+
if (dirty) {
|
|
897
|
+
const std::uint16_t *strip = g_stripBuffer + static_cast<std::size_t>(core) * kStripRows * kWidth;
|
|
898
|
+
const int width = dx1 - dx0 + 1;
|
|
899
|
+
for (int y = dy0; y <= dy1; ++y) {
|
|
900
|
+
std::memcpy(&g_drawFramebuffer[static_cast<std::size_t>(y) * kWidth + dx0],
|
|
901
|
+
&strip[static_cast<std::size_t>(y - st.y0) * kWidth + dx0],
|
|
902
|
+
static_cast<std::size_t>(width) * sizeof(std::uint16_t));
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
canvas.bindPixels(g_drawFramebuffer, kWidth, kHeight);
|
|
906
|
+
canvas.setGlobalAlpha(st.alpha);
|
|
907
|
+
// bindPixels reset the dirty tracker: restore the frame's accumulated union,
|
|
908
|
+
// then add this strip's painted bbox so the publish copy transmits it.
|
|
909
|
+
if (st.hadDirty) canvas.markDirty(st.dx0, st.dy0, st.dx1, st.dy1);
|
|
910
|
+
if (dirty) canvas.markDirty(dx0, dy0, dx1, dy1);
|
|
911
|
+
st.cbUs += esp_timer_get_time() - e0;
|
|
912
|
+
if (++st.strips >= kStageDiagStrips) {
|
|
913
|
+
std::printf("[stage] core%d strips=%d px=%d seed=%dus body=%dus cb=%dus (avg/strip) pie=%d/%dpx\n",
|
|
914
|
+
core, st.strips, st.px / st.strips,
|
|
915
|
+
static_cast<int>(st.seedUs / st.strips),
|
|
916
|
+
static_cast<int>(st.bodyUs / st.strips),
|
|
917
|
+
static_cast<int>(st.cbUs / st.strips),
|
|
918
|
+
g_pieCalls, g_pieCount8 * 8);
|
|
919
|
+
g_pieCalls = 0;
|
|
920
|
+
g_pieCount8 = 0;
|
|
921
|
+
st.seedUs = st.bodyUs = st.cbUs = 0;
|
|
922
|
+
st.strips = 0;
|
|
923
|
+
st.px = 0;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
namespace {
|
|
928
|
+
|
|
929
|
+
// ── PIE SIMD over-blend (gea_pie_blend hooks) ────────────────────────────────
|
|
930
|
+
// Same S3 vector kernel as targets/esp32/display.cpp's pieBlendSpan8, minus the
|
|
931
|
+
// panel<->normal byte-swap steps: this board stores native-order RGB565
|
|
932
|
+
// (GEA_EMBEDDED_PIXEL_PANEL_ENDIAN=0), so the framebuffer bytes already ARE the
|
|
933
|
+
// "normal" layout the channel masks need. Contract unchanged: dst = bg in /
|
|
934
|
+
// result out (storage order), fgN = normal-RGB565 fg, a5 = per-pixel 0..32;
|
|
935
|
+
// lerp oC = bgC + ((fgC-bgC)*a5)>>5 per channel, +16 round-to-nearest.
|
|
936
|
+
// cb2 rows (16B apart): [0]=1, [1]=0x1F, [2]=0x3F, [5]=2048(<<11), [6]=32(<<5),
|
|
937
|
+
// [7]=16(round); rows 3/4 (0xFF mask, <<8) are the swap constants — unused here
|
|
938
|
+
// but kept so the table layout matches the esp32 kernel's documented block.
|
|
939
|
+
// Held: q0=bg, q1=ones, q2=fgN, q3=a5, q6=accum. Scratch: q4, q5(const/mask), q7.
|
|
940
|
+
void pieBlendSpan8Native(std::uint16_t *dst, const std::uint16_t *fgN, const std::int16_t *a5, int count8,
|
|
941
|
+
const std::int16_t *cb2)
|
|
942
|
+
{
|
|
943
|
+
int t, ad;
|
|
944
|
+
asm volatile(
|
|
945
|
+
"ee.vld.128.ip q1, %[cb], 0\n" // q1 = ones (cb2[0])
|
|
946
|
+
"1:\n"
|
|
947
|
+
"ee.vld.128.ip q0, %[d], 0\n" // q0 = bg (native order), no increment (stored back)
|
|
948
|
+
"ee.vld.128.ip q2, %[f], 16\n" // q2 = fgN
|
|
949
|
+
"ee.vld.128.ip q3, %[a], 16\n" // q3 = a5
|
|
950
|
+
// B channel (bits 0-4): oB = bgB + ((fgB-bgB)*a5 + 16)>>5
|
|
951
|
+
"addi %[ad], %[cb], 16\n ee.vld.128.ip q5, %[ad], 0\n" // q5 = mask1F
|
|
952
|
+
"ee.andq q4, q0, q5\n" // bgB
|
|
953
|
+
"ee.andq q7, q2, q5\n" // fgB
|
|
954
|
+
"ee.vsubs.s16 q7, q7, q4\n" // fgB-bgB
|
|
955
|
+
"movi %[t], 0\n wsr.sar %[t]\n ee.vmul.s16 q7, q7, q3\n" // diff*a5 (raw)
|
|
956
|
+
"addi %[ad], %[cb], 112\n ee.vld.128.ip q5, %[ad], 0\n ee.vadds.s16 q7, q7, q5\n" // +16 (round)
|
|
957
|
+
"movi %[t], 5\n wsr.sar %[t]\n ee.vmul.s16 q7, q7, q1\n" // >>5
|
|
958
|
+
"ee.vadds.s16 q6, q7, q4\n" // oB (accum)
|
|
959
|
+
// G channel (bits 5-10): mask 0x3F, repack <<5
|
|
960
|
+
"addi %[ad], %[cb], 32\n ee.vld.128.ip q5, %[ad], 0\n" // q5 = mask3F
|
|
961
|
+
"movi %[t], 5\n wsr.sar %[t]\n ee.vmul.s16 q4, q0, q1\n ee.andq q4, q4, q5\n" // bgG
|
|
962
|
+
"ee.vmul.s16 q7, q2, q1\n ee.andq q7, q7, q5\n" // fgG (SAR still 5)
|
|
963
|
+
"ee.vsubs.s16 q7, q7, q4\n" // diff
|
|
964
|
+
"movi %[t], 0\n wsr.sar %[t]\n ee.vmul.s16 q7, q7, q3\n" // diff*a5 (raw)
|
|
965
|
+
"addi %[ad], %[cb], 112\n ee.vld.128.ip q5, %[ad], 0\n ee.vadds.s16 q7, q7, q5\n" // +16
|
|
966
|
+
"movi %[t], 5\n wsr.sar %[t]\n ee.vmul.s16 q7, q7, q1\n" // >>5
|
|
967
|
+
"ee.vadds.s16 q7, q7, q4\n" // oG
|
|
968
|
+
"movi %[t], 0\n wsr.sar %[t]\n addi %[ad], %[cb], 96\n ee.vld.128.ip q5, %[ad], 0\n ee.vmul.s16 q7, q7, q5\n" // oG<<5 (c32)
|
|
969
|
+
"ee.orq q6, q6, q7\n"
|
|
970
|
+
// R channel (bits 11-15): mask 0x1F, repack <<11
|
|
971
|
+
"addi %[ad], %[cb], 16\n ee.vld.128.ip q5, %[ad], 0\n" // q5 = mask1F
|
|
972
|
+
"movi %[t], 11\n wsr.sar %[t]\n ee.vmul.s16 q4, q0, q1\n ee.andq q4, q4, q5\n" // bgR
|
|
973
|
+
"ee.vmul.s16 q7, q2, q1\n ee.andq q7, q7, q5\n" // fgR (SAR still 11)
|
|
974
|
+
"ee.vsubs.s16 q7, q7, q4\n"
|
|
975
|
+
"movi %[t], 0\n wsr.sar %[t]\n ee.vmul.s16 q7, q7, q3\n" // diff*a5 (raw)
|
|
976
|
+
"addi %[ad], %[cb], 112\n ee.vld.128.ip q5, %[ad], 0\n ee.vadds.s16 q7, q7, q5\n" // +16
|
|
977
|
+
"movi %[t], 5\n wsr.sar %[t]\n ee.vmul.s16 q7, q7, q1\n" // >>5
|
|
978
|
+
"ee.vadds.s16 q7, q7, q4\n" // oR
|
|
979
|
+
"movi %[t], 0\n wsr.sar %[t]\n addi %[ad], %[cb], 80\n ee.vld.128.ip q5, %[ad], 0\n ee.vmul.s16 q7, q7, q5\n" // oR<<11 (c2048)
|
|
980
|
+
"ee.orq q6, q6, q7\n" // q6 = result (native order)
|
|
981
|
+
"ee.vst.128.ip q6, %[d], 16\n" // store result + advance dst by 8 px
|
|
982
|
+
"addi %[n], %[n], -1\n bnez %[n], 1b\n"
|
|
983
|
+
: [d] "+r"(dst), [f] "+r"(fgN), [a] "+r"(a5), [n] "+r"(count8), [t] "=&r"(t), [ad] "=&r"(ad)
|
|
984
|
+
: [cb] "r"(cb2)
|
|
985
|
+
: "memory");
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
} // namespace
|
|
989
|
+
|
|
990
|
+
// Like-for-like on css-3d-cube (same app build, even split, no staging): scalar
|
|
991
|
+
// gradient replay = 28-41ms/frame, SIMD = ~13.5ms — the kernel halves the
|
|
992
|
+
// dominant replay cost. (An earlier "no difference" reading compared across two
|
|
993
|
+
// different app revisions — the example was being reworked in a parallel session
|
|
994
|
+
// mid-measurement.)
|
|
995
|
+
extern "C" bool gea_pie_blend_available() { return true; }
|
|
996
|
+
extern "C" void gea_pie_blend_span8(std::uint16_t *dst, const std::uint16_t *fgN, const std::int16_t *a5, int count8)
|
|
997
|
+
{
|
|
998
|
+
// Same constant block layout as the esp32 kernel (rows 3/4 unused here).
|
|
999
|
+
alignas(16) static const std::int16_t cb2[8][8] = {
|
|
1000
|
+
{1, 1, 1, 1, 1, 1, 1, 1},
|
|
1001
|
+
{0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F},
|
|
1002
|
+
{0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F},
|
|
1003
|
+
{0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF},
|
|
1004
|
+
{256, 256, 256, 256, 256, 256, 256, 256},
|
|
1005
|
+
{2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048},
|
|
1006
|
+
{32, 32, 32, 32, 32, 32, 32, 32},
|
|
1007
|
+
{16, 16, 16, 16, 16, 16, 16, 16},
|
|
1008
|
+
};
|
|
1009
|
+
// PER-CORE critical section — the PIE q-registers are not saved across FreeRTOS
|
|
1010
|
+
// context switches, so a mid-kernel preemption (WiFi/system tasks on core 0,
|
|
1011
|
+
// the render worker's own preemptors on core 1) corrupts the blend. Per-core
|
|
1012
|
+
// mux so the two render cores never serialize on it (proven pattern on the
|
|
1013
|
+
// esp32 target, where corruption stripes appeared without the guard).
|
|
1014
|
+
static portMUX_TYPE pieMux[2] = {portMUX_INITIALIZER_UNLOCKED, portMUX_INITIALIZER_UNLOCKED};
|
|
1015
|
+
portMUX_TYPE *mux = &pieMux[xPortGetCoreID() & 1];
|
|
1016
|
+
g_pieCalls = g_pieCalls + 1;
|
|
1017
|
+
g_pieCount8 = g_pieCount8 + count8;
|
|
1018
|
+
taskENTER_CRITICAL(mux);
|
|
1019
|
+
pieBlendSpan8Native(dst, fgN, a5, count8, &cb2[0][0]);
|
|
1020
|
+
taskEXIT_CRITICAL(mux);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
extern "C" int gea_current_render_core()
|
|
1024
|
+
{
|
|
1025
|
+
return static_cast<int>(xPortGetCoreID());
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
extern "C" void gea_render_parallel_wait()
|
|
1029
|
+
{
|
|
1030
|
+
if (!g_renderRowWorker.task) return;
|
|
1031
|
+
const std::int64_t w0 = esp_timer_get_time();
|
|
1032
|
+
const std::int64_t deadline = w0 + 100000;
|
|
1033
|
+
while (!g_renderRowWorker.done.load(std::memory_order_acquire)) {
|
|
1034
|
+
if (esp_timer_get_time() > deadline) {
|
|
1035
|
+
ESP_LOGW(kTag, "row worker wait timeout");
|
|
1036
|
+
break;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
if (g_lastSubmitWasDrawBand) {
|
|
1040
|
+
g_drawBandWaitUs += esp_timer_get_time() - w0;
|
|
1041
|
+
if (++g_drawBandJobs >= 300) {
|
|
1042
|
+
std::printf("[worker] draw-band jobs=300 wait=%dus band=%dus avg\n",
|
|
1043
|
+
static_cast<int>(g_drawBandWaitUs / 300),
|
|
1044
|
+
static_cast<int>(g_renderRowWorker.bandUs / 300));
|
|
1045
|
+
g_drawBandWaitUs = 0;
|
|
1046
|
+
g_drawBandJobs = 0;
|
|
1047
|
+
g_renderRowWorker.bandUs = 0;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
namespace gea::platform::display {
|
|
1053
|
+
|
|
1054
|
+
bool Display::init()
|
|
1055
|
+
{
|
|
1056
|
+
if (g_initialized) return true;
|
|
1057
|
+
esp_err_t err = initBacklight();
|
|
1058
|
+
if (err != ESP_OK) return false;
|
|
1059
|
+
err = initSt7701();
|
|
1060
|
+
if (err != ESP_OK) {
|
|
1061
|
+
ESP_LOGE(kTag, "ST7701 init failed: %s", esp_err_to_name(err));
|
|
1062
|
+
return false;
|
|
1063
|
+
}
|
|
1064
|
+
err = initRgbPanel();
|
|
1065
|
+
if (err != ESP_OK) return false;
|
|
1066
|
+
g_initialized = true;
|
|
1067
|
+
return true;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
bool Display::start()
|
|
1071
|
+
{
|
|
1072
|
+
if (!g_initialized && !init()) return false;
|
|
1073
|
+
setBrightness(g_brightness);
|
|
1074
|
+
flush();
|
|
1075
|
+
return true;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
// Routed per-core: the worker core's band replay (and render.cpp helpers that
|
|
1079
|
+
// draw raw pixels through canvas()) must hit the band canvas — its own clip +
|
|
1080
|
+
// dirty accumulator over the same framebuffer. On the main core this is g_canvas.
|
|
1081
|
+
gea::framework::graphics::Canvas *Display::canvas() { return &replayCanvas(); }
|
|
1082
|
+
|
|
1083
|
+
bool Display::copySnapshotRgb565(std::uint16_t *dst, int pixelCapacity, int *width, int *height, bool)
|
|
1084
|
+
{
|
|
1085
|
+
if (width) *width = kWidth;
|
|
1086
|
+
if (height) *height = kHeight;
|
|
1087
|
+
if (!dst || pixelCapacity < static_cast<int>(kPixelCount)) return false;
|
|
1088
|
+
const std::uint16_t *source = g_framebuffer ? g_framebuffer : g_drawFramebuffer;
|
|
1089
|
+
if (!source) return false;
|
|
1090
|
+
std::copy_n(source, kPixelCount, dst);
|
|
1091
|
+
return true;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
int Display::countNonBlackPixels(bool)
|
|
1095
|
+
{
|
|
1096
|
+
const std::uint16_t *source = g_framebuffer ? g_framebuffer : g_drawFramebuffer;
|
|
1097
|
+
if (!source) return 0;
|
|
1098
|
+
int count = 0;
|
|
1099
|
+
for (std::size_t i = 0; i < kPixelCount; ++i) {
|
|
1100
|
+
if (source[i] != 0) ++count;
|
|
1101
|
+
}
|
|
1102
|
+
return count;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
void Display::clear()
|
|
1106
|
+
{
|
|
1107
|
+
g_canvas.clear(0x0000);
|
|
1108
|
+
flush();
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
void Display::clearNoFlush() { g_canvas.clear(0x0000); }
|
|
1112
|
+
void Display::print(const char *) {}
|
|
1113
|
+
|
|
1114
|
+
void Display::flush()
|
|
1115
|
+
{
|
|
1116
|
+
if (!g_framebuffer || !g_drawFramebuffer) return;
|
|
1117
|
+
const int64_t start = esp_timer_get_time();
|
|
1118
|
+
int64_t copyUs = 0;
|
|
1119
|
+
int64_t cacheUs = 0;
|
|
1120
|
+
int x0 = 0;
|
|
1121
|
+
int y0 = 0;
|
|
1122
|
+
int x1 = -1;
|
|
1123
|
+
int y1 = -1;
|
|
1124
|
+
int pixels = 0;
|
|
1125
|
+
if (g_canvas.dirty(&x0, &y0, &x1, &y1)) {
|
|
1126
|
+
const int64_t copyStart = esp_timer_get_time();
|
|
1127
|
+
pixels = publishDrawRect(x0, y0, x1, y1, &x0, &y0, &x1, &y1);
|
|
1128
|
+
copyUs += esp_timer_get_time() - copyStart;
|
|
1129
|
+
}
|
|
1130
|
+
if (pixels > 0) {
|
|
1131
|
+
const int64_t cacheStart = esp_timer_get_time();
|
|
1132
|
+
cacheWritebackRect(x0, y0, x1, y1);
|
|
1133
|
+
cacheUs += esp_timer_get_time() - cacheStart;
|
|
1134
|
+
}
|
|
1135
|
+
g_canvas.resetDirty();
|
|
1136
|
+
addFlushStats(esp_timer_get_time() - start, pixels);
|
|
1137
|
+
addFlushStageStats(copyUs, cacheUs);
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
void Display::flushRects(const DisplayFlushRect *rects, int count, bool)
|
|
1141
|
+
{
|
|
1142
|
+
if (!g_framebuffer || !g_drawFramebuffer || !rects || count <= 0) return;
|
|
1143
|
+
const int64_t start = esp_timer_get_time();
|
|
1144
|
+
int64_t copyUs = 0;
|
|
1145
|
+
int64_t cacheUs = 0;
|
|
1146
|
+
int pixels = 0;
|
|
1147
|
+
for (int i = 0; i < count; ++i) {
|
|
1148
|
+
int x0 = 0;
|
|
1149
|
+
int y0 = 0;
|
|
1150
|
+
int x1 = -1;
|
|
1151
|
+
int y1 = -1;
|
|
1152
|
+
const int64_t copyStart = esp_timer_get_time();
|
|
1153
|
+
const int rectPixels = publishDrawRect(rects[i].x0, rects[i].y0, rects[i].x1, rects[i].y1, &x0, &y0, &x1, &y1);
|
|
1154
|
+
copyUs += esp_timer_get_time() - copyStart;
|
|
1155
|
+
if (rectPixels > 0) {
|
|
1156
|
+
pixels += rectPixels;
|
|
1157
|
+
const int64_t cacheStart = esp_timer_get_time();
|
|
1158
|
+
cacheWritebackRect(x0, y0, x1, y1);
|
|
1159
|
+
cacheUs += esp_timer_get_time() - cacheStart;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
g_canvas.resetDirty();
|
|
1163
|
+
addFlushStats(esp_timer_get_time() - start, pixels);
|
|
1164
|
+
addFlushStageStats(copyUs, cacheUs);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
bool Display::streamRect(int x, int y, int w, int h, DisplayStreamRasterFn raster, void *user)
|
|
1168
|
+
{
|
|
1169
|
+
if (!g_framebuffer || !g_drawFramebuffer || !raster || w <= 0 || h <= 0) return false;
|
|
1170
|
+
int x0 = x;
|
|
1171
|
+
int y0 = y;
|
|
1172
|
+
int x1 = x + w - 1;
|
|
1173
|
+
int y1 = y + h - 1;
|
|
1174
|
+
if (x0 < 0) x0 = 0;
|
|
1175
|
+
if (y0 < 0) y0 = 0;
|
|
1176
|
+
if (x1 >= kWidth) x1 = kWidth - 1;
|
|
1177
|
+
if (y1 >= kHeight) y1 = kHeight - 1;
|
|
1178
|
+
if (x0 > x1 || y0 > y1) return true;
|
|
1179
|
+
|
|
1180
|
+
const int width = x1 - x0 + 1;
|
|
1181
|
+
const int height = y1 - y0 + 1;
|
|
1182
|
+
const std::size_t bytes = static_cast<std::size_t>(width) * static_cast<std::size_t>(height) * sizeof(std::uint16_t);
|
|
1183
|
+
auto *scratch = static_cast<std::uint16_t *>(heap_caps_malloc(bytes, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT));
|
|
1184
|
+
if (!scratch) scratch = static_cast<std::uint16_t *>(heap_caps_malloc(bytes, MALLOC_CAP_8BIT));
|
|
1185
|
+
if (!scratch) return false;
|
|
1186
|
+
|
|
1187
|
+
const int64_t start = esp_timer_get_time();
|
|
1188
|
+
raster(scratch, width, height, x0, y0, user);
|
|
1189
|
+
for (int row = 0; row < height; ++row) {
|
|
1190
|
+
std::copy_n(&scratch[static_cast<std::size_t>(row) * width],
|
|
1191
|
+
width,
|
|
1192
|
+
&g_drawFramebuffer[static_cast<std::size_t>(y0 + row) * kWidth + x0]);
|
|
1193
|
+
}
|
|
1194
|
+
heap_caps_free(scratch);
|
|
1195
|
+
int publishedX0 = 0;
|
|
1196
|
+
int publishedY0 = 0;
|
|
1197
|
+
int publishedX1 = -1;
|
|
1198
|
+
int publishedY1 = -1;
|
|
1199
|
+
const int pixels = publishDrawRect(x0, y0, x1, y1, &publishedX0, &publishedY0, &publishedX1, &publishedY1);
|
|
1200
|
+
if (pixels > 0) cacheWritebackRect(publishedX0, publishedY0, publishedX1, publishedY1);
|
|
1201
|
+
g_canvas.resetDirty();
|
|
1202
|
+
addFlushStats(esp_timer_get_time() - start, pixels);
|
|
1203
|
+
return true;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
bool Display::present(const DisplayPresentCommand *commands, int commandCount)
|
|
1207
|
+
{
|
|
1208
|
+
if (!commands || commandCount <= 0) return false;
|
|
1209
|
+
#if GEA_EMBEDDED_DISPLAY_RGB_STRIP_RASTER
|
|
1210
|
+
// Fast path: full-screen-redraw frames compose in SRAM strips and publish
|
|
1211
|
+
// straight to scanout. Anything without a full-screen opaque base needs the
|
|
1212
|
+
// persistent back buffer, so it falls through.
|
|
1213
|
+
if (g_stripBuffer) {
|
|
1214
|
+
present::Frame frame;
|
|
1215
|
+
if (present::extractFrame(commands, commandCount, frame) &&
|
|
1216
|
+
present::frameHasOpaqueBase(frame, kWidth, kHeight)) {
|
|
1217
|
+
return presentStripFused(frame);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
#endif
|
|
1221
|
+
// Fallback: per-command replay into the PSRAM back buffer, then publish. If
|
|
1222
|
+
// the last frame went through the strip path, the back buffer is stale —
|
|
1223
|
+
// re-seed it from the live scanout before drawing the partial update on top.
|
|
1224
|
+
if (g_drawBufferStale && g_drawFramebuffer != g_framebuffer) {
|
|
1225
|
+
std::memcpy(g_drawFramebuffer, g_framebuffer, kFramebufferBytes);
|
|
1226
|
+
g_drawBufferStale = false;
|
|
1227
|
+
}
|
|
1228
|
+
for (int i = 0; i < commandCount; ++i) {
|
|
1229
|
+
replayPresentCommand(commands[i]);
|
|
1230
|
+
}
|
|
1231
|
+
g_canvas.setGlobalAlpha(255);
|
|
1232
|
+
flush();
|
|
1233
|
+
return true;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
void Display::setFlushConfig(int chunkRows, int queueDepth)
|
|
1237
|
+
{
|
|
1238
|
+
g_flushRows = chunkRows;
|
|
1239
|
+
g_flushDepth = queueDepth;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
void Display::reserveInternal(std::size_t) {}
|
|
1243
|
+
bool Display::setHighBrightnessMode(bool) { return false; }
|
|
1244
|
+
bool Display::highBrightnessMode() { return false; }
|
|
1245
|
+
// The RGB-panel backend draws straight into the framebuffer with no separate
|
|
1246
|
+
// internal-RAM flush staging to reserve, so the deferred-reserve apply is a no-op
|
|
1247
|
+
// here (matches reserveInternal above). Required since frame_scheduler now calls it.
|
|
1248
|
+
void Display::applyPendingInternalReserve() {}
|
|
1249
|
+
int Display::flushChunkRows() { return g_flushRows; }
|
|
1250
|
+
int Display::flushQueueDepth() { return g_flushDepth; }
|
|
1251
|
+
int Display::flushBufferBytes() { return 0; }
|
|
1252
|
+
// All clip/alpha/draw entry points below route through replayCanvas() so the
|
|
1253
|
+
// 2nd-core band replay lands on the worker canvas (its own clip + dirty over
|
|
1254
|
+
// the same framebuffer). On the main core replayCanvas() == g_canvas, so the
|
|
1255
|
+
// single-core paths are unchanged.
|
|
1256
|
+
void Display::pushClip(int x, int y, int w, int h) { replayCanvas().pushClip(x, y, w, h); }
|
|
1257
|
+
void Display::popClip() { replayCanvas().popClip(); }
|
|
1258
|
+
void Display::resetClip() { replayCanvas().resetClip(); }
|
|
1259
|
+
void Display::setAlpha(std::uint8_t alpha) { replayCanvas().setGlobalAlpha(alpha); }
|
|
1260
|
+
std::uint8_t Display::alpha() { return replayCanvas().globalAlpha(); }
|
|
1261
|
+
int Display::brightness() { return g_brightness; }
|
|
1262
|
+
|
|
1263
|
+
void Display::setBrightness(int brightnessPercent)
|
|
1264
|
+
{
|
|
1265
|
+
if (brightnessPercent < 0) brightnessPercent = 0;
|
|
1266
|
+
if (brightnessPercent > 100) brightnessPercent = 100;
|
|
1267
|
+
g_brightness = brightnessPercent;
|
|
1268
|
+
if (g_backlightPwmInitialized) updateBacklightDuty();
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
// Tearing sync (TE/VBlank): not implemented on this target.
|
|
1272
|
+
void Display::setVSync(bool) {}
|
|
1273
|
+
void Display::invalidate() {}
|
|
1274
|
+
bool Display::vsyncEnabled() { return false; }
|
|
1275
|
+
void Display::vsyncWaitForFrame() {}
|
|
1276
|
+
|
|
1277
|
+
void Display::clip(int *x0, int *y0, int *x1, int *y1) { replayCanvas().currentClip(x0, y0, x1, y1); }
|
|
1278
|
+
void Display::fillRect(int x, int y, int w, int h, std::uint16_t color) { replayCanvas().fillRect(x, y, w, h, color); }
|
|
1279
|
+
void Display::scrollRect(int x, int y, int w, int h, int dx, int dy) { replayCanvas().scrollRect(x, y, w, h, dx, dy); }
|
|
1280
|
+
void Display::resetScrollRegion() { replayCanvas().setScrollRegion(0, 0, 0); }
|
|
1281
|
+
void Display::strokeRect(int x, int y, int w, int h, std::uint16_t color) { replayCanvas().strokeRect(x, y, w, h, color); }
|
|
1282
|
+
void Display::fillCircle(int cx, int cy, int r, std::uint16_t color) { replayCanvas().fillCircle(cx, cy, r, color); }
|
|
1283
|
+
void Display::strokeCircle(int cx, int cy, int r, std::uint16_t color) { replayCanvas().strokeCircle(cx, cy, r, color); }
|
|
1284
|
+
void Display::drawLine(int x0, int y0, int x1, int y1, std::uint16_t color) { replayCanvas().drawLine(x0, y0, x1, y1, color); }
|
|
1285
|
+
void Display::drawArc(int cx, int cy, int r, int startDeg, int endDeg, std::uint16_t color) { replayCanvas().drawArc(cx, cy, r, startDeg, endDeg, color); }
|
|
1286
|
+
void Display::fillTriangle(int x0, int y0, int x1, int y1, int x2, int y2, std::uint16_t color) { replayCanvas().fillTriangle(x0, y0, x1, y1, x2, y2, color); }
|
|
1287
|
+
void Display::drawText(const char *text, int x, int y, std::uint16_t color, float scale) { replayCanvas().drawText(text, x, y, color, scale); }
|
|
1288
|
+
void Display::drawTextFont(const char *text, int x, int y, std::uint16_t color, int fontId) { replayCanvas().drawTextFont(text, x, y, color, fontId); }
|
|
1289
|
+
void Display::drawTextFontFamily(const char *text, int x, int y, std::uint16_t color, int familyId, int sizePx) { replayCanvas().drawTextFontFamily(text, x, y, color, familyId, sizePx); }
|
|
1290
|
+
void Display::setPixel(int x, int y, std::uint16_t color) { replayCanvas().fillRect(x, y, 1, 1, color); }
|
|
1291
|
+
void Display::fillRoundedRect(int x, int y, int w, int h, int tl, int tr, int br, int bl, std::uint16_t color) { replayCanvas().fillRoundedRect(x, y, w, h, tl, tr, br, bl, color); }
|
|
1292
|
+
void Display::fillRoundedRectBoxesRgb565(const std::int16_t *xs, const std::int16_t *ys, int count,
|
|
1293
|
+
int w, int h, int tl, int tr, int br, int bl,
|
|
1294
|
+
const std::uint16_t *colors)
|
|
1295
|
+
{
|
|
1296
|
+
replayCanvas().fillRoundedRectBoxesRgb565(xs, ys, count, w, h, tl, tr, br, bl, colors);
|
|
1297
|
+
}
|
|
1298
|
+
void Display::strokeRoundedRect(int x, int y, int w, int h, int tl, int tr, int br, int bl, int lineWidth, std::uint16_t color) { replayCanvas().strokeRoundedRect(x, y, w, h, tl, tr, br, bl, lineWidth, color); }
|
|
1299
|
+
void Display::blitImage(const gea::framework::graphics::pixel::native_t *src, const std::uint8_t *alpha, int srcWidth, int srcHeight, int dx, int dy) { replayCanvas().drawImage(src, alpha, srcWidth, srcHeight, dx, dy); }
|
|
1300
|
+
void Display::blitImageScaled(const gea::framework::graphics::pixel::native_t *src, const std::uint8_t *alpha, int srcWidth, int srcHeight, int dx, int dy, int dstWidth, int dstHeight) { replayCanvas().drawImage(src, alpha, srcWidth, srcHeight, dx, dy, dstWidth, dstHeight); }
|
|
1301
|
+
void Display::setWorldOverlay(const std::uint16_t *, int, int, int, int) {}
|
|
1302
|
+
void Display::setWorldScroll(int) {}
|
|
1303
|
+
|
|
1304
|
+
void Display::flushStatsRead(int64_t *totalUs, int *callCount, int *pixelCount)
|
|
1305
|
+
{
|
|
1306
|
+
if (totalUs) *totalUs = g_stats.totalUs;
|
|
1307
|
+
if (callCount) *callCount = g_stats.callCount;
|
|
1308
|
+
if (pixelCount) *pixelCount = g_stats.pixelCount;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
DisplayFlushPerfStats Display::flushPerfStatsRead() { return g_stats; }
|
|
1312
|
+
void Display::flushStatsReset() { g_stats = {}; }
|
|
1313
|
+
const char *Display::flushStageName() { return "idle"; }
|
|
1314
|
+
int Display::flushStageChunk() { return 0; }
|
|
1315
|
+
DisplayFlushStageDetail Display::flushStageDetail() { return {}; }
|
|
1316
|
+
|
|
1317
|
+
} // namespace gea::platform::display
|
|
1318
|
+
|
|
1319
|
+
// Full-screen PSRAM scratch for the static-backdrop cache. Without this hook the
|
|
1320
|
+
// weak default in ui/render.cpp returns nullptr and the bake SILENTLY never runs —
|
|
1321
|
+
// an animated-transform scene (css-3d-cube) then full-rebuilds + re-rasterizes the
|
|
1322
|
+
// whole static stage every frame (~17fps at 480x480) instead of reprojecting over
|
|
1323
|
+
// a baked backdrop. Same shape as the targets/esp32/display.cpp implementation.
|
|
1324
|
+
extern "C" std::uint16_t *gea_backdrop_cache(int *cap_px)
|
|
1325
|
+
{
|
|
1326
|
+
static std::uint16_t *buffer = nullptr;
|
|
1327
|
+
static bool attempted = false;
|
|
1328
|
+
constexpr int kCapPx = gea::platform::display::kWidth * gea::platform::display::kHeight;
|
|
1329
|
+
if (!attempted)
|
|
1330
|
+
{
|
|
1331
|
+
attempted = true;
|
|
1332
|
+
buffer = static_cast<std::uint16_t *>(heap_caps_malloc(
|
|
1333
|
+
static_cast<std::size_t>(kCapPx) * sizeof(std::uint16_t), MALLOC_CAP_SPIRAM));
|
|
1334
|
+
}
|
|
1335
|
+
if (cap_px)
|
|
1336
|
+
*cap_px = buffer ? kCapPx : 0;
|
|
1337
|
+
return buffer;
|
|
1338
|
+
}
|