Added functionality to align display refreshes
This commit is contained in:
16
TRMNL.h
16
TRMNL.h
@@ -18,6 +18,7 @@ private:
|
||||
std::string m_api_key;
|
||||
std::string m_friendly_id;
|
||||
int m_refresh_rate;
|
||||
bool m_is_refresh_aligned;
|
||||
|
||||
std::function<void (const TRMNL& trmnl)> m_update_handler;
|
||||
|
||||
@@ -26,7 +27,8 @@ public:
|
||||
TRMNL(const std::string& id = "",
|
||||
const std::string& api_key = "",
|
||||
const std::string& friendly_id = "",
|
||||
int refresh_rate = DEFAULT_REFRESH_RATE);
|
||||
int refresh_rate = DEFAULT_REFRESH_RATE,
|
||||
bool is_refresh_aligned = true);
|
||||
|
||||
TRMNL(const nlohmann::json& j);
|
||||
|
||||
@@ -35,12 +37,24 @@ public:
|
||||
const std::string& api_key() const;
|
||||
const std::string& friendly_id() const;
|
||||
int refresh_rate() const;
|
||||
bool is_refresh_aligned() const;
|
||||
|
||||
// Uses the current time to return when next this device should refresh
|
||||
// min_time
|
||||
// - if calculated time is lower than this - increase by refresh rate until higher
|
||||
// - Capped to the refresh rate
|
||||
// offset
|
||||
// - offset to apply to the refresh rate
|
||||
// - Capped to the refresh rate
|
||||
// - useful when generating images via cron and you want the refresh to happen a few seconds later
|
||||
int get_next_refresh(int min_time = 0, int offset = 0) const;
|
||||
|
||||
// Setters
|
||||
void id(const std::string& id);
|
||||
void api_key(const std::string& api_key);
|
||||
void friendly_id(const std::string& friendly_id);
|
||||
void refresh_rate(int refresh_rate);
|
||||
void is_refresh_aligned(bool to_align);
|
||||
|
||||
void set_update_handler(std::function<void (const TRMNL& trmnl)> handler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user