Files
Flipdot-display/src/esp32/logic/page_render.h
T

35 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <stdint.h>
#include "logic/font.h"
#include "logic/local_time.h"
#include "logic/page.h"
// Draws a dynamic page into a full screen bitmap (logic/bitmap_format.h). Used for the
// display and for the previews in the web UI. Pure logic, tested in test/test_esp32.
// Where the page gets its bitmaps, fonts and Home Assistant values
class PageResources
{
public:
// Loads a background bitmap; false when it is gone (the background is blank then)
virtual bool background(const char *name, uint8_t *bitmap) = 0;
// A font by name; a font without data when it is gone ("Normal" is used then)
virtual Font font(const char *name) = 0;
// The current value of a Home Assistant element; nullptr when not known
virtual const char *haValue(const PageElement &element) = 0;
};
// The area an element covers on the screen (for the editor), may be partly off screen
struct ElementBox
{
int16_t x = 0;
int16_t y = 0;
int16_t width = 0;
int16_t height = 0;
};
// boxes: nullptr, or room for page.element_count boxes
void renderPage(const DynamicPage &page, const LocalTime &time, PageResources &resources, uint8_t *bitmap,
ElementBox *boxes = nullptr);