@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,45 @@
1
+ set(GEA_BOARD_COMPONENT_DIR "${CMAKE_CURRENT_LIST_DIR}")
2
+ set(GEA_BOARD_TARGET_DIR "${CMAKE_CURRENT_LIST_DIR}/..")
3
+ set(GEA_EMBEDDED_CPP_BOARD "esp32-s3-m5stack-stopwatch")
4
+ set(GEA_EMBEDDED_CSS_DEVICE_PIXEL_RATIO "1.5")
5
+ set(GEA_EMBEDDED_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../..")
6
+ cmake_path(ABSOLUTE_PATH GEA_EMBEDDED_ROOT NORMALIZE)
7
+ include("${GEA_EMBEDDED_ROOT}/targets/esp32/gea_framework.cmake")
8
+
9
+ set(GEA_BOARD_DISPLAY_WIDTH 466)
10
+ set(GEA_BOARD_DISPLAY_HEIGHT 466)
11
+ set(GEA_BOARD_QSPI_PCLK_HZ 80000000)
12
+ set(GEA_BOARD_FRAMEBUFFER_STREAM_FLUSH 1)
13
+ set(GEA_BOARD_PARTIAL_PAD_X 0)
14
+ set(GEA_BOARD_PARTIAL_PAD_Y 0)
15
+ set(GEA_BOARD_EXTRA_REQUIRES bootloader_support esp_psram)
16
+ set(GEA_BOARD_EXTRA_COMPILE_DEFINITIONS
17
+ GEA_BOARD_PREPARE_DISPLAY_PANEL=1
18
+ GEA_BOARD_LAUNCHER_BUTTON_GPIO=1
19
+ GEA_EMBEDDED_CO5300_STOPWATCH_INIT=1
20
+ GEA_EMBEDDED_CO5300_PANEL_X_GAP=6
21
+ GEA_EMBEDDED_CO5300_PANEL_Y_GAP=0
22
+ )
23
+
24
+ # Keep the application pipeline shared; only the native board wiring differs.
25
+ # Ancillary audio, battery telemetry and IMU APIs retain the explicit unsupported
26
+ # facades until their StopWatch power/control paths are integrated.
27
+ set(GEA_BOARD_PLATFORM_SOURCES
28
+ "${CMAKE_CURRENT_LIST_DIR}/../../esp32-s3-touch-amoled-1.8/main/app_main.cpp"
29
+ "${CMAKE_CURRENT_LIST_DIR}/../../esp32-s3-touch-amoled-1.8/main/i2c.cpp"
30
+ "${CMAKE_CURRENT_LIST_DIR}/../../esp32-s3-touch-amoled-1.8/main/launcher_button.cpp"
31
+ "${CMAKE_CURRENT_LIST_DIR}/touch.cpp"
32
+ "${CMAKE_CURRENT_LIST_DIR}/panel_reset.cpp"
33
+ "${CMAKE_CURRENT_LIST_DIR}/../../esp32-s3-elecrow-rotary-2.1/main/platform_stubs.cpp"
34
+ "${GEA_CHIPS}/displays/co5300/co5300.cpp"
35
+ "${GEA_EMBEDDED_ROOT}/targets/esp32/display.cpp"
36
+ "${GEA_EMBEDDED_ROOT}/targets/esp32/chip_bindings/displays/co5300.cpp"
37
+ )
38
+ include("${CMAKE_CURRENT_LIST_DIR}/../../esp32-s3-touch-amoled-1.8/main/CMakeLists.txt")
39
+
40
+ # Generated app archives can reference the hardware RNG after IDF archives
41
+ # were visited; keep the same extraction rule as other S3 targets.
42
+ if(NOT CMAKE_SCRIPT_MODE_FILE)
43
+ target_link_libraries(${COMPONENT_LIB} INTERFACE
44
+ "-u bootloader_random_enable" "-u bootloader_random_disable")
45
+ endif()
@@ -0,0 +1 @@
1
+ rsource "../../esp32-s3-touch-amoled-1.8/main/Kconfig.projbuild"
@@ -0,0 +1,4 @@
1
+ dependencies:
2
+ espressif/esp_lcd_co5300: '^2.0.2'
3
+ idf:
4
+ version: '>=5.3'
@@ -0,0 +1,33 @@
1
+ #pragma once
2
+
3
+ #include "driver/gpio.h"
4
+ #include "driver/spi_master.h"
5
+ #include "panel_power.h"
6
+
7
+ namespace gea::platform::board {
8
+
9
+ struct I2cBusConfig { gpio_num_t sda; gpio_num_t scl; };
10
+ struct Co5300DisplayConfig {
11
+ spi_host_device_t spiHost;
12
+ gpio_num_t cs;
13
+ gpio_num_t pclk;
14
+ gpio_num_t data0;
15
+ gpio_num_t data1;
16
+ gpio_num_t data2;
17
+ gpio_num_t data3;
18
+ gpio_num_t reset;
19
+ gpio_num_t te;
20
+ };
21
+ struct Cst820TouchConfig { gpio_num_t interrupt; };
22
+
23
+ // https://docs.m5stack.com/en/core/StopWatch
24
+ // OLED and touch resets are M5IOE1 outputs, not ESP32 GPIOs.
25
+ inline constexpr I2cBusConfig i2c{GPIO_NUM_47, GPIO_NUM_48};
26
+ inline constexpr Co5300DisplayConfig display{
27
+ SPI2_HOST, GPIO_NUM_39, GPIO_NUM_40,
28
+ GPIO_NUM_41, GPIO_NUM_42, GPIO_NUM_46, GPIO_NUM_45,
29
+ GPIO_NUM_NC, GPIO_NUM_38
30
+ };
31
+ inline constexpr Cst820TouchConfig touch{GPIO_NUM_13};
32
+
33
+ } // namespace gea::platform::board
@@ -0,0 +1,12 @@
1
+ #pragma once
2
+
3
+ namespace gea::platform::board {
4
+
5
+ // Initialize the PM1/IOE1, enable the AMOLED rail and reset display and touch.
6
+ // Hardware failures abort initialization instead of leaving a dark display.
7
+ void prepareDisplayPanel();
8
+
9
+ // Reset CST820 through IOE1 while preserving every other expander output.
10
+ void resetTouchPanel();
11
+
12
+ } // namespace gea::platform::board
@@ -0,0 +1,199 @@
1
+ // StopWatch routes AMOLED power/reset and touch reset through an M5IOE1.
2
+ // Pin names in the schematic are one-based; IOE1 register bits are zero-based.
3
+ // https://docs.m5stack.com/en/core/StopWatch
4
+ // https://github.com/m5stack/M5StopWatch-UserDemo/blob/main/main/hal/hal_ioe.cpp
5
+ // https://github.com/m5stack/M5IOE1/blob/main/src/M5IOE1.h
6
+ // https://github.com/m5stack/M5PM1/blob/main/src/M5PM1.h
7
+ #include "panel_power.h"
8
+ #include "i2c.h"
9
+ #include "driver/i2c_master.h"
10
+ #include "esp_err.h"
11
+ #include "esp_log.h"
12
+ #include "esp_rom_sys.h"
13
+ #include "freertos/FreeRTOS.h"
14
+ #include "freertos/task.h"
15
+ #include <cstddef>
16
+ #include <cstdint>
17
+ #include <mutex>
18
+
19
+ namespace {
20
+ constexpr char kTag[] = "stopwatch_power";
21
+ constexpr std::uint8_t kPm1Address = 0x6E;
22
+ constexpr std::uint8_t kPm1I2cConfig = 0x09;
23
+ constexpr std::uint8_t kPm1Watchdog = 0x0A;
24
+ constexpr std::uint8_t kIoeMode = 0x03;
25
+ constexpr std::uint8_t kIoeOutput = 0x05;
26
+ constexpr std::uint8_t kIoeInput = 0x07;
27
+ constexpr std::uint8_t kIoePullUp = 0x09;
28
+ constexpr std::uint8_t kIoePullDown = 0x0B;
29
+ constexpr std::uint8_t kIoeDrive = 0x13;
30
+ constexpr std::uint8_t kIoePowerPwm = 0x1D;
31
+ constexpr std::uint8_t kIoeI2cConfig = 0x23;
32
+ constexpr std::uint16_t kTouchReset = 1U << 3; // PIN_4
33
+ constexpr std::uint16_t kOledReset = 1U << 4; // PIN_5
34
+ constexpr std::uint16_t kOledPower = 1U << 7; // PIN_8, L3B_EN
35
+ constexpr std::uint16_t kResets = kTouchReset | kOledReset;
36
+ constexpr std::uint16_t kPanelPins = kResets | kOledPower;
37
+
38
+ std::mutex powerMutex;
39
+ i2c_master_dev_handle_t pm1 = nullptr;
40
+ i2c_master_dev_handle_t ioe = nullptr;
41
+ bool initialized = false;
42
+
43
+ void delayMs(std::uint32_t milliseconds)
44
+ {
45
+ vTaskDelay(pdMS_TO_TICKS(milliseconds));
46
+ }
47
+
48
+ esp_err_t readRegisters(i2c_master_dev_handle_t device, std::uint8_t reg,
49
+ std::uint8_t *bytes, std::size_t size)
50
+ {
51
+ esp_err_t result = ESP_FAIL;
52
+ for (int attempt = 0; attempt < 3; ++attempt) {
53
+ result = i2c_master_transmit_receive(device, &reg, 1, bytes, size, 100);
54
+ // IOE1/PM1 firmware needs processing time between transactions.
55
+ esp_rom_delay_us(500);
56
+ if (result == ESP_OK) return result;
57
+ if (attempt < 2) delayMs(50);
58
+ }
59
+ return result;
60
+ }
61
+
62
+ esp_err_t writeRegisters(i2c_master_dev_handle_t device, const std::uint8_t *bytes,
63
+ std::size_t size)
64
+ {
65
+ esp_err_t result = ESP_FAIL;
66
+ for (int attempt = 0; attempt < 3; ++attempt) {
67
+ result = i2c_master_transmit(device, bytes, size, 100);
68
+ esp_rom_delay_us(500);
69
+ if (result == ESP_OK) return result;
70
+ if (attempt < 2) delayMs(50);
71
+ }
72
+ return result;
73
+ }
74
+
75
+ std::uint8_t read8(i2c_master_dev_handle_t device, std::uint8_t reg)
76
+ {
77
+ std::uint8_t value = 0;
78
+ ESP_ERROR_CHECK(readRegisters(device, reg, &value, 1));
79
+ return value;
80
+ }
81
+
82
+ std::uint16_t read16(i2c_master_dev_handle_t device, std::uint8_t reg)
83
+ {
84
+ std::uint8_t bytes[2]{};
85
+ ESP_ERROR_CHECK(readRegisters(device, reg, bytes, sizeof(bytes)));
86
+ return static_cast<std::uint16_t>(bytes[0]) |
87
+ (static_cast<std::uint16_t>(bytes[1]) << 8);
88
+ }
89
+
90
+ void write8(i2c_master_dev_handle_t device, std::uint8_t reg, std::uint8_t value)
91
+ {
92
+ const std::uint8_t bytes[]{reg, value};
93
+ ESP_ERROR_CHECK(writeRegisters(device, bytes, sizeof(bytes)));
94
+ if (read8(device, reg) != value) ESP_ERROR_CHECK(ESP_ERR_INVALID_RESPONSE);
95
+ }
96
+
97
+ void write16(i2c_master_dev_handle_t device, std::uint8_t reg, std::uint16_t value)
98
+ {
99
+ const std::uint8_t bytes[]{reg, static_cast<std::uint8_t>(value),
100
+ static_cast<std::uint8_t>(value >> 8)};
101
+ ESP_ERROR_CHECK(writeRegisters(device, bytes, sizeof(bytes)));
102
+ if (read16(device, reg) != value) ESP_ERROR_CHECK(ESP_ERR_INVALID_RESPONSE);
103
+ }
104
+
105
+ void updateOutput(std::uint16_t mask, std::uint16_t value)
106
+ {
107
+ const std::uint16_t previous = read16(ioe, kIoeOutput);
108
+ write16(ioe, kIoeOutput, (previous & ~mask) | (value & mask));
109
+ }
110
+
111
+ i2c_master_dev_handle_t attachDevice(i2c_master_bus_handle_t bus,
112
+ std::uint8_t address)
113
+ {
114
+ // The first START wakes a sleeping PM1/IOE1 and may legitimately NACK.
115
+ (void)i2c_master_probe(bus, address, 20);
116
+ delayMs(10);
117
+ i2c_device_config_t config{};
118
+ config.dev_addr_length = I2C_ADDR_BIT_LEN_7;
119
+ config.device_address = address;
120
+ config.scl_speed_hz = 100000;
121
+ i2c_master_dev_handle_t device = nullptr;
122
+ ESP_ERROR_CHECK(i2c_master_bus_add_device(bus, &config, &device));
123
+ return device;
124
+ }
125
+
126
+ void initializeLocked()
127
+ {
128
+ if (initialized) return;
129
+ const auto sharedBus = gea::platform::i2c::Bus::primary();
130
+ if (!sharedBus.available()) ESP_ERROR_CHECK(ESP_ERR_INVALID_STATE);
131
+ const auto bus = static_cast<i2c_master_bus_handle_t>(sharedBus.nativeHandle());
132
+
133
+ pm1 = attachDevice(bus, kPm1Address);
134
+ std::uint8_t pm1Identity[4]{};
135
+ ESP_ERROR_CHECK(readRegisters(pm1, 0x00, pm1Identity, sizeof(pm1Identity)));
136
+ // Factory firmware disables both I2C sleep and the PM1 watchdog. The
137
+ // watchdog is independent of ESP-IDF's watchdog and otherwise resets us.
138
+ for (int attempt = 0; attempt < 2; ++attempt) {
139
+ write8(pm1, kPm1I2cConfig, read8(pm1, kPm1I2cConfig) & ~0x0FU);
140
+ }
141
+ write8(pm1, kPm1Watchdog, 0);
142
+
143
+ std::uint8_t ioeIdentity[3]{};
144
+ std::uint8_t ioeAddress = 0x4F;
145
+ ioe = attachDevice(bus, ioeAddress);
146
+ if (readRegisters(ioe, 0x00, ioeIdentity, sizeof(ioeIdentity)) != ESP_OK) {
147
+ ESP_ERROR_CHECK(i2c_master_bus_rm_device(ioe));
148
+ ioeAddress = 0x6F;
149
+ ioe = attachDevice(bus, ioeAddress);
150
+ ESP_ERROR_CHECK(readRegisters(ioe, 0x00, ioeIdentity, sizeof(ioeIdentity)));
151
+ }
152
+ for (int attempt = 0; attempt < 2; ++attempt) {
153
+ write8(ioe, kIoeI2cConfig, read8(ioe, kIoeI2cConfig) & ~0x0FU);
154
+ }
155
+
156
+ // PIN_8 can be PWM channel 2. A warm factory state must not override the
157
+ // display's power latch with PWM, pull resistors or an open-drain output.
158
+ write16(ioe, kIoePowerPwm, read16(ioe, kIoePowerPwm) & ~0x8000U);
159
+ updateOutput(kPanelPins, kOledPower); // Hold resets low before driving pins.
160
+ write16(ioe, kIoePullUp, read16(ioe, kIoePullUp) & ~kPanelPins);
161
+ write16(ioe, kIoePullDown, read16(ioe, kIoePullDown) & ~kPanelPins);
162
+ write16(ioe, kIoeDrive, read16(ioe, kIoeDrive) & ~kPanelPins);
163
+ write16(ioe, kIoeMode, read16(ioe, kIoeMode) | kPanelPins);
164
+
165
+ bool powered = false;
166
+ for (int attempt = 0; attempt < 4; ++attempt) {
167
+ delayMs(80);
168
+ if ((read16(ioe, kIoeInput) & kOledPower) != 0) {
169
+ powered = true;
170
+ break;
171
+ }
172
+ updateOutput(kOledPower, kOledPower);
173
+ }
174
+ if (!powered) ESP_ERROR_CHECK(ESP_ERR_INVALID_STATE);
175
+ updateOutput(kResets, kResets);
176
+ delayMs(50);
177
+ initialized = true;
178
+ ESP_LOGI(kTag, "PM1 watchdog disabled; IOE1 0x%02X AMOLED power and resets ready",
179
+ ioeAddress);
180
+ }
181
+ } // namespace
182
+
183
+ namespace gea::platform::board {
184
+ void prepareDisplayPanel()
185
+ {
186
+ const std::lock_guard<std::mutex> guard(powerMutex);
187
+ initializeLocked();
188
+ }
189
+
190
+ void resetTouchPanel()
191
+ {
192
+ const std::lock_guard<std::mutex> guard(powerMutex);
193
+ initializeLocked();
194
+ updateOutput(kTouchReset, 0);
195
+ delayMs(10);
196
+ updateOutput(kTouchReset, kTouchReset);
197
+ delayMs(50);
198
+ }
199
+ } // namespace gea::platform::board
@@ -0,0 +1,147 @@
1
+ #include "touch.h"
2
+
3
+ #include "board.h"
4
+ #include "display.h"
5
+ #include "i2c.h"
6
+
7
+ #include <algorithm>
8
+ #include <atomic>
9
+ #include <cstdint>
10
+
11
+ #include "driver/i2c_master.h"
12
+ #include "esp_attr.h"
13
+ #include "esp_log.h"
14
+
15
+ namespace {
16
+
17
+ using gea::platform::touch::Phase;
18
+ using gea::platform::touch::Touchscreen;
19
+ constexpr char kTag[] = "cst820";
20
+ i2c_master_dev_handle_t device = nullptr;
21
+ Touchscreen::Observer observer = nullptr;
22
+ Touchscreen::PointerObserver pointerObserver = nullptr;
23
+ bool pressed = false;
24
+ int cachedX = 0;
25
+ int cachedY = 0;
26
+ int latestX = 0;
27
+ int latestY = 0;
28
+ bool moveQueued = false;
29
+ std::uint32_t lastPoll = 0;
30
+ std::uint32_t lastReport = 0;
31
+ std::atomic<bool> reportPending{false};
32
+
33
+ void IRAM_ATTR touchInterrupt(void *)
34
+ {
35
+ reportPending.store(true, std::memory_order_relaxed);
36
+ }
37
+
38
+ void notify(Phase phase, bool touching, int x, int y)
39
+ {
40
+ if (pointerObserver) pointerObserver(phase, touching, x, y, 0);
41
+ else if (observer) observer(phase, touching, x, y);
42
+ }
43
+
44
+ void update(Phase phase, bool touching, int x, int y)
45
+ {
46
+ pressed = touching;
47
+ cachedX = x;
48
+ cachedY = y;
49
+ latestX = x;
50
+ latestY = y;
51
+ if (phase == Phase::Move) {
52
+ if (moveQueued) return;
53
+ moveQueued = true;
54
+ }
55
+ notify(phase, touching, x, y);
56
+ }
57
+
58
+ } // namespace
59
+
60
+ namespace gea::platform::touch {
61
+
62
+ void Touchscreen::setObserver(Observer next) { observer = next; }
63
+ void Touchscreen::setPointerObserver(PointerObserver next) { pointerObserver = next; }
64
+
65
+ bool Touchscreen::init()
66
+ {
67
+ if (device) return true;
68
+ board::resetTouchPanel();
69
+ const auto bus = i2c::Bus::primary();
70
+ if (!bus.available()) return false;
71
+ i2c_device_config_t config = {};
72
+ config.dev_addr_length = I2C_ADDR_BIT_LEN_7;
73
+ config.device_address = 0x15;
74
+ config.scl_speed_hz = 100000;
75
+ const auto handle = static_cast<i2c_master_bus_handle_t>(bus.nativeHandle());
76
+ esp_err_t err = i2c_master_probe(handle, config.device_address, 100);
77
+ if (err == ESP_OK) err = i2c_master_bus_add_device(handle, &config, &device);
78
+ if (err != ESP_OK) {
79
+ ESP_LOGE(kTag, "CST820 not found: %s", esp_err_to_name(err));
80
+ return false;
81
+ }
82
+ gpio_config_t interrupt = {};
83
+ interrupt.pin_bit_mask = 1ULL << board::touch.interrupt;
84
+ interrupt.mode = GPIO_MODE_INPUT;
85
+ interrupt.pull_up_en = GPIO_PULLUP_ENABLE;
86
+ interrupt.intr_type = GPIO_INTR_NEGEDGE;
87
+ ESP_ERROR_CHECK(gpio_config(&interrupt));
88
+ err = gpio_install_isr_service(0);
89
+ if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) ESP_ERROR_CHECK(err);
90
+ ESP_ERROR_CHECK(gpio_isr_handler_add(board::touch.interrupt, touchInterrupt, nullptr));
91
+ reportPending.store(true, std::memory_order_relaxed);
92
+ ESP_LOGI(kTag, "touch ready (address=0x15, INT=GPIO%d)", board::touch.interrupt);
93
+ return true;
94
+ }
95
+
96
+ void Touchscreen::poll(int nowMs)
97
+ {
98
+ if (!device) return;
99
+ const auto now = static_cast<std::uint32_t>(nowMs);
100
+ if (now - lastPoll < 10) return;
101
+ // Avoid waking the controller or blocking animation when it has no report.
102
+ // While held, poll too so a lost release interrupt cannot stick the pointer.
103
+ const bool pending = reportPending.exchange(false, std::memory_order_relaxed);
104
+ if (!pressed && !pending && gpio_get_level(board::touch.interrupt) != 0) return;
105
+ lastPoll = now;
106
+ const std::uint8_t reg = 0x00;
107
+ std::uint8_t report[7] = {};
108
+ if (i2c_master_transmit_receive(device, &reg, 1, report, sizeof(report), 10) != ESP_OK) {
109
+ // The controller sleeps after idle. A missed final report followed by
110
+ // NACKs must not leave a finger permanently held in the runtime.
111
+ if (pressed && now - lastReport >= 60) update(Phase::Up, false, cachedX, cachedY);
112
+ return;
113
+ }
114
+ lastReport = now;
115
+ // The CST820 report is not the CST92xx protocol. Decode the factory
116
+ // firmware's seven-byte report, including its explicit lift event.
117
+ const unsigned event = report[3] >> 6;
118
+ const bool touching = (report[2] & 0x0F) != 0 && (event == 0 || event == 2);
119
+ if (!touching) {
120
+ if (pressed) update(Phase::Up, false, cachedX, cachedY);
121
+ return;
122
+ }
123
+ const int x = std::clamp(((report[3] & 0x0F) << 8) | report[4], 0, display::kWidth - 1);
124
+ const int y = std::clamp(((report[5] & 0x0F) << 8) | report[6], 0, display::kHeight - 1);
125
+ if (!pressed) update(Phase::Down, true, x, y);
126
+ else if (x != cachedX || y != cachedY) update(Phase::Move, true, x, y);
127
+ }
128
+
129
+ int Touchscreen::read(int *x, int *y) { return readCached(x, y); }
130
+ int Touchscreen::readCached(int *x, int *y)
131
+ {
132
+ if (x) *x = cachedX;
133
+ if (y) *y = cachedY;
134
+ return pressed ? 1 : 0;
135
+ }
136
+ void Touchscreen::consumeLatestMove(int *x, int *y)
137
+ {
138
+ moveQueued = false;
139
+ if (x) *x = latestX;
140
+ if (y) *y = latestY;
141
+ }
142
+ void Touchscreen::injectEvent(Phase phase, bool touching, int x, int y)
143
+ {
144
+ update(phase, touching, x, y);
145
+ }
146
+
147
+ } // namespace gea::platform::touch
@@ -0,0 +1,8 @@
1
+ # M5Stack StopWatch C152, 16 MB flash.
2
+ # Name, Type, SubType, Offset, Size
3
+ nvs, data, nvs, 0x9000, 0x6000
4
+ otadata, data, ota, 0xf000, 0x2000
5
+ phy_init, data, phy, 0x11000, 0x1000
6
+ ota_0, app, ota_0, 0x20000, 0x700000
7
+ ota_1, app, ota_1, 0x720000, 0x700000
8
+ storage, data, spiffs, 0xe20000, 0x1c0000
@@ -0,0 +1,33 @@
1
+ CONFIG_IDF_TARGET="esp32s3"
2
+ CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
3
+ CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
4
+ CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
5
+ CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
6
+ CONFIG_ESP_CONSOLE_SECONDARY_NONE=y
7
+ CONFIG_FREERTOS_HZ=1000
8
+ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
9
+ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=240
10
+ CONFIG_ESP_MAIN_TASK_STACK_SIZE=32768
11
+ CONFIG_ESP_IPC_TASK_STACK_SIZE=4096
12
+ CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=4096
13
+ CONFIG_PARTITION_TABLE_CUSTOM=y
14
+ CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
15
+ CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y
16
+ CONFIG_SPIRAM=y
17
+ CONFIG_SPIRAM_MODE_OCT=y
18
+ CONFIG_SPIRAM_SPEED_80M=y
19
+ CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
20
+ CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y
21
+ CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0
22
+ CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=0
23
+ CONFIG_COMPILER_OPTIMIZATION_PERF=y
24
+ # CONFIG_COMPILER_OPTIMIZATION_DEBUG is not set
25
+ CONFIG_LOG_DEFAULT_LEVEL_INFO=y
26
+ CONFIG_LOG_DEFAULT_LEVEL=3
27
+ CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y
28
+ CONFIG_LOG_MAXIMUM_LEVEL=3
29
+ CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
30
+ CONFIG_BOOTLOADER_LOG_LEVEL=3
31
+ CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
32
+ CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2
33
+ CONFIG_HEAP_TRACING_OFF=y
@@ -624,6 +624,15 @@ if(NOT GEA_APP_CANVAS_ONLY)
624
624
  )
625
625
  endif()
626
626
 
627
+ set(GEA_EMBEDDED_FRAMEBUFFER_STREAM_VALUE 1)
628
+ if(GEA_CUSTOM_QSPI_TRANSFER_MODE STREQUAL "bitmap")
629
+ set(GEA_EMBEDDED_FRAMEBUFFER_STREAM_VALUE 0)
630
+ endif()
631
+
632
+ if(NOT GEA_CUSTOM_QSPI_PCLK_HZ)
633
+ set(GEA_CUSTOM_QSPI_PCLK_HZ 80000000)
634
+ endif()
635
+
627
636
  idf_component_register(
628
637
  SRCS
629
638
  ${GEA_EMBEDDED_BOARD_SOURCES}
@@ -718,7 +727,7 @@ target_compile_definitions(${COMPONENT_LIB} PRIVATE
718
727
  # (bigger than all 64 balls' fill). Keeping the sparse per-ball rects lets the
719
728
  # replay re-raster the badge only where a ball actually overlaps it ("only
720
729
  # re-render the changing parts"); the flush still coalesces via ADAPTIVE_COALESCE.
721
- GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_STREAM_FLUSH=1
730
+ GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_STREAM_FLUSH=${GEA_EMBEDDED_FRAMEBUFFER_STREAM_VALUE}
722
731
  # Per-app: pipeline the fused framebuffer flush like the present path (see value
723
732
  # block above). Takes priority over FRAMEBUFFER_STREAM_FLUSH's draining txColor
724
733
  # in display.cpp (streamFlush only runs when csHeldStream is false).
@@ -765,7 +774,7 @@ target_compile_definitions(${COMPONENT_LIB} PRIVATE
765
774
  # artifact). A full-screen flush is 410x502x2B = 411 KB, bandwidth-bound over
766
775
  # the 4 QSPI lanes, so the clock sets flush time linearly: 80 MHz (~40 MB/s,
767
776
  # ~10.3 ms) vs 60 MHz (~30 MB/s, ~13.7 ms). Dominates full-screen canvas apps.
768
- GEA_EMBEDDED_DISPLAY_QSPI_PCLK_HZ=80000000
777
+ GEA_EMBEDDED_DISPLAY_QSPI_PCLK_HZ=${GEA_CUSTOM_QSPI_PCLK_HZ}
769
778
  # Direct PSRAM->SPI framebuffer flush: DISABLED — we use the
770
779
  # PSRAM->internal-staging->SPI path instead. Exhaustively tested (PSRAM at
771
780
  # 80/60/40/20 MHz, GDMA burst 32/64B, and PSRAM overclocked to 120 MHz): the
@@ -25,6 +25,8 @@ dependencies:
25
25
  rules:
26
26
  - if: '$GEA_EMBEDDED_CAPABILITY_NETWORK == 1'
27
27
  espressif/esp_lcd_co5300: '^2.0.3'
28
+ # Custom QSPI boards may select the existing SH8601 binding.
29
+ espressif/esp_lcd_sh8601: '^2.0.0'
28
30
  esp_lcd_panel_io_additions: '^1'
29
31
  # chip_bindings/audio/es8311.cpp
30
32
  espressif/esp_codec_dev:
@@ -0,0 +1,158 @@
1
+ {
2
+ "id": "esp32-s3-touch-amoled-2.06-sh8601",
3
+ "extends": "esp32-s3",
4
+ "adapter": "esp32-idf",
5
+ "mcu": "esp32s3",
6
+ "buses": {
7
+ "i2c": {
8
+ "sda": 15,
9
+ "scl": 14
10
+ }
11
+ },
12
+ "chips": {
13
+ "display": {
14
+ "driver": "sh8601",
15
+ "interface": "qspi",
16
+ "width": 410,
17
+ "height": 502,
18
+ "spiHost": "spi2",
19
+ "pins": {
20
+ "cs": 12,
21
+ "pclk": 11,
22
+ "data0": 4,
23
+ "data1": 5,
24
+ "data2": 6,
25
+ "data3": 7,
26
+ "reset": 8,
27
+ "te": 13
28
+ },
29
+ "panel": {
30
+ "xGap": 22,
31
+ "yGap": 0,
32
+ "initCommands": [
33
+ {
34
+ "command": 17,
35
+ "delayMs": 120
36
+ },
37
+ {
38
+ "command": 196,
39
+ "data": [
40
+ 128
41
+ ]
42
+ },
43
+ {
44
+ "command": 68,
45
+ "data": [
46
+ 1,
47
+ 209
48
+ ]
49
+ },
50
+ {
51
+ "command": 53,
52
+ "data": [
53
+ 0
54
+ ]
55
+ },
56
+ {
57
+ "command": 83,
58
+ "data": [
59
+ 32
60
+ ],
61
+ "delayMs": 10
62
+ },
63
+ {
64
+ "command": 99,
65
+ "data": [
66
+ 255
67
+ ],
68
+ "delayMs": 10
69
+ },
70
+ {
71
+ "command": 81,
72
+ "data": [
73
+ 0
74
+ ],
75
+ "delayMs": 10
76
+ },
77
+ {
78
+ "command": 42,
79
+ "data": [
80
+ 0,
81
+ 22,
82
+ 1,
83
+ 175
84
+ ]
85
+ },
86
+ {
87
+ "command": 43,
88
+ "data": [
89
+ 0,
90
+ 0,
91
+ 1,
92
+ 245
93
+ ]
94
+ },
95
+ {
96
+ "command": 41,
97
+ "delayMs": 10
98
+ },
99
+ {
100
+ "command": 81,
101
+ "data": [
102
+ 255
103
+ ]
104
+ }
105
+ ],
106
+ "transferMode": "bitmap",
107
+ "minChunkRows": 2
108
+ },
109
+ "pclkHz": 40000000
110
+ },
111
+ "touch": {
112
+ "driver": "ft3168",
113
+ "interface": "i2c",
114
+ "pins": {
115
+ "reset": 9,
116
+ "interrupt": 38
117
+ }
118
+ },
119
+ "power": {
120
+ "driver": "axp2101",
121
+ "interface": "i2c"
122
+ },
123
+ "imu": {
124
+ "driver": "qmi8658",
125
+ "interface": "i2c"
126
+ },
127
+ "audio": {
128
+ "driver": "es8311",
129
+ "interface": "i2s",
130
+ "pins": {
131
+ "mclk": 16,
132
+ "bclk": 41,
133
+ "ws": 45,
134
+ "dout": 40,
135
+ "din": 42,
136
+ "powerAmplifier": 46
137
+ },
138
+ "es7210Address": 64
139
+ }
140
+ },
141
+ "storage": {
142
+ "microSD": {
143
+ "interface": "sdmmc-1bit",
144
+ "pins": {
145
+ "clk": 2,
146
+ "cmd": 1,
147
+ "data0": 3
148
+ }
149
+ }
150
+ },
151
+ "controls": {
152
+ "launcherButton": {
153
+ "pin": 0,
154
+ "activeLevel": 0
155
+ }
156
+ },
157
+ "flashSize": "32MB"
158
+ }