@geastack/targets 0.1.95 → 0.1.99
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/README.md +6 -0
- package/build-config.json +79 -0
- package/package.json +2 -2
- package/targets/esp32/chip_bindings/displays/co5300.cpp +50 -2
- package/targets/esp32/chip_bindings/displays/sh8601.cpp +22 -3
- package/targets/esp32/chip_bindings/touch/cst9217.cpp +19 -1
- package/targets/esp32/display.cpp +4 -0
- package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +10 -0
- package/targets/esp32-s3-m5stack-sticks3/main/display.cpp +29 -8
- package/targets/esp32-s3-m5stack-stopwatch/CMakeLists.txt +9 -0
- package/targets/esp32-s3-m5stack-stopwatch/README.md +76 -0
- package/targets/esp32-s3-m5stack-stopwatch/dependencies.lock +35 -0
- package/targets/esp32-s3-m5stack-stopwatch/main/CMakeLists.txt +45 -0
- package/targets/esp32-s3-m5stack-stopwatch/main/Kconfig.projbuild +1 -0
- package/targets/esp32-s3-m5stack-stopwatch/main/idf_component.yml +4 -0
- package/targets/esp32-s3-m5stack-stopwatch/main/include/board.h +33 -0
- package/targets/esp32-s3-m5stack-stopwatch/main/include/panel_power.h +12 -0
- package/targets/esp32-s3-m5stack-stopwatch/main/panel_reset.cpp +199 -0
- package/targets/esp32-s3-m5stack-stopwatch/main/touch.cpp +147 -0
- package/targets/esp32-s3-m5stack-stopwatch/partitions.csv +8 -0
- package/targets/esp32-s3-m5stack-stopwatch/sdkconfig.defaults +33 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +11 -2
- package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +2 -0
- package/targets/esp32-s3-touch-amoled-2.06-sh8601.json +158 -0
- package/targets/esp32-s3-touch-lcd-1.54/CMakeLists.txt +10 -0
- package/targets/esp32-s3-touch-lcd-1.54/README.md +45 -0
- package/targets/esp32-s3-touch-lcd-1.54/dependencies.lock +87 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/CMakeLists.txt +27 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/Kconfig.projbuild +12 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/app_main.cpp +133 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/buttons.cpp +102 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/display.cpp +2 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/fatfs_ffconf.h +377 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/i2c.cpp +2 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/idf_component.yml +7 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/include/board.h +37 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/include/buttons.h +2 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/launcher_button.cpp +2 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/power.cpp +69 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/sdcard_mount.cpp +2 -0
- package/targets/esp32-s3-touch-lcd-1.54/main/touch.cpp +2 -0
- package/targets/esp32-s3-touch-lcd-1.54/partitions.csv +7 -0
- package/targets/esp32-s3-touch-lcd-1.54/sdkconfig.defaults +272 -0
- package/targets/esp32-s31-espressif-mosaico/main/CMakeLists.txt +2 -0
- package/targets/esp32-s31-espressif-mosaico/main/include/mosaico_peer_uart.h +17 -0
- package/targets/esp32-s31-espressif-mosaico/main/peer_uart.cpp +86 -0
- package/targets/rp2350-tufty-2350/CMakeLists.txt +11 -2
- package/targets/rp2350-waveshare-touch-amoled-2.41/CMakeLists.txt +6 -2
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/app.cpp +5 -1
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.cpp +13 -7
- package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.h +4 -0
- package/targets.json +29 -0
|
@@ -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
|