@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.
Files changed (348) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +83 -0
  3. package/package.json +50 -0
  4. package/targets/cmake/geatsc-generated-archive-build.mjs +614 -0
  5. package/targets/cmake/geatsc_generated_archive.cmake +116 -0
  6. package/targets/cmake/geatsc_generated_archive_build.cmake +50 -0
  7. package/targets/esp32/app_project.cmake +33 -0
  8. package/targets/esp32/apps/app_manager.cpp +188 -0
  9. package/targets/esp32/apps/app_manager.h +10 -0
  10. package/targets/esp32/chip_bindings/README.md +58 -0
  11. package/targets/esp32/chip_bindings/audio/es8311.cpp +556 -0
  12. package/targets/esp32/chip_bindings/displays/co5300.cpp +510 -0
  13. package/targets/esp32/chip_bindings/displays/co5300.h +47 -0
  14. package/targets/esp32/chip_bindings/displays/co5300_async_stream.inc +79 -0
  15. package/targets/esp32/chip_bindings/displays/qspi_panel.h +65 -0
  16. package/targets/esp32/chip_bindings/displays/sh8601.cpp +583 -0
  17. package/targets/esp32/chip_bindings/displays/sh8601.h +36 -0
  18. package/targets/esp32/chip_bindings/gps/lc76g.cpp +296 -0
  19. package/targets/esp32/chip_bindings/gps/lc76g.h +7 -0
  20. package/targets/esp32/chip_bindings/imu/bmi270.cpp +299 -0
  21. package/targets/esp32/chip_bindings/imu/bmi270_config.inl +439 -0
  22. package/targets/esp32/chip_bindings/imu/qmi8658.cpp +213 -0
  23. package/targets/esp32/chip_bindings/power/axp2101.cpp +185 -0
  24. package/targets/esp32/chip_bindings/touch/cst9217.cpp +229 -0
  25. package/targets/esp32/chip_bindings/touch/cst9217_controller.h +78 -0
  26. package/targets/esp32/chip_bindings/touch/ft3168.cpp +340 -0
  27. package/targets/esp32/chip_bindings/touch/ft3168_controller.h +103 -0
  28. package/targets/esp32/chip_bindings/touch/ft6336.cpp +310 -0
  29. package/targets/esp32/chip_bindings/touch/ft6336_controller.h +90 -0
  30. package/targets/esp32/components/gea_framework/CMakeLists.txt +62 -0
  31. package/targets/esp32/connectivity/ble_hid.cpp +2916 -0
  32. package/targets/esp32/connectivity/ble_hid.h +8 -0
  33. package/targets/esp32/connectivity/diagnostics_transport.cpp +523 -0
  34. package/targets/esp32/connectivity/diagnostics_transport_offline.cpp +108 -0
  35. package/targets/esp32/connectivity/wifi.cpp +615 -0
  36. package/targets/esp32/connectivity/wifi_debug_offline.cpp +37 -0
  37. package/targets/esp32/connectivity/wifi_task_stack.h +119 -0
  38. package/targets/esp32/display.cpp +6010 -0
  39. package/targets/esp32/display_headless.cpp +468 -0
  40. package/targets/esp32/gea/platform_random.h +11 -0
  41. package/targets/esp32/gea_framework.cmake +382 -0
  42. package/targets/esp32/gpio.cpp +229 -0
  43. package/targets/esp32/host_sources.cmake +35 -0
  44. package/targets/esp32/imu_absent.cpp +36 -0
  45. package/targets/esp32/ldfragments/gea_ui_state_external.lf +35 -0
  46. package/targets/esp32/memory_config.h +64 -0
  47. package/targets/esp32/power_absent.cpp +22 -0
  48. package/targets/esp32/sdk-patches/0001-esp_ptr_dma_capable-accept-PSRAM.patch +70 -0
  49. package/targets/esp32/sdk-patches/0002-gdma-access_ext_mem-spi_master.patch +59 -0
  50. package/targets/esp32/sdk-patches/README.md +127 -0
  51. package/targets/esp32/services/app_runner.cpp +248 -0
  52. package/targets/esp32/services/app_state.cpp +56 -0
  53. package/targets/esp32/services/audio_runtime_stub.cpp +86 -0
  54. package/targets/esp32/services/battery_service.cpp +31 -0
  55. package/targets/esp32/services/device_control.cpp +1896 -0
  56. package/targets/esp32/services/device_control.h +31 -0
  57. package/targets/esp32/services/frame_scheduler.cpp +1571 -0
  58. package/targets/esp32/services/heap.cpp +129 -0
  59. package/targets/esp32/services/memory.cpp +103 -0
  60. package/targets/esp32/services/ota.cpp +840 -0
  61. package/targets/esp32/services/ota_image.cpp +162 -0
  62. package/targets/esp32/services/ota_image.h +16 -0
  63. package/targets/esp32/services/storage_service.cpp +159 -0
  64. package/targets/esp32/touch_absent.cpp +44 -0
  65. package/targets/esp32-m5stack-m5paper/CMakeLists.txt +10 -0
  66. package/targets/esp32-m5stack-m5paper/README.md +55 -0
  67. package/targets/esp32-m5stack-m5paper/dependencies.lock +76 -0
  68. package/targets/esp32-m5stack-m5paper/main/CMakeLists.txt +46 -0
  69. package/targets/esp32-m5stack-m5paper/main/Kconfig.projbuild +10 -0
  70. package/targets/esp32-m5stack-m5paper/main/app_main.cpp +114 -0
  71. package/targets/esp32-m5stack-m5paper/main/audio_stub.cpp +27 -0
  72. package/targets/esp32-m5stack-m5paper/main/buttons.cpp +111 -0
  73. package/targets/esp32-m5stack-m5paper/main/display.cpp +1074 -0
  74. package/targets/esp32-m5stack-m5paper/main/i2c.cpp +36 -0
  75. package/targets/esp32-m5stack-m5paper/main/idf_component.yml +7 -0
  76. package/targets/esp32-m5stack-m5paper/main/imu_stub.cpp +20 -0
  77. package/targets/esp32-m5stack-m5paper/main/include/board.h +100 -0
  78. package/targets/esp32-m5stack-m5paper/main/include/buttons.h +8 -0
  79. package/targets/esp32-m5stack-m5paper/main/launcher_button.cpp +82 -0
  80. package/targets/esp32-m5stack-m5paper/main/m5paper_psram.lf +20 -0
  81. package/targets/esp32-m5stack-m5paper/main/power.cpp +73 -0
  82. package/targets/esp32-m5stack-m5paper/main/sdcard_mount.cpp +82 -0
  83. package/targets/esp32-m5stack-m5paper/main/touch.cpp +279 -0
  84. package/targets/esp32-m5stack-m5paper/partitions.csv +9 -0
  85. package/targets/esp32-m5stack-m5paper/sdkconfig.defaults +84 -0
  86. package/targets/esp32-p4-m5stack-tab5/CMakeLists.txt +10 -0
  87. package/targets/esp32-p4-m5stack-tab5/dependencies.lock +276 -0
  88. package/targets/esp32-p4-m5stack-tab5/main/CMakeLists.txt +586 -0
  89. package/targets/esp32-p4-m5stack-tab5/main/Kconfig.projbuild +12 -0
  90. package/targets/esp32-p4-m5stack-tab5/main/app_main.cpp +177 -0
  91. package/targets/esp32-p4-m5stack-tab5/main/camera.cpp +2025 -0
  92. package/targets/esp32-p4-m5stack-tab5/main/display.cpp +4033 -0
  93. package/targets/esp32-p4-m5stack-tab5/main/fatfs_ffconf.h +383 -0
  94. package/targets/esp32-p4-m5stack-tab5/main/i2c.cpp +39 -0
  95. package/targets/esp32-p4-m5stack-tab5/main/idf_component.yml +21 -0
  96. package/targets/esp32-p4-m5stack-tab5/main/include/board.h +130 -0
  97. package/targets/esp32-p4-m5stack-tab5/main/include/tab5_drivers.h +68 -0
  98. package/targets/esp32-p4-m5stack-tab5/main/include/wifi_config.h.example +5 -0
  99. package/targets/esp32-p4-m5stack-tab5/main/launcher_button.cpp +188 -0
  100. package/targets/esp32-p4-m5stack-tab5/main/power.cpp +22 -0
  101. package/targets/esp32-p4-m5stack-tab5/main/sdcard_mount.cpp +125 -0
  102. package/targets/esp32-p4-m5stack-tab5/main/tab5_audio.cpp +345 -0
  103. package/targets/esp32-p4-m5stack-tab5/main/tab5_drivers.cpp +871 -0
  104. package/targets/esp32-p4-m5stack-tab5/main/tab5_imu.cpp +246 -0
  105. package/targets/esp32-p4-m5stack-tab5/main/touch.cpp +206 -0
  106. package/targets/esp32-p4-m5stack-tab5/partitions.csv +12 -0
  107. package/targets/esp32-p4-m5stack-tab5/sdkconfig.defaults +128 -0
  108. package/targets/esp32-p4-waveshare-touch-lcd-3.5/CMakeLists.txt +19 -0
  109. package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/0001-esp_video-csi-raw-passthrough-p4-rev-lt-v3.patch +28 -0
  110. package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/README.md +45 -0
  111. package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/apply.sh +37 -0
  112. package/targets/esp32-p4-waveshare-touch-lcd-3.5/dependencies.lock +196 -0
  113. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/CMakeLists.txt +562 -0
  114. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/Kconfig.projbuild +12 -0
  115. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/app_main.cpp +166 -0
  116. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/camera.cpp +2105 -0
  117. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/display.cpp +1730 -0
  118. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/fatfs_ffconf.h +383 -0
  119. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/i2c.cpp +39 -0
  120. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/idf_component.yml +11 -0
  121. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/board.h +87 -0
  122. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/panel_native.h +59 -0
  123. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/wifi_config.h.example +5 -0
  124. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/launcher_button.cpp +191 -0
  125. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/power.cpp +15 -0
  126. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/touch.cpp +306 -0
  127. package/targets/esp32-p4-waveshare-touch-lcd-3.5/partitions.csv +13 -0
  128. package/targets/esp32-p4-waveshare-touch-lcd-3.5/patches/README.md +22 -0
  129. package/targets/esp32-p4-waveshare-touch-lcd-3.5/patches/espressif__esp_video-csi-bypass.patch +28 -0
  130. package/targets/esp32-p4-waveshare-touch-lcd-3.5/sdkconfig.defaults +109 -0
  131. package/targets/esp32-p4-waveshare-touch-lcd-3.5/tools/README-camera-capture.md +84 -0
  132. package/targets/esp32-p4-waveshare-touch-lcd-3.5/tools/capture-camera.py +369 -0
  133. package/targets/esp32-p4-waveshare-touch-lcd-7/CMakeLists.txt +10 -0
  134. package/targets/esp32-p4-waveshare-touch-lcd-7/dependencies.lock +258 -0
  135. package/targets/esp32-p4-waveshare-touch-lcd-7/main/CMakeLists.txt +577 -0
  136. package/targets/esp32-p4-waveshare-touch-lcd-7/main/Kconfig.projbuild +12 -0
  137. package/targets/esp32-p4-waveshare-touch-lcd-7/main/app_main.cpp +177 -0
  138. package/targets/esp32-p4-waveshare-touch-lcd-7/main/camera.cpp +1935 -0
  139. package/targets/esp32-p4-waveshare-touch-lcd-7/main/display.cpp +2832 -0
  140. package/targets/esp32-p4-waveshare-touch-lcd-7/main/fatfs_ffconf.h +383 -0
  141. package/targets/esp32-p4-waveshare-touch-lcd-7/main/i2c.cpp +39 -0
  142. package/targets/esp32-p4-waveshare-touch-lcd-7/main/idf_component.yml +23 -0
  143. package/targets/esp32-p4-waveshare-touch-lcd-7/main/include/board.h +68 -0
  144. package/targets/esp32-p4-waveshare-touch-lcd-7/main/include/wifi_config.h.example +5 -0
  145. package/targets/esp32-p4-waveshare-touch-lcd-7/main/launcher_button.cpp +191 -0
  146. package/targets/esp32-p4-waveshare-touch-lcd-7/main/power.cpp +15 -0
  147. package/targets/esp32-p4-waveshare-touch-lcd-7/main/sdcard_mount.cpp +125 -0
  148. package/targets/esp32-p4-waveshare-touch-lcd-7/main/touch.cpp +332 -0
  149. package/targets/esp32-p4-waveshare-touch-lcd-7/partitions.csv +12 -0
  150. package/targets/esp32-p4-waveshare-touch-lcd-7/sdkconfig.defaults +122 -0
  151. package/targets/esp32-p4-waveshare-touch-lcd-7/tools/README-camera-capture.md +84 -0
  152. package/targets/esp32-p4-waveshare-touch-lcd-7/tools/capture-camera.py +369 -0
  153. package/targets/esp32-s3-devkit-n16r8.json +31 -0
  154. package/targets/esp32-s3-elecrow-rotary-2.1/CMakeLists.txt +10 -0
  155. package/targets/esp32-s3-elecrow-rotary-2.1/dependencies.lock +40 -0
  156. package/targets/esp32-s3-elecrow-rotary-2.1/main/CMakeLists.txt +549 -0
  157. package/targets/esp32-s3-elecrow-rotary-2.1/main/Kconfig.projbuild +12 -0
  158. package/targets/esp32-s3-elecrow-rotary-2.1/main/app_main.cpp +187 -0
  159. package/targets/esp32-s3-elecrow-rotary-2.1/main/display_rgb.cpp +1338 -0
  160. package/targets/esp32-s3-elecrow-rotary-2.1/main/i2c.cpp +39 -0
  161. package/targets/esp32-s3-elecrow-rotary-2.1/main/idf_component.yml +5 -0
  162. package/targets/esp32-s3-elecrow-rotary-2.1/main/include/board.h +142 -0
  163. package/targets/esp32-s3-elecrow-rotary-2.1/main/include/pcf8574.h +16 -0
  164. package/targets/esp32-s3-elecrow-rotary-2.1/main/include/rotary_encoder.h +7 -0
  165. package/targets/esp32-s3-elecrow-rotary-2.1/main/launcher_button.cpp +191 -0
  166. package/targets/esp32-s3-elecrow-rotary-2.1/main/pcf8574.cpp +86 -0
  167. package/targets/esp32-s3-elecrow-rotary-2.1/main/platform_stubs.cpp +47 -0
  168. package/targets/esp32-s3-elecrow-rotary-2.1/main/rotary_encoder.cpp +135 -0
  169. package/targets/esp32-s3-elecrow-rotary-2.1/main/touch.cpp +250 -0
  170. package/targets/esp32-s3-elecrow-rotary-2.1/partitions.csv +8 -0
  171. package/targets/esp32-s3-elecrow-rotary-2.1/sdkconfig.defaults +116 -0
  172. package/targets/esp32-s3-epaper-1.54/CMakeLists.txt +10 -0
  173. package/targets/esp32-s3-epaper-1.54/dependencies.lock +76 -0
  174. package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +691 -0
  175. package/targets/esp32-s3-epaper-1.54/main/Kconfig.projbuild +12 -0
  176. package/targets/esp32-s3-epaper-1.54/main/app_main.cpp +181 -0
  177. package/targets/esp32-s3-epaper-1.54/main/buttons.cpp +144 -0
  178. package/targets/esp32-s3-epaper-1.54/main/display.cpp +1281 -0
  179. package/targets/esp32-s3-epaper-1.54/main/fatfs_ffconf.h +377 -0
  180. package/targets/esp32-s3-epaper-1.54/main/i2c.cpp +39 -0
  181. package/targets/esp32-s3-epaper-1.54/main/idf_component.yml +7 -0
  182. package/targets/esp32-s3-epaper-1.54/main/imu_stub.cpp +21 -0
  183. package/targets/esp32-s3-epaper-1.54/main/include/board.h +119 -0
  184. package/targets/esp32-s3-epaper-1.54/main/include/buttons.h +9 -0
  185. package/targets/esp32-s3-epaper-1.54/main/include/wifi_config.h.example +5 -0
  186. package/targets/esp32-s3-epaper-1.54/main/launcher_button.cpp +191 -0
  187. package/targets/esp32-s3-epaper-1.54/main/power.cpp +15 -0
  188. package/targets/esp32-s3-epaper-1.54/main/sdcard_mount.cpp +89 -0
  189. package/targets/esp32-s3-epaper-1.54/main/touch.cpp +299 -0
  190. package/targets/esp32-s3-epaper-1.54/partitions.csv +8 -0
  191. package/targets/esp32-s3-epaper-1.54/sdkconfig.defaults +217 -0
  192. package/targets/esp32-s3-lilygo-t-display-s3-long/CMakeLists.txt +10 -0
  193. package/targets/esp32-s3-lilygo-t-display-s3-long/README.md +29 -0
  194. package/targets/esp32-s3-lilygo-t-display-s3-long/dependencies.lock +116 -0
  195. package/targets/esp32-s3-lilygo-t-display-s3-long/main/CMakeLists.txt +90 -0
  196. package/targets/esp32-s3-lilygo-t-display-s3-long/main/idf_component.yml +7 -0
  197. package/targets/esp32-s3-lilygo-t-display-s3-long/main/include/board.h +61 -0
  198. package/targets/esp32-s3-lilygo-t-display-s3-long/main/touch.cpp +299 -0
  199. package/targets/esp32-s3-lilygo-t-display-s3-long/partitions.csv +7 -0
  200. package/targets/esp32-s3-lilygo-t-display-s3-long/sdkconfig.defaults +50 -0
  201. package/targets/esp32-s3-lilygo-t5-epaper-4.7/CMakeLists.txt +12 -0
  202. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/CMakeLists.txt +17 -0
  203. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/ed047tc1.c +269 -0
  204. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/ed047tc1.h +142 -0
  205. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/epd_driver.c +1114 -0
  206. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/epd_driver.h +410 -0
  207. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/gea_epd.c +989 -0
  208. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/i2s_data_bus.c +489 -0
  209. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/i2s_data_bus.h +104 -0
  210. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/rmt_pulse.c +136 -0
  211. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/rmt_pulse.h +78 -0
  212. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/utilities.h +49 -0
  213. package/targets/esp32-s3-lilygo-t5-epaper-4.7/dependencies.lock +35 -0
  214. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/CMakeLists.txt +30 -0
  215. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/Kconfig.projbuild +10 -0
  216. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/app_main.cpp +95 -0
  217. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/audio_stub.cpp +27 -0
  218. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/buttons.cpp +40 -0
  219. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/display.cpp +627 -0
  220. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/i2c.cpp +36 -0
  221. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/idf_component.yml +4 -0
  222. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/imu_stub.cpp +20 -0
  223. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/include/board.h +85 -0
  224. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/include/buttons.h +8 -0
  225. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/launcher_button.cpp +82 -0
  226. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/power.cpp +36 -0
  227. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/sdcard_mount.cpp +90 -0
  228. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/touch.cpp +293 -0
  229. package/targets/esp32-s3-lilygo-t5-epaper-4.7/partitions.csv +9 -0
  230. package/targets/esp32-s3-lilygo-t5-epaper-4.7/sdkconfig.defaults +217 -0
  231. package/targets/esp32-s3-m5stack-papers3/CMakeLists.txt +13 -0
  232. package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/CMakeLists.txt +5 -0
  233. package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/include/papers3_epd.h +74 -0
  234. package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/papers3_epd.c +671 -0
  235. package/targets/esp32-s3-m5stack-papers3/dependencies.lock +76 -0
  236. package/targets/esp32-s3-m5stack-papers3/main/CMakeLists.txt +64 -0
  237. package/targets/esp32-s3-m5stack-papers3/main/Kconfig.projbuild +10 -0
  238. package/targets/esp32-s3-m5stack-papers3/main/app_main.cpp +96 -0
  239. package/targets/esp32-s3-m5stack-papers3/main/audio_stub.cpp +27 -0
  240. package/targets/esp32-s3-m5stack-papers3/main/buttons.cpp +49 -0
  241. package/targets/esp32-s3-m5stack-papers3/main/display.cpp +706 -0
  242. package/targets/esp32-s3-m5stack-papers3/main/i2c.cpp +36 -0
  243. package/targets/esp32-s3-m5stack-papers3/main/idf_component.yml +14 -0
  244. package/targets/esp32-s3-m5stack-papers3/main/imu.cpp +351 -0
  245. package/targets/esp32-s3-m5stack-papers3/main/include/board.h +101 -0
  246. package/targets/esp32-s3-m5stack-papers3/main/include/buttons.h +8 -0
  247. package/targets/esp32-s3-m5stack-papers3/main/launcher_button.cpp +96 -0
  248. package/targets/esp32-s3-m5stack-papers3/main/power.cpp +102 -0
  249. package/targets/esp32-s3-m5stack-papers3/main/sdcard_mount.cpp +88 -0
  250. package/targets/esp32-s3-m5stack-papers3/main/touch.cpp +287 -0
  251. package/targets/esp32-s3-m5stack-papers3/partitions.csv +9 -0
  252. package/targets/esp32-s3-m5stack-papers3/sdkconfig.defaults +232 -0
  253. package/targets/esp32-s3-m5stack-sticks3/CMakeLists.txt +10 -0
  254. package/targets/esp32-s3-m5stack-sticks3/dependencies.lock +51 -0
  255. package/targets/esp32-s3-m5stack-sticks3/main/CMakeLists.txt +51 -0
  256. package/targets/esp32-s3-m5stack-sticks3/main/Kconfig.projbuild +12 -0
  257. package/targets/esp32-s3-m5stack-sticks3/main/app_main.cpp +130 -0
  258. package/targets/esp32-s3-m5stack-sticks3/main/buttons.cpp +101 -0
  259. package/targets/esp32-s3-m5stack-sticks3/main/display.cpp +1391 -0
  260. package/targets/esp32-s3-m5stack-sticks3/main/i2c.cpp +39 -0
  261. package/targets/esp32-s3-m5stack-sticks3/main/idf_component.yml +8 -0
  262. package/targets/esp32-s3-m5stack-sticks3/main/imu_stub.cpp +9 -0
  263. package/targets/esp32-s3-m5stack-sticks3/main/include/board.h +89 -0
  264. package/targets/esp32-s3-m5stack-sticks3/main/include/buttons.h +9 -0
  265. package/targets/esp32-s3-m5stack-sticks3/main/launcher_button.cpp +191 -0
  266. package/targets/esp32-s3-m5stack-sticks3/main/power.cpp +15 -0
  267. package/targets/esp32-s3-m5stack-sticks3/main/sdcard_mount.cpp +8 -0
  268. package/targets/esp32-s3-m5stack-sticks3/main/touch.cpp +65 -0
  269. package/targets/esp32-s3-m5stack-sticks3/partitions.csv +8 -0
  270. package/targets/esp32-s3-m5stack-sticks3/sdkconfig.defaults +130 -0
  271. package/targets/esp32-s3-touch-amoled-1.75/CMakeLists.txt +10 -0
  272. package/targets/esp32-s3-touch-amoled-1.75/dependencies.lock +130 -0
  273. package/targets/esp32-s3-touch-amoled-1.75/main/CMakeLists.txt +589 -0
  274. package/targets/esp32-s3-touch-amoled-1.75/main/Kconfig.projbuild +12 -0
  275. package/targets/esp32-s3-touch-amoled-1.75/main/app_main.cpp +153 -0
  276. package/targets/esp32-s3-touch-amoled-1.75/main/i2c.cpp +39 -0
  277. package/targets/esp32-s3-touch-amoled-1.75/main/idf_component.yml +9 -0
  278. package/targets/esp32-s3-touch-amoled-1.75/main/include/board.h +110 -0
  279. package/targets/esp32-s3-touch-amoled-1.75/main/include/wifi_config.h.example +5 -0
  280. package/targets/esp32-s3-touch-amoled-1.75/main/launcher_button.cpp +191 -0
  281. package/targets/esp32-s3-touch-amoled-1.75/main/touch.cpp +45 -0
  282. package/targets/esp32-s3-touch-amoled-1.75/partitions.csv +8 -0
  283. package/targets/esp32-s3-touch-amoled-1.75/sdkconfig.defaults +179 -0
  284. package/targets/esp32-s3-touch-amoled-1.8/CMakeLists.txt +10 -0
  285. package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +105 -0
  286. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +768 -0
  287. package/targets/esp32-s3-touch-amoled-1.8/main/Kconfig.projbuild +12 -0
  288. package/targets/esp32-s3-touch-amoled-1.8/main/app_main.cpp +172 -0
  289. package/targets/esp32-s3-touch-amoled-1.8/main/i2c.cpp +39 -0
  290. package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +8 -0
  291. package/targets/esp32-s3-touch-amoled-1.8/main/include/board.h +83 -0
  292. package/targets/esp32-s3-touch-amoled-1.8/main/include/wifi_config.h.example +5 -0
  293. package/targets/esp32-s3-touch-amoled-1.8/main/launcher_button.cpp +191 -0
  294. package/targets/esp32-s3-touch-amoled-1.8/main/touch.cpp +41 -0
  295. package/targets/esp32-s3-touch-amoled-1.8/partitions.csv +8 -0
  296. package/targets/esp32-s3-touch-amoled-1.8/sdkconfig.defaults +179 -0
  297. package/targets/esp32-s3-touch-amoled-2.06/CMakeLists.txt +10 -0
  298. package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +64 -0
  299. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +1121 -0
  300. package/targets/esp32-s3-touch-amoled-2.06/main/Kconfig.projbuild +12 -0
  301. package/targets/esp32-s3-touch-amoled-2.06/main/app_main.cpp +333 -0
  302. package/targets/esp32-s3-touch-amoled-2.06/main/i2c.cpp +39 -0
  303. package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +27 -0
  304. package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +114 -0
  305. package/targets/esp32-s3-touch-amoled-2.06/main/include/wifi_config.h.example +5 -0
  306. package/targets/esp32-s3-touch-amoled-2.06/main/launcher_button.cpp +199 -0
  307. package/targets/esp32-s3-touch-amoled-2.06/main/sdcard_mount.cpp +105 -0
  308. package/targets/esp32-s3-touch-amoled-2.06/main/touch.cpp +49 -0
  309. package/targets/esp32-s3-touch-amoled-2.06/partitions.csv +14 -0
  310. package/targets/esp32-s3-touch-amoled-2.06/sdkconfig.defaults +273 -0
  311. package/targets/esp32-s3-touch-amoled-2.41/CMakeLists.txt +10 -0
  312. package/targets/esp32-s3-touch-amoled-2.41/main/CMakeLists.txt +71 -0
  313. package/targets/esp32-s3-touch-amoled-2.41/main/Kconfig.projbuild +12 -0
  314. package/targets/esp32-s3-touch-amoled-2.41/main/idf_component.yml +27 -0
  315. package/targets/esp32-s3-touch-amoled-2.41/main/include/board.h +108 -0
  316. package/targets/esp32-s3-touch-amoled-2.41/main/include/wifi_config.h.example +5 -0
  317. package/targets/esp32-s3-touch-amoled-2.41/main/panel_reset.cpp +82 -0
  318. package/targets/esp32-s3-touch-amoled-2.41/main/touch.cpp +49 -0
  319. package/targets/esp32-s3-touch-amoled-2.41/partitions.csv +8 -0
  320. package/targets/esp32-s3-touch-amoled-2.41/sdkconfig.defaults +273 -0
  321. package/targets/rp2350-tufty-2350/CMakeLists.txt +348 -0
  322. package/targets/rp2350-tufty-2350/README.md +53 -0
  323. package/targets/rp2350-tufty-2350/boards/pimoroni_tufty2350.h +87 -0
  324. package/targets/rp2350-tufty-2350/main/bringup.cpp +187 -0
  325. package/targets/rp2350-tufty-2350/main/include/board.h +124 -0
  326. package/targets/rp2350-tufty-2350/main/rp2350_panel.cpp +428 -0
  327. package/targets/rp2350-tufty-2350/main/rp2350_panel.h +46 -0
  328. package/targets/rp2350-tufty-2350/main/st7789_parallel.pio +7 -0
  329. package/targets/rp2350-waveshare-touch-amoled-2.41/CMakeLists.txt +345 -0
  330. package/targets/rp2350-waveshare-touch-amoled-2.41/README.md +153 -0
  331. package/targets/rp2350-waveshare-touch-amoled-2.41/boards/waveshare_rp2350_touch_amoled_2_41.h +59 -0
  332. package/targets/rp2350-waveshare-touch-amoled-2.41/main/app.cpp +984 -0
  333. package/targets/rp2350-waveshare-touch-amoled-2.41/main/bringup.cpp +222 -0
  334. package/targets/rp2350-waveshare-touch-amoled-2.41/main/include/board.h +138 -0
  335. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.cpp +2553 -0
  336. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.h +18 -0
  337. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_host_fetch_stub.cpp +64 -0
  338. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.cpp +677 -0
  339. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.h +48 -0
  340. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/rp_pico_alloc.c +354 -0
  341. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/rp_pico_alloc.h +56 -0
  342. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf.c +1284 -0
  343. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf.h +95 -0
  344. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf_block_functions.h +123 -0
  345. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf_common.h +127 -0
  346. package/targets/rp2350-waveshare-touch-amoled-2.41/tools/rp2350-scroll-bench.py +162 -0
  347. package/targets/rp2350-waveshare-touch-amoled-2.41/tools/rp2350-scroll-parity.py +198 -0
  348. package/targets.json +154 -0
@@ -0,0 +1,984 @@
1
+ #include <rp2350_gea_platform.h>
2
+ #include <rp2350_panel.h>
3
+
4
+ #include "display.h"
5
+ #include "events.h"
6
+ #include "image.h"
7
+ #include "css/declarative.h"
8
+ #include "css/engine.h"
9
+ #include "host/timers.h"
10
+ #include "host/memory.h"
11
+ #include "pixel.h"
12
+ #include "services/frame_scheduler.h"
13
+ #include "ui/document.h"
14
+ #include "ui/tree_internal.h"
15
+ #include "ui/refresh_perf.h"
16
+ #include "ui/style.h"
17
+
18
+ #include "hardware/clocks.h"
19
+ #include "hardware/irq.h"
20
+ #include "hardware/structs/timer.h"
21
+ #include "hardware/vreg.h"
22
+ #include "hardware/watchdog.h"
23
+ #include "hardware/structs/watchdog.h"
24
+ #include "pico/stdlib.h"
25
+ #include "pico/stdio_usb.h"
26
+
27
+ #include <cstdint>
28
+ #include <cstdio>
29
+ #include <cstdarg>
30
+ #include <cstring>
31
+
32
+ extern void __gea_top_level();
33
+ // Deferred CSS/prelude registration: the codegen emits it as this function
34
+ // (via --cpp-prelude-symbol) so it runs after memoryInit() and the stylesheet
35
+ // allocates from PSRAM, not the small pre-main SRAM heap. Weak + C++ linkage
36
+ // (the emitter writes a plain C++ function); bringup builds without an app
37
+ // don't define it.
38
+ void gea_plugin_cpp_register_prelude() __attribute__((weak));
39
+
40
+ namespace gea::framework::app::generated {
41
+ void drainMicrotasks();
42
+ } // namespace gea::framework::app::generated
43
+
44
+ // ---- Pre-main crash logger (boot-debug aid) --------------------------------
45
+ // A HardFault before main() leaves the board dark on USB with nothing to
46
+ // observe. The handler stashes the faulting PC/LR in watchdog scratch (which
47
+ // survives a reboot) and resets; the priority-101 constructor below runs
48
+ // before all other C++ static constructors, brings USB up, and reports the
49
+ // previous run's fault (or a hang marker) for ~8 s so a host capture sees it.
50
+ extern "C" void isr_hardfault(void)
51
+ {
52
+ std::uint32_t *sp;
53
+ __asm volatile("mrs %0, msp" : "=r"(sp));
54
+ watchdog_hw->scratch[4] = 0xFA17FA17u;
55
+ watchdog_hw->scratch[5] = sp[6]; // stacked PC
56
+ watchdog_hw->scratch[6] = sp[5]; // stacked LR
57
+ watchdog_reboot(0, 0, 0);
58
+ while (true) {
59
+ tight_loop_contents();
60
+ }
61
+ }
62
+
63
+ // Panic override (boot-debug aid): the SDK default prints once and hits a
64
+ // breakpoint, which without a debugger lands in a lockup-reset before the USB
65
+ // buffer drains — the message is lost. Broadcast it for a while instead, then
66
+ // reboot cleanly.
67
+ extern "C" void __attribute__((noreturn)) gea_panic(const char *fmt, ...)
68
+ {
69
+ char buf[256];
70
+ va_list args;
71
+ va_start(args, fmt);
72
+ std::vsnprintf(buf, sizeof buf, fmt, args);
73
+ va_end(args);
74
+ const std::uint64_t untilUs = time_us_64() + 8000000u;
75
+ while (time_us_64() < untilUs) {
76
+ std::printf("GEA_PANIC %s\n", buf);
77
+ std::fflush(stdout);
78
+ sleep_ms(250);
79
+ }
80
+ watchdog_reboot(0, 0, 0);
81
+ while (true) {
82
+ tight_loop_contents();
83
+ }
84
+ }
85
+
86
+ // PC sampler: a raw TIMER0 alarm IRQ fires every ~1 ms and stores the
87
+ // interrupted instruction address straight into watchdog scratch[5] (which
88
+ // survives the mystery lockup-reset). The next boot reports it — pointing at
89
+ // the exact code the previous boot was stuck in.
90
+ extern "C" {
91
+ volatile std::uint32_t *gea_pc_sample_slot = &watchdog_hw->scratch[5];
92
+ // Boot profile ring: the same 1ms IRQ also appends each PC here until full
93
+ // (~4s — covers the whole boot). Dumped over GEADEV BOOTPROF and folded into
94
+ // a function histogram host-side with addr2line.
95
+ constexpr int kPcRingEntries = 4096;
96
+ std::uint32_t gea_pc_ring[kPcRingEntries];
97
+ std::uint32_t *gea_pc_ring_ptr = gea_pc_ring;
98
+ std::uint32_t *gea_pc_ring_limit = gea_pc_ring + kPcRingEntries;
99
+ void gea_pc_sampler_rearm(void);
100
+ // Last CSS recompute-batch profile line (style.cpp, GEA_RECPROF builds; null otherwise).
101
+ const char *gea_recprof_last(void);
102
+
103
+ __attribute__((naked)) void gea_pc_sampler_irq(void)
104
+ {
105
+ __asm volatile(
106
+ "mrs r0, msp\n"
107
+ "ldr r1, [r0, #24]\n" // stacked PC of the interrupted code
108
+ "ldr r2, =gea_pc_sample_slot\n"
109
+ "ldr r2, [r2]\n"
110
+ "str r1, [r2]\n"
111
+ "ldr r2, =gea_pc_ring_ptr\n"
112
+ "ldr r3, [r2]\n"
113
+ "ldr r0, =gea_pc_ring_limit\n"
114
+ "ldr r0, [r0]\n"
115
+ "cmp r3, r0\n"
116
+ "bcs 1f\n" // ring full: keep only the hang slot updated
117
+ "str r1, [r3]\n"
118
+ "adds r3, #4\n"
119
+ "str r3, [r2]\n"
120
+ "1:\n"
121
+ "b gea_pc_sampler_rearm\n");
122
+ }
123
+
124
+ void gea_pc_sampler_rearm(void)
125
+ {
126
+ timer0_hw->intr = 1u; // ack alarm 0
127
+ timer0_hw->alarm[0] = timer0_hw->timerawl + 1000u;
128
+ }
129
+ }
130
+
131
+ namespace {
132
+
133
+ struct EarlyBootBeacon {
134
+ EarlyBootBeacon()
135
+ {
136
+ stdio_init_all();
137
+ const bool faulted = watchdog_hw->scratch[4] == 0xFA17FA17u;
138
+ const bool hungInCtors = !faulted && watchdog_hw->scratch[7] == 0xC702C702u;
139
+ if (faulted || hungInCtors) {
140
+ const std::uint32_t pc = watchdog_hw->scratch[5];
141
+ const std::uint32_t lr = watchdog_hw->scratch[6];
142
+ const std::uint64_t untilUs = time_us_64() + 8000000u;
143
+ while (time_us_64() < untilUs) {
144
+ if (faulted) {
145
+ std::printf("GEA_FAULT pre-main pc=%08x lr=%08x\n",
146
+ static_cast<unsigned>(pc),
147
+ static_cast<unsigned>(lr));
148
+ } else {
149
+ std::printf("GEA_HANG pre-main, last sampled pc=%08x\n",
150
+ static_cast<unsigned>(pc));
151
+ }
152
+ std::fflush(stdout);
153
+ sleep_ms(250);
154
+ }
155
+ watchdog_hw->scratch[4] = 0;
156
+ }
157
+ watchdog_hw->scratch[7] = 0xC702C702u; // phase: static ctors running
158
+ watchdog_hw->scratch[5] = 0;
159
+
160
+ // Start the PC sampler for the remainder of the boot.
161
+ irq_set_exclusive_handler(TIMER0_IRQ_0, gea_pc_sampler_irq);
162
+ timer0_hw->inte |= 1u;
163
+ timer0_hw->alarm[0] = timer0_hw->timerawl + 1000u;
164
+ irq_set_enabled(TIMER0_IRQ_0, true);
165
+ }
166
+ };
167
+
168
+ __attribute__((init_priority(101))) EarlyBootBeacon gEarlyBootBeacon;
169
+
170
+ } // namespace
171
+ // ----------------------------------------------------------------------------
172
+
173
+ namespace {
174
+
175
+ #ifndef GEA_RP2350_SYS_CLOCK_KHZ
176
+ // 300 MHz: the software raster/present is pure integer compute and scales ~linearly
177
+ // with clock. Stable at 1.20V (below the ~1.30V that 400MHz needs). The QSPI PIO
178
+ // divides from clk_sys, so rp2350_panel.cpp pins the panel wire clock with a
179
+ // runtime divider to keep the bus at its tuned speed regardless of this overclock.
180
+ #define GEA_RP2350_SYS_CLOCK_KHZ 300000
181
+ #endif
182
+
183
+ #ifndef GEA_RP2350_VREG_VOLTAGE
184
+ #define GEA_RP2350_VREG_VOLTAGE VREG_VOLTAGE_1_20
185
+ #endif
186
+
187
+ #ifndef GEA_RP2350_HAS_TOUCH
188
+ #define GEA_RP2350_HAS_TOUCH 1
189
+ #endif
190
+
191
+ #ifndef GEA_EMBEDDED_CSS_DEVICE_PIXEL_RATIO
192
+ #define GEA_EMBEDDED_CSS_DEVICE_PIXEL_RATIO 2.0
193
+ #endif
194
+
195
+ #ifndef GEA_RP2350_STARTUP_TRACE
196
+ #define GEA_RP2350_STARTUP_TRACE 0
197
+ #endif
198
+
199
+ #ifndef GEA_RP2350_FRAME_PHASE_PERF
200
+ #define GEA_RP2350_FRAME_PHASE_PERF 0
201
+ #endif
202
+
203
+ #ifndef GEA_RP2350_REFRESH_DETAIL_PERF
204
+ #define GEA_RP2350_REFRESH_DETAIL_PERF 0
205
+ #endif
206
+
207
+ #ifndef GEA_RP2350_PERF_LOG
208
+ #define GEA_RP2350_PERF_LOG 1
209
+ #endif
210
+
211
+ #if GEA_RP2350_FRAME_PHASE_PERF
212
+ struct FramePhaseStats {
213
+ std::uint64_t workUs = 0;
214
+ std::uint64_t inputUs = 0;
215
+ std::uint64_t microtaskUs = 0;
216
+ std::uint64_t rafUs = 0;
217
+ std::uint64_t cssUs = 0;
218
+ std::uint64_t documentUs = 0;
219
+ std::uint64_t refreshUs = 0;
220
+ std::uint64_t sleepUs = 0;
221
+ std::uint32_t frames = 0;
222
+ std::uint32_t overBudgetFrames = 0;
223
+ std::uint32_t worstWorkUs = 0;
224
+ };
225
+
226
+ FramePhaseStats gFramePhaseStats;
227
+ std::uint64_t gFramePhaseStartUs = 0;
228
+
229
+ void phaseBeginFrame(std::uint64_t startUs)
230
+ {
231
+ gFramePhaseStartUs = startUs;
232
+ }
233
+
234
+ void phaseEndFrame(std::uint64_t endUs, std::uint32_t budgetUs)
235
+ {
236
+ const auto workUs = static_cast<std::uint32_t>(endUs - gFramePhaseStartUs);
237
+ gFramePhaseStats.workUs += workUs;
238
+ ++gFramePhaseStats.frames;
239
+ if (budgetUs > 0 && workUs > budgetUs) ++gFramePhaseStats.overBudgetFrames;
240
+ if (workUs > gFramePhaseStats.worstWorkUs) gFramePhaseStats.worstWorkUs = workUs;
241
+ }
242
+
243
+ void phaseAddSleep(std::uint32_t sleepUs)
244
+ {
245
+ gFramePhaseStats.sleepUs += sleepUs;
246
+ }
247
+
248
+ void phaseLogAndReset()
249
+ {
250
+ const auto frames = gFramePhaseStats.frames;
251
+ const std::uint64_t avgWorkUs = frames > 0 ? (gFramePhaseStats.workUs + frames / 2u) / frames : 0;
252
+ const std::uint64_t avgRefreshUs = frames > 0 ? (gFramePhaseStats.refreshUs + frames / 2u) / frames : 0;
253
+ std::printf("gea.rp2350.phase frames=%u work_ms=%llu avg_work_us=%llu worst_work_us=%u over_budget=%u input_ms=%llu micro_ms=%llu raf_ms=%llu css_ms=%llu doc_ms=%llu refresh_ms=%llu avg_refresh_us=%llu sleep_ms=%llu\n",
254
+ static_cast<unsigned>(frames),
255
+ static_cast<unsigned long long>(gFramePhaseStats.workUs / 1000u),
256
+ static_cast<unsigned long long>(avgWorkUs),
257
+ static_cast<unsigned>(gFramePhaseStats.worstWorkUs),
258
+ static_cast<unsigned>(gFramePhaseStats.overBudgetFrames),
259
+ static_cast<unsigned long long>(gFramePhaseStats.inputUs / 1000u),
260
+ static_cast<unsigned long long>(gFramePhaseStats.microtaskUs / 1000u),
261
+ static_cast<unsigned long long>(gFramePhaseStats.rafUs / 1000u),
262
+ static_cast<unsigned long long>(gFramePhaseStats.cssUs / 1000u),
263
+ static_cast<unsigned long long>(gFramePhaseStats.documentUs / 1000u),
264
+ static_cast<unsigned long long>(gFramePhaseStats.refreshUs / 1000u),
265
+ static_cast<unsigned long long>(avgRefreshUs),
266
+ static_cast<unsigned long long>(gFramePhaseStats.sleepUs / 1000u));
267
+ gFramePhaseStats = {};
268
+ }
269
+ #endif
270
+
271
+ #if GEA_RP2350_REFRESH_DETAIL_PERF
272
+ void refreshDetailLogAndReset(int frames)
273
+ {
274
+ const auto stats = gea::embedded::ui::refreshPerfStatsRead();
275
+ const int denom = frames > 0 ? frames : 1;
276
+ std::printf("gea.rp2350.refresh frames=%d layout_us=%lld dlist_us=%lld record_us=%lld dirty_us=%lld coal_us=%lld replay_us=%lld regions=%d origin_regions=%d checks=%d fill_us=%lld circle_us=%lld text_us=%lld grad_us=%lld img_us=%lld other_us=%lld flush_us=%lld snap_us=%lld full_records=%d reprojects=%d recorded_nodes=%d recorded_cmds=%d\n",
277
+ frames,
278
+ static_cast<long long>(stats.treeLayoutUs / denom),
279
+ static_cast<long long>(stats.treeDisplayListUs / denom),
280
+ static_cast<long long>(stats.treeRecordNodeUs / denom),
281
+ static_cast<long long>(stats.treeDirtyCollectUs / denom),
282
+ static_cast<long long>(stats.treeDirtyCoalesceUs / denom),
283
+ static_cast<long long>(stats.treeReplayUs / denom),
284
+ stats.treeReplayRegions / denom,
285
+ stats.treeReplayOriginRegions / denom,
286
+ stats.treeReplayCommandChecks / denom,
287
+ static_cast<long long>(stats.treeReplayFillUs / denom),
288
+ static_cast<long long>(stats.treeReplayCircleUs / denom),
289
+ static_cast<long long>(stats.treeReplayTextUs / denom),
290
+ static_cast<long long>(stats.treeReplayGradientUs / denom),
291
+ static_cast<long long>(stats.treeReplayImageUs / denom),
292
+ static_cast<long long>(stats.treeReplayOtherUs / denom),
293
+ static_cast<long long>(stats.treeFlushRectsUs / denom),
294
+ static_cast<long long>(stats.treeSnapshotUs / denom),
295
+ stats.treeFullRecords,
296
+ stats.treeReprojects,
297
+ stats.treeRecordedNodes / denom,
298
+ stats.treeRecordedCommands / denom);
299
+ std::printf("gea.rp2350.replay_detail frames=%d direct1=%d directN=%d simple1=%d parallel_try=%d parallel_ok=%d split_bg_us=%lld split_dyn_us=%lld split_raster_us=%lld bg_restore_us=%lld node_walk_us=%lld filter_us=%lld filter_calls=%d clip_us=%lld clip_calls=%d draw_counts=fill:%d circle:%d round:%d xround:%d text:%d other:%d\n",
300
+ frames,
301
+ stats.treeReplayDirectRegionCalls / denom,
302
+ stats.treeReplayDirectRegionsCalls / denom,
303
+ stats.treeReplaySimpleRegionCalls / denom,
304
+ stats.treeReplayParallelAttempts / denom,
305
+ stats.treeReplayParallelSuccesses / denom,
306
+ static_cast<long long>(stats.treeReplaySplitBgUs / denom),
307
+ static_cast<long long>(stats.treeReplaySplitDynUs / denom),
308
+ static_cast<long long>(stats.treeReplaySplitRasterUs / denom),
309
+ static_cast<long long>(stats.treeReplayBgRestoreUs / denom),
310
+ static_cast<long long>(stats.treeReplayNodeWalkUs / denom),
311
+ static_cast<long long>(stats.treeReplayCommandFilterUs / denom),
312
+ stats.treeReplayCommandFilterCalls / denom,
313
+ static_cast<long long>(stats.treeReplayCommandClipUs / denom),
314
+ stats.treeReplayCommandClipCalls / denom,
315
+ stats.treeReplayFillRectCommands / denom,
316
+ stats.treeReplayCircleCommands / denom,
317
+ stats.treeReplayRoundedRectCommands / denom,
318
+ stats.treeReplayTransformedRoundedRectCommands / denom,
319
+ stats.treeReplayTextCommands / denom,
320
+ stats.treeReplayOtherCommands / denom);
321
+ std::printf("gea.rp2350.layout frames=%d node_calls=%d memo_hits=%d scoped=%d repositions=%d text_us=%lld set_style=%d/%d set_text=%d/%d layout_changed=%d\n",
322
+ frames,
323
+ stats.treeLayoutNodeCalls,
324
+ stats.treeLayoutMemoHits,
325
+ stats.treeScopedLayouts,
326
+ stats.treeLayoutRepositionCalls,
327
+ static_cast<long long>(stats.treeLayoutTextUs),
328
+ stats.treeSetStyleCalls,
329
+ stats.treeSetStyleChanged,
330
+ stats.treeSetTextCalls,
331
+ stats.treeSetTextChanged,
332
+ stats.treeSetStyleLayoutChanged);
333
+ std::printf("gea.rp2350.abs_mode frames=%d calls=%d fast=%d full=%d noop=%d dirty=%d reject_node=%d reject_reason=%d scoped_reject=%d/%d\n",
334
+ frames,
335
+ stats.treeAbsModeCalls,
336
+ stats.treeAbsModeFast,
337
+ stats.treeAbsModeFull,
338
+ stats.treeAbsModeNoop,
339
+ stats.treeAbsModeDirtyNodes,
340
+ stats.treeAbsModeRejectNode,
341
+ stats.treeAbsModeRejectReason,
342
+ stats.treeScopedRejectReason,
343
+ stats.treeScopedRejectNode);
344
+ std::printf("gea.rp2350.root_scroll frames=%d calls=%d accepted=%d rejected=%d scan_us=%lld rebuild_us=%lld scrollrect_us=%lld strip_us=%lld scrollbar_us=%lld full_replay_us=%lld stream_us=%lld extra_us=%lld flush_us=%lld move_px=%d strip_px=%d viewport_px=%d\n",
345
+ frames,
346
+ stats.rootScrollCalls,
347
+ stats.rootScrollAccepted,
348
+ stats.rootScrollRejected,
349
+ static_cast<long long>(stats.rootScrollScanUs / denom),
350
+ static_cast<long long>(stats.rootScrollRebuildUs / denom),
351
+ static_cast<long long>(stats.rootScrollScrollRectUs / denom),
352
+ static_cast<long long>(stats.rootScrollStripReplayUs / denom),
353
+ static_cast<long long>(stats.rootScrollScrollbarReplayUs / denom),
354
+ static_cast<long long>(stats.rootScrollFullReplayUs / denom),
355
+ static_cast<long long>(stats.rootScrollStreamUs / denom),
356
+ static_cast<long long>(stats.rootScrollExtraReplayUs / denom),
357
+ static_cast<long long>(stats.rootScrollFlushUs / denom),
358
+ stats.rootScrollMovePx,
359
+ stats.rootScrollStripPx,
360
+ stats.rootScrollViewportPx);
361
+ std::printf("gea.rp2350.text_cache frames=%d calls=%d hits=%d misses=%d fallback=%d sram_uses=%d psram_uses=%d cached_bytes=%d sram_bytes=%d max_entry=%d\n",
362
+ frames,
363
+ stats.projectedTextCacheCalls,
364
+ stats.projectedTextCacheHits,
365
+ stats.projectedTextCacheMisses,
366
+ stats.projectedTextCacheFallbacks,
367
+ stats.projectedTextCacheSramUses,
368
+ stats.projectedTextCachePsramUses,
369
+ stats.projectedTextCacheBytes,
370
+ stats.projectedTextCacheSramBytes,
371
+ stats.projectedTextCacheMaxEntryBytes);
372
+ gea::embedded::ui::refreshPerfStatsReset();
373
+ }
374
+ #endif
375
+
376
+ void configureClock()
377
+ {
378
+ constexpr std::uint32_t kSysClockKhz = GEA_RP2350_SYS_CLOCK_KHZ;
379
+ if constexpr (kSysClockKhz > 150000) {
380
+ vreg_set_voltage(GEA_RP2350_VREG_VOLTAGE);
381
+ sleep_ms(2);
382
+ }
383
+ set_sys_clock_khz(kSysClockKhz, true);
384
+ clock_configure(clk_peri,
385
+ 0,
386
+ CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS,
387
+ kSysClockKhz * 1000,
388
+ kSysClockKhz * 1000);
389
+ }
390
+
391
+ void runFrame(int timestampMs)
392
+ {
393
+ static bool cssAnimationsStarted = false;
394
+ const auto nowMs = static_cast<std::uint32_t>(timestampMs);
395
+ #if GEA_RP2350_FRAME_PHASE_PERF
396
+ std::uint64_t phaseUs = time_us_64();
397
+ #endif
398
+ if (!cssAnimationsStarted) {
399
+ gea::css::DeclarativeAnimations::scanAndStart(nowMs);
400
+ gea::embedded::ui::StyleSheet::instance().startCssAnimations(nowMs);
401
+ cssAnimationsStarted = true;
402
+ }
403
+
404
+ gea::rp2350::pollTouch();
405
+ gea::rp2350::pollButtons();
406
+ gea::rp2350::dispatchQueuedEvents();
407
+ #if GEA_RP2350_FRAME_PHASE_PERF
408
+ {
409
+ const std::uint64_t nowUs = time_us_64();
410
+ gFramePhaseStats.inputUs += nowUs - phaseUs;
411
+ phaseUs = nowUs;
412
+ }
413
+ #endif
414
+ // Coalesce class-style recomputes from this frame's reactive updates
415
+ // (microtasks + rAF): a city/theme switch flips a near-root class plus a
416
+ // few descendant classes, and unbatched each flip re-walks its subtree
417
+ // against the stylesheet. endStyleMountBatch() below runs one coalesced,
418
+ // dependency-filtered pass before layout/paint. Same bracketing as
419
+ // gea_app_entry.cpp's frame().
420
+ gea::embedded::ui::beginStyleMountBatch();
421
+ gea::framework::app::generated::drainMicrotasks();
422
+ #if GEA_RP2350_FRAME_PHASE_PERF
423
+ {
424
+ const std::uint64_t nowUs = time_us_64();
425
+ gFramePhaseStats.microtaskUs += nowUs - phaseUs;
426
+ phaseUs = nowUs;
427
+ }
428
+ #endif
429
+ gea::host::runAnimationFrameCallbacks(static_cast<double>(timestampMs));
430
+ #if GEA_RP2350_FRAME_PHASE_PERF
431
+ {
432
+ const std::uint64_t nowUs = time_us_64();
433
+ gFramePhaseStats.rafUs += nowUs - phaseUs;
434
+ phaseUs = nowUs;
435
+ }
436
+ #endif
437
+ gea::css::AnimationEngine::instance().tick(nowMs);
438
+ #if GEA_RP2350_FRAME_PHASE_PERF
439
+ {
440
+ const std::uint64_t nowUs = time_us_64();
441
+ gFramePhaseStats.cssUs += nowUs - phaseUs;
442
+ phaseUs = nowUs;
443
+ }
444
+ #endif
445
+ gea::rp2350::dispatchQueuedEvents();
446
+ #if GEA_RP2350_FRAME_PHASE_PERF
447
+ {
448
+ const std::uint64_t nowUs = time_us_64();
449
+ gFramePhaseStats.inputUs += nowUs - phaseUs;
450
+ phaseUs = nowUs;
451
+ }
452
+ #endif
453
+ // Apply the coalesced recompute so layout/paint below see final styles.
454
+ gea::embedded::ui::endStyleMountBatch();
455
+ gea::embedded::ui::Document::instance().frame(timestampMs);
456
+ #if GEA_RP2350_FRAME_PHASE_PERF
457
+ {
458
+ const std::uint64_t nowUs = time_us_64();
459
+ gFramePhaseStats.documentUs += nowUs - phaseUs;
460
+ phaseUs = nowUs;
461
+ }
462
+ #endif
463
+ gea::framework::app::generated::drainMicrotasks();
464
+ #if GEA_RP2350_FRAME_PHASE_PERF
465
+ {
466
+ const std::uint64_t nowUs = time_us_64();
467
+ gFramePhaseStats.microtaskUs += nowUs - phaseUs;
468
+ phaseUs = nowUs;
469
+ }
470
+ #endif
471
+ gea::embedded::ui::Document::instance().refreshMountedIfDirty();
472
+ #if GEA_RP2350_FRAME_PHASE_PERF
473
+ {
474
+ const std::uint64_t nowUs = time_us_64();
475
+ gFramePhaseStats.refreshUs += nowUs - phaseUs;
476
+ }
477
+ #endif
478
+ }
479
+
480
+ void logFlushStats(int timestampMs)
481
+ {
482
+ #if GEA_RP2350_PERF_LOG
483
+ static int lastLogMs = -1;
484
+ static int frames = 0;
485
+ if (lastLogMs < 0) {
486
+ lastLogMs = timestampMs;
487
+ gea::rp2350::panelFlushStatsReset();
488
+ return;
489
+ }
490
+
491
+ ++frames;
492
+ const int elapsedMs = timestampMs - lastLogMs;
493
+ if (elapsedMs < 1000) return;
494
+
495
+ const auto stats = gea::rp2350::panelFlushStatsRead();
496
+ const int fps = elapsedMs > 0 ? (frames * 1000 + elapsedMs / 2) / elapsedMs : 0;
497
+ std::printf("gea.rp2350.perf fps=%d frames=%d ms=%d flush_calls=%d flush_kpx=%d chunks=%d total_ms=%lld window_ms=%lld copy_ms=%lld txwait_ms=%lld\n",
498
+ fps,
499
+ frames,
500
+ elapsedMs,
501
+ stats.callCount,
502
+ (stats.pixelCount + 999) / 1000,
503
+ stats.chunkCount,
504
+ static_cast<long long>(stats.totalUs / 1000),
505
+ static_cast<long long>(stats.setWindowUs / 1000),
506
+ static_cast<long long>(stats.copyUs / 1000),
507
+ static_cast<long long>(stats.txWaitUs / 1000));
508
+ std::printf("gea.rp2350.alloc sram_allocs=%u psram_allocs=%u sram_live=%u psram_live=%u sram_peak=%u psram_peak=%u psram_free=%u\n",
509
+ static_cast<unsigned>(gea::framework::memory::MemoryBackend::allocationSramCount()),
510
+ static_cast<unsigned>(gea::framework::memory::MemoryBackend::allocationPsramCount()),
511
+ static_cast<unsigned>(gea::framework::memory::MemoryBackend::allocationSramBytes()),
512
+ static_cast<unsigned>(gea::framework::memory::MemoryBackend::allocationPsramBytes()),
513
+ static_cast<unsigned>(gea::framework::memory::MemoryBackend::allocationSramPeakBytes()),
514
+ static_cast<unsigned>(gea::framework::memory::MemoryBackend::allocationPsramPeakBytes()),
515
+ static_cast<unsigned>(gea::framework::memory::MemoryBackend::psramFree()));
516
+ #if GEA_RP2350_FRAME_PHASE_PERF
517
+ phaseLogAndReset();
518
+ #endif
519
+ #if GEA_RP2350_REFRESH_DETAIL_PERF
520
+ refreshDetailLogAndReset(frames);
521
+ #endif
522
+ gea::rp2350::panelFlushStatsReset();
523
+ lastLogMs = timestampMs;
524
+ frames = 0;
525
+ #else
526
+ (void)timestampMs;
527
+ #endif
528
+ }
529
+
530
+ #if GEA_RP2350_STARTUP_TRACE
531
+ void waitForUsbConsole(std::uint32_t timeoutMs = 8000)
532
+ {
533
+ const std::uint64_t deadlineUs = time_us_64() + static_cast<std::uint64_t>(timeoutMs) * 1000u;
534
+ while (!stdio_usb_connected() && time_us_64() < deadlineUs) {
535
+ sleep_ms(10);
536
+ }
537
+ }
538
+
539
+ void startupLog(const char *stage, std::uint64_t startUs = 0)
540
+ {
541
+ const std::uint64_t nowUs = time_us_64();
542
+ if (startUs > 0) {
543
+ std::printf("GEA_START %s t=%llu ms delta=%llu ms\n",
544
+ stage,
545
+ static_cast<unsigned long long>(nowUs / 1000u),
546
+ static_cast<unsigned long long>((nowUs - startUs) / 1000u));
547
+ } else {
548
+ std::printf("GEA_START %s t=%llu ms\n",
549
+ stage,
550
+ static_cast<unsigned long long>(nowUs / 1000u));
551
+ }
552
+ std::fflush(stdout);
553
+ }
554
+ #endif
555
+
556
+ class Base64Writer {
557
+ public:
558
+ void writeByte(std::uint8_t byte)
559
+ {
560
+ pending_[pendingLength_++] = byte;
561
+ if (pendingLength_ == 3) flushTriplet(3);
562
+ }
563
+
564
+ void finish()
565
+ {
566
+ if (pendingLength_ > 0) flushTriplet(pendingLength_);
567
+ flushLine();
568
+ }
569
+
570
+ private:
571
+ void flushTriplet(int length)
572
+ {
573
+ const std::uint32_t a = pending_[0];
574
+ const std::uint32_t b = length > 1 ? pending_[1] : 0;
575
+ const std::uint32_t c = length > 2 ? pending_[2] : 0;
576
+ const std::uint32_t value = (a << 16) | (b << 8) | c;
577
+
578
+ append(kAlphabet[(value >> 18) & 0x3f]);
579
+ append(kAlphabet[(value >> 12) & 0x3f]);
580
+ append(length > 1 ? kAlphabet[(value >> 6) & 0x3f] : '=');
581
+ append(length > 2 ? kAlphabet[value & 0x3f] : '=');
582
+ pendingLength_ = 0;
583
+ }
584
+
585
+ void append(char ch)
586
+ {
587
+ line_[lineLength_++] = ch;
588
+ if (lineLength_ >= kLineLength) flushLine();
589
+ }
590
+
591
+ void flushLine()
592
+ {
593
+ if (lineLength_ <= 0) return;
594
+ std::printf("GEADEV:DATA %.*s\n", lineLength_, line_);
595
+ std::fflush(stdout);
596
+ lineLength_ = 0;
597
+ }
598
+
599
+ static constexpr int kLineLength = 76;
600
+ static constexpr char kAlphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
601
+
602
+ std::uint8_t pending_[3]{};
603
+ int pendingLength_ = 0;
604
+ char line_[kLineLength]{};
605
+ int lineLength_ = 0;
606
+ };
607
+
608
+ void writeU16(Base64Writer &writer, std::uint16_t value)
609
+ {
610
+ writer.writeByte(static_cast<std::uint8_t>(value & 0xff));
611
+ writer.writeByte(static_cast<std::uint8_t>((value >> 8) & 0xff));
612
+ }
613
+
614
+ void writeRun(Base64Writer &writer, std::uint16_t count, std::uint16_t rgb565)
615
+ {
616
+ writeU16(writer, count);
617
+ writeU16(writer, gea::framework::graphics::pixel::toRgb565(rgb565));
618
+ }
619
+
620
+ void writeScreenshot()
621
+ {
622
+ using gea::platform::display::Display;
623
+
624
+ std::uint16_t *pixels = nullptr;
625
+ int width = 0;
626
+ int height = 0;
627
+ if (!Display::panelScanoutSurface(&pixels, &width, &height) || !pixels || width <= 0 || height <= 0) {
628
+ std::printf("GEADEV:ERR SCREENSHOT display-unavailable\n");
629
+ std::fflush(stdout);
630
+ return;
631
+ }
632
+
633
+ const std::size_t pixelCount = static_cast<std::size_t>(width) * static_cast<std::size_t>(height);
634
+ std::printf("GEADEV:SCREENSHOT BEGIN width=%d height=%d encoding=rgb565-rle-v1 app=css-3d-cube\n",
635
+ width,
636
+ height);
637
+ std::fflush(stdout);
638
+
639
+ Base64Writer writer;
640
+ if (pixelCount > 0) {
641
+ // Serialize in LOGICAL row order (the scroll register's circular remap
642
+ // makes the raw buffer order scroll-dependent) so captures compare
643
+ // across scroll positions.
644
+ auto pixelAt = [&](std::size_t i) {
645
+ const int row = static_cast<int>(i) / width;
646
+ const int col = static_cast<int>(i) % width;
647
+ return pixels[static_cast<std::size_t>(gea::rp2350::scanoutRowToPhysical(row)) * width + col];
648
+ };
649
+ std::uint16_t runValue = pixelAt(0);
650
+ std::uint16_t runCount = 1;
651
+ for (std::size_t i = 1; i < pixelCount; ++i) {
652
+ const std::uint16_t value = pixelAt(i);
653
+ if (value == runValue && runCount < 65535) {
654
+ runCount++;
655
+ continue;
656
+ }
657
+ writeRun(writer, runCount, runValue);
658
+ runValue = value;
659
+ runCount = 1;
660
+ }
661
+ writeRun(writer, runCount, runValue);
662
+ }
663
+ writer.finish();
664
+ std::printf("GEADEV:SCREENSHOT END\n");
665
+ std::fflush(stdout);
666
+ }
667
+
668
+ // Boot-time snapshot, queryable over GEADEV BOOTSTATS: the boot prints happen
669
+ // before a host console can attach, so main() stores them here instead.
670
+ struct BootStatsSnapshot {
671
+ std::uint32_t topLevelUs = 0;
672
+ std::uint32_t initialRefreshUs = 0;
673
+ std::uint32_t loopEnterUs = 0;
674
+ // PC-ring indices bracketing the boot phases (1 sample/ms).
675
+ int profTopLevelStart = 0;
676
+ int profTopLevelEnd = 0;
677
+ int profLoopEnter = 0;
678
+ #if GEA_RP2350_REFRESH_DETAIL_PERF
679
+ int nodeCalls = 0;
680
+ int memoHits = 0;
681
+ long long textUs = 0;
682
+ int setTextCalls = 0;
683
+ int setTextChanged = 0;
684
+ int refreshCalls = 0;
685
+ int fullRecords = 0;
686
+ long long replayUs = 0;
687
+ int parallelTries = 0;
688
+ int parallelOks = 0;
689
+ int directReplays = 0;
690
+ #endif
691
+ };
692
+ BootStatsSnapshot gBootStats;
693
+
694
+ void printBootStats()
695
+ {
696
+ std::printf("GEADEV:BOOTSTATS top_level_us=%lu initial_refresh_us=%lu loop_enter_us=%lu",
697
+ static_cast<unsigned long>(gBootStats.topLevelUs),
698
+ static_cast<unsigned long>(gBootStats.initialRefreshUs),
699
+ static_cast<unsigned long>(gBootStats.loopEnterUs));
700
+ #if GEA_RP2350_REFRESH_DETAIL_PERF
701
+ std::printf(" node_calls=%d memo_hits=%d text_us=%lld set_text=%d/%d refreshes=%d full_records=%d replay_us=%lld par=%d/%d direct=%d",
702
+ gBootStats.nodeCalls,
703
+ gBootStats.memoHits,
704
+ gBootStats.textUs,
705
+ gBootStats.setTextCalls,
706
+ gBootStats.setTextChanged,
707
+ gBootStats.refreshCalls,
708
+ gBootStats.fullRecords,
709
+ gBootStats.replayUs,
710
+ gBootStats.parallelTries,
711
+ gBootStats.parallelOks,
712
+ gBootStats.directReplays);
713
+ #endif
714
+ std::printf("\n");
715
+ if (const char *rec = gea_recprof_last()) std::printf("GEADEV:RECPROF %s\n", rec);
716
+ }
717
+
718
+ void printBootProfile()
719
+ {
720
+ const int count = static_cast<int>(gea_pc_ring_ptr - gea_pc_ring);
721
+ std::printf("GEADEV:BOOTPROF BEGIN count=%d tl0=%d tl1=%d loop=%d\n",
722
+ count, gBootStats.profTopLevelStart, gBootStats.profTopLevelEnd,
723
+ gBootStats.profLoopEnter);
724
+ for (int i = 0; i < count; i += 16) {
725
+ std::printf("GEADEV:DATA");
726
+ for (int j = i; j < i + 16 && j < count; j++) std::printf(" %08x", static_cast<unsigned>(gea_pc_ring[j]));
727
+ std::printf("\n");
728
+ }
729
+ std::printf("GEADEV:BOOTPROF END\n");
730
+ }
731
+
732
+ void handleDevCommand(char *line)
733
+ {
734
+ while (*line == ' ' || *line == '\t') ++line;
735
+ if (std::strncmp(line, "GEADEV", 6) != 0) return;
736
+ line += 6;
737
+ while (*line == ' ' || *line == '\t') ++line;
738
+ if (std::strncmp(line, "PING", 4) == 0) {
739
+ std::printf("GEADEV:PONG app=css-3d-cube\n");
740
+ std::fflush(stdout);
741
+ } else if (std::strncmp(line, "BOOTSTATS", 9) == 0) {
742
+ printBootStats();
743
+ std::fflush(stdout);
744
+ } else if (std::strncmp(line, "BOOTPROF", 8) == 0) {
745
+ printBootProfile();
746
+ std::fflush(stdout);
747
+ } else if (std::strncmp(line, "TREE", 4) == 0) {
748
+ // Dump visible node boxes for layout debugging.
749
+ auto &tree = gea::embedded::ui::Tree::instance();
750
+ std::printf("GEADEV:TREE count=%d root=%d\n", tree.nodeCount(), tree.mountedRoot());
751
+ for (int i = 0; i < tree.nodeCount(); i++) {
752
+ const auto &n = tree.node(i);
753
+ if (n.style.display == 1) continue;
754
+ if (n.layout.width <= 0 || n.layout.height <= 0) continue;
755
+ std::printf("GEADEV:DATA id=%d p=%d t=%d x=%d y=%d w=%d h=%d sy=%d ov=%d\n",
756
+ i, n.parent, static_cast<int>(n.type),
757
+ n.layout.x, n.layout.y, n.layout.width, n.layout.height,
758
+ n.layout.scroll_y, n.style.overflow_y);
759
+ }
760
+ std::printf("GEADEV:TREE END\n");
761
+ std::fflush(stdout);
762
+ } else if (std::strncmp(line, "PROFARM", 7) == 0) {
763
+ // Re-arm the PC sample ring: records the next ~4s of 1ms samples.
764
+ gea_pc_ring_ptr = gea_pc_ring;
765
+ std::printf("GEADEV:OK PROFARM\n");
766
+ std::fflush(stdout);
767
+ } else if (std::strncmp(line, "SCREENSHOT", 10) == 0) {
768
+ writeScreenshot();
769
+ } else if (std::strncmp(line, "VSCROLL", 7) == 0) {
770
+ // Direct panel scroll-register test: the visible image should rotate
771
+ // vertically by <rows> without any pixel data being streamed.
772
+ int rows = 0;
773
+ if (std::sscanf(line + 7, "%d", &rows) != 1) {
774
+ std::printf("GEADEV:ERR VSCROLL usage=GEADEV_VSCROLL_rows\n");
775
+ } else {
776
+ gea::rp2350::panelSetVerticalScroll(rows);
777
+ std::printf("GEADEV:OK VSCROLL rows=%d\n", rows);
778
+ }
779
+ std::fflush(stdout);
780
+ } else if (std::strncmp(line, "DRAG", 4) == 0) {
781
+ int x1 = 0, y1 = 0, x2 = 0, y2 = 0, steps = 24, delayMs = 16;
782
+ const int parsed = std::sscanf(line + 4, "%d %d %d %d %d %d", &x1, &y1, &x2, &y2, &steps, &delayMs);
783
+ if (parsed < 4) {
784
+ std::printf("GEADEV:ERR DRAG usage=GEADEV_DRAG_x1_y1_x2_y2_[steps]_[delay_ms]\n");
785
+ } else if (!gea::rp2350::startSyntheticDrag(x1, y1, x2, y2, steps, delayMs)) {
786
+ std::printf("GEADEV:ERR DRAG touch-unavailable-or-busy\n");
787
+ }
788
+ std::fflush(stdout);
789
+ } else {
790
+ std::printf("GEADEV:ERR unknown-command\n");
791
+ std::fflush(stdout);
792
+ }
793
+ }
794
+
795
+ void pollDevControl()
796
+ {
797
+ static char line[96]{};
798
+ static int length = 0;
799
+ while (true) {
800
+ const int ch = getchar_timeout_us(0);
801
+ if (ch == PICO_ERROR_TIMEOUT) break;
802
+ if (ch == '\r') continue;
803
+ if (ch == '\n') {
804
+ line[length] = '\0';
805
+ if (length > 0) handleDevCommand(line);
806
+ length = 0;
807
+ continue;
808
+ }
809
+ if (length < static_cast<int>(sizeof(line)) - 1) {
810
+ line[length++] = static_cast<char>(ch);
811
+ } else {
812
+ length = 0;
813
+ }
814
+ }
815
+ }
816
+
817
+ } // namespace
818
+
819
+ int main()
820
+ {
821
+ // USB console first, before any clock/board/PSRAM work: if a boot stage
822
+ // crashes, the beacon below tells us we made it out of the C++ static
823
+ // constructors, and the stage logs narrow the rest. (Boot-debug aid; the
824
+ // default clocks are USB-capable, and set_sys_clock_khz leaves clk_usb's
825
+ // PLL alone.)
826
+ stdio_init_all();
827
+ watchdog_hw->scratch[7] = 0; // phase: static ctors completed, main reached
828
+ #if GEA_RP2350_STARTUP_TRACE
829
+ sleep_ms(2500);
830
+ std::printf("GEA_START beacon (pre-clock)\n");
831
+ std::fflush(stdout);
832
+ #endif
833
+ configureClock();
834
+ #if GEA_RP2350_STARTUP_TRACE
835
+ std::uint64_t stageUs = time_us_64();
836
+ startupLog("clock");
837
+ #endif
838
+ gea::rp2350::boardIoInit();
839
+ // Brief settle for the I2C pull-ups / ADC; the old 1500ms here was only a
840
+ // USB-console courtesy and cost every boot (trace builds wait for the
841
+ // console explicitly below).
842
+ sleep_ms(50);
843
+ #if GEA_RP2350_STARTUP_TRACE
844
+ startupLog("boardIoInit", stageUs);
845
+ waitForUsbConsole();
846
+ startupLog("stdio");
847
+ stageUs = time_us_64();
848
+ #endif
849
+ gea::rp2350::memoryInit();
850
+ #if GEA_RP2350_STARTUP_TRACE
851
+ startupLog("memoryInit", stageUs);
852
+ #endif
853
+ if (gea_plugin_cpp_register_prelude) gea_plugin_cpp_register_prelude();
854
+
855
+ std::printf("Gea RP2350 launching app\n");
856
+ #if GEA_RP2350_STARTUP_TRACE
857
+ stageUs = time_us_64();
858
+ #endif
859
+ gea::platform::display::Display::init();
860
+ #if GEA_RP2350_STARTUP_TRACE
861
+ startupLog("displayInit", stageUs);
862
+ #endif
863
+ gea::embedded::ui::Document::setPreferredMountSize(gea::rp2350::kPanelWidth, gea::rp2350::kPanelHeight);
864
+ gea::embedded::ui::setViewportMetrics(gea::rp2350::kPanelWidth,
865
+ gea::rp2350::kPanelHeight,
866
+ GEA_EMBEDDED_CSS_DEVICE_PIXEL_RATIO);
867
+ #if GEA_RP2350_STARTUP_TRACE
868
+ stageUs = time_us_64();
869
+ #endif
870
+ auto queue = gea::framework::services::FrameScheduler::createEventQueue();
871
+ gea::framework::services::FrameScheduler::start(queue);
872
+ #if GEA_RP2350_HAS_TOUCH
873
+ gea::framework::events::TouchRuntime::start();
874
+ #endif
875
+ #if GEA_RP2350_STARTUP_TRACE
876
+ startupLog("scheduler", stageUs);
877
+ stageUs = time_us_64();
878
+ #endif
879
+
880
+ const std::uint64_t topLevelStartUs = time_us_64();
881
+ gBootStats.profTopLevelStart = static_cast<int>(gea_pc_ring_ptr - gea_pc_ring);
882
+ // Defer per-node class-style recomputes for the whole initial mount:
883
+ // without the batch every setClassName/appendChild re-walks the growing
884
+ // subtree against the stylesheet — O(nodes^2 x rules) (this was ~420ms of
885
+ // weather's boot). endStyleMountBatch() runs ONE coalesced pass instead.
886
+ // Same bracketing as gea_app_entry.cpp's launcher path.
887
+ gea::embedded::ui::beginStyleMountBatch();
888
+ __gea_top_level();
889
+ gea::embedded::ui::endStyleMountBatch();
890
+ gBootStats.profTopLevelEnd = static_cast<int>(gea_pc_ring_ptr - gea_pc_ring);
891
+ gBootStats.topLevelUs = static_cast<std::uint32_t>(time_us_64() - topLevelStartUs);
892
+ #if GEA_RP2350_STARTUP_TRACE
893
+ startupLog("topLevel", stageUs);
894
+ stageUs = time_us_64();
895
+ #endif
896
+ gea::framework::app::generated::drainMicrotasks();
897
+ #if GEA_RP2350_STARTUP_TRACE
898
+ startupLog("initialDrain", stageUs);
899
+ stageUs = time_us_64();
900
+ #endif
901
+ const std::uint64_t initialRefreshStartUs = time_us_64();
902
+ // The mount inside __gea_top_level() ran while the style batch was open, so
903
+ // Tree::mount skipped its layout/paint (that frame would have been
904
+ // unstyled). Re-mount now for the first styled present; the refresh below
905
+ // is then a no-op unless the drain above dirtied something.
906
+ {
907
+ auto &tree = gea::embedded::ui::Tree::instance();
908
+ const int root = tree.mountedRoot();
909
+ if (root >= 0) tree.mount(root, tree.mountedWidth(), tree.mountedHeight());
910
+ }
911
+ gea::embedded::ui::Document::instance().refreshMountedIfDirty();
912
+ gBootStats.initialRefreshUs = static_cast<std::uint32_t>(time_us_64() - initialRefreshStartUs);
913
+ gBootStats.loopEnterUs = static_cast<std::uint32_t>(time_us_64());
914
+ gBootStats.profLoopEnter = static_cast<int>(gea_pc_ring_ptr - gea_pc_ring);
915
+ #if GEA_RP2350_STARTUP_TRACE
916
+ startupLog("initialRefresh", stageUs);
917
+ #endif
918
+ gea::rp2350::panelFlushStatsReset();
919
+ #if GEA_RP2350_REFRESH_DETAIL_PERF
920
+ {
921
+ // Boot totals (mount + first layout), queryable later via GEADEV BOOTSTATS
922
+ // (this runs before a host console can attach, so printing is useless).
923
+ const auto bootPerf = gea::embedded::ui::refreshPerfStatsRead();
924
+ gBootStats.nodeCalls = bootPerf.treeLayoutNodeCalls;
925
+ gBootStats.memoHits = bootPerf.treeLayoutMemoHits;
926
+ gBootStats.textUs = static_cast<long long>(bootPerf.treeLayoutTextUs);
927
+ gBootStats.setTextCalls = bootPerf.treeSetTextCalls;
928
+ gBootStats.setTextChanged = bootPerf.treeSetTextChanged;
929
+ gBootStats.refreshCalls = bootPerf.treeRefreshCalls;
930
+ gBootStats.fullRecords = bootPerf.treeFullRecords;
931
+ gBootStats.replayUs = static_cast<long long>(bootPerf.treeReplayUs);
932
+ gBootStats.parallelTries = bootPerf.treeReplayParallelAttempts;
933
+ gBootStats.parallelOks = bootPerf.treeReplayParallelSuccesses;
934
+ gBootStats.directReplays = bootPerf.treeDirectReplayCalls;
935
+ }
936
+ gea::embedded::ui::refreshPerfStatsReset();
937
+ #endif
938
+ #if GEA_RP2350_STARTUP_TRACE
939
+ startupLog("loop");
940
+ #endif
941
+
942
+ while (true) {
943
+ const std::uint64_t frameStartUs = time_us_64();
944
+ const int nowMs = static_cast<int>(frameStartUs / 1000u);
945
+ #if GEA_RP2350_FRAME_PHASE_PERF
946
+ phaseBeginFrame(frameStartUs);
947
+ #endif
948
+ runFrame(nowMs);
949
+ pollDevControl();
950
+ const int intervalMs = gea::framework::services::FrameScheduler::frameIntervalMs();
951
+ if (intervalMs > 0) {
952
+ const std::uint64_t frameBudgetUs = static_cast<std::uint64_t>(intervalMs) * 1000u;
953
+ std::uint64_t elapsedUs = time_us_64() - frameStartUs;
954
+ // Idle-time image pre-decode: drain one deferred decode per mostly-idle
955
+ // frame so lazy-loaded assets (decodeDeferred) never bunch their decode
956
+ // cost into a later first-draw frame. Runs on core 0 while the core-1
957
+ // raster worker is parked, so ImageStore access stays single-threaded.
958
+ if (elapsedUs * 2 < frameBudgetUs &&
959
+ gea::framework::graphics::ImageStore::instance().materializeOneDeferred()) {
960
+ elapsedUs = time_us_64() - frameStartUs;
961
+ }
962
+ #if GEA_RP2350_FRAME_PHASE_PERF
963
+ phaseEndFrame(frameStartUs + elapsedUs, static_cast<std::uint32_t>(frameBudgetUs));
964
+ #endif
965
+ logFlushStats(nowMs);
966
+ if (elapsedUs < frameBudgetUs) {
967
+ const auto sleepDurationUs = static_cast<std::uint32_t>(frameBudgetUs - elapsedUs);
968
+ sleep_us(sleepDurationUs);
969
+ #if GEA_RP2350_FRAME_PHASE_PERF
970
+ phaseAddSleep(sleepDurationUs);
971
+ #endif
972
+ }
973
+ } else {
974
+ #if GEA_RP2350_FRAME_PHASE_PERF
975
+ phaseEndFrame(time_us_64(), 0);
976
+ #endif
977
+ logFlushStats(nowMs);
978
+ sleep_us(1000);
979
+ #if GEA_RP2350_FRAME_PHASE_PERF
980
+ phaseAddSleep(1000);
981
+ #endif
982
+ }
983
+ }
984
+ }