Gate touch_read on ISR flag instead of double-polling
touch_read() had two branches that both called getPoint() unconditionally — the touch_data_ready flag served no purpose. Gate the I2C transaction on the flag so the ISR finally pulls its weight: idle loops no longer hit I2C, getPoint() runs only when the CST9220 actually raised the TP_INT line. Also scope touch_pressed/x/y to file-static (no cross-TU users) and drop the stale 'permanent while we work on it' comment by the default boot screen — splash-on-boot is documented in CLAUDE.md.
This commit is contained in:
+4
-16
@@ -30,9 +30,9 @@ SensorQMI8658 imu;
|
||||
static UsageData usage = {};
|
||||
|
||||
// ---- Touch interrupt + shared state ----
|
||||
volatile bool touch_pressed = false;
|
||||
volatile uint16_t touch_x = 0;
|
||||
volatile uint16_t touch_y = 0;
|
||||
static volatile bool touch_pressed = false;
|
||||
static volatile uint16_t touch_x = 0;
|
||||
static volatile uint16_t touch_y = 0;
|
||||
static volatile bool touch_data_ready = false;
|
||||
|
||||
static void IRAM_ATTR touch_isr(void) {
|
||||
@@ -40,18 +40,7 @@ static void IRAM_ATTR touch_isr(void) {
|
||||
}
|
||||
|
||||
static void touch_read() {
|
||||
if (!touch_data_ready) {
|
||||
int16_t tx[5], ty[5];
|
||||
uint8_t n = touch.getPoint(tx, ty, touch.getSupportTouchPoint());
|
||||
if (n > 0) {
|
||||
touch_pressed = true;
|
||||
touch_x = (uint16_t)tx[0];
|
||||
touch_y = (uint16_t)ty[0];
|
||||
} else {
|
||||
touch_pressed = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!touch_data_ready) return;
|
||||
touch_data_ready = false;
|
||||
|
||||
int16_t tx[5], ty[5];
|
||||
@@ -305,7 +294,6 @@ void setup() {
|
||||
// Show initial battery status
|
||||
ui_update_battery(power_battery_pct(), power_is_charging());
|
||||
|
||||
// Default to splash screen (permanent while we work on it)
|
||||
ui_show_screen(SCREEN_SPLASH);
|
||||
|
||||
Serial.println("Dashboard ready, waiting for data on BLE...");
|
||||
|
||||
Reference in New Issue
Block a user