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
@@ -56,6 +56,27 @@ typedef struct {
|
||||
bool dimmable;
|
||||
} ha_light_cfg_t;
|
||||
|
||||
/*
|
||||
* Which way a reading has moved over the last hour.
|
||||
*
|
||||
* UNKNOWN is deliberately 0 so a freshly wiped ha_data_t renders no arrow --
|
||||
* after boot there is no history, and "no arrow" is the honest display until
|
||||
* at least HA_TREND_MIN_AGE_MS of samples exist.
|
||||
*/
|
||||
typedef enum {
|
||||
HA_TREND_UNKNOWN = 0,
|
||||
HA_TREND_FLAT,
|
||||
HA_TREND_RISING,
|
||||
HA_TREND_FALLING,
|
||||
} ha_trend_t;
|
||||
|
||||
enum {
|
||||
HA_TREND_CH_INDOOR = 0,
|
||||
HA_TREND_CH_OUTDOOR,
|
||||
HA_TREND_CH_PRESSURE,
|
||||
HA_TREND_CHANNELS,
|
||||
};
|
||||
|
||||
/* Generated from HA_LIGHT_LIST; index-aligned with ha_data_t.lights. */
|
||||
extern const ha_light_cfg_t HA_LIGHTS[HA_LIGHT_COUNT];
|
||||
|
||||
@@ -93,6 +114,16 @@ typedef struct {
|
||||
|
||||
ha_forecast_day_t forecast[HA_FORECAST_DAYS];
|
||||
uint8_t forecast_count; /* 0 when no forecast has been fetched yet */
|
||||
|
||||
/*
|
||||
* Filled by the CALLER after parsing, from ha_trend_feed/compute --
|
||||
* the parser wipes them to UNKNOWN. Local ring-buffer history, not an HA
|
||||
* query: an /api/history call returns hundreds of points per entity,
|
||||
* which is silly when the device already sees every reading each poll.
|
||||
*/
|
||||
ha_trend_t trend_indoor;
|
||||
ha_trend_t trend_outdoor;
|
||||
ha_trend_t trend_pressure;
|
||||
} ha_data_t;
|
||||
|
||||
/*
|
||||
@@ -133,4 +164,19 @@ const char *ha_condition_short(const char *slug);
|
||||
/* Compass point for a bearing in degrees ("NNE"). */
|
||||
const char *ha_wind_cardinal(float degrees);
|
||||
|
||||
/*
|
||||
* Trend tracking. Feed one sample per poll; compute compares the newest
|
||||
* sample against the one closest to an hour old. Timestamps come from the
|
||||
* caller (lv_tick_get() or xTaskGetTickCount-derived ms) so this file stays
|
||||
* free of LVGL and FreeRTOS. Wrap-safe on uint32 ms.
|
||||
*
|
||||
* compute returns UNKNOWN until the oldest usable sample is at least
|
||||
* HA_TREND_MIN_AGE_MS old -- "trending" over 90 seconds is noise.
|
||||
*/
|
||||
#define HA_TREND_WINDOW_MS (60u * 60u * 1000u)
|
||||
#define HA_TREND_MIN_AGE_MS (5u * 60u * 1000u)
|
||||
|
||||
void ha_trend_feed(int channel, float value, uint32_t now_ms);
|
||||
ha_trend_t ha_trend_compute(int channel, float threshold_per_hour, uint32_t now_ms);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user