@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,1730 @@
|
|
|
1
|
+
#include "display.h"
|
|
2
|
+
|
|
3
|
+
#include "board.h"
|
|
4
|
+
#include "canvas.h"
|
|
5
|
+
#include "display_present.h"
|
|
6
|
+
#include "panel_native.h"
|
|
7
|
+
#include "host/display_orientation.h"
|
|
8
|
+
#include "pixel.h"
|
|
9
|
+
|
|
10
|
+
#include <algorithm>
|
|
11
|
+
#include <atomic>
|
|
12
|
+
#include <cstddef>
|
|
13
|
+
#include <cstdint>
|
|
14
|
+
#include <cstring>
|
|
15
|
+
#include <new>
|
|
16
|
+
#include <utility>
|
|
17
|
+
|
|
18
|
+
#include "driver/gpio.h"
|
|
19
|
+
#include "driver/ledc.h"
|
|
20
|
+
#include "driver/spi_master.h"
|
|
21
|
+
#include "esp_attr.h"
|
|
22
|
+
#include "esp_cache.h"
|
|
23
|
+
#include "esp_err.h"
|
|
24
|
+
#include "esp_heap_caps.h"
|
|
25
|
+
#include "esp_lcd_panel_io.h"
|
|
26
|
+
#include "esp_lcd_panel_ops.h"
|
|
27
|
+
#include "esp_lcd_panel_vendor.h"
|
|
28
|
+
#include "esp_lcd_st7796.h"
|
|
29
|
+
#include "esp_log.h"
|
|
30
|
+
#include "esp_rom_gpio.h"
|
|
31
|
+
#include "esp_timer.h"
|
|
32
|
+
#include "freertos/FreeRTOS.h"
|
|
33
|
+
#include "freertos/semphr.h"
|
|
34
|
+
#include "freertos/task.h"
|
|
35
|
+
#include "soc/gpio_sig_map.h"
|
|
36
|
+
#include "soc/spi_periph.h"
|
|
37
|
+
|
|
38
|
+
namespace platform_display = gea::platform::display;
|
|
39
|
+
namespace orientation_detail = gea::framework::display::detail;
|
|
40
|
+
namespace pixel = gea::framework::graphics::pixel;
|
|
41
|
+
namespace present = gea::framework::display_present;
|
|
42
|
+
|
|
43
|
+
namespace gea::platform::esp32_p4_waveshare::display {
|
|
44
|
+
|
|
45
|
+
namespace {
|
|
46
|
+
|
|
47
|
+
constexpr const char *kTag = "waveshare_p4_display";
|
|
48
|
+
constexpr int kNativeWidth = platform_display::kNativeWidth;
|
|
49
|
+
constexpr int kNativeHeight = platform_display::kNativeHeight;
|
|
50
|
+
constexpr int kMaxLogicalWidth = kNativeHeight > kNativeWidth ? kNativeHeight : kNativeWidth;
|
|
51
|
+
constexpr int kMaxLogicalHeight = kNativeHeight;
|
|
52
|
+
constexpr int kMaxPixels = kNativeWidth * kNativeHeight;
|
|
53
|
+
constexpr int kFlushRowsDefault = 64;
|
|
54
|
+
// ST7796 SPI panel (Waveshare ESP32-P4-WIFI6-Touch-LCD-3.5): 320x480, SPI mode 3,
|
|
55
|
+
// 8-bit command/parameter, 80 MHz pixel clock, BGR element order, color-inverted,
|
|
56
|
+
// X-mirrored. Flushed via esp_lcd_panel_draw_bitmap. The panel latches RGB565
|
|
57
|
+
// MSB-first, so each band is byte-swapped into an internal-RAM staging buffer
|
|
58
|
+
// before the SPI DMA (the PSRAM framebuffer stays native little-endian RGB565,
|
|
59
|
+
// which keeps the camera's PPA direct-present path correct).
|
|
60
|
+
constexpr int kSpiPclkHz = 80 * 1000 * 1000;
|
|
61
|
+
constexpr int kPanelBitsPerPixel = 16;
|
|
62
|
+
constexpr int kSpiTransQueueDepth = 8;
|
|
63
|
+
// Flush rotation modes: landscape logical frames are rotated into the panel's
|
|
64
|
+
// portrait scan order at flush time instead of via MADCTL (which would make
|
|
65
|
+
// GRAM writes perpendicular to the gate scan and shear/tear on motion).
|
|
66
|
+
constexpr int kFlushRotationNone = 0;
|
|
67
|
+
constexpr int kFlushRotationLandscapePrimary = 1;
|
|
68
|
+
constexpr int kFlushRotationLandscapeSecondary = 2;
|
|
69
|
+
// Internal-RAM bounce band for CPU-composed flushes — sized for the widest
|
|
70
|
+
// band across both orientations (landscape is 480 wide).
|
|
71
|
+
constexpr int kStagingBytes = kMaxLogicalWidth * kFlushRowsDefault * static_cast<int>(sizeof(std::uint16_t));
|
|
72
|
+
// The SPI bus itself takes up to a full panel frame in one transaction: the
|
|
73
|
+
// camera NativeOverlay pushes its PPA-rendered, pre-byteswapped PSRAM buffer
|
|
74
|
+
// as a single DMA (like the stock Waveshare demo's max_transfer_sz).
|
|
75
|
+
constexpr int kSpiMaxTransferBytes = kMaxPixels * static_cast<int>(sizeof(std::uint16_t));
|
|
76
|
+
constexpr ledc_channel_t kBacklightLedcChannel = LEDC_CHANNEL_1;
|
|
77
|
+
constexpr ledc_timer_t kBacklightLedcTimer = LEDC_TIMER_1;
|
|
78
|
+
constexpr int kBacklightLedcMaxDuty = 1023;
|
|
79
|
+
constexpr int kMaxPresentRects = 16;
|
|
80
|
+
constexpr int kOwnedFrameBufferPixels = kMaxPixels;
|
|
81
|
+
// ST7796 register reads (GSCAN scanline) need a slow clock — the panel's read
|
|
82
|
+
// cycle is ~150 ns vs the 12.5 ns write cycle, so a dedicated low-speed IO on
|
|
83
|
+
// the same bus handles them. 2 MHz is comfortably inside read timing.
|
|
84
|
+
constexpr int kSpiReadClkHz = 2 * 1000 * 1000;
|
|
85
|
+
constexpr std::uint8_t kSt7796CmdGetScanline = 0x45;
|
|
86
|
+
|
|
87
|
+
// Waveshare's vendor init for this glass (ported from the board's stock
|
|
88
|
+
// demo BSP, esp32_p4_wifi6_touch_lcd_35.c): command-2 unlock, inversion
|
|
89
|
+
// mode, power/VCOM, display-output timing adjust (0xE8), gamma, lock.
|
|
90
|
+
// Without it the panel runs on ST7796 power-on defaults, which differ from
|
|
91
|
+
// the stock firmware's drive timing. SLPOUT/COLMOD/MADCTL/INVON/DISPON are
|
|
92
|
+
// issued by the esp_lcd_st7796 driver itself and are not repeated here.
|
|
93
|
+
constexpr std::uint8_t kInitCmd2Unlock1[] = {0xC3};
|
|
94
|
+
constexpr std::uint8_t kInitCmd2Unlock2[] = {0x96};
|
|
95
|
+
// Panel scan timing — LOAD-BEARING for camera cadence AND tear sync. All
|
|
96
|
+
// numbers GSCAN-measured on this glass; the datasheet frame-rate formula
|
|
97
|
+
// does NOT match (measured: RTNA=16 → 17.095 ms scan, RTNA=15 → 17.064 ms
|
|
98
|
+
// (~31 us/step near here), RTNA=7 → 14.286 ms (non-linear cliff), FRS=9 →
|
|
99
|
+
// 18.671 ms, all at VFP/VBP=2/2 → 484 lines, ~35.3 us/line).
|
|
100
|
+
//
|
|
101
|
+
// Goal: the vsync-gated camera present must hit an INTEGER number of scans
|
|
102
|
+
// per sensor frame or motion judders ("two frames forward, one back").
|
|
103
|
+
// The AE paces the sensor at 50.0 ms/frame in normal light (the 1280x960
|
|
104
|
+
// mode is nominally 45 fps; the IPA stretches it, so sensor-side VTS
|
|
105
|
+
// alignment would fight the AE). Panel-side, porch lines give fine-grained
|
|
106
|
+
// control — and porch lines are SHORTER than active lines on this glass
|
|
107
|
+
// (two-point GSCAN calibration: VFP+VBP=4 → 17.095 ms; VFP+VBP=228 →
|
|
108
|
+
// 22.741 ms → ~25.2 us per porch line vs ~35.3 us per active line). Stretch
|
|
109
|
+
// to VFP=VBP=159 (318 porch lines) → scan ≈ 25.0 ms (40 Hz), TWO scans ≈
|
|
110
|
+
// 50.02 ms ≈ one sensor frame; the ~20-30 us residual = a single-scan
|
|
111
|
+
// cadence slip only every ~1 min. The ~31 ms push still fits two scan
|
|
112
|
+
// periods with wide margin (tear-free needs T_s ≥ ~15.8 ms). RTNA stays at
|
|
113
|
+
// the default 16; its ~31 us micro-steps remain available for future trim.
|
|
114
|
+
// RTNA=8 → 16.700 ms scan (GSCAN-measured): THREE scans = 50.10 ms ≈ the
|
|
115
|
+
// AE's current 50.0 ms sensor period → the vsync-gated camera present locks
|
|
116
|
+
// 1:1 with at most one single-scan cadence slip every ~8 s, and the ~31 ms
|
|
117
|
+
// full-frame push still fits two scans (33.4 ms) for tear-free geometry.
|
|
118
|
+
// This is the best static point on this glass: RTNA steps ~31-41 µs down to
|
|
119
|
+
// here (16→17.095, 15→17.064, 14→17.013) and CLIFF to 14.286 ms at RTNA=7
|
|
120
|
+
// (which tears); large porches misbehave outright (VFP/VBP=159 → 13.8 ms).
|
|
121
|
+
// Lighting changes move the AE's frame period — the static alignment holds for
|
|
122
|
+
// ~50 ms-class indoor light; the adaptive runtime controller is the open item
|
|
123
|
+
// for full robustness. Re-measure with measureScanTiming() on the glass: the
|
|
124
|
+
// ST7796S datasheet frame-rate formula does not match this panel.
|
|
125
|
+
constexpr std::uint8_t kInitFrameRate[] = {0xA0, 0x08};
|
|
126
|
+
constexpr std::uint8_t kInitPorch[] = {0x02, 0x02, 0x00, 0x04};
|
|
127
|
+
constexpr std::uint8_t kInitInversion[] = {0x01};
|
|
128
|
+
constexpr std::uint8_t kInitEntryMode[] = {0xC6};
|
|
129
|
+
constexpr std::uint8_t kInitPower1[] = {0x80, 0x45};
|
|
130
|
+
constexpr std::uint8_t kInitPower2[] = {0x13};
|
|
131
|
+
constexpr std::uint8_t kInitPower3[] = {0xA7};
|
|
132
|
+
constexpr std::uint8_t kInitVcom[] = {0x0A};
|
|
133
|
+
constexpr std::uint8_t kInitDoca[] = {0x40, 0x8A, 0x00, 0x00, 0x29, 0x19, 0xA5, 0x33};
|
|
134
|
+
constexpr std::uint8_t kInitGammaP[] = {0xD0, 0x08, 0x0F, 0x06, 0x06, 0x33, 0x30, 0x33,
|
|
135
|
+
0x47, 0x17, 0x13, 0x13, 0x2B, 0x31};
|
|
136
|
+
constexpr std::uint8_t kInitGammaN[] = {0xD0, 0x0A, 0x11, 0x0B, 0x09, 0x07, 0x2F, 0x33,
|
|
137
|
+
0x47, 0x38, 0x15, 0x16, 0x2C, 0x32};
|
|
138
|
+
constexpr std::uint8_t kInitCmd2Lock1[] = {0x3C};
|
|
139
|
+
constexpr std::uint8_t kInitCmd2Lock2[] = {0x69};
|
|
140
|
+
constexpr st7796_lcd_init_cmd_t kVendorInitCmds[] = {
|
|
141
|
+
{0xF0, kInitCmd2Unlock1, sizeof(kInitCmd2Unlock1), 0},
|
|
142
|
+
{0xF0, kInitCmd2Unlock2, sizeof(kInitCmd2Unlock2), 0},
|
|
143
|
+
{0xB1, kInitFrameRate, sizeof(kInitFrameRate), 0},
|
|
144
|
+
{0xB5, kInitPorch, sizeof(kInitPorch), 0},
|
|
145
|
+
{0xB4, kInitInversion, sizeof(kInitInversion), 0},
|
|
146
|
+
{0xB7, kInitEntryMode, sizeof(kInitEntryMode), 0},
|
|
147
|
+
{0xC0, kInitPower1, sizeof(kInitPower1), 0},
|
|
148
|
+
{0xC1, kInitPower2, sizeof(kInitPower2), 0},
|
|
149
|
+
{0xC2, kInitPower3, sizeof(kInitPower3), 0},
|
|
150
|
+
{0xC5, kInitVcom, sizeof(kInitVcom), 0},
|
|
151
|
+
{0xE8, kInitDoca, sizeof(kInitDoca), 0},
|
|
152
|
+
{0xE0, kInitGammaP, sizeof(kInitGammaP), 0},
|
|
153
|
+
{0xE1, kInitGammaN, sizeof(kInitGammaN), 0},
|
|
154
|
+
{0xF0, kInitCmd2Lock1, sizeof(kInitCmd2Lock1), 0},
|
|
155
|
+
{0xF0, kInitCmd2Lock2, sizeof(kInitCmd2Lock2), 120},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
present::Rect clampLogicalRect(present::Rect rect, int width, int height)
|
|
159
|
+
{
|
|
160
|
+
if (width <= 0 || height <= 0) return {};
|
|
161
|
+
rect = present::clampAndAlign(rect, width, height);
|
|
162
|
+
if (!present::valid(rect)) return {};
|
|
163
|
+
return rect;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
} // namespace
|
|
167
|
+
|
|
168
|
+
class DisplayBackend {
|
|
169
|
+
public:
|
|
170
|
+
static DisplayBackend &instance()
|
|
171
|
+
{
|
|
172
|
+
static DisplayBackend backend;
|
|
173
|
+
return backend;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
bool init()
|
|
177
|
+
{
|
|
178
|
+
if (initialized_) return true;
|
|
179
|
+
mutex_ = xSemaphoreCreateMutex();
|
|
180
|
+
if (!mutex_) {
|
|
181
|
+
ESP_LOGE(kTag, "failed to allocate display mutex");
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 128-byte aligned so the PPA can target it as an output picture (the
|
|
186
|
+
// camera's direct-present scales straight into this framebuffer). PPA
|
|
187
|
+
// output to PSRAM requires the buffer base + size aligned to the cache
|
|
188
|
+
// line; round the size up to match.
|
|
189
|
+
{
|
|
190
|
+
const std::size_t fbBytes =
|
|
191
|
+
(static_cast<std::size_t>(kOwnedFrameBufferPixels) * sizeof(std::uint16_t) + 127) & ~static_cast<std::size_t>(127);
|
|
192
|
+
ownedFrameBuffer_ = static_cast<std::uint16_t *>(
|
|
193
|
+
heap_caps_aligned_alloc(128, fbBytes, MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA | MALLOC_CAP_8BIT));
|
|
194
|
+
if (ownedFrameBuffer_) std::memset(ownedFrameBuffer_, 0, fbBytes);
|
|
195
|
+
}
|
|
196
|
+
if (!ownedFrameBuffer_) {
|
|
197
|
+
ESP_LOGE(kTag, "display owned framebuffer alloc failed");
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (!initPanel()) {
|
|
202
|
+
ESP_LOGE(kTag, "panel init failed");
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
bindCanvas();
|
|
206
|
+
if (frameBuffer_) {
|
|
207
|
+
std::memset(frameBuffer_, 0, static_cast<std::size_t>(kMaxPixels) * sizeof(std::uint16_t));
|
|
208
|
+
}
|
|
209
|
+
initialized_ = true;
|
|
210
|
+
ESP_LOGI(kTag, "display ready native=%dx%d logical=%dx%d", kNativeWidth, kNativeHeight, logicalWidth(), logicalHeight());
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
bool start() { return init(); }
|
|
215
|
+
|
|
216
|
+
gea::framework::graphics::Canvas *canvas()
|
|
217
|
+
{
|
|
218
|
+
if (!frameBuffer_) init();
|
|
219
|
+
return &replayCanvas();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Public accessor: is canvas() the panel scanout buffer (no logical->panel
|
|
223
|
+
// rotation)? Used by the camera direct-present to skip the rotate-flush.
|
|
224
|
+
bool framebufferIsPanelDirect() const { return usingPanelFrameBufferDirectly(); }
|
|
225
|
+
|
|
226
|
+
gea::framework::graphics::Canvas *drawingCanvas()
|
|
227
|
+
{
|
|
228
|
+
if (!frameBuffer_) init();
|
|
229
|
+
return &replayCanvas();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
void applyOrientation()
|
|
233
|
+
{
|
|
234
|
+
take();
|
|
235
|
+
bindCanvasLocked();
|
|
236
|
+
applyPanelOrientation();
|
|
237
|
+
if (!frameBuffer_) {
|
|
238
|
+
give();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
std::memset(frameBuffer_, 0, static_cast<std::size_t>(kMaxPixels) * sizeof(std::uint16_t));
|
|
242
|
+
canvas_.markDirty(0, 0, logicalWidth() - 1, logicalHeight() - 1);
|
|
243
|
+
previousPresentValid_ = false;
|
|
244
|
+
needsFullPhysicalFlush_ = true;
|
|
245
|
+
frameBufferCoherent_ = true;
|
|
246
|
+
give();
|
|
247
|
+
ESP_LOGI(kTag, "orientation=%s logical=%dx%d",
|
|
248
|
+
orientation_detail::DisplayOrientationState::orientationString().c_str(),
|
|
249
|
+
logicalWidth(), logicalHeight());
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
void clear()
|
|
253
|
+
{
|
|
254
|
+
clearNoFlush();
|
|
255
|
+
flush();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
void clearNoFlush()
|
|
259
|
+
{
|
|
260
|
+
if (!frameBuffer_) init();
|
|
261
|
+
take();
|
|
262
|
+
std::memset(frameBuffer_, 0, static_cast<std::size_t>(kMaxPixels) * sizeof(std::uint16_t));
|
|
263
|
+
canvas_.markDirty(0, 0, logicalWidth() - 1, logicalHeight() - 1);
|
|
264
|
+
previousPresentValid_ = false;
|
|
265
|
+
needsFullPhysicalFlush_ = true;
|
|
266
|
+
frameBufferCoherent_ = true;
|
|
267
|
+
give();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
void flush()
|
|
271
|
+
{
|
|
272
|
+
if (!init()) return;
|
|
273
|
+
const bool fullPhysicalFlush = needsFullPhysicalFlush_;
|
|
274
|
+
if (!fullPhysicalFlush && !canvas_.dirty(nullptr, nullptr, nullptr, nullptr)) return;
|
|
275
|
+
const std::int64_t started = esp_timer_get_time();
|
|
276
|
+
gea::framework::graphics::CanvasDirtyRect dirtyRects[gea::framework::graphics::Canvas::kMaxDirtyRects];
|
|
277
|
+
int dirtyCount = 0;
|
|
278
|
+
if (fullPhysicalFlush) {
|
|
279
|
+
dirtyRects[0] = {0, 0, logicalWidth() - 1, logicalHeight() - 1};
|
|
280
|
+
dirtyCount = 1;
|
|
281
|
+
ESP_LOGI(kTag, "first physical flush covers full logical frame %dx%d", logicalWidth(), logicalHeight());
|
|
282
|
+
} else {
|
|
283
|
+
dirtyCount = canvas_.dirtyRects(dirtyRects, gea::framework::graphics::Canvas::kMaxDirtyRects);
|
|
284
|
+
}
|
|
285
|
+
if (!fullPhysicalFlush && dirtyCount <= 0) {
|
|
286
|
+
int x0 = 0;
|
|
287
|
+
int y0 = 0;
|
|
288
|
+
int x1 = -1;
|
|
289
|
+
int y1 = -1;
|
|
290
|
+
if (canvas_.dirty(&x0, &y0, &x1, &y1)) {
|
|
291
|
+
dirtyRects[0] = {x0, y0, x1, y1};
|
|
292
|
+
dirtyCount = 1;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
bool ok = true;
|
|
296
|
+
flushStats_.callCount++;
|
|
297
|
+
for (int i = 0; i < dirtyCount; ++i) {
|
|
298
|
+
const auto &rect = dirtyRects[i];
|
|
299
|
+
if (!flushNativeLogicalRect({rect.x0, rect.y0, rect.x1, rect.y1})) {
|
|
300
|
+
ok = false;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
flushStats_.totalUs += esp_timer_get_time() - started;
|
|
305
|
+
if (ok) {
|
|
306
|
+
canvas_.resetDirty();
|
|
307
|
+
if (fullPhysicalFlush) needsFullPhysicalFlush_ = false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
void flushRects(const platform_display::DisplayFlushRect *rects, int count)
|
|
312
|
+
{
|
|
313
|
+
if (!rects || count <= 0) return;
|
|
314
|
+
if (!init()) return;
|
|
315
|
+
if (needsFullPhysicalFlush_) {
|
|
316
|
+
const std::int64_t started = esp_timer_get_time();
|
|
317
|
+
flushStats_.callCount++;
|
|
318
|
+
ESP_LOGI(kTag, "first physical flush covers full logical frame %dx%d", logicalWidth(), logicalHeight());
|
|
319
|
+
const bool ok = flushNativeLogicalRect({0, 0, logicalWidth() - 1, logicalHeight() - 1});
|
|
320
|
+
flushStats_.totalUs += esp_timer_get_time() - started;
|
|
321
|
+
if (ok) {
|
|
322
|
+
canvas_.resetDirty();
|
|
323
|
+
needsFullPhysicalFlush_ = false;
|
|
324
|
+
}
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const std::int64_t started = esp_timer_get_time();
|
|
328
|
+
bool ok = true;
|
|
329
|
+
flushStats_.callCount++;
|
|
330
|
+
for (int i = 0; i < count; ++i) {
|
|
331
|
+
const auto &rect = rects[i];
|
|
332
|
+
if (!flushNativeLogicalRect({rect.x0, rect.y0, rect.x1, rect.y1})) {
|
|
333
|
+
ok = false;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
flushStats_.totalUs += esp_timer_get_time() - started;
|
|
338
|
+
if (ok) canvas_.resetDirty();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
bool streamRect(int x, int y, int w, int h, platform_display::DisplayStreamRasterFn raster, void *user)
|
|
342
|
+
{
|
|
343
|
+
if (!raster || w <= 0 || h <= 0) return false;
|
|
344
|
+
if (!init()) return false;
|
|
345
|
+
const int x0 = std::max(0, x);
|
|
346
|
+
const int y0 = std::max(0, y);
|
|
347
|
+
const int x1 = std::min(logicalWidth() - 1, x + w - 1);
|
|
348
|
+
const int y1 = std::min(logicalHeight() - 1, y + h - 1);
|
|
349
|
+
if (x0 > x1 || y0 > y1) return true;
|
|
350
|
+
|
|
351
|
+
const int width = x1 - x0 + 1;
|
|
352
|
+
const int maxRows = std::max(1, kFlushRowsDefault);
|
|
353
|
+
for (int row = y0; row <= y1; row += maxRows) {
|
|
354
|
+
int rows = maxRows;
|
|
355
|
+
if (row + rows > y1 + 1) rows = y1 - row + 1;
|
|
356
|
+
if (x0 == 0 && width == logicalStride_) {
|
|
357
|
+
raster(frameBuffer_ + static_cast<std::size_t>(row) * logicalStride_, width, rows, x0, row, user);
|
|
358
|
+
} else {
|
|
359
|
+
for (int copyRow = 0; copyRow < rows; ++copyRow) {
|
|
360
|
+
raster(frameBuffer_ + static_cast<std::size_t>(row + copyRow) * logicalStride_ + x0,
|
|
361
|
+
width,
|
|
362
|
+
1,
|
|
363
|
+
x0,
|
|
364
|
+
row + copyRow,
|
|
365
|
+
user);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
canvas_.markDirty(x0, y0, x1, y1);
|
|
370
|
+
frameBufferCoherent_ = true;
|
|
371
|
+
flush();
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
bool presentCommands(const platform_display::DisplayPresentCommand *commands, int commandCount)
|
|
376
|
+
{
|
|
377
|
+
if (!commands || commandCount <= 0 || !init()) return false;
|
|
378
|
+
present::Frame current;
|
|
379
|
+
if (!present::extractFrame(commands, commandCount, current)) return false;
|
|
380
|
+
if (!present::frameHasOpaqueBase(current, logicalWidth(), logicalHeight())) return false;
|
|
381
|
+
if (!isFastClearFillCirclesFrame(current) && !frameBufferCoherent_) {
|
|
382
|
+
previousPresentValid_ = false;
|
|
383
|
+
needsFullPhysicalFlush_ = true;
|
|
384
|
+
}
|
|
385
|
+
if (isFastClearFillCirclesFrame(current) && incrementalCirclePathBeneficial(current)) {
|
|
386
|
+
const bool ok = presentClearFillCirclesFrame(current);
|
|
387
|
+
if (ok) {
|
|
388
|
+
previousPresentFrame_ = std::move(current);
|
|
389
|
+
previousPresentValid_ = true;
|
|
390
|
+
needsFullPhysicalFlush_ = false;
|
|
391
|
+
canvas_.resetDirty();
|
|
392
|
+
}
|
|
393
|
+
return ok;
|
|
394
|
+
}
|
|
395
|
+
present::Rect regions[kMaxPresentRects];
|
|
396
|
+
int regionCount = 0;
|
|
397
|
+
if (previousPresentValid_) {
|
|
398
|
+
regionCount = present::dirtyRects(&previousPresentFrame_,
|
|
399
|
+
current,
|
|
400
|
+
regions,
|
|
401
|
+
kMaxPresentRects,
|
|
402
|
+
logicalWidth(),
|
|
403
|
+
logicalHeight());
|
|
404
|
+
} else {
|
|
405
|
+
regions[0] = {0, 0, logicalWidth() - 1, logicalHeight() - 1};
|
|
406
|
+
regionCount = 1;
|
|
407
|
+
}
|
|
408
|
+
if (regionCount <= 0) {
|
|
409
|
+
previousPresentFrame_ = std::move(current);
|
|
410
|
+
previousPresentValid_ = true;
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const std::int64_t started = esp_timer_get_time();
|
|
415
|
+
bool ok = true;
|
|
416
|
+
flushStats_.callCount++;
|
|
417
|
+
for (int i = 0; i < regionCount; ++i) {
|
|
418
|
+
present::Rect region = clampLogicalRect(regions[i], logicalWidth(), logicalHeight());
|
|
419
|
+
if (!present::valid(region)) continue;
|
|
420
|
+
rasterPresentRegion(current, region);
|
|
421
|
+
ok = flushNativeLogicalRect(region);
|
|
422
|
+
if (!ok) {
|
|
423
|
+
ok = false;
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
flushStats_.totalUs += esp_timer_get_time() - started;
|
|
428
|
+
if (ok) {
|
|
429
|
+
previousPresentFrame_ = std::move(current);
|
|
430
|
+
previousPresentValid_ = true;
|
|
431
|
+
needsFullPhysicalFlush_ = false;
|
|
432
|
+
frameBufferCoherent_ = true;
|
|
433
|
+
canvas_.resetDirty();
|
|
434
|
+
}
|
|
435
|
+
return ok;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// A frame whose base layer is [Clear, FillCircles]. Commands AFTER the circle
|
|
439
|
+
// batch (FPS text, a HUD rect, ...) are overlays drawn on top — they ride the
|
|
440
|
+
// incremental path via a per-frame overlay re-raster, so they no longer
|
|
441
|
+
// disqualify it. (Previously this required EXACTLY two commands, which dropped
|
|
442
|
+
// any circle frame carrying an FPS counter onto the slow full-screen path.)
|
|
443
|
+
static bool isFastClearFillCirclesFrame(const present::Frame &frame)
|
|
444
|
+
{
|
|
445
|
+
using Type = gea::platform::display::DisplayPresentCommandType;
|
|
446
|
+
if (frame.commands.size() < 2) return false;
|
|
447
|
+
const present::Command &clear = frame.commands[0];
|
|
448
|
+
const present::Command &circles = frame.commands[1];
|
|
449
|
+
if (clear.type != Type::Clear || circles.type != Type::FillCirclesRgb565) return false;
|
|
450
|
+
if (circles.alpha != 255 || circles.radius <= 0 || circles.circlesCount < 0) return false;
|
|
451
|
+
return circles.hasCircleEntries();
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// The incremental circle path erases + redraws every ball (2x scattered writes
|
|
455
|
+
// over the whole framebuffer — cache-thrashing) to save the cache writeback on
|
|
456
|
+
// the untouched area. That trade only pays when the touched area is small; for a
|
|
457
|
+
// dense/full-screen ball field the general chunked rasterizer is faster (measured
|
|
458
|
+
// 21.6 vs 18.2fps for 1000 balls). So gate the incremental path on the would-be
|
|
459
|
+
// dirty area, mirroring the amoled's geometric band-collapse decision.
|
|
460
|
+
bool incrementalCirclePathBeneficial(const present::Frame ¤t) const
|
|
461
|
+
{
|
|
462
|
+
if (!previousPresentValid_ || needsFullPhysicalFlush_) return false;
|
|
463
|
+
if (!isFastClearFillCirclesFrame(previousPresentFrame_)) return false;
|
|
464
|
+
if (previousPresentFrame_.commands[0].color != current.commands[0].color) return false;
|
|
465
|
+
present::Rect dirty = present::unite(circleBatchBounds(previousPresentFrame_.commands[1]),
|
|
466
|
+
circleBatchBounds(current.commands[1]));
|
|
467
|
+
for (std::size_t i = 2; i < current.commands.size(); ++i)
|
|
468
|
+
dirty = present::unite(dirty, present::commandBounds(current.commands[i], logicalWidth(), logicalHeight()));
|
|
469
|
+
for (std::size_t i = 2; i < previousPresentFrame_.commands.size(); ++i)
|
|
470
|
+
dirty = present::unite(dirty, present::commandBounds(previousPresentFrame_.commands[i], logicalWidth(), logicalHeight()));
|
|
471
|
+
dirty = clampLogicalRect(dirty, logicalWidth(), logicalHeight());
|
|
472
|
+
if (!present::valid(dirty)) return true; // nothing moved — trivially cheap
|
|
473
|
+
const long long dirtyArea = static_cast<long long>(dirty.x1 - dirty.x0 + 1) * (dirty.y1 - dirty.y0 + 1);
|
|
474
|
+
const long long screenArea = static_cast<long long>(logicalWidth()) * logicalHeight();
|
|
475
|
+
return dirtyArea * 3 < screenArea; // only when < ~1/3 of the screen is touched
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
bool presentClearFillCirclesFrame(const present::Frame ¤t)
|
|
479
|
+
{
|
|
480
|
+
const present::Command &clear = current.commands[0];
|
|
481
|
+
const present::Command &circles = current.commands[1];
|
|
482
|
+
const bool canIncremental =
|
|
483
|
+
previousPresentValid_ &&
|
|
484
|
+
isFastClearFillCirclesFrame(previousPresentFrame_) &&
|
|
485
|
+
previousPresentFrame_.commands[0].color == clear.color;
|
|
486
|
+
|
|
487
|
+
// Overlays = every command past the circle batch (e.g. the FPS text). They
|
|
488
|
+
// sit on top of the balls and don't move with them, so their box — current
|
|
489
|
+
// AND previous (to erase the stale overlay) — is repainted independently and
|
|
490
|
+
// re-composited from scratch. Empty when the frame is pure [Clear, FillCircles].
|
|
491
|
+
present::Rect overlayDirty{};
|
|
492
|
+
for (std::size_t i = 2; i < current.commands.size(); ++i)
|
|
493
|
+
overlayDirty = present::unite(overlayDirty, present::commandBounds(current.commands[i], logicalWidth(), logicalHeight()));
|
|
494
|
+
if (canIncremental)
|
|
495
|
+
for (std::size_t i = 2; i < previousPresentFrame_.commands.size(); ++i)
|
|
496
|
+
overlayDirty = present::unite(overlayDirty, present::commandBounds(previousPresentFrame_.commands[i], logicalWidth(), logicalHeight()));
|
|
497
|
+
overlayDirty = clampLogicalRect(overlayDirty, logicalWidth(), logicalHeight());
|
|
498
|
+
|
|
499
|
+
present::Rect dirty = present::fullScreen(logicalWidth(), logicalHeight());
|
|
500
|
+
if (canIncremental && !needsFullPhysicalFlush_) {
|
|
501
|
+
dirty = present::unite(circleBatchBounds(previousPresentFrame_.commands[1]), circleBatchBounds(circles));
|
|
502
|
+
if (present::valid(overlayDirty)) dirty = present::unite(dirty, overlayDirty);
|
|
503
|
+
dirty = clampLogicalRect(dirty, logicalWidth(), logicalHeight());
|
|
504
|
+
if (!present::valid(dirty)) return true;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const std::int64_t started = esp_timer_get_time();
|
|
508
|
+
flushStats_.callCount++;
|
|
509
|
+
const std::int64_t rasterStartUs = esp_timer_get_time();
|
|
510
|
+
if (canIncremental && !needsFullPhysicalFlush_) {
|
|
511
|
+
drawCircleBatchRaw(previousPresentFrame_.commands[1], clear.color, true);
|
|
512
|
+
} else {
|
|
513
|
+
clearFrameBufferRows(0, logicalHeight() - 1, clear.color);
|
|
514
|
+
}
|
|
515
|
+
drawCircleBatchRaw(circles, 0, false);
|
|
516
|
+
// Composite overlays: re-raster their box from the full frame (clear + the
|
|
517
|
+
// balls behind them + the overlay itself), so the old overlay is erased and
|
|
518
|
+
// the new one lands on top of whatever balls sit behind it.
|
|
519
|
+
if (present::valid(overlayDirty)) rasterPresentRegion(current, overlayDirty);
|
|
520
|
+
flushStats_.rasterUs += esp_timer_get_time() - rasterStartUs;
|
|
521
|
+
|
|
522
|
+
const bool ok = flushNativeLogicalRect(dirty);
|
|
523
|
+
flushStats_.totalUs += esp_timer_get_time() - started;
|
|
524
|
+
if (ok) frameBufferCoherent_ = true;
|
|
525
|
+
return ok;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
present::Rect circleBatchBounds(const present::Command &command) const
|
|
529
|
+
{
|
|
530
|
+
present::Rect bounds{};
|
|
531
|
+
const auto *circles = command.circleEntries();
|
|
532
|
+
if (!circles || command.circlesCount <= 0) return bounds;
|
|
533
|
+
for (int i = 0; i < command.circlesCount; ++i) {
|
|
534
|
+
bounds = present::unite(bounds,
|
|
535
|
+
present::circleBounds(static_cast<int>(circles[i].x),
|
|
536
|
+
static_cast<int>(circles[i].y),
|
|
537
|
+
command.radius));
|
|
538
|
+
}
|
|
539
|
+
return bounds;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
void clearFrameBufferRows(int y0, int y1, std::uint16_t color)
|
|
543
|
+
{
|
|
544
|
+
if (!frameBuffer_) return;
|
|
545
|
+
y0 = std::max(0, y0);
|
|
546
|
+
y1 = std::min(logicalHeight() - 1, y1);
|
|
547
|
+
if (y0 > y1) return;
|
|
548
|
+
const int width = logicalWidth();
|
|
549
|
+
const int rows = y1 - y0 + 1;
|
|
550
|
+
std::uint16_t *dst = frameBuffer_ + static_cast<std::size_t>(y0) * logicalStride_;
|
|
551
|
+
if (logicalStride_ == width) {
|
|
552
|
+
const std::size_t pixels = static_cast<std::size_t>(width) * rows;
|
|
553
|
+
if (color == 0) std::memset(dst, 0, pixels * sizeof(std::uint16_t));
|
|
554
|
+
else std::fill_n(dst, pixels, color);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
for (int y = y0; y <= y1; ++y) {
|
|
558
|
+
std::uint16_t *row = frameBuffer_ + static_cast<std::size_t>(y) * logicalStride_;
|
|
559
|
+
if (color == 0) std::memset(row, 0, static_cast<std::size_t>(width) * sizeof(std::uint16_t));
|
|
560
|
+
else std::fill_n(row, width, color);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
void drawCircleBatchRaw(const present::Command &command, std::uint16_t overrideColor, bool useOverrideColor)
|
|
565
|
+
{
|
|
566
|
+
if (!frameBuffer_ || command.radius <= 0 || command.circlesCount <= 0) return;
|
|
567
|
+
const auto *circles = command.circleEntries();
|
|
568
|
+
if (!circles) return;
|
|
569
|
+
const int width = logicalWidth();
|
|
570
|
+
const int height = logicalHeight();
|
|
571
|
+
const int r = command.radius;
|
|
572
|
+
for (int i = 0; i < command.circlesCount; ++i) {
|
|
573
|
+
const int cx = static_cast<int>(circles[i].x);
|
|
574
|
+
const int cy = static_cast<int>(circles[i].y);
|
|
575
|
+
const std::uint16_t color = useOverrideColor ? overrideColor : circles[i].color;
|
|
576
|
+
int dy0 = -r;
|
|
577
|
+
int dy1 = r;
|
|
578
|
+
if (cy + dy0 < 0) dy0 = -cy;
|
|
579
|
+
if (cy + dy1 >= height) dy1 = height - 1 - cy;
|
|
580
|
+
if (dy0 > dy1) continue;
|
|
581
|
+
for (int dy = dy0; dy <= dy1; ++dy) {
|
|
582
|
+
const int spanIndex = dy + command.spans.origin;
|
|
583
|
+
const int halfWidth =
|
|
584
|
+
spanIndex >= 0 && spanIndex < static_cast<int>(command.spans.halfWidths.size())
|
|
585
|
+
? command.spans.halfWidths[static_cast<std::size_t>(spanIndex)]
|
|
586
|
+
: present::integerSqrt(r * r - dy * dy);
|
|
587
|
+
int x0 = cx - halfWidth;
|
|
588
|
+
int x1 = cx + halfWidth;
|
|
589
|
+
if (x0 < 0) x0 = 0;
|
|
590
|
+
if (x1 >= width) x1 = width - 1;
|
|
591
|
+
if (x0 > x1) continue;
|
|
592
|
+
std::uint16_t *dst = frameBuffer_ + static_cast<std::size_t>(cy + dy) * logicalStride_ + x0;
|
|
593
|
+
const int count = x1 - x0 + 1;
|
|
594
|
+
if (color == 0) std::memset(dst, 0, static_cast<std::size_t>(count) * sizeof(std::uint16_t));
|
|
595
|
+
else std::fill_n(dst, count, color);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
void setFlushConfig(int chunkRows, int queueDepth)
|
|
601
|
+
{
|
|
602
|
+
if (chunkRows > 0) flushRows_ = std::min(chunkRows, kFlushRowsDefault);
|
|
603
|
+
if (queueDepth > 0) flushDepth_ = queueDepth;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
int flushChunkRows() const { return flushRows_; }
|
|
607
|
+
int flushQueueDepth() const { return flushDepth_; }
|
|
608
|
+
int flushBufferBytes() const { return 0; }
|
|
609
|
+
|
|
610
|
+
bool copySnapshotRgb565(std::uint16_t *dst, int pixelCapacity, int *width, int *height)
|
|
611
|
+
{
|
|
612
|
+
if (!dst || pixelCapacity < logicalWidth() * logicalHeight()) return false;
|
|
613
|
+
if (width) *width = logicalWidth();
|
|
614
|
+
if (height) *height = logicalHeight();
|
|
615
|
+
for (int row = 0; row < logicalHeight(); ++row) {
|
|
616
|
+
std::memcpy(dst + static_cast<std::size_t>(row) * logicalWidth(),
|
|
617
|
+
frameBuffer_ + static_cast<std::size_t>(row) * logicalStride_,
|
|
618
|
+
static_cast<std::size_t>(logicalWidth()) * sizeof(std::uint16_t));
|
|
619
|
+
}
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
int countNonBlackPixels() const
|
|
624
|
+
{
|
|
625
|
+
if (!frameBuffer_) return 0;
|
|
626
|
+
int count = 0;
|
|
627
|
+
for (int y = 0; y < logicalHeight(); ++y) {
|
|
628
|
+
const std::uint16_t *row = frameBuffer_ + static_cast<std::size_t>(y) * logicalStride_;
|
|
629
|
+
for (int x = 0; x < logicalWidth(); ++x) {
|
|
630
|
+
if (pixel::toRgb565(row[x]) != 0) ++count;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return count;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
void setBrightness(int brightness)
|
|
637
|
+
{
|
|
638
|
+
if (brightness < 0) brightness = 0;
|
|
639
|
+
if (brightness > 100) brightness = 100;
|
|
640
|
+
brightness_ = brightness;
|
|
641
|
+
if (brightnessInitialized_) updateBacklightDuty();
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
int brightness() const { return brightness_; }
|
|
645
|
+
|
|
646
|
+
platform_display::DisplayFlushPerfStats flushStats() const { return flushStats_; }
|
|
647
|
+
void flushStatsReset() { flushStats_ = {}; }
|
|
648
|
+
|
|
649
|
+
const char *flushStageName() const { return "idle"; }
|
|
650
|
+
int flushStageChunk() const { return 0; }
|
|
651
|
+
platform_display::DisplayFlushStageDetail flushStageDetail() const { return {}; }
|
|
652
|
+
std::uint16_t *backgroundCache(int *capPx) { return fullScreenScratch(backgroundCache_, backgroundCacheAttempted_, capPx, "background"); }
|
|
653
|
+
std::uint16_t *backdropCache(int *capPx) { return fullScreenScratch(backdropCache_, backdropCacheAttempted_, capPx, "backdrop"); }
|
|
654
|
+
void setRenderCore(int core)
|
|
655
|
+
{
|
|
656
|
+
renderCoreId_ = core;
|
|
657
|
+
if (frameBuffer_) workerCanvas_.bindPixels(frameBuffer_, logicalWidth(), logicalHeight(), logicalStride_);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
void absorbWorkerDirty()
|
|
661
|
+
{
|
|
662
|
+
int x0 = 0;
|
|
663
|
+
int y0 = 0;
|
|
664
|
+
int x1 = -1;
|
|
665
|
+
int y1 = -1;
|
|
666
|
+
if (workerCanvas_.dirty(&x0, &y0, &x1, &y1)) canvas_.markDirty(x0, y0, x1, y1);
|
|
667
|
+
workerCanvas_.resetDirty();
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
private:
|
|
671
|
+
DisplayBackend() = default;
|
|
672
|
+
|
|
673
|
+
int logicalWidth() const { return orientation_detail::DisplayOrientationState::width(); }
|
|
674
|
+
int logicalHeight() const { return orientation_detail::DisplayOrientationState::height(); }
|
|
675
|
+
bool onWorkerCore() const { return renderCoreId_ >= 0 && xPortGetCoreID() != renderCoreId_; }
|
|
676
|
+
gea::framework::graphics::Canvas &replayCanvas() { return onWorkerCore() ? workerCanvas_ : canvas_; }
|
|
677
|
+
|
|
678
|
+
std::uint16_t *fullScreenScratch(std::uint16_t *&buffer, bool &attempted, int *capPx, const char *label)
|
|
679
|
+
{
|
|
680
|
+
if (!attempted) {
|
|
681
|
+
attempted = true;
|
|
682
|
+
buffer = static_cast<std::uint16_t *>(
|
|
683
|
+
heap_caps_malloc(static_cast<std::size_t>(kMaxPixels) * sizeof(std::uint16_t),
|
|
684
|
+
MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT));
|
|
685
|
+
if (buffer) {
|
|
686
|
+
ESP_LOGI(kTag, "allocated %s cache %.1f KiB", label, (kMaxPixels * sizeof(std::uint16_t)) / 1024.0);
|
|
687
|
+
} else {
|
|
688
|
+
ESP_LOGW(kTag, "failed to allocate %s cache (%zu bytes)",
|
|
689
|
+
label,
|
|
690
|
+
static_cast<std::size_t>(kMaxPixels) * sizeof(std::uint16_t));
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (capPx) *capPx = buffer ? kMaxPixels : 0;
|
|
694
|
+
return buffer;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
void bindCanvas()
|
|
698
|
+
{
|
|
699
|
+
take();
|
|
700
|
+
bindCanvasLocked();
|
|
701
|
+
give();
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
void bindCanvasLocked()
|
|
705
|
+
{
|
|
706
|
+
const int width = logicalWidth();
|
|
707
|
+
const int height = logicalHeight();
|
|
708
|
+
const int stride = width;
|
|
709
|
+
std::uint16_t *targetFrameBuffer = preferredFrameBuffer();
|
|
710
|
+
if (!targetFrameBuffer) return;
|
|
711
|
+
if (frameBuffer_ != targetFrameBuffer) frameBuffer_ = targetFrameBuffer;
|
|
712
|
+
if (canvas_.pixels() == frameBuffer_ && canvas_.width() == width && canvas_.height() == height && logicalStride_ == stride) return;
|
|
713
|
+
logicalStride_ = stride;
|
|
714
|
+
canvas_.bindPixels(frameBuffer_, width, height, logicalStride_);
|
|
715
|
+
workerCanvas_.bindPixels(frameBuffer_, width, height, logicalStride_);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
std::uint16_t *preferredFrameBuffer() const
|
|
719
|
+
{
|
|
720
|
+
// ST7796 SPI is a push panel: there is no scanout framebuffer the canvas can
|
|
721
|
+
// draw into directly, so we always render into our owned PSRAM buffer and
|
|
722
|
+
// flush dirty bands to the panel.
|
|
723
|
+
return ownedFrameBuffer_;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// A push panel never exposes its own scanout buffer, so writes always require an
|
|
727
|
+
// explicit flush. The camera direct-present path checks this to decide whether it
|
|
728
|
+
// can scale straight into the canvas.
|
|
729
|
+
bool usingPanelFrameBufferDirectly() const { return false; }
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
bool initBacklight()
|
|
733
|
+
{
|
|
734
|
+
if (brightnessInitialized_) return true;
|
|
735
|
+
|
|
736
|
+
ledc_timer_config_t timerConfig{};
|
|
737
|
+
timerConfig.speed_mode = LEDC_LOW_SPEED_MODE;
|
|
738
|
+
timerConfig.duty_resolution = LEDC_TIMER_10_BIT;
|
|
739
|
+
timerConfig.timer_num = kBacklightLedcTimer;
|
|
740
|
+
timerConfig.freq_hz = 5000;
|
|
741
|
+
timerConfig.clk_cfg = LEDC_AUTO_CLK;
|
|
742
|
+
esp_err_t err = ledc_timer_config(&timerConfig);
|
|
743
|
+
if (err != ESP_OK) {
|
|
744
|
+
ESP_LOGE(kTag, "backlight LEDC timer init failed: %s", esp_err_to_name(err));
|
|
745
|
+
return false;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
ledc_channel_config_t channelConfig{};
|
|
749
|
+
channelConfig.gpio_num = gea::platform::board::display.backlight;
|
|
750
|
+
channelConfig.speed_mode = LEDC_LOW_SPEED_MODE;
|
|
751
|
+
channelConfig.channel = kBacklightLedcChannel;
|
|
752
|
+
channelConfig.timer_sel = kBacklightLedcTimer;
|
|
753
|
+
channelConfig.duty = 0;
|
|
754
|
+
channelConfig.hpoint = 0;
|
|
755
|
+
err = ledc_channel_config(&channelConfig);
|
|
756
|
+
if (err != ESP_OK) {
|
|
757
|
+
ESP_LOGE(kTag, "backlight LEDC channel init failed: %s", esp_err_to_name(err));
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
brightnessInitialized_ = true;
|
|
762
|
+
updateBacklightDuty();
|
|
763
|
+
return true;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
void updateBacklightDuty()
|
|
767
|
+
{
|
|
768
|
+
const std::uint32_t duty = static_cast<std::uint32_t>((kBacklightLedcMaxDuty * brightness_) / 100);
|
|
769
|
+
const esp_err_t setErr = ledc_set_duty(LEDC_LOW_SPEED_MODE, kBacklightLedcChannel, duty);
|
|
770
|
+
const esp_err_t updateErr = ledc_update_duty(LEDC_LOW_SPEED_MODE, kBacklightLedcChannel);
|
|
771
|
+
if (setErr != ESP_OK || updateErr != ESP_OK) {
|
|
772
|
+
ESP_LOGE(kTag, "backlight duty update failed: set=%s update=%s",
|
|
773
|
+
esp_err_to_name(setErr),
|
|
774
|
+
esp_err_to_name(updateErr));
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
static bool IRAM_ATTR onColorTransDone(esp_lcd_panel_io_handle_t,
|
|
779
|
+
esp_lcd_panel_io_event_data_t *,
|
|
780
|
+
void *userCtx)
|
|
781
|
+
{
|
|
782
|
+
auto *self = static_cast<DisplayBackend *>(userCtx);
|
|
783
|
+
BaseType_t woken = pdFALSE;
|
|
784
|
+
if (self && self->flushDoneSem_) xSemaphoreGiveFromISR(self->flushDoneSem_, &woken);
|
|
785
|
+
return woken == pdTRUE;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Rotate the panel itself (ST7796 MADCTL swap_xy + mirror) to match the app's
|
|
789
|
+
// requested orientation, so the logical frame maps 1:1 onto the panel with no
|
|
790
|
+
// software rotation. Portrait-primary matches the vendor BSP (known good); the
|
|
791
|
+
// landscape/secondary mirror flags are verified on-device.
|
|
792
|
+
// The ST7796's gate driver always scans the physical (portrait) lines —
|
|
793
|
+
// MADCTL only remaps GRAM *addressing*, not the refresh scan. Writing
|
|
794
|
+
// landscape full-width bands through a swapped MADCTL therefore advances
|
|
795
|
+
// PERPENDICULAR to the panel's scan, which shears/tears on any motion no
|
|
796
|
+
// matter how fast the push is. (The stock Waveshare camera demo is tear-free
|
|
797
|
+
// precisely because it pushes portrait rows in scan order with the very same
|
|
798
|
+
// SPI config.) So landscape orientations keep the panel in PORTRAIT
|
|
799
|
+
// addressing and the flush path rotates each band into scan order instead
|
|
800
|
+
// (see flushRotatedLogicalRect); only portrait orientations use MADCTL.
|
|
801
|
+
void applyPanelOrientation()
|
|
802
|
+
{
|
|
803
|
+
if (!panel_) return;
|
|
804
|
+
using gea::framework::display::DisplayOrientation;
|
|
805
|
+
bool swapXy = false;
|
|
806
|
+
bool mirrorX = true;
|
|
807
|
+
bool mirrorY = false;
|
|
808
|
+
flushRotation_ = kFlushRotationNone;
|
|
809
|
+
switch (orientation_detail::DisplayOrientationState::orientation()) {
|
|
810
|
+
case DisplayOrientation::LandscapePrimary:
|
|
811
|
+
// Portrait-primary MADCTL + rotate-on-flush. Mapping derived from the
|
|
812
|
+
// (verified) landscape MADCTL swap+mirror(true,true) this replaces:
|
|
813
|
+
// panel x = logical y, panel y = (panelH-1) - logical x.
|
|
814
|
+
flushRotation_ = kFlushRotationLandscapePrimary;
|
|
815
|
+
break;
|
|
816
|
+
case DisplayOrientation::LandscapeSecondary:
|
|
817
|
+
// panel x = (panelW-1) - logical y, panel y = logical x.
|
|
818
|
+
flushRotation_ = kFlushRotationLandscapeSecondary;
|
|
819
|
+
break;
|
|
820
|
+
case DisplayOrientation::PortraitSecondary:
|
|
821
|
+
swapXy = false; mirrorX = false; mirrorY = true;
|
|
822
|
+
break;
|
|
823
|
+
case DisplayOrientation::PortraitPrimary:
|
|
824
|
+
default:
|
|
825
|
+
swapXy = false; mirrorX = true; mirrorY = false;
|
|
826
|
+
break;
|
|
827
|
+
}
|
|
828
|
+
esp_lcd_panel_swap_xy(panel_, swapXy);
|
|
829
|
+
esp_lcd_panel_mirror(panel_, mirrorX, mirrorY);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
bool initPanel()
|
|
833
|
+
{
|
|
834
|
+
if (panel_) return true;
|
|
835
|
+
if (!initBacklight()) return false;
|
|
836
|
+
|
|
837
|
+
flushDoneSem_ = xSemaphoreCreateBinary();
|
|
838
|
+
if (!flushDoneSem_) {
|
|
839
|
+
ESP_LOGE(kTag, "failed to allocate flush-done semaphore");
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// One internal-RAM staging band. Each flush copies a full-width band of the
|
|
844
|
+
// PSRAM framebuffer here, byte-swapped to the panel's MSB-first RGB565, then
|
|
845
|
+
// DMAs it over SPI. Internal RAM keeps the SPI GDMA on the fast path.
|
|
846
|
+
stagingPixels_ = static_cast<std::uint16_t *>(
|
|
847
|
+
heap_caps_malloc(static_cast<std::size_t>(kStagingBytes), MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT));
|
|
848
|
+
if (!stagingPixels_) {
|
|
849
|
+
ESP_LOGE(kTag, "display staging band alloc (%d bytes) failed", kStagingBytes);
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
spi_bus_config_t busConfig = {};
|
|
854
|
+
busConfig.mosi_io_num = gea::platform::board::display.mosi;
|
|
855
|
+
// LCD_MISO (panel SDO) — scanline reads for tear-sync; see readScanline().
|
|
856
|
+
busConfig.miso_io_num = gea::platform::board::display.miso;
|
|
857
|
+
busConfig.sclk_io_num = gea::platform::board::display.sclk;
|
|
858
|
+
busConfig.quadwp_io_num = GPIO_NUM_NC;
|
|
859
|
+
busConfig.quadhd_io_num = GPIO_NUM_NC;
|
|
860
|
+
busConfig.max_transfer_sz = kSpiMaxTransferBytes;
|
|
861
|
+
esp_err_t err = spi_bus_initialize(gea::platform::board::display.spiHost, &busConfig, SPI_DMA_CH_AUTO);
|
|
862
|
+
if (err != ESP_OK) {
|
|
863
|
+
ESP_LOGE(kTag, "SPI bus init failed: %s", esp_err_to_name(err));
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
esp_lcd_panel_io_spi_config_t ioConfig = {};
|
|
868
|
+
ioConfig.cs_gpio_num = gea::platform::board::display.cs;
|
|
869
|
+
ioConfig.dc_gpio_num = gea::platform::board::display.dc;
|
|
870
|
+
ioConfig.spi_mode = 3;
|
|
871
|
+
ioConfig.pclk_hz = kSpiPclkHz;
|
|
872
|
+
ioConfig.trans_queue_depth = kSpiTransQueueDepth;
|
|
873
|
+
ioConfig.lcd_cmd_bits = 8;
|
|
874
|
+
ioConfig.lcd_param_bits = 8;
|
|
875
|
+
ioConfig.on_color_trans_done = &DisplayBackend::onColorTransDone;
|
|
876
|
+
ioConfig.user_ctx = this;
|
|
877
|
+
err = esp_lcd_new_panel_io_spi(
|
|
878
|
+
static_cast<esp_lcd_spi_bus_handle_t>(gea::platform::board::display.spiHost), &ioConfig, &io_);
|
|
879
|
+
if (err != ESP_OK) {
|
|
880
|
+
ESP_LOGE(kTag, "SPI panel IO init failed: %s", esp_err_to_name(err));
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// Second, slow IO on the same bus for ST7796 register reads (GSCAN tear
|
|
885
|
+
// sync). cs_gpio_num = -1: the CS pin belongs to the main IO's hardware CS
|
|
886
|
+
// slot; readScanline() temporarily drives it as a plain GPIO around each
|
|
887
|
+
// read transaction (the display mutex serializes all panel access).
|
|
888
|
+
esp_lcd_panel_io_spi_config_t readIoConfig = {};
|
|
889
|
+
readIoConfig.cs_gpio_num = GPIO_NUM_NC;
|
|
890
|
+
readIoConfig.dc_gpio_num = gea::platform::board::display.dc;
|
|
891
|
+
readIoConfig.spi_mode = 3;
|
|
892
|
+
readIoConfig.pclk_hz = kSpiReadClkHz;
|
|
893
|
+
readIoConfig.trans_queue_depth = 1;
|
|
894
|
+
readIoConfig.lcd_cmd_bits = 8;
|
|
895
|
+
readIoConfig.lcd_param_bits = 8;
|
|
896
|
+
err = esp_lcd_new_panel_io_spi(
|
|
897
|
+
static_cast<esp_lcd_spi_bus_handle_t>(gea::platform::board::display.spiHost), &readIoConfig, &ioRead_);
|
|
898
|
+
if (err != ESP_OK) {
|
|
899
|
+
ESP_LOGW(kTag, "scanline read IO init failed (%s); tear sync disabled", esp_err_to_name(err));
|
|
900
|
+
ioRead_ = nullptr;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
esp_lcd_panel_dev_config_t panelConfig = {};
|
|
904
|
+
panelConfig.reset_gpio_num = gea::platform::board::display.reset;
|
|
905
|
+
panelConfig.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR;
|
|
906
|
+
panelConfig.bits_per_pixel = kPanelBitsPerPixel;
|
|
907
|
+
st7796_vendor_config_t vendorConfig = {};
|
|
908
|
+
vendorConfig.init_cmds = kVendorInitCmds;
|
|
909
|
+
vendorConfig.init_cmds_size = sizeof(kVendorInitCmds) / sizeof(kVendorInitCmds[0]);
|
|
910
|
+
panelConfig.vendor_config = &vendorConfig;
|
|
911
|
+
err = esp_lcd_new_panel_st7796(io_, &panelConfig, &panel_);
|
|
912
|
+
if (err != ESP_OK) {
|
|
913
|
+
ESP_LOGE(kTag, "ST7796 panel create failed: %s", esp_err_to_name(err));
|
|
914
|
+
return false;
|
|
915
|
+
}
|
|
916
|
+
err = esp_lcd_panel_reset(panel_);
|
|
917
|
+
if (err != ESP_OK) {
|
|
918
|
+
ESP_LOGE(kTag, "panel reset failed: %s", esp_err_to_name(err));
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
921
|
+
err = esp_lcd_panel_init(panel_);
|
|
922
|
+
if (err != ESP_OK) {
|
|
923
|
+
ESP_LOGE(kTag, "panel init failed: %s", esp_err_to_name(err));
|
|
924
|
+
return false;
|
|
925
|
+
}
|
|
926
|
+
// Waveshare panel ships color-inverted; match the vendor BSP. Orientation
|
|
927
|
+
// (swap_xy + mirror) is applied separately so the panel rotates with the app's
|
|
928
|
+
// requested orientation — already set if the app declared landscape before init.
|
|
929
|
+
esp_lcd_panel_invert_color(panel_, true);
|
|
930
|
+
applyPanelOrientation();
|
|
931
|
+
err = esp_lcd_panel_disp_on_off(panel_, true);
|
|
932
|
+
if (err != ESP_OK) {
|
|
933
|
+
ESP_LOGE(kTag, "panel on failed: %s", esp_err_to_name(err));
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
// Learn the panel's scan period for tear-synced camera pushes.
|
|
937
|
+
measureScanTiming();
|
|
938
|
+
ESP_LOGI(kTag,
|
|
939
|
+
"ST7796 SPI panel ready %dx%d host=%d pclk=%dMHz mode=3 cs=%d dc=%d rst=%d bl=%d",
|
|
940
|
+
kNativeWidth, kNativeHeight,
|
|
941
|
+
static_cast<int>(gea::platform::board::display.spiHost),
|
|
942
|
+
kSpiPclkHz / 1000000,
|
|
943
|
+
static_cast<int>(gea::platform::board::display.cs),
|
|
944
|
+
static_cast<int>(gea::platform::board::display.dc),
|
|
945
|
+
static_cast<int>(gea::platform::board::display.reset),
|
|
946
|
+
static_cast<int>(gea::platform::board::display.backlight));
|
|
947
|
+
return true;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
bool flushNativeLogicalRect(present::Rect logicalRect)
|
|
951
|
+
{
|
|
952
|
+
logicalRect = clampLogicalRect(logicalRect, logicalWidth(), logicalHeight());
|
|
953
|
+
if (!present::valid(logicalRect)) return true;
|
|
954
|
+
if (flushRotation_ != kFlushRotationNone) return flushRotatedLogicalRect(logicalRect);
|
|
955
|
+
|
|
956
|
+
take();
|
|
957
|
+
bindCanvasLocked();
|
|
958
|
+
if (!panel_ || !frameBuffer_ || !stagingPixels_) {
|
|
959
|
+
give();
|
|
960
|
+
return false;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// The logical frame maps 1:1 to the panel (the panel MADCTL is rotated to the
|
|
964
|
+
// current orientation), so flush full-width bands: that keeps each band's
|
|
965
|
+
// framebuffer rows contiguous (logicalStride_ == logicalWidth()) and lets one
|
|
966
|
+
// packed staging buffer feed the SPI DMA. Each band is byte-swapped to the
|
|
967
|
+
// panel's MSB-first RGB565.
|
|
968
|
+
const int width = logicalWidth();
|
|
969
|
+
const int y0 = std::max(0, logicalRect.y0);
|
|
970
|
+
const int y1 = std::min(logicalHeight() - 1, logicalRect.y1);
|
|
971
|
+
const int maxRows = std::max(1, std::min(flushRows_, kFlushRowsDefault));
|
|
972
|
+
|
|
973
|
+
bool ok = true;
|
|
974
|
+
for (int row = y0; row <= y1 && ok; row += maxRows) {
|
|
975
|
+
int rows = maxRows;
|
|
976
|
+
if (row + rows > y1 + 1) rows = y1 - row + 1;
|
|
977
|
+
const std::size_t bandPixels = static_cast<std::size_t>(width) * rows;
|
|
978
|
+
|
|
979
|
+
const std::int64_t swapStartUs = esp_timer_get_time();
|
|
980
|
+
const std::uint16_t *src = frameBuffer_ + static_cast<std::size_t>(row) * logicalStride_;
|
|
981
|
+
for (std::size_t i = 0; i < bandPixels; ++i) stagingPixels_[i] = __builtin_bswap16(src[i]);
|
|
982
|
+
// Write the band back to PSRAM so physical memory matches what is being
|
|
983
|
+
// pushed. CPU-drawn UI pixels otherwise live only in the write-back cache —
|
|
984
|
+
// and the camera's NativeOverlay presentDirect() INVALIDATES (M2C) its
|
|
985
|
+
// full-width framebuffer rows every frame, discarding those dirty lines.
|
|
986
|
+
// The camera's own full-width band flush then re-pushes the panel columns
|
|
987
|
+
// from stale PSRAM, visibly reverting any small UI update (status text,
|
|
988
|
+
// button labels) ~one camera frame after it appeared. Camera-column lines
|
|
989
|
+
// are clean here (the PPA writes PSRAM directly), so this writeback only
|
|
990
|
+
// persists UI-drawn pixels — it cannot clobber a live camera frame.
|
|
991
|
+
// (Range is cache-line aligned: stride*2 = 960 B per row off a 128-aligned
|
|
992
|
+
// base, so no UNALIGNED flag is needed.)
|
|
993
|
+
esp_cache_msync(const_cast<std::uint16_t *>(src), bandPixels * sizeof(std::uint16_t),
|
|
994
|
+
ESP_CACHE_MSYNC_FLAG_DIR_C2M);
|
|
995
|
+
flushStats_.byteSwapUs += esp_timer_get_time() - swapStartUs;
|
|
996
|
+
|
|
997
|
+
const std::int64_t txStartUs = esp_timer_get_time();
|
|
998
|
+
const esp_err_t err = esp_lcd_panel_draw_bitmap(panel_, 0, row, width, row + rows, stagingPixels_);
|
|
999
|
+
if (err != ESP_OK) {
|
|
1000
|
+
ESP_LOGE(kTag, "draw_bitmap failed: %s", esp_err_to_name(err));
|
|
1001
|
+
ok = false;
|
|
1002
|
+
break;
|
|
1003
|
+
}
|
|
1004
|
+
// Block until the SPI DMA completes so the single staging band can be reused.
|
|
1005
|
+
if (flushDoneSem_) xSemaphoreTake(flushDoneSem_, portMAX_DELAY);
|
|
1006
|
+
flushStats_.txUs += esp_timer_get_time() - txStartUs;
|
|
1007
|
+
flushStats_.chunkCount++;
|
|
1008
|
+
flushStats_.pixelCount += static_cast<int>(bandPixels);
|
|
1009
|
+
}
|
|
1010
|
+
give();
|
|
1011
|
+
return ok;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
public:
|
|
1015
|
+
// Camera NativeOverlay fast path (panel_native.h): map a logical rect into
|
|
1016
|
+
// panel-native portrait coordinates so the camera can PPA-render straight
|
|
1017
|
+
// into a panel-ordered buffer (no CPU rotate, no byteswap pass).
|
|
1018
|
+
bool panelMapLogicalRect(int lx, int ly, int lw, int lh,
|
|
1019
|
+
int *px, int *py, int *pw, int *ph, int *extraRotCcw)
|
|
1020
|
+
{
|
|
1021
|
+
if (flushRotation_ == kFlushRotationNone || lw <= 0 || lh <= 0) return false;
|
|
1022
|
+
const int x1 = lx + lw - 1;
|
|
1023
|
+
const int y1 = ly + lh - 1;
|
|
1024
|
+
if (flushRotation_ == kFlushRotationLandscapePrimary) {
|
|
1025
|
+
*px = ly;
|
|
1026
|
+
*py = kNativeHeight - 1 - x1;
|
|
1027
|
+
*extraRotCcw = 1;
|
|
1028
|
+
} else {
|
|
1029
|
+
*px = kNativeWidth - 1 - y1;
|
|
1030
|
+
*py = lx;
|
|
1031
|
+
*extraRotCcw = 3;
|
|
1032
|
+
}
|
|
1033
|
+
*pw = lh;
|
|
1034
|
+
*ph = lw;
|
|
1035
|
+
return true;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// Push a packed little-endian RGB565 block (e.g. PPA output) to the panel at
|
|
1039
|
+
// portrait coordinates as ONE continuous SPI DMA. The byteswap to the
|
|
1040
|
+
// ST7796's MSB-first stream happens as a single full-block pass into a
|
|
1041
|
+
// dedicated PSRAM buffer first (the PPA can't pre-swap — its byte_swap flag
|
|
1042
|
+
// scrambles colors through the downscale filter). A single uninterrupted
|
|
1043
|
+
// transfer matters: pushing in CPU-interleaved bands makes the GRAM write
|
|
1044
|
+
// front advance in stop-start jerks that the panel's scan keeps crossing —
|
|
1045
|
+
// visible shear — while one wire-speed burst crosses it once, invisibly
|
|
1046
|
+
// (verified on-device: the banded push tore, the single burst didn't).
|
|
1047
|
+
bool presentPanelRect(const std::uint16_t *pixels, int px, int py, int w, int h)
|
|
1048
|
+
{
|
|
1049
|
+
if (!pixels || w <= 0 || h <= 0) return false;
|
|
1050
|
+
if (!init()) return false;
|
|
1051
|
+
take();
|
|
1052
|
+
if (!panel_ || !ensurePanelSwapBuf()) {
|
|
1053
|
+
give();
|
|
1054
|
+
return false;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
const std::size_t pixelCount = static_cast<std::size_t>(w) * h;
|
|
1058
|
+
const std::int64_t swapStartUs = esp_timer_get_time();
|
|
1059
|
+
// 4 pixels per 64-bit op: swap the bytes within each 16-bit lane.
|
|
1060
|
+
const std::uint64_t *src64 = reinterpret_cast<const std::uint64_t *>(pixels);
|
|
1061
|
+
std::uint64_t *dst64 = reinterpret_cast<std::uint64_t *>(panelSwapBuf_);
|
|
1062
|
+
const std::size_t quads = pixelCount / 4;
|
|
1063
|
+
for (std::size_t i = 0; i < quads; ++i) {
|
|
1064
|
+
const std::uint64_t v = src64[i];
|
|
1065
|
+
dst64[i] = ((v & 0xFF00FF00FF00FF00ull) >> 8) | ((v & 0x00FF00FF00FF00FFull) << 8);
|
|
1066
|
+
}
|
|
1067
|
+
for (std::size_t i = quads * 4; i < pixelCount; ++i)
|
|
1068
|
+
panelSwapBuf_[i] = __builtin_bswap16(pixels[i]);
|
|
1069
|
+
// The SPI GDMA reads physical PSRAM — write the swapped block back.
|
|
1070
|
+
esp_cache_msync(panelSwapBuf_,
|
|
1071
|
+
(pixelCount * sizeof(std::uint16_t) + 127) & ~static_cast<std::size_t>(127),
|
|
1072
|
+
ESP_CACHE_MSYNC_FLAG_DIR_C2M);
|
|
1073
|
+
flushStats_.byteSwapUs += esp_timer_get_time() - swapStartUs;
|
|
1074
|
+
|
|
1075
|
+
// Tear sync: start the GRAM write at the panel's scan top. A write that
|
|
1076
|
+
// starts at vsync keeps the write front between the two scan fronts for
|
|
1077
|
+
// the whole frame, so the scan never crosses it mid-rect — the crawling
|
|
1078
|
+
// shear band this panel otherwise shows on camera pushes. This path is
|
|
1079
|
+
// camera-exclusive (UI flushes go through the staging-band path), so
|
|
1080
|
+
// EVERY push is gated — an inset (non-full-screen) viewfinder pushes
|
|
1081
|
+
// fewer pixels but tears just the same without the gate. The wait
|
|
1082
|
+
// happens with the mutex RELEASED (readScanline retakes it per poll) so
|
|
1083
|
+
// UI flushes aren't blocked behind it; the swap buffer is camera-only,
|
|
1084
|
+
// so nothing can clobber it in the gap.
|
|
1085
|
+
give();
|
|
1086
|
+
waitForScanTop();
|
|
1087
|
+
take();
|
|
1088
|
+
if (!panel_) {
|
|
1089
|
+
give();
|
|
1090
|
+
return false;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
const std::int64_t txStartUs = esp_timer_get_time();
|
|
1094
|
+
const esp_err_t err = esp_lcd_panel_draw_bitmap(panel_, px, py, px + w, py + h, panelSwapBuf_);
|
|
1095
|
+
bool ok = err == ESP_OK;
|
|
1096
|
+
if (!ok) {
|
|
1097
|
+
ESP_LOGE(kTag, "presentPanelRect draw_bitmap failed: %s", esp_err_to_name(err));
|
|
1098
|
+
} else if (flushDoneSem_) {
|
|
1099
|
+
xSemaphoreTake(flushDoneSem_, portMAX_DELAY);
|
|
1100
|
+
}
|
|
1101
|
+
flushStats_.txUs += esp_timer_get_time() - txStartUs;
|
|
1102
|
+
flushStats_.chunkCount++;
|
|
1103
|
+
flushStats_.pixelCount += static_cast<int>(pixelCount);
|
|
1104
|
+
give();
|
|
1105
|
+
return ok;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// Asynchronous variant: hand the block to the panel-push worker task and
|
|
1109
|
+
// return; the caller may immediately start composing the NEXT frame into a
|
|
1110
|
+
// different buffer (the camera double-buffers), overlapping the ~30+ ms SPI
|
|
1111
|
+
// push with the PPA scale of the following frame. Back-pressured to one job
|
|
1112
|
+
// in flight: submitting waits for the previous push, so a buffer handed
|
|
1113
|
+
// back-to-back-alternately is never read and rewritten at the same time.
|
|
1114
|
+
bool presentPanelRectAsync(const std::uint16_t *pixels, int px, int py, int w, int h)
|
|
1115
|
+
{
|
|
1116
|
+
if (!ensurePanelPushTask()) return presentPanelRect(pixels, px, py, w, h);
|
|
1117
|
+
if (panelPushPending_) {
|
|
1118
|
+
xSemaphoreTake(panelPushDone_, portMAX_DELAY);
|
|
1119
|
+
panelPushPending_ = false;
|
|
1120
|
+
}
|
|
1121
|
+
panelPushInflight_.fetch_add(1, std::memory_order_acq_rel);
|
|
1122
|
+
panelPushJob_ = PanelPushJob{pixels, px, py, w, h};
|
|
1123
|
+
panelPushPending_ = true;
|
|
1124
|
+
xSemaphoreGive(panelPushStart_);
|
|
1125
|
+
return true;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
// Block until no async panel push is queued or streaming. Used by the
|
|
1129
|
+
// camera when the viewfinder GEOMETRY changes: a stale-rect push that
|
|
1130
|
+
// lands after the renderer repaints the freed region would wipe the new
|
|
1131
|
+
// UI with one dead frame of old-geometry camera content. Poll-wait is
|
|
1132
|
+
// fine — geometry changes are rare (layout switches), pushes are ≤~50 ms.
|
|
1133
|
+
void waitPanelPushIdle()
|
|
1134
|
+
{
|
|
1135
|
+
while (panelPushInflight_.load(std::memory_order_acquire) != 0) vTaskDelay(pdMS_TO_TICKS(1));
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
std::int64_t panelScanPeriodUs() const { return scanPeriodUs_; }
|
|
1139
|
+
|
|
1140
|
+
// See panel_native.h clearLogicalRect: blacks out a logical-fb rect so UI
|
|
1141
|
+
// flushes overlapping the camera-owned region paint black, not the stale
|
|
1142
|
+
// frame the panel-native present left behind there.
|
|
1143
|
+
void clearLogicalRect(int x, int y, int w, int h)
|
|
1144
|
+
{
|
|
1145
|
+
take();
|
|
1146
|
+
if (!frameBuffer_) {
|
|
1147
|
+
give();
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
const int lw = logicalWidth();
|
|
1151
|
+
const int lh = logicalHeight();
|
|
1152
|
+
const int x0 = std::max(0, x);
|
|
1153
|
+
const int y0 = std::max(0, y);
|
|
1154
|
+
const int x1 = std::min(lw, x + w);
|
|
1155
|
+
const int y1 = std::min(lh, y + h);
|
|
1156
|
+
if (x0 < x1 && y0 < y1) {
|
|
1157
|
+
for (int row = y0; row < y1; ++row) {
|
|
1158
|
+
std::memset(frameBuffer_ + static_cast<std::size_t>(row) * logicalStride_ + x0, 0,
|
|
1159
|
+
static_cast<std::size_t>(x1 - x0) * sizeof(std::uint16_t));
|
|
1160
|
+
}
|
|
1161
|
+
esp_cache_msync(frameBuffer_,
|
|
1162
|
+
(static_cast<std::size_t>(kMaxPixels) * sizeof(std::uint16_t) + 127) &
|
|
1163
|
+
~static_cast<std::size_t>(127),
|
|
1164
|
+
ESP_CACHE_MSYNC_FLAG_DIR_C2M);
|
|
1165
|
+
}
|
|
1166
|
+
give();
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
private:
|
|
1170
|
+
struct PanelPushJob {
|
|
1171
|
+
const std::uint16_t *pixels;
|
|
1172
|
+
int px, py, w, h;
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
static void panelPushTaskEntry(void *arg)
|
|
1176
|
+
{
|
|
1177
|
+
auto *self = static_cast<DisplayBackend *>(arg);
|
|
1178
|
+
for (;;) {
|
|
1179
|
+
xSemaphoreTake(self->panelPushStart_, portMAX_DELAY);
|
|
1180
|
+
const PanelPushJob job = self->panelPushJob_;
|
|
1181
|
+
self->presentPanelRect(job.pixels, job.px, job.py, job.w, job.h);
|
|
1182
|
+
self->panelPushInflight_.fetch_sub(1, std::memory_order_acq_rel);
|
|
1183
|
+
xSemaphoreGive(self->panelPushDone_);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
bool ensurePanelSwapBuf()
|
|
1188
|
+
{
|
|
1189
|
+
if (panelSwapBuf_) return true;
|
|
1190
|
+
const std::size_t bytes = static_cast<std::size_t>(kMaxPixels) * sizeof(std::uint16_t);
|
|
1191
|
+
panelSwapBuf_ = static_cast<std::uint16_t *>(
|
|
1192
|
+
heap_caps_aligned_alloc(128, bytes, MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA | MALLOC_CAP_8BIT));
|
|
1193
|
+
if (!panelSwapBuf_) ESP_LOGE(kTag, "panel swap buffer alloc (%zu bytes) failed", bytes);
|
|
1194
|
+
return panelSwapBuf_ != nullptr;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
bool ensurePanelPushTask()
|
|
1198
|
+
{
|
|
1199
|
+
if (panelPushTask_) return true;
|
|
1200
|
+
panelPushStart_ = xSemaphoreCreateBinary();
|
|
1201
|
+
panelPushDone_ = xSemaphoreCreateBinary();
|
|
1202
|
+
if (!panelPushStart_ || !panelPushDone_) return false;
|
|
1203
|
+
// Pin opposite the render core so the byteswap bursts overlap the frame
|
|
1204
|
+
// task's PPA/compose work instead of preempting it.
|
|
1205
|
+
const BaseType_t core = renderCoreId_ == 0 ? 1 : renderCoreId_ == 1 ? 0 : tskNO_AFFINITY;
|
|
1206
|
+
if (xTaskCreatePinnedToCore(panelPushTaskEntry, "panel_push", 4096, this, 5, &panelPushTask_, core) !=
|
|
1207
|
+
pdPASS) {
|
|
1208
|
+
panelPushTask_ = nullptr;
|
|
1209
|
+
return false;
|
|
1210
|
+
}
|
|
1211
|
+
return true;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// Read the ST7796 GSCAN (0x45) register: the current gate line as a
|
|
1215
|
+
// monotonic ramp that wraps at the scan top. The read IO has no CS slot of
|
|
1216
|
+
// its own (one CS wire, owned by the main IO's hardware CS), so the CS pin
|
|
1217
|
+
// is driven as a plain GPIO around the transaction and then handed back to
|
|
1218
|
+
// the SPI peripheral. A dummy clock precedes the data, so the absolute
|
|
1219
|
+
// value is bit-shifted — callers only rely on ramp+wrap, never the line
|
|
1220
|
+
// number itself. Takes the display mutex internally.
|
|
1221
|
+
bool readScanline(int *outLine)
|
|
1222
|
+
{
|
|
1223
|
+
if (!ioRead_) return false;
|
|
1224
|
+
take();
|
|
1225
|
+
const gpio_num_t cs = gea::platform::board::display.cs;
|
|
1226
|
+
gpio_set_level(cs, 1);
|
|
1227
|
+
esp_rom_gpio_connect_out_signal(cs, SIG_GPIO_OUT_IDX, false, false);
|
|
1228
|
+
gpio_set_direction(cs, GPIO_MODE_OUTPUT);
|
|
1229
|
+
gpio_set_level(cs, 0);
|
|
1230
|
+
std::uint8_t raw[2] = {0, 0};
|
|
1231
|
+
const esp_err_t err = esp_lcd_panel_io_rx_param(ioRead_, kSt7796CmdGetScanline, raw, sizeof(raw));
|
|
1232
|
+
gpio_set_level(cs, 1);
|
|
1233
|
+
esp_rom_gpio_connect_out_signal(
|
|
1234
|
+
cs, spi_periph_signal[gea::platform::board::display.spiHost].spics_out[0], false, false);
|
|
1235
|
+
give();
|
|
1236
|
+
if (err != ESP_OK) return false;
|
|
1237
|
+
*outLine = (static_cast<int>(raw[0]) << 8) | raw[1];
|
|
1238
|
+
return true;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// Sample GSCAN for ~160 ms after panel init: learn the ramp's max value and
|
|
1242
|
+
// the scan (vsync) period. Leaves scanPeriodUs_ at 0 — tear sync disabled —
|
|
1243
|
+
// when the register can't be read (e.g. SDO not actually wired through).
|
|
1244
|
+
// Robustness: a single glitched read used to register a FALSE wrap, which
|
|
1245
|
+
// split one inter-wrap delta in two and skewed the mean period by a whole
|
|
1246
|
+
// divisor (measured 14.46 ms on a build whose true period was 16.7 ms). So
|
|
1247
|
+
// wraps must look like real wraps (high ramp → low ramp), and the period
|
|
1248
|
+
// is the MEDIAN of the inter-wrap deltas, which one bad wrap can't move.
|
|
1249
|
+
void measureScanTiming()
|
|
1250
|
+
{
|
|
1251
|
+
if (!ioRead_) return;
|
|
1252
|
+
constexpr int kMaxDeltas = 24;
|
|
1253
|
+
std::int64_t deltas[kMaxDeltas];
|
|
1254
|
+
int deltaCount = 0;
|
|
1255
|
+
int maxLine = 0;
|
|
1256
|
+
int prev = -1;
|
|
1257
|
+
std::int64_t lastWrapUs = 0;
|
|
1258
|
+
const std::int64_t until = esp_timer_get_time() + 160 * 1000;
|
|
1259
|
+
while (esp_timer_get_time() < until && deltaCount < kMaxDeltas) {
|
|
1260
|
+
int line = 0;
|
|
1261
|
+
if (!readScanline(&line)) {
|
|
1262
|
+
scanPeriodUs_ = 0;
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
if (line > maxLine) maxLine = line;
|
|
1266
|
+
const bool wrapped =
|
|
1267
|
+
prev >= 0 && maxLine > 16 && prev > (maxLine * 3) / 4 && line < maxLine / 4;
|
|
1268
|
+
if (wrapped) {
|
|
1269
|
+
const std::int64_t now = esp_timer_get_time();
|
|
1270
|
+
if (lastWrapUs != 0 && now > lastWrapUs) {
|
|
1271
|
+
if (deltaCount < kMaxDeltas) deltas[deltaCount++] = now - lastWrapUs;
|
|
1272
|
+
}
|
|
1273
|
+
lastWrapUs = now;
|
|
1274
|
+
}
|
|
1275
|
+
prev = line;
|
|
1276
|
+
}
|
|
1277
|
+
if (deltaCount >= 3 && maxLine > 16) {
|
|
1278
|
+
std::sort(deltas, deltas + deltaCount);
|
|
1279
|
+
scanPeriodUs_ = deltas[deltaCount / 2];
|
|
1280
|
+
scanlineMax_ = maxLine;
|
|
1281
|
+
ESP_LOGI(kTag, "panel scan: period=%lldus (%.1f Hz, median/%d) gscan-max=%d — tear sync ON",
|
|
1282
|
+
static_cast<long long>(scanPeriodUs_), 1e6 / static_cast<double>(scanPeriodUs_),
|
|
1283
|
+
deltaCount, scanlineMax_);
|
|
1284
|
+
} else {
|
|
1285
|
+
scanPeriodUs_ = 0;
|
|
1286
|
+
ESP_LOGW(kTag, "GSCAN unreadable (max=%d deltas=%d) — tear sync disabled", maxLine, deltaCount);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
// Block until the panel's gate scan wraps to the top. Sleeps through the
|
|
1291
|
+
// bulk of the ramp (estimated from the measured period), then spin-polls
|
|
1292
|
+
// the wrap. No-op when scan timing is unknown. Called WITHOUT the mutex.
|
|
1293
|
+
void waitForScanTop()
|
|
1294
|
+
{
|
|
1295
|
+
if (!ioRead_ || scanPeriodUs_ <= 0 || scanlineMax_ <= 0) return;
|
|
1296
|
+
const std::int64_t deadline = esp_timer_get_time() + 2 * scanPeriodUs_;
|
|
1297
|
+
int prev = -1;
|
|
1298
|
+
for (;;) {
|
|
1299
|
+
int line = 0;
|
|
1300
|
+
if (!readScanline(&line)) return;
|
|
1301
|
+
if (prev >= 0 && line + scanlineMax_ / 4 < prev) return; // wrapped: scan is at the top
|
|
1302
|
+
if (line >= 0 && line < scanlineMax_) {
|
|
1303
|
+
const std::int64_t remainUs =
|
|
1304
|
+
static_cast<std::int64_t>(scanlineMax_ - line) * scanPeriodUs_ / scanlineMax_;
|
|
1305
|
+
if (remainUs > 3000) vTaskDelay(pdMS_TO_TICKS((remainUs - 2000) / 1000));
|
|
1306
|
+
}
|
|
1307
|
+
prev = line;
|
|
1308
|
+
if (esp_timer_get_time() > deadline) return;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
// Landscape flush onto the portrait-addressed panel: rotate each band into
|
|
1313
|
+
// the panel's scan order so the GRAM write front advances WITH the gate
|
|
1314
|
+
// scan (top physical row to bottom), the way the tear-free stock demo
|
|
1315
|
+
// pushes. A logical rect {x0..x1, y0..y1} maps to the panel rect
|
|
1316
|
+
// {px: y0..y1, py: panelH-1-x1 .. panelH-1-x0} (LandscapePrimary) or
|
|
1317
|
+
// {px: panelW-1-y1 .. panelW-1-y0, py: x0..x1} (LandscapeSecondary).
|
|
1318
|
+
// The transpose loop reads the logical framebuffer row-sequentially (each
|
|
1319
|
+
// inner run is a contiguous <=band-height stretch of one logical row in
|
|
1320
|
+
// PSRAM) and scatters into the internal-RAM staging band, where strided
|
|
1321
|
+
// writes are cheap.
|
|
1322
|
+
bool flushRotatedLogicalRect(const present::Rect &logicalRect)
|
|
1323
|
+
{
|
|
1324
|
+
take();
|
|
1325
|
+
bindCanvasLocked();
|
|
1326
|
+
if (!panel_ || !frameBuffer_ || !stagingPixels_) {
|
|
1327
|
+
give();
|
|
1328
|
+
return false;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
const bool primary = flushRotation_ == kFlushRotationLandscapePrimary;
|
|
1332
|
+
const int panelH = kNativeHeight; // 480 physical scan lines
|
|
1333
|
+
const int panelW = kNativeWidth; // 320 pixels per scan line
|
|
1334
|
+
const int x0 = logicalRect.x0, x1 = logicalRect.x1;
|
|
1335
|
+
const int y0 = logicalRect.y0, y1 = logicalRect.y1;
|
|
1336
|
+
|
|
1337
|
+
// Write back the logical source region first so PSRAM stays coherent
|
|
1338
|
+
// with what is pushed (same hazard as the 1:1 path: the camera's
|
|
1339
|
+
// NativeOverlay invalidate would otherwise drop CPU-drawn pixels that
|
|
1340
|
+
// only live in the write-back cache). Full-width rows keep the range
|
|
1341
|
+
// cache-line aligned.
|
|
1342
|
+
esp_cache_msync(frameBuffer_ + static_cast<std::size_t>(y0) * logicalStride_,
|
|
1343
|
+
static_cast<std::size_t>(y1 - y0 + 1) * logicalStride_ * sizeof(std::uint16_t),
|
|
1344
|
+
ESP_CACHE_MSYNC_FLAG_DIR_C2M);
|
|
1345
|
+
|
|
1346
|
+
const int px0 = primary ? y0 : panelW - 1 - y1;
|
|
1347
|
+
const int px1 = primary ? y1 : panelW - 1 - y0;
|
|
1348
|
+
const int py0 = primary ? panelH - 1 - x1 : x0;
|
|
1349
|
+
const int py1 = primary ? panelH - 1 - x0 : x1;
|
|
1350
|
+
const int bandW = px1 - px0 + 1;
|
|
1351
|
+
const int maxRows = std::max(1, std::min(flushRows_, kFlushRowsDefault));
|
|
1352
|
+
|
|
1353
|
+
bool ok = true;
|
|
1354
|
+
for (int row = py0; row <= py1 && ok; row += maxRows) {
|
|
1355
|
+
int rows = maxRows;
|
|
1356
|
+
if (row + rows > py1 + 1) rows = py1 - row + 1;
|
|
1357
|
+
|
|
1358
|
+
const std::int64_t swapStartUs = esp_timer_get_time();
|
|
1359
|
+
for (int ly = y0; ly <= y1; ++ly) {
|
|
1360
|
+
const std::uint16_t *srcRow = frameBuffer_ + static_cast<std::size_t>(ly) * logicalStride_;
|
|
1361
|
+
const int cx = primary ? ly - y0 : y1 - ly; // column inside the staging band
|
|
1362
|
+
std::uint16_t *dst = stagingPixels_ + cx;
|
|
1363
|
+
for (int r = row; r < row + rows; ++r) {
|
|
1364
|
+
const int lx = primary ? panelH - 1 - r : r;
|
|
1365
|
+
dst[static_cast<std::size_t>(r - row) * bandW] = __builtin_bswap16(srcRow[lx]);
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
flushStats_.byteSwapUs += esp_timer_get_time() - swapStartUs;
|
|
1369
|
+
|
|
1370
|
+
const std::int64_t txStartUs = esp_timer_get_time();
|
|
1371
|
+
const esp_err_t err =
|
|
1372
|
+
esp_lcd_panel_draw_bitmap(panel_, px0, row, px1 + 1, row + rows, stagingPixels_);
|
|
1373
|
+
if (err != ESP_OK) {
|
|
1374
|
+
ESP_LOGE(kTag, "rotated draw_bitmap failed: %s", esp_err_to_name(err));
|
|
1375
|
+
ok = false;
|
|
1376
|
+
break;
|
|
1377
|
+
}
|
|
1378
|
+
if (flushDoneSem_) xSemaphoreTake(flushDoneSem_, portMAX_DELAY);
|
|
1379
|
+
flushStats_.txUs += esp_timer_get_time() - txStartUs;
|
|
1380
|
+
flushStats_.chunkCount++;
|
|
1381
|
+
flushStats_.pixelCount += bandW * rows;
|
|
1382
|
+
}
|
|
1383
|
+
give();
|
|
1384
|
+
return ok;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
void rasterPresentRegion(const present::Frame &frame, const present::Rect ®ion)
|
|
1388
|
+
{
|
|
1389
|
+
if (!present::valid(region)) return;
|
|
1390
|
+
const int width = region.x1 - region.x0 + 1;
|
|
1391
|
+
const int height = logicalHeight();
|
|
1392
|
+
const int maxRows = std::max(1, kFlushRowsDefault);
|
|
1393
|
+
for (int row = region.y0; row <= region.y1; row += maxRows) {
|
|
1394
|
+
int rows = maxRows;
|
|
1395
|
+
if (row + rows > region.y1 + 1) rows = region.y1 - row + 1;
|
|
1396
|
+
std::uint16_t *rasterTarget = frameBuffer_ + static_cast<std::size_t>(row) * logicalStride_ + region.x0;
|
|
1397
|
+
const std::int64_t rasterStartUs = esp_timer_get_time();
|
|
1398
|
+
present::rasterFrameRowsStrided(rasterTarget,
|
|
1399
|
+
logicalStride_,
|
|
1400
|
+
region.x0,
|
|
1401
|
+
width,
|
|
1402
|
+
row,
|
|
1403
|
+
rows,
|
|
1404
|
+
height,
|
|
1405
|
+
frame);
|
|
1406
|
+
flushStats_.rasterUs += esp_timer_get_time() - rasterStartUs;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
void take()
|
|
1411
|
+
{
|
|
1412
|
+
if (mutex_) xSemaphoreTake(mutex_, portMAX_DELAY);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
void give()
|
|
1416
|
+
{
|
|
1417
|
+
if (mutex_) xSemaphoreGive(mutex_);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
SemaphoreHandle_t mutex_ = nullptr;
|
|
1421
|
+
esp_lcd_panel_handle_t panel_ = nullptr;
|
|
1422
|
+
esp_lcd_panel_io_handle_t io_ = nullptr;
|
|
1423
|
+
// Slow IO for ST7796 GSCAN reads + the measured panel scan timing
|
|
1424
|
+
// (see measureScanTiming/waitForScanTop). scanPeriodUs_ == 0 disables sync.
|
|
1425
|
+
esp_lcd_panel_io_handle_t ioRead_ = nullptr;
|
|
1426
|
+
std::int64_t scanPeriodUs_ = 0;
|
|
1427
|
+
int scanlineMax_ = 0;
|
|
1428
|
+
SemaphoreHandle_t flushDoneSem_ = nullptr;
|
|
1429
|
+
std::uint16_t *frameBuffer_ = nullptr;
|
|
1430
|
+
std::uint16_t *ownedFrameBuffer_ = nullptr;
|
|
1431
|
+
std::uint16_t *stagingPixels_ = nullptr;
|
|
1432
|
+
std::uint16_t *panelSwapBuf_ = nullptr; // camera present: byteswapped full block (PSRAM)
|
|
1433
|
+
// Panel-push worker (presentPanelRectAsync).
|
|
1434
|
+
TaskHandle_t panelPushTask_ = nullptr;
|
|
1435
|
+
SemaphoreHandle_t panelPushStart_ = nullptr;
|
|
1436
|
+
SemaphoreHandle_t panelPushDone_ = nullptr;
|
|
1437
|
+
PanelPushJob panelPushJob_{};
|
|
1438
|
+
bool panelPushPending_ = false;
|
|
1439
|
+
// Queued-or-streaming async pushes (see waitPanelPushIdle). Distinct from
|
|
1440
|
+
// panelPushPending_/panelPushDone_, which belong to the submitter's
|
|
1441
|
+
// back-pressure handshake and must not be touched by other threads.
|
|
1442
|
+
std::atomic<int> panelPushInflight_{0};
|
|
1443
|
+
std::uint16_t *backgroundCache_ = nullptr;
|
|
1444
|
+
std::uint16_t *backdropCache_ = nullptr;
|
|
1445
|
+
gea::framework::graphics::Canvas canvas_;
|
|
1446
|
+
gea::framework::graphics::Canvas workerCanvas_;
|
|
1447
|
+
int logicalStride_ = kMaxLogicalWidth;
|
|
1448
|
+
int renderCoreId_ = -1;
|
|
1449
|
+
int flushRows_ = kFlushRowsDefault;
|
|
1450
|
+
// Landscape-on-portrait-panel flush rotation (see applyPanelOrientation).
|
|
1451
|
+
int flushRotation_ = kFlushRotationNone;
|
|
1452
|
+
int flushDepth_ = 1;
|
|
1453
|
+
int brightness_ = 100;
|
|
1454
|
+
bool brightnessInitialized_ = false;
|
|
1455
|
+
bool initialized_ = false;
|
|
1456
|
+
bool frameBufferCoherent_ = true;
|
|
1457
|
+
bool backgroundCacheAttempted_ = false;
|
|
1458
|
+
bool backdropCacheAttempted_ = false;
|
|
1459
|
+
platform_display::DisplayFlushPerfStats flushStats_{};
|
|
1460
|
+
present::Frame previousPresentFrame_{};
|
|
1461
|
+
bool previousPresentValid_ = false;
|
|
1462
|
+
bool needsFullPhysicalFlush_ = true;
|
|
1463
|
+
};
|
|
1464
|
+
|
|
1465
|
+
} // namespace gea::platform::esp32_p4_waveshare::display
|
|
1466
|
+
|
|
1467
|
+
extern "C" std::uint16_t *gea_bg_cache(int *cap_px)
|
|
1468
|
+
{
|
|
1469
|
+
return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().backgroundCache(cap_px);
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
extern "C" std::uint16_t *gea_backdrop_cache(int *cap_px)
|
|
1473
|
+
{
|
|
1474
|
+
return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().backdropCache(cap_px);
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
namespace {
|
|
1478
|
+
|
|
1479
|
+
struct P4RenderWorker {
|
|
1480
|
+
TaskHandle_t task = nullptr;
|
|
1481
|
+
void (*volatile fn)(void *, int, int) = nullptr;
|
|
1482
|
+
void *volatile ctx = nullptr;
|
|
1483
|
+
volatile int y0 = 0;
|
|
1484
|
+
volatile int y1 = 0;
|
|
1485
|
+
std::atomic<std::uint32_t> jobSeq{0};
|
|
1486
|
+
std::atomic<bool> done{true};
|
|
1487
|
+
bool attempted = false;
|
|
1488
|
+
};
|
|
1489
|
+
|
|
1490
|
+
P4RenderWorker gRenderWorker;
|
|
1491
|
+
volatile std::int64_t gRenderWorkerSubmitUs = 0;
|
|
1492
|
+
std::int64_t gRenderWorkerStartLatencyUs = 0;
|
|
1493
|
+
std::int64_t gRenderWorkerBandUs = 0;
|
|
1494
|
+
std::int64_t gRenderWorkerWaitUs = 0;
|
|
1495
|
+
int gRenderWorkerJobs = 0;
|
|
1496
|
+
constexpr std::uint32_t kRenderWorkerStackBytes = 12288;
|
|
1497
|
+
|
|
1498
|
+
void renderWorkerTask(void *)
|
|
1499
|
+
{
|
|
1500
|
+
// MUST start at 0 (jobSeq's initial value), NOT jobSeq.load(): submit() creates
|
|
1501
|
+
// this task and increments jobSeq immediately after, so loading here usually
|
|
1502
|
+
// reads 1 and swallows job 1 (the caller times out and the first parallel band
|
|
1503
|
+
// is silently dropped). Same race fixed on the elecrow in d22bfc5f9.
|
|
1504
|
+
std::uint32_t seen = 0;
|
|
1505
|
+
std::int64_t idleSince = esp_timer_get_time();
|
|
1506
|
+
for (;;) {
|
|
1507
|
+
while (gRenderWorker.jobSeq.load(std::memory_order_acquire) == seen) {
|
|
1508
|
+
if (esp_timer_get_time() - idleSince > 4000) {
|
|
1509
|
+
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(100));
|
|
1510
|
+
idleSince = esp_timer_get_time();
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
seen = gRenderWorker.jobSeq.load(std::memory_order_acquire);
|
|
1514
|
+
const std::int64_t started = esp_timer_get_time();
|
|
1515
|
+
gRenderWorkerStartLatencyUs += started - gRenderWorkerSubmitUs;
|
|
1516
|
+
void (*fn)(void *, int, int) = gRenderWorker.fn;
|
|
1517
|
+
if (fn) fn(gRenderWorker.ctx, gRenderWorker.y0, gRenderWorker.y1);
|
|
1518
|
+
gRenderWorkerBandUs += esp_timer_get_time() - started;
|
|
1519
|
+
gRenderWorker.done.store(true, std::memory_order_release);
|
|
1520
|
+
idleSince = esp_timer_get_time();
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
} // namespace
|
|
1525
|
+
|
|
1526
|
+
extern "C" bool gea_render_parallel_submit(void (*fn)(void *, int, int), void *ctx, int y0, int y1)
|
|
1527
|
+
{
|
|
1528
|
+
if (!gRenderWorker.attempted) {
|
|
1529
|
+
gRenderWorker.attempted = true;
|
|
1530
|
+
const BaseType_t renderCore = xPortGetCoreID();
|
|
1531
|
+
const BaseType_t workerCore = (renderCore == 0) ? 1 : 0;
|
|
1532
|
+
const UBaseType_t priority = uxTaskPriorityGet(nullptr);
|
|
1533
|
+
const BaseType_t created = xTaskCreatePinnedToCore(renderWorkerTask,
|
|
1534
|
+
"gea_rwrk",
|
|
1535
|
+
kRenderWorkerStackBytes,
|
|
1536
|
+
nullptr,
|
|
1537
|
+
priority,
|
|
1538
|
+
&gRenderWorker.task,
|
|
1539
|
+
workerCore);
|
|
1540
|
+
std::printf("[render-worker] task=%p create=%d renderCore=%d workerCore=%d prio=%u stack=%u\n",
|
|
1541
|
+
static_cast<void *>(gRenderWorker.task),
|
|
1542
|
+
static_cast<int>(created),
|
|
1543
|
+
static_cast<int>(renderCore),
|
|
1544
|
+
static_cast<int>(workerCore),
|
|
1545
|
+
static_cast<unsigned>(priority),
|
|
1546
|
+
static_cast<unsigned>(kRenderWorkerStackBytes));
|
|
1547
|
+
if (created != pdPASS || !gRenderWorker.task) {
|
|
1548
|
+
multi_heap_info_t info{};
|
|
1549
|
+
heap_caps_get_info(&info, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
|
1550
|
+
std::printf("[render-worker] create failed: create=%d stack=%u internal_free=%u internal_largest=%u internal_min=%u free_blocks=%u alloc_blocks=%u total_blocks=%u\n",
|
|
1551
|
+
static_cast<int>(created),
|
|
1552
|
+
static_cast<unsigned>(kRenderWorkerStackBytes),
|
|
1553
|
+
static_cast<unsigned>(info.total_free_bytes),
|
|
1554
|
+
static_cast<unsigned>(info.largest_free_block),
|
|
1555
|
+
static_cast<unsigned>(info.minimum_free_bytes),
|
|
1556
|
+
static_cast<unsigned>(info.free_blocks),
|
|
1557
|
+
static_cast<unsigned>(info.allocated_blocks),
|
|
1558
|
+
static_cast<unsigned>(info.total_blocks));
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
if (!gRenderWorker.task) return false;
|
|
1562
|
+
gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().setRenderCore(static_cast<int>(xPortGetCoreID()));
|
|
1563
|
+
gRenderWorker.fn = fn;
|
|
1564
|
+
gRenderWorker.ctx = ctx;
|
|
1565
|
+
gRenderWorker.y0 = y0;
|
|
1566
|
+
gRenderWorker.y1 = y1;
|
|
1567
|
+
gRenderWorker.done.store(false, std::memory_order_release);
|
|
1568
|
+
gRenderWorkerSubmitUs = esp_timer_get_time();
|
|
1569
|
+
gRenderWorker.jobSeq.fetch_add(1, std::memory_order_release);
|
|
1570
|
+
xTaskNotifyGive(gRenderWorker.task);
|
|
1571
|
+
return true;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
extern "C" void gea_render_parallel_wait()
|
|
1575
|
+
{
|
|
1576
|
+
if (!gRenderWorker.task) return;
|
|
1577
|
+
const std::int64_t waitStarted = esp_timer_get_time();
|
|
1578
|
+
const std::int64_t deadline = waitStarted + 100000;
|
|
1579
|
+
while (!gRenderWorker.done.load(std::memory_order_acquire)) {
|
|
1580
|
+
if (esp_timer_get_time() > deadline) {
|
|
1581
|
+
std::printf("[render-worker] WAIT TIMEOUT\n");
|
|
1582
|
+
break;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
gRenderWorkerWaitUs += esp_timer_get_time() - waitStarted;
|
|
1586
|
+
if (++gRenderWorkerJobs >= 300) {
|
|
1587
|
+
std::printf("[worker] startLat=%dus band=%dus wait=%dus (avg/300)\n",
|
|
1588
|
+
static_cast<int>(gRenderWorkerStartLatencyUs / 300),
|
|
1589
|
+
static_cast<int>(gRenderWorkerBandUs / 300),
|
|
1590
|
+
static_cast<int>(gRenderWorkerWaitUs / 300));
|
|
1591
|
+
gRenderWorkerStartLatencyUs = 0;
|
|
1592
|
+
gRenderWorkerBandUs = 0;
|
|
1593
|
+
gRenderWorkerWaitUs = 0;
|
|
1594
|
+
gRenderWorkerJobs = 0;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
extern "C" void gea_render_parallel_merge_dirty()
|
|
1599
|
+
{
|
|
1600
|
+
gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().absorbWorkerDirty();
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
extern "C" int gea_current_render_core()
|
|
1604
|
+
{
|
|
1605
|
+
return static_cast<int>(xPortGetCoreID());
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
namespace gea::platform::esp32_p4_waveshare::display_native {
|
|
1609
|
+
|
|
1610
|
+
bool panelMapLogicalRect(int lx, int ly, int lw, int lh,
|
|
1611
|
+
int *px, int *py, int *pw, int *ph, int *extraRotCcw)
|
|
1612
|
+
{
|
|
1613
|
+
return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().panelMapLogicalRect(
|
|
1614
|
+
lx, ly, lw, lh, px, py, pw, ph, extraRotCcw);
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
bool presentPanelRect(const std::uint16_t *pixels, int px, int py, int w, int h)
|
|
1618
|
+
{
|
|
1619
|
+
return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().presentPanelRect(pixels, px, py, w, h);
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
bool presentPanelRectAsync(const std::uint16_t *pixels, int px, int py, int w, int h)
|
|
1623
|
+
{
|
|
1624
|
+
return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().presentPanelRectAsync(pixels, px, py, w, h);
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
std::int64_t panelScanPeriodUs()
|
|
1628
|
+
{
|
|
1629
|
+
return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().panelScanPeriodUs();
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
void waitPanelPushIdle()
|
|
1633
|
+
{
|
|
1634
|
+
gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().waitPanelPushIdle();
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
void clearLogicalRect(int x, int y, int w, int h)
|
|
1638
|
+
{
|
|
1639
|
+
gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().clearLogicalRect(x, y, w, h);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
} // namespace gea::platform::esp32_p4_waveshare::display_native
|
|
1643
|
+
|
|
1644
|
+
namespace gea::platform::display {
|
|
1645
|
+
|
|
1646
|
+
namespace {
|
|
1647
|
+
|
|
1648
|
+
gea::framework::graphics::Canvas *drawingCanvas()
|
|
1649
|
+
{
|
|
1650
|
+
return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().drawingCanvas();
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
} // namespace
|
|
1654
|
+
|
|
1655
|
+
bool Display::init() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().init(); }
|
|
1656
|
+
bool Display::start() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().start(); }
|
|
1657
|
+
gea::framework::graphics::Canvas *Display::canvas() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().canvas(); }
|
|
1658
|
+
bool Display::framebufferIsPanelDirect() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().framebufferIsPanelDirect(); }
|
|
1659
|
+
void Display::clear() { gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().clear(); }
|
|
1660
|
+
void Display::clearNoFlush() { gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().clearNoFlush(); }
|
|
1661
|
+
void Display::print(const char *) {}
|
|
1662
|
+
void Display::flush() { gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flush(); }
|
|
1663
|
+
void Display::flushRects(const DisplayFlushRect *rects, int count, bool) { gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushRects(rects, count); }
|
|
1664
|
+
bool Display::streamRect(int x, int y, int w, int h, DisplayStreamRasterFn raster, void *user) { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().streamRect(x, y, w, h, raster, user); }
|
|
1665
|
+
bool Display::present(const DisplayPresentCommand *commands, int command_count) { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().presentCommands(commands, command_count); }
|
|
1666
|
+
void Display::setFlushConfig(int chunk_rows, int queue_depth) { gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().setFlushConfig(chunk_rows, queue_depth); }
|
|
1667
|
+
void Display::reserveInternal(std::size_t) {}
|
|
1668
|
+
bool Display::setHighBrightnessMode(bool) { return false; }
|
|
1669
|
+
bool Display::highBrightnessMode() { return false; }
|
|
1670
|
+
void Display::applyPendingInternalReserve() {}
|
|
1671
|
+
int Display::flushChunkRows() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushChunkRows(); }
|
|
1672
|
+
int Display::flushQueueDepth() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushQueueDepth(); }
|
|
1673
|
+
int Display::flushBufferBytes() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushBufferBytes(); }
|
|
1674
|
+
void Display::pushClip(int x, int y, int w, int h) { if (auto *c = drawingCanvas()) c->pushClip(x, y, w, h); }
|
|
1675
|
+
void Display::popClip() { if (auto *c = drawingCanvas()) c->popClip(); }
|
|
1676
|
+
void Display::resetClip() { if (auto *c = drawingCanvas()) c->resetClip(); }
|
|
1677
|
+
void Display::setAlpha(std::uint8_t alpha) { if (auto *c = drawingCanvas()) c->setGlobalAlpha(alpha); }
|
|
1678
|
+
std::uint8_t Display::alpha() { return drawingCanvas() ? drawingCanvas()->globalAlpha() : 255; }
|
|
1679
|
+
int Display::brightness() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().brightness(); }
|
|
1680
|
+
void Display::setBrightness(int brightness_percent) { gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().setBrightness(brightness_percent); }
|
|
1681
|
+
// Tearing sync (TE/VBlank): not implemented on this target.
|
|
1682
|
+
void Display::setVSync(bool) {}
|
|
1683
|
+
void Display::invalidate() {}
|
|
1684
|
+
bool Display::vsyncEnabled() { return false; }
|
|
1685
|
+
void Display::vsyncWaitForFrame() {}
|
|
1686
|
+
void Display::clip(int *x0, int *y0, int *x1, int *y1)
|
|
1687
|
+
{
|
|
1688
|
+
if (auto *c = drawingCanvas()) c->currentClip(x0, y0, x1, y1);
|
|
1689
|
+
}
|
|
1690
|
+
void Display::fillRect(int x, int y, int w, int h, std::uint16_t color) { if (auto *c = drawingCanvas()) c->fillRect(x, y, w, h, color); }
|
|
1691
|
+
void Display::scrollRect(int x, int y, int w, int h, int dx, int dy) { if (auto *c = drawingCanvas()) c->scrollRect(x, y, w, h, dx, dy); }
|
|
1692
|
+
void Display::resetScrollRegion() {}
|
|
1693
|
+
void Display::strokeRect(int x, int y, int w, int h, std::uint16_t color) { if (auto *c = drawingCanvas()) c->strokeRect(x, y, w, h, color); }
|
|
1694
|
+
void Display::fillCircle(int cx, int cy, int r, std::uint16_t color) { if (auto *c = drawingCanvas()) c->fillCircle(cx, cy, r, color); }
|
|
1695
|
+
void Display::strokeCircle(int cx, int cy, int r, std::uint16_t color) { if (auto *c = drawingCanvas()) c->strokeCircle(cx, cy, r, color); }
|
|
1696
|
+
void Display::drawLine(int x0, int y0, int x1, int y1, std::uint16_t color) { if (auto *c = drawingCanvas()) c->drawLine(x0, y0, x1, y1, color); }
|
|
1697
|
+
void Display::drawArc(int cx, int cy, int r, int start_deg, int end_deg, std::uint16_t color) { if (auto *c = drawingCanvas()) c->drawArc(cx, cy, r, start_deg, end_deg, color); }
|
|
1698
|
+
void Display::fillTriangle(int x0, int y0, int x1, int y1, int x2, int y2, std::uint16_t color) { if (auto *c = drawingCanvas()) c->fillTriangle(x0, y0, x1, y1, x2, y2, color); }
|
|
1699
|
+
void Display::drawText(const char *text, int x, int y, std::uint16_t color, float scale) { if (auto *c = drawingCanvas()) c->drawText(text, x, y, color, scale); }
|
|
1700
|
+
void Display::drawTextFont(const char *text, int x, int y, std::uint16_t color, int font_id) { if (auto *c = drawingCanvas()) c->drawTextFont(text, x, y, color, font_id); }
|
|
1701
|
+
void Display::drawTextFontFamily(const char *text, int x, int y, std::uint16_t color, int family_id, int size_px) { if (auto *c = drawingCanvas()) c->drawTextFontFamily(text, x, y, color, family_id, size_px); }
|
|
1702
|
+
void Display::setPixel(int x, int y, std::uint16_t color) { if (auto *c = drawingCanvas()) c->fillRect(x, y, 1, 1, color); }
|
|
1703
|
+
void Display::fillRoundedRect(int x, int y, int w, int h, int tl, int tr, int br, int bl, std::uint16_t color) { if (auto *c = drawingCanvas()) c->fillRoundedRect(x, y, w, h, tl, tr, br, bl, color); }
|
|
1704
|
+
void Display::fillRoundedRectBoxesRgb565(const std::int16_t *xs, const std::int16_t *ys, int count, int w, int h, int tl, int tr, int br, int bl, const std::uint16_t *colors) { if (auto *c = drawingCanvas()) c->fillRoundedRectBoxesRgb565(xs, ys, count, w, h, tl, tr, br, bl, colors); }
|
|
1705
|
+
void Display::strokeRoundedRect(int x, int y, int w, int h, int tl, int tr, int br, int bl, int lw, std::uint16_t color) { if (auto *c = drawingCanvas()) c->strokeRoundedRect(x, y, w, h, tl, tr, br, bl, lw, color); }
|
|
1706
|
+
void Display::blitImage(const gea::framework::graphics::pixel::native_t *src, const std::uint8_t *alpha, int src_w, int src_h, int dx, int dy) { if (auto *c = drawingCanvas()) c->drawImage(src, alpha, src_w, src_h, dx, dy); }
|
|
1707
|
+
void Display::blitImageScaled(const gea::framework::graphics::pixel::native_t *src, const std::uint8_t *alpha, int src_w, int src_h, int dx, int dy, int dst_w, int dst_h) { if (auto *c = drawingCanvas()) c->drawImage(src, alpha, src_w, src_h, dx, dy, dst_w, dst_h); }
|
|
1708
|
+
void Display::setWorldOverlay(const std::uint16_t *, int, int, int, int) {}
|
|
1709
|
+
void Display::setWorldScroll(int) {}
|
|
1710
|
+
void Display::flushStatsRead(std::int64_t *total_us, int *call_count, int *pixel_count)
|
|
1711
|
+
{
|
|
1712
|
+
const auto stats = gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushStats();
|
|
1713
|
+
if (total_us) *total_us = stats.totalUs;
|
|
1714
|
+
if (call_count) *call_count = stats.callCount;
|
|
1715
|
+
if (pixel_count) *pixel_count = stats.pixelCount;
|
|
1716
|
+
}
|
|
1717
|
+
DisplayFlushPerfStats Display::flushPerfStatsRead() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushStats(); }
|
|
1718
|
+
void Display::flushStatsReset() { gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushStatsReset(); }
|
|
1719
|
+
const char *Display::flushStageName() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushStageName(); }
|
|
1720
|
+
int Display::flushStageChunk() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushStageChunk(); }
|
|
1721
|
+
DisplayFlushStageDetail Display::flushStageDetail() { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().flushStageDetail(); }
|
|
1722
|
+
bool Display::copySnapshotRgb565(std::uint16_t *dst, int pixel_capacity, int *width, int *height, bool) { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().copySnapshotRgb565(dst, pixel_capacity, width, height); }
|
|
1723
|
+
int Display::countNonBlackPixels(bool) { return gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().countNonBlackPixels(); }
|
|
1724
|
+
|
|
1725
|
+
void applyOrientation(gea::framework::display::DisplayOrientation)
|
|
1726
|
+
{
|
|
1727
|
+
gea::platform::esp32_p4_waveshare::display::DisplayBackend::instance().applyOrientation();
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
} // namespace gea::platform::display
|