next iteration on display, still some artifacting issues, and ux with buttons states and updating
This commit is contained in:
1 parent
45998b6176
commit
ae5d12b3a2
14 files changed
+860
-398
No files matched your search
+48
-7
@@ -38,6 +38,14 @@ static const char *TAG = "main";
|
||||
/* Consecutive failed polls before the displayed reading is treated as stale. */
|
||||
#define STALE_AFTER_POLLS 2
|
||||
|
||||
/*
|
||||
* Trend arrow thresholds, per hour. Below these a reading renders as flat:
|
||||
* a thermostat's indoor temp wobbles a couple of tenths continuously, and an
|
||||
* arrow that flickers on noise is worse than none.
|
||||
*/
|
||||
#define TREND_TEMP_PER_HOUR_F 0.5f
|
||||
#define TREND_PRESS_PER_HOUR_INHG 0.02f
|
||||
|
||||
/* Depth 8: a burst of taps while the network is slow should queue rather than
|
||||
* be dropped, but a user cannot meaningfully get more than a few ahead. */
|
||||
#define CMD_QUEUE_DEPTH 8
|
||||
@@ -190,6 +198,29 @@ static void ha_task(void *arg)
|
||||
consecutive_failures = 0;
|
||||
have_reading = true;
|
||||
|
||||
/*
|
||||
* Trend history is local: the device sees every reading anyway,
|
||||
* so an /api/history query would be hundreds of JSON points to
|
||||
* answer a question one ring buffer answers for free. History is
|
||||
* lost on reboot; arrows reappear ~5 minutes later.
|
||||
*/
|
||||
const uint32_t now_ms = xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
if (ha_data.indoor_temp_f.valid) {
|
||||
ha_trend_feed(HA_TREND_CH_INDOOR, ha_data.indoor_temp_f.value, now_ms);
|
||||
}
|
||||
if (ha_data.outdoor_temp_f.valid) {
|
||||
ha_trend_feed(HA_TREND_CH_OUTDOOR, ha_data.outdoor_temp_f.value, now_ms);
|
||||
}
|
||||
if (ha_data.pressure_inhg.valid) {
|
||||
ha_trend_feed(HA_TREND_CH_PRESSURE, ha_data.pressure_inhg.value, now_ms);
|
||||
}
|
||||
ha_data.trend_indoor =
|
||||
ha_trend_compute(HA_TREND_CH_INDOOR, TREND_TEMP_PER_HOUR_F, now_ms);
|
||||
ha_data.trend_outdoor =
|
||||
ha_trend_compute(HA_TREND_CH_OUTDOOR, TREND_TEMP_PER_HOUR_F, now_ms);
|
||||
ha_data.trend_pressure =
|
||||
ha_trend_compute(HA_TREND_CH_PRESSURE, TREND_PRESS_PER_HOUR_INHG, now_ms);
|
||||
|
||||
ui_update(&ha_data);
|
||||
ui_set_stale(false);
|
||||
|
||||
@@ -227,14 +258,23 @@ void app_main(void)
|
||||
ESP_LOGI(TAG, "Thermostat HMI -- CrowPanel 7.0\" ESP32-S3 (800x480)");
|
||||
|
||||
/*
|
||||
* WiFi comes up FIRST, before the RGB panel exists.
|
||||
* Panel BUFFERS first, WiFi second, panel SCAN-OUT third. Both orderings
|
||||
* are load-bearing:
|
||||
*
|
||||
* The panel's bounce-buffer ISR reads the framebuffer out of PSRAM, and
|
||||
* PSRAM shares the cache with flash on the ESP32-S3. Bringing up NVS and
|
||||
* the WiFi PHY writes calibration data to flash, which disables the cache
|
||||
* and faults that ISR. Doing it here means every flash write is finished
|
||||
* before the panel starts scanning.
|
||||
* - display_alloc() before WiFi: the bounce buffers need two contiguous
|
||||
* 25.6KB internal DMA blocks, and WiFi's RX buffer churn fragments
|
||||
* the internal heap within seconds of association. Allocating from
|
||||
* the virgin heap is deterministic; observed otherwise as a
|
||||
* boot-loop with 84KB free and no block big enough.
|
||||
*
|
||||
* - display_start() after WiFi: from the moment scan-out begins, the
|
||||
* bounce-refill ISR reads PSRAM continuously, and PSRAM shares the
|
||||
* cache with flash on the S3. NVS and WiFi PHY calibration write
|
||||
* flash; doing all of that before the first scan means the ISR can
|
||||
* never hit "Cache disabled but cached memory region accessed".
|
||||
*/
|
||||
ESP_ERROR_CHECK(display_alloc());
|
||||
|
||||
const esp_err_t wifi_err = wifi_init_sta();
|
||||
if (wifi_err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "WiFi not up yet -- polling starts when it connects");
|
||||
@@ -254,7 +294,8 @@ void app_main(void)
|
||||
}
|
||||
i2c_bus_scan(TAG);
|
||||
|
||||
ESP_ERROR_CHECK(display_init());
|
||||
/* Buffers were allocated before WiFi; this only starts scan-out. */
|
||||
ESP_ERROR_CHECK(display_start());
|
||||
|
||||
if (touch_init() != ESP_OK) {
|
||||
/* A dead touch panel should not stop the display from working -- but
|
||||
|
||||
Reference in new issue
Block a user