#pragma once #include "epdiy.h" namespace ui { struct BatteryProps { bool valid; int percent; }; class BatteryView { public: void layout(int screen_width, int screen_height); EpdRect dirty_bounds(const BatteryProps& props, int pad_x = 4, int pad_y = 4) const; void render(uint8_t* framebuffer, const BatteryProps& props); const EpdRect& bounds() const; private: EpdRect measure_text_bounds(const BatteryProps& props) const; EpdRect bounds_ = {0, 0, 0, 0}; int text_x_ = 0; int text_y_ = 0; EpdRect last_text_bounds_ = {0, 0, 0, 0}; bool has_last_text_bounds_ = false; }; } // namespace ui