@geastack/targets 0.1.95 → 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.
- 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/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,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, ®, 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, ®, 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
|
|
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
|
|
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
|
+
}
|
|
@@ -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.
|