@geastack/targets 0.1.94 → 0.1.98

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 (51) hide show
  1. package/README.md +6 -0
  2. package/build-config.json +79 -0
  3. package/package.json +6 -6
  4. package/targets/esp32/chip_bindings/displays/co5300.cpp +50 -2
  5. package/targets/esp32/chip_bindings/displays/rgb_panel.cpp +8 -1
  6. package/targets/esp32/chip_bindings/displays/sh8601.cpp +22 -3
  7. package/targets/esp32/chip_bindings/touch/cst9217.cpp +19 -1
  8. package/targets/esp32/display.cpp +4 -0
  9. package/targets/esp32/services/device_control.cpp +35 -2
  10. package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +10 -0
  11. package/targets/esp32-s3-m5stack-sticks3/main/display.cpp +29 -8
  12. package/targets/esp32-s3-m5stack-stopwatch/CMakeLists.txt +9 -0
  13. package/targets/esp32-s3-m5stack-stopwatch/README.md +76 -0
  14. package/targets/esp32-s3-m5stack-stopwatch/dependencies.lock +35 -0
  15. package/targets/esp32-s3-m5stack-stopwatch/main/CMakeLists.txt +45 -0
  16. package/targets/esp32-s3-m5stack-stopwatch/main/Kconfig.projbuild +1 -0
  17. package/targets/esp32-s3-m5stack-stopwatch/main/idf_component.yml +4 -0
  18. package/targets/esp32-s3-m5stack-stopwatch/main/include/board.h +33 -0
  19. package/targets/esp32-s3-m5stack-stopwatch/main/include/panel_power.h +12 -0
  20. package/targets/esp32-s3-m5stack-stopwatch/main/panel_reset.cpp +199 -0
  21. package/targets/esp32-s3-m5stack-stopwatch/main/touch.cpp +147 -0
  22. package/targets/esp32-s3-m5stack-stopwatch/partitions.csv +8 -0
  23. package/targets/esp32-s3-m5stack-stopwatch/sdkconfig.defaults +33 -0
  24. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +11 -2
  25. package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +2 -0
  26. package/targets/esp32-s3-touch-amoled-2.06-sh8601.json +158 -0
  27. package/targets/esp32-s3-touch-lcd-1.54/CMakeLists.txt +10 -0
  28. package/targets/esp32-s3-touch-lcd-1.54/README.md +45 -0
  29. package/targets/esp32-s3-touch-lcd-1.54/dependencies.lock +87 -0
  30. package/targets/esp32-s3-touch-lcd-1.54/main/CMakeLists.txt +27 -0
  31. package/targets/esp32-s3-touch-lcd-1.54/main/Kconfig.projbuild +12 -0
  32. package/targets/esp32-s3-touch-lcd-1.54/main/app_main.cpp +133 -0
  33. package/targets/esp32-s3-touch-lcd-1.54/main/buttons.cpp +102 -0
  34. package/targets/esp32-s3-touch-lcd-1.54/main/display.cpp +2 -0
  35. package/targets/esp32-s3-touch-lcd-1.54/main/fatfs_ffconf.h +377 -0
  36. package/targets/esp32-s3-touch-lcd-1.54/main/i2c.cpp +2 -0
  37. package/targets/esp32-s3-touch-lcd-1.54/main/idf_component.yml +7 -0
  38. package/targets/esp32-s3-touch-lcd-1.54/main/include/board.h +37 -0
  39. package/targets/esp32-s3-touch-lcd-1.54/main/include/buttons.h +2 -0
  40. package/targets/esp32-s3-touch-lcd-1.54/main/launcher_button.cpp +2 -0
  41. package/targets/esp32-s3-touch-lcd-1.54/main/power.cpp +69 -0
  42. package/targets/esp32-s3-touch-lcd-1.54/main/sdcard_mount.cpp +2 -0
  43. package/targets/esp32-s3-touch-lcd-1.54/main/touch.cpp +2 -0
  44. package/targets/esp32-s3-touch-lcd-1.54/partitions.csv +7 -0
  45. package/targets/esp32-s3-touch-lcd-1.54/sdkconfig.defaults +272 -0
  46. package/targets/rp2350-tufty-2350/CMakeLists.txt +11 -2
  47. package/targets/rp2350-waveshare-touch-amoled-2.41/CMakeLists.txt +6 -2
  48. package/targets/rp2350-waveshare-touch-amoled-2.41/main/app.cpp +5 -1
  49. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.cpp +13 -7
  50. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.h +4 -0
  51. package/targets.json +29 -0
@@ -0,0 +1,10 @@
1
+ cmake_minimum_required(VERSION 3.16)
2
+
3
+ set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/../esp32/components")
4
+ include("${CMAKE_CURRENT_LIST_DIR}/../esp32/app_project.cmake")
5
+ set(GEA_EMBEDDED_APP "tic-tac-toe" CACHE STRING "Example app to build (must match a package.json gea.id)")
6
+ set(PROJECT_VER "${GEA_EMBEDDED_APP}" CACHE STRING "Firmware app id" FORCE)
7
+
8
+ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
9
+ idf_build_set_property(MINIMAL_BUILD ON)
10
+ project(gea_embedded)
@@ -0,0 +1,45 @@
1
+ # Waveshare ESP32-S3-Touch-LCD-1.54
2
+
3
+ Target: `esp32-s3-touch-lcd-1.54`; setup catalog alias: `waveshare-154`.
4
+ This is the color touch LCD board, not the similarly named e-paper board.
5
+
6
+ Hardware assignments follow the [Waveshare factory ESP-IDF BSP](https://github.com/waveshareteam/ESP32-S3-Touch-LCD-1.54/tree/main/examples/ESP32-S3-Touch-LCD-1.54-demo/ESP-IDF-5.5.1/01_factory/components/esp_bsp).
7
+
8
+ | Peripheral | Implementation / connections |
9
+ | --- | --- |
10
+ | LCD | ST7789 240×240, SPI2 mode 3 at 40 MHz; MOSI 39, SCLK 38, CS 21, DC 45, reset 40 |
11
+ | Backlight | PWM on GPIO46, brightness 0–100% |
12
+ | Touch | CST816 at I2C 0x15; reset 47, interrupt 48 |
13
+ | Shared I2C | SDA 42, SCL 41 |
14
+ | Speaker | ES8311, NS4150B amplifier enable GPIO7 |
15
+ | Microphone | ES7210 at 0x40; I2S input GPIO11 |
16
+ | I2S | MCLK 8, BCLK 9, WS 10, output 12, input 11 |
17
+ | Motion | QMI8658 accelerometer and gyroscope, shared I2C |
18
+ | SD card | FAT32 at `/sdcard`; SDMMC 1-bit CLK 16, CMD 15, D0 17 |
19
+ | Battery | GPIO2 soft latch; active-low charging GPIO3; calibrated ADC1 channel 0 / GPIO1, 3:1 divider |
20
+ | Buttons | BOOT GPIO0 → ArrowUp, PLUS GPIO4 → ArrowDown, PWR GPIO5 → Enter; hold PWR 2 seconds to release battery latch |
21
+ | Wireless | Native 2.4 GHz Wi-Fi and NimBLE BLE, shared ESP32 drivers |
22
+ | Internal storage | 16 MB flash, 8 MB octal PSRAM; NVS and SPIFFS, two 6 MB OTA slots |
23
+
24
+ Wi-Fi, BLE and audio use the existing app capability/build policies. Apps must
25
+ request the corresponding APIs to link their implementation. The diagnostics app
26
+ requests all three and exposes the hardware checks. SD mount failures never format
27
+ the card. Battery percentage is a voltage estimate, not a coulomb counter; without
28
+ ADC calibration it returns unknown rather than inventing a reading.
29
+
30
+ Build with the local Gea CLI (or installed `gea`):
31
+
32
+ ```sh
33
+ gea build --target esp32-s3-touch-lcd-1.54 --app diagnostics
34
+ ```
35
+
36
+ The shared ST7789 pipeline retains StickS3 defaults; this board overrides only
37
+ SPI timing, glass offsets, and the absence of its M5PM1 LCD power rail. CST816
38
+ uses Espressif's controller driver through the shared touch event pipeline.
39
+
40
+ Validation: diagnostics firmware builds with network, BLE and audio enabled.
41
+ Bouncing Balls JSX was flashed over USB with hash verification and boots with
42
+ changing 240×240 rendered pixels. Speaker output, microphone quality, physical
43
+ touch alignment, battery accuracy, SD throughput and radio reliability still
44
+ require hardware checks. The offline app currently reports an empty app ID
45
+ in the serial discovery response.
@@ -0,0 +1,87 @@
1
+ dependencies:
2
+ 78/esp-opus:
3
+ component_hash: 8182b733f071d7bfe1e837f4c9f8649a63e4c937177f089e65772880c02f2e17
4
+ dependencies:
5
+ - name: idf
6
+ require: private
7
+ version: '>=5.0'
8
+ source:
9
+ registry_url: https://components.espressif.com/
10
+ type: service
11
+ version: 1.0.5
12
+ espressif/esp_codec_dev:
13
+ component_hash: 4779f31a3ba3f9b38aee1afe6ccb9ba8f6108dc3a6e77d39d7d714e9a215371b
14
+ dependencies:
15
+ - name: idf
16
+ require: private
17
+ version: '>=4.0'
18
+ source:
19
+ registry_url: https://components.espressif.com/
20
+ type: service
21
+ version: 1.6.2
22
+ espressif/esp_lcd_touch:
23
+ component_hash: 3f85a7d95af876f1a6ecca8eb90a81614890d0f03a038390804e5a77e2caf862
24
+ dependencies:
25
+ - name: idf
26
+ require: private
27
+ version: '>=4.4.2'
28
+ source:
29
+ registry_url: https://components.espressif.com
30
+ type: service
31
+ version: 1.2.1
32
+ espressif/esp_lcd_touch_cst816s:
33
+ component_hash: f017808eb754d3fe16987d413a2385f6356890f5737ee3fe36b6a548ea1d1d74
34
+ dependencies:
35
+ - name: espressif/esp_lcd_touch
36
+ registry_url: https://components.espressif.com
37
+ require: public
38
+ version: ^1.2.0
39
+ - name: idf
40
+ require: private
41
+ version: '>=5.2'
42
+ source:
43
+ registry_url: https://components.espressif.com/
44
+ type: service
45
+ version: 1.1.2
46
+ espressif/esp_libsrtp:
47
+ component_hash: 131560184c73ec09f77d8904a2db709307803f0f9f111898921b6966776eac15
48
+ dependencies: []
49
+ source:
50
+ registry_url: https://components.espressif.com
51
+ type: service
52
+ version: 1.0.0
53
+ espressif/esp_peer:
54
+ component_hash: e29d65a3d2eba15f761e7d2740ab62650384edff27a1f8277dd6ccfa45813863
55
+ dependencies:
56
+ - name: espressif/esp_libsrtp
57
+ registry_url: https://components.espressif.com
58
+ require: private
59
+ version: ^1.0.0
60
+ source:
61
+ registry_url: https://components.espressif.com/
62
+ type: service
63
+ version: 1.5.6
64
+ espressif/esp_websocket_client:
65
+ component_hash: dc00233af846f3a744ada283a300e0d586040aadc3ee67361645ecdce4523672
66
+ dependencies:
67
+ - name: idf
68
+ require: private
69
+ version: '>=5.0'
70
+ source:
71
+ registry_url: https://components.espressif.com/
72
+ type: service
73
+ version: 1.8.0
74
+ idf:
75
+ source:
76
+ type: idf
77
+ version: 6.0.2
78
+ direct_dependencies:
79
+ - 78/esp-opus
80
+ - espressif/esp_codec_dev
81
+ - espressif/esp_lcd_touch_cst816s
82
+ - espressif/esp_peer
83
+ - espressif/esp_websocket_client
84
+ - idf
85
+ manifest_hash: 65c1a68a9650a49fbcd7695be4801776f283d86878a58d46dee899478b808683
86
+ target: esp32s3
87
+ version: 3.0.0
@@ -0,0 +1,27 @@
1
+ set(GEA_EMBEDDED_TARGET_MAIN_DIR "${CMAKE_CURRENT_LIST_DIR}")
2
+ set(GEA_EMBEDDED_TARGET_CPP_BOARD "esp32-s3-touch-lcd-1.54")
3
+ set(GEA_EMBEDDED_TARGET_DISPLAY_WIDTH 240)
4
+ set(GEA_EMBEDDED_TARGET_DISPLAY_HEIGHT 240)
5
+ set(GEA_EMBEDDED_TARGET_CSS_DEVICE_PIXEL_RATIO "1.5")
6
+ set(GEA_EMBEDDED_TARGET_DISPLAY_MONOCHROME 0)
7
+ set(GEA_EMBEDDED_TARGET_PIXEL_PANEL_ENDIAN 1)
8
+ set(GEA_EMBEDDED_TARGET_IMU_SOURCE "${CMAKE_CURRENT_LIST_DIR}/../../esp32/chip_bindings/imu/qmi8658.cpp")
9
+ set(GEA_EMBEDDED_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../..")
10
+ cmake_path(ABSOLUTE_PATH GEA_EMBEDDED_ROOT NORMALIZE)
11
+ include("${CMAKE_CURRENT_LIST_DIR}/../../esp32/gea_framework.cmake")
12
+ set(GEA_EMBEDDED_TARGET_EXTRA_SOURCES
13
+ "${GEA_CHIPS}/imu/qmi8658/qmi8658.cpp"
14
+ "${CMAKE_CURRENT_LIST_DIR}/../../esp32/chip_bindings/touch/cst9217.cpp")
15
+ set(GEA_EMBEDDED_TARGET_EXTRA_REQUIRES
16
+ bootloader_support esp_driver_ledc esp_adc spi_flash esp_psram esp_lcd_touch_cst816s)
17
+ set(GEA_EMBEDDED_TARGET_COMPILE_DEFINITIONS
18
+ GEA_BOARD_TOUCH_CST816=1
19
+ GEA_ST7789_LOG_TAG="lcd154_display"
20
+ GEA_ST7789_PCLK_HZ=40000000 GEA_ST7789_SPI_MODE=3
21
+ GEA_ST7789_GAP_X=0 GEA_ST7789_GAP_Y=0
22
+ GEA_ST7789_MIRROR_GAP_X=0 GEA_ST7789_MIRROR_GAP_Y=80
23
+ GEA_ST7789_M5PM1_POWER=0)
24
+ include("${CMAKE_CURRENT_LIST_DIR}/../../esp32-s3-epaper-1.54/main/CMakeLists.txt")
25
+ if(NOT CMAKE_SCRIPT_MODE_FILE)
26
+ target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bootloader_random_enable" "-u bootloader_random_disable")
27
+ endif()
@@ -0,0 +1,12 @@
1
+ menu "Gea Embedded"
2
+
3
+ config GEA_EMBEDDED_PRODUCTION_LOCKDOWN
4
+ bool "Production lockdown"
5
+ default n
6
+ help
7
+ Compile out Gea frame/perf logs, heap diagnostics, and the
8
+ diagnostics server for production firmware. Local development builds
9
+ should leave this disabled so serial monitor and VS Code launch
10
+ tasks show fps and diagnostic logs.
11
+
12
+ endmenu
@@ -0,0 +1,133 @@
1
+ #include "gea_embedded_app_config.h"
2
+
3
+ #include "apps/app_manager.h"
4
+ #include "buttons.h"
5
+ #include "power.h"
6
+ namespace gea::platform::storage { void installSdCardFileCache(); }
7
+ #ifndef GEA_EMBEDDED_BLE_DISABLED
8
+ #include "connectivity/ble_hid.h"
9
+ #endif
10
+ #include "display.h"
11
+ #include "host/display_orientation.h"
12
+
13
+ // Forward-declare here instead of through a header — there's already a
14
+ // `wifi.h` in `lib/gea-embedded/include/` defining WifiAdapter/WifiDriver,
15
+ // and adding a second `wifi.h` under `targets/esp32/connectivity/` shadows
16
+ // it in the include search path, breaking the WifiStation TU which needs
17
+ // the base class.
18
+ namespace gea::targets::esp32::wifi {
19
+ void registerDriver();
20
+ }
21
+ #include "memory_config.h"
22
+ #include "runtime.h"
23
+ #include "services/device_control.h"
24
+
25
+ #if GEA_EMBEDDED_HEAP_DIAGNOSTICS_LOG
26
+ #include "esp_heap_caps.h"
27
+ #endif
28
+ #include "esp_log.h"
29
+ #include "sdkconfig.h"
30
+ #include "freertos/FreeRTOS.h"
31
+ #include "freertos/task.h"
32
+
33
+ namespace {
34
+
35
+ constexpr const char *kTag = "gea_embedded";
36
+
37
+ #if GEA_EMBEDDED_HEAP_DIAGNOSTICS_LOG
38
+ void logHeapProbe(const char *stage)
39
+ {
40
+ ESP_LOGI(kTag,
41
+ "heap probe [%s] internal_free=%u internal_largest=%u internal_min=%u psram_free=%u",
42
+ stage ? stage : "?",
43
+ static_cast<unsigned>(heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)),
44
+ static_cast<unsigned>(heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)),
45
+ static_cast<unsigned>(heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)),
46
+ static_cast<unsigned>(heap_caps_get_free_size(MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)));
47
+ }
48
+ #endif
49
+
50
+ constexpr int kAppMainTaskStack = CONFIG_ESP_MAIN_TASK_STACK_SIZE;
51
+ // An app whose own realtime tasks must outrank the render loop (audio DSP, a USB
52
+ // isochronous host) sets gea.defines.GEA_EMBEDDED_RUNTIME_TASK_PRIORITY to place
53
+ // this below them; the default is what this board needs on its own.
54
+ #ifndef GEA_EMBEDDED_RUNTIME_TASK_PRIORITY
55
+ #define GEA_EMBEDDED_RUNTIME_TASK_PRIORITY 5
56
+ #endif
57
+ constexpr UBaseType_t kRuntimeTaskPriority = GEA_EMBEDDED_RUNTIME_TASK_PRIORITY;
58
+
59
+ #if GEA_EMBEDDED_FRAME_SCHEDULER_PERF_LOG
60
+ void logCurrentTaskStack(const char *stage, int stackBytes)
61
+ {
62
+ TaskHandle_t currentTask = xTaskGetCurrentTaskHandle();
63
+ ESP_LOGI(kTag,
64
+ "stack probe [%s] task=%s core=%d stack_arg=%d hwm=%u",
65
+ stage ? stage : "?",
66
+ currentTask ? pcTaskGetName(currentTask) : "?",
67
+ static_cast<int>(xPortGetCoreID()),
68
+ stackBytes,
69
+ static_cast<unsigned>(uxTaskGetStackHighWaterMark(currentTask)));
70
+ }
71
+ #endif
72
+
73
+ void runRuntime()
74
+ {
75
+ gea::framework::RuntimeOptions options{};
76
+ options.width = gea::framework::display::detail::DisplayOrientationState::width();
77
+ options.height = gea::framework::display::detail::DisplayOrientationState::height();
78
+ gea::framework::Runtime::run(options);
79
+ }
80
+
81
+ } // namespace
82
+
83
+ extern "C" void app_main(void)
84
+ {
85
+ gea::platform::power::Power::init();
86
+ gea::platform::storage::installSdCardFileCache();
87
+ // BOOT/PLUS/PWR buttons deliver keyboard events alongside touch.
88
+ gea::platform::waveshare_lcd154::buttons::startButtonsTask();
89
+
90
+ // Force the targets/esp32/apps/app_manager.cpp TU to be linked in. That
91
+ // TU's only side effect is a file-scope `PlatformRegistration` whose
92
+ // constructor calls AppManager::setPlatform(...). With -Wl,--gc-sections
93
+ // and the main component built as a static archive, nothing else
94
+ // references launcherPlatform(), so the linker drops the entire object
95
+ // file — the static ctor never runs, AppManager::platform_ stays null,
96
+ // and AppManager::startLauncherButtonTask() / returnRunningAppToLauncher
97
+ // / ... all become silent no-ops. Result: the BOOT button task is never
98
+ // created and no `launcher_button` log lines are ever emitted.
99
+ (void)gea::platform::esp32::apps::launcherPlatform();
100
+
101
+ // Same static-archive trap as `launcherPlatform()` above: the ESP32 WiFi
102
+ // driver TU's only side effect is an anonymous-namespace static-init
103
+ // global with no external references, so the archive linker would drop it
104
+ // and leave the silent NullWifiDriver active. Register explicitly.
105
+ #ifndef GEA_EMBEDDED_WIFI_DISABLED
106
+ gea::targets::esp32::wifi::registerDriver();
107
+ #endif
108
+
109
+ // Same static-archive trap: reference the HID driver explicitly so its TU
110
+ // is pulled in and `HidServer` replaces the board-independent
111
+ // `NullBleDriver`.
112
+ #ifndef GEA_EMBEDDED_BLE_DISABLED
113
+ gea::targets::esp32::ble::registerHidDriver();
114
+ #endif
115
+
116
+ vTaskPrioritySet(nullptr, kRuntimeTaskPriority);
117
+ #if GEA_EMBEDDED_FRAME_SCHEDULER_PERF_LOG
118
+ logCurrentTaskStack("main_task:before_runtime", kAppMainTaskStack);
119
+ #endif
120
+ #if GEA_EMBEDDED_HEAP_DIAGNOSTICS_LOG
121
+ logHeapProbe("app_main:before_device_control_task");
122
+ #endif
123
+ gea::platform::esp32::services::startDeviceControlTask();
124
+ #if GEA_EMBEDDED_HEAP_DIAGNOSTICS_LOG
125
+ logHeapProbe("app_main:before_runtime");
126
+ #endif
127
+ runRuntime();
128
+
129
+ ESP_LOGE(kTag, "Runtime returned unexpectedly; parking main task");
130
+ while (true) {
131
+ vTaskDelay(pdMS_TO_TICKS(1000));
132
+ }
133
+ }
@@ -0,0 +1,102 @@
1
+ // BOOT/PLUS/PWR: GPIO0/4/5, active low. BOOT and PLUS repeat as
2
+ // ArrowUp/ArrowDown; PWR sends Enter. Holding PWR drops the battery latch.
3
+ #include "buttons.h"
4
+
5
+ #include "board.h"
6
+ #include "input.h"
7
+
8
+ #include <cstdint>
9
+
10
+ #include "driver/gpio.h"
11
+ #include "esp_log.h"
12
+ #include "esp_timer.h"
13
+ #include "freertos/FreeRTOS.h"
14
+ #include "freertos/task.h"
15
+
16
+ namespace gea::platform::waveshare_lcd154::buttons {
17
+
18
+ namespace {
19
+
20
+ constexpr const char *kTag = "lcd154_buttons";
21
+ constexpr gpio_num_t kUpPin = gea::platform::board::buttons.key1;
22
+ constexpr gpio_num_t kDownPin = gea::platform::board::buttons.key2;
23
+ constexpr gpio_num_t kPowerPin = GPIO_NUM_5;
24
+ constexpr int kUpKeyCode = 38; // ArrowUp
25
+ constexpr int kDownKeyCode = 40; // ArrowDown
26
+ constexpr int kPollMs = 20;
27
+ constexpr int kDebouncePolls = 2; // 2 consecutive matching reads = stable
28
+ constexpr int kRepeatDelayMs = 450; // hold this long before auto-repeat
29
+ constexpr int kRepeatIntervalMs = 200; // then one press per interval
30
+ constexpr std::uint32_t kTaskStackBytes = 3072;
31
+ constexpr UBaseType_t kTaskPriority = 10;
32
+
33
+ struct ButtonState {
34
+ gpio_num_t pin;
35
+ int keyCode;
36
+ bool pressed = false;
37
+ int stablePolls = 0;
38
+ std::int64_t pressedAtUs = 0;
39
+ std::int64_t lastRepeatUs = 0;
40
+ };
41
+
42
+ void pollButton(ButtonState &button)
43
+ {
44
+ const bool rawPressed = gpio_get_level(button.pin) == 0;
45
+ if (rawPressed != button.pressed) {
46
+ if (++button.stablePolls < kDebouncePolls) return;
47
+ button.stablePolls = 0;
48
+ button.pressed = rawPressed;
49
+ if (rawPressed) {
50
+ const std::int64_t now = esp_timer_get_time();
51
+ button.pressedAtUs = now;
52
+ button.lastRepeatUs = now;
53
+ gea::framework::input::queueKeyDown(button.keyCode);
54
+ }
55
+ return;
56
+ }
57
+ button.stablePolls = 0;
58
+ if (!button.pressed) return;
59
+ const std::int64_t now = esp_timer_get_time();
60
+ if (now - button.pressedAtUs < static_cast<std::int64_t>(kRepeatDelayMs) * 1000) return;
61
+ if (now - button.lastRepeatUs < static_cast<std::int64_t>(kRepeatIntervalMs) * 1000) return;
62
+ button.lastRepeatUs = now;
63
+ gea::framework::input::queueKeyDown(button.keyCode);
64
+ }
65
+
66
+ void buttonsTask(void *)
67
+ {
68
+ ButtonState up{kUpPin, kUpKeyCode};
69
+ ButtonState down{kDownPin, kDownKeyCode};
70
+ ButtonState power{kPowerPin, 13};
71
+ for (;;) {
72
+ vTaskDelay(pdMS_TO_TICKS(kPollMs));
73
+ pollButton(up);
74
+ pollButton(down);
75
+ pollButton(power);
76
+ if (power.pressed && esp_timer_get_time() - power.pressedAtUs >= 2000000) {
77
+ gpio_set_level(gea::platform::board::power.enable, 0);
78
+ }
79
+ }
80
+ }
81
+
82
+ } // namespace
83
+
84
+ void startButtonsTask()
85
+ {
86
+ gpio_config_t conf = {};
87
+ conf.intr_type = GPIO_INTR_DISABLE;
88
+ conf.mode = GPIO_MODE_INPUT;
89
+ conf.pin_bit_mask = (1ULL << kUpPin) | (1ULL << kDownPin) | (1ULL << kPowerPin);
90
+ conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
91
+ conf.pull_up_en = GPIO_PULLUP_ENABLE;
92
+ ESP_ERROR_CHECK_WITHOUT_ABORT(gpio_config(&conf));
93
+
94
+ if (xTaskCreatePinnedToCore(buttonsTask, "lcd154_buttons", kTaskStackBytes, nullptr, kTaskPriority, nullptr, 1) != pdPASS) {
95
+ ESP_LOGE(kTag, "failed to start buttons task");
96
+ return;
97
+ }
98
+ ESP_LOGI(kTag, "buttons ready: KEY1(GPIO%d)=ArrowUp KEY2(GPIO%d)=ArrowDown",
99
+ static_cast<int>(kUpPin), static_cast<int>(kDownPin));
100
+ }
101
+
102
+ } // namespace gea::platform::waveshare_lcd154::buttons
@@ -0,0 +1,2 @@
1
+ // Reuse the shared hardware implementation with this board profile.
2
+ #include "../../esp32-s3-m5stack-sticks3/main/display.cpp"