Files
Flipdot-display/src/esp32/display/page_resources.cpp
T

56 lines
1.2 KiB
C++
Raw Normal View History

#include "display/page_resources.h"
#include <Arduino.h>
#include <sys/time.h>
#include "display/bitmap_store.h"
#include "display/font_store.h"
#include "display/icon_store.h"
2026-10-20 17:52:25 +02:00
#include "display/life_player.h"
#include "net/ha_api.h"
Stopwatch stopwatch;
StoredPageResources pageResources(stopwatch);
bool StoredPageResources::background(const char *name, uint8_t *bitmap)
{
if (loadBitmap(name, bitmap))
return true;
Icon icon;
if (!loadIcon(name, icon))
return false;
iconToBitmap(icon, bitmap); // at the top left: images are drawn from their x, y
return true;
}
Font StoredPageResources::font(const char *name)
{
return findFont(name);
}
const char *StoredPageResources::haValue(const PageElement &element)
{
return haApiValue(element.entity, element.attribute);
}
uint64_t StoredPageResources::stopwatchMs()
{
return _stopwatch.elapsed(epochMs());
}
int64_t epochMs()
{
struct timeval tv;
gettimeofday(&tv, nullptr);
return (int64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
bool StoredPageResources::stopwatchRunning()
{
return _stopwatch.running();
}
2026-10-20 17:52:25 +02:00
const LifeRunner *StoredPageResources::life(const PageElement &element)
{
return lifePlayer.runner(element);
}