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:
@@ -1,21 +1,12 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "theme.h"
|
||||
|
||||
namespace tile_palette {
|
||||
// Match the editor palette; all backgrounds are chosen for dark text.
|
||||
inline uint32_t color(const std::string &name) {
|
||||
if(name=="red")return 0xFADADD;
|
||||
if(name=="orange")return 0xFFE1C6;
|
||||
if(name=="yellow")return 0xFFF0C2;
|
||||
if(name=="green")return 0xD9EEDC;
|
||||
if(name=="mint")return 0xD5F0EA;
|
||||
if(name=="blue")return 0xD9EAFB;
|
||||
if(name=="purple")return 0xE9DDF5;
|
||||
if(name=="pink")return 0xF7DDEC;
|
||||
if(name=="gray")return 0xE5E7EB;
|
||||
return 0; // Automatic/default, including unknown future palette names.
|
||||
}
|
||||
// The named card colours ESP Screens offers (theme::SWATCHES). A tile and an alert keep the light value as the colour's
|
||||
// identity; theme::surface() draws it in the current look. Unknown future names and "auto" are 0: the normal card.
|
||||
inline uint32_t color(const std::string &name) { return theme::swatch(name); }
|
||||
// "None": no card behind the tile contents. Older firmware treats it as automatic.
|
||||
inline bool transparent(const std::string &name) { return name=="none"; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user