#include "display/page_resources.h" #include #include #include "display/bitmap_store.h" #include "display/font_store.h" #include "display/icon_store.h" #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(); } const LifeRunner *StoredPageResources::life(const PageElement &element) { return lifePlayer.runner(element); }