Add Dark mode for a screen beside the bed, with every colour in one table (0.2.63)
Dark mode is a new switch under Brightness on the screen's settings page, in the Screen settings of ESP Screens and as switch.<screen>_dark_mode in Home Assistant, so an automation can turn it on at bedtime. The screen changes look at once, open cards and an alert included, and keeps it after a restart. The design stays the same: a black page, graphite cards with a hairline, soft white text, Home Assistant's state colours where they tell something, and pastel card colours as deeper versions of themselves. Every colour the firmware chooses now lives in components/smart_display/ theme.h: roles with a light and a dark value, the named card colours and Home Assistant's state colours. The board profiles give widgets colourless shared styles that theme.h fills, so a change of look refills those styles and draws again what code painted by state. The light look is unchanged apart from merges below one panel step. Dark mode costs 440 bytes of static RAM on the CYD, and the LVGL tree of the host build is 416 bytes smaller; tests keep colours out of every other file. Comparing a screen that switched looks with one that booted in it also found two older bugs, now fixed: a settings switch that was on showed its knob at the left whenever its page was drawn, and the sun card's sunlit area turned orange after a palette change. Firmware 0.2.54. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// a -/+ step lands on the entity's grid, and the status line beside them. The
|
||||
// LVGL drawing lives in runtime_tiles.h; tests/test_tile_controls.cpp covers this.
|
||||
#include "runtime_model.h"
|
||||
#include "theme.h"
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
@@ -49,13 +50,14 @@ inline std::string panel_kind(const Tile &t) {
|
||||
inline bool has_mode(const std::string &hvac_modes, const char *mode) { return hvac_modes.find("\"" + std::string(mode) + "\"") != std::string::npos; }
|
||||
// Home Assistant's colour for a climate mode (the card and its mode keys use it).
|
||||
inline uint32_t mode_color(const std::string &mode) {
|
||||
if (mode == "heat") return 0xFF6F22;
|
||||
if (mode == "cool") return 0x2196F3;
|
||||
if (mode == "heat_cool") return 0xFFC107;
|
||||
if (mode == "auto") return 0x4CAF50;
|
||||
if (mode == "fan_only") return 0x00BCD4;
|
||||
if (mode == "dry") return 0xFF9800;
|
||||
return 0x9E9E9E;
|
||||
using namespace theme::ha;
|
||||
if (mode == "heat") return DEEP_ORANGE;
|
||||
if (mode == "cool") return BLUE;
|
||||
if (mode == "heat_cool") return AMBER;
|
||||
if (mode == "auto") return GREEN;
|
||||
if (mode == "fan_only") return CYAN;
|
||||
if (mode == "dry") return ORANGE;
|
||||
return GREY;
|
||||
}
|
||||
inline const char *mode_icon(const std::string &mode) {
|
||||
if (mode == "off") return glyph::POWER;
|
||||
|
||||
Reference in New Issue
Block a user