mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
The display runs the ptaru/nspanel-terminal TFT and ESPHome draws the UI with LVGL (component from a local checkout for now, see PR ptaru/nspanel-terminal#1). Pages: home (clock, weather, forecast, temperatures), lights, outside, irrigation, thermostat, gate, status/boot screen; light detail with brightness, colour temperature or hue on long press. Grid tiles come from packages in common/nspanel_terminal/ that add themselves to a page. Unavailable entities are greyed out, OTA progress shows on the status page, sleep dim and the notify/show_info actions match the other panels.
18 lines
584 B
C++
18 lines
584 B
C++
#pragma once
|
|
#include <cmath>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <string>
|
|
|
|
// HA brightness 0..255 -> slider percent; NaN (light off) -> 0
|
|
inline int brightness_pct(float b) { return std::isnan(b) ? 0 : int(std::lround(b * 100 / 255)); }
|
|
|
|
// Hue from the hs_color attribute, "(30.0, 80.0)" or "[30.0, 80.0]"; -1 if missing
|
|
inline int parse_hue(const std::string &s) {
|
|
size_t p = s.find_first_of("([");
|
|
if (p == std::string::npos) return -1;
|
|
char *end;
|
|
float h = std::strtof(s.c_str() + p + 1, &end);
|
|
return end == s.c_str() + p + 1 ? -1 : int(std::lround(h));
|
|
}
|