Public Access
55 lines
2.0 KiB
C++
55 lines
2.0 KiB
C++
// Cyberpunk-style animated pages for the ESPHome display: a netrunner HUD, a
|
|||
|
|
// self-solving breach protocol, an optics boot-and-scan sequence, and a HUD
|
||
|
|
// with a small breach matrix. Inspired by the look of Cyberpunk 2077; the
|
||
|
|
// layouts and graphics are drawn from scratch, no game assets are used.
|
||
|
|
//
|
||
|
|
// Each function draws a whole page. Call it from a page lambda and list that
|
||
|
|
// page under animated_pages: the animation clock is the display's
|
||
|
|
// page_age_ms(), so every page starts its intro when it is shown.
|
||
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <cmath>
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
#include "esphome/components/display/display.h"
|
||
|
|
#include "esphome/core/time.h"
|
||
|
|
|
||
|
|
namespace esphome::el512 {
|
||
|
|
|
||
|
|
class EL512Display;
|
||
|
|
|
||
|
|
namespace cyber {
|
||
|
|
|
||
|
|
struct Fonts {
|
||
|
|
display::BaseFont *title{nullptr}; // wide display face for headers (Orbitron)
|
||
|
|
display::BaseFont *label{nullptr}; // condensed labels (Rajdhani)
|
||
|
|
display::BaseFont *value{nullptr}; // condensed readouts (Rajdhani bold)
|
||
|
|
display::BaseFont *huge{nullptr}; // clock digits (Rajdhani bold)
|
||
|
|
display::BaseFont *mono{nullptr}; // small monospace for logs and tickers (Share Tech Mono)
|
||
|
|
display::BaseFont *code{nullptr}; // larger monospace for breach codes (Share Tech Mono)
|
||
|
|
};
|
||
|
|
|
||
|
|
struct Reading {
|
||
|
|
std::string name;
|
||
|
|
float value{NAN};
|
||
|
|
};
|
||
|
|
|
||
|
|
// Home Assistant values shown on the pages; NAN or "" when unknown.
|
||
|
|
struct HomeData {
|
||
|
|
std::string weather; // condition, e.g. "partlycloudy"
|
||
|
|
float temp{NAN}; // °C
|
||
|
|
float humidity{NAN}; // %
|
||
|
|
float wind{NAN}; // km/h
|
||
|
|
float solar{NAN}; // W
|
||
|
|
float house{NAN}; // W
|
||
|
|
float grid{NAN}; // W, > 0 = import
|
||
|
|
Reading rooms[4];
|
||
|
|
};
|
||
|
|
|
||
|
|
void netrunner_hud(EL512Display &it, const Fonts &f, const HomeData &d, ESPTime now);
|
||
|
|
void breach_protocol(EL512Display &it, const Fonts &f);
|
||
|
|
void optics_scan(EL512Display &it, const Fonts &f, const HomeData &d, ESPTime now);
|
||
|
|
void split_hud(EL512Display &it, const Fonts &f, const HomeData &d, ESPTime now);
|
||
|
|
|
||
|
|
} // namespace cyber
|
||
|
|
} // namespace esphome::el512
|