mirror of
https://github.com/esphome/esphome.git
synced 2025-01-18 20:10:55 +00:00
Fix delta
This commit is contained in:
parent
9162c34517
commit
2ae12f9f9e
@ -20,8 +20,9 @@ void UptimeTextSensor::update() {
|
||||
auto now = millis();
|
||||
// get whole seconds since last update. Note that even if the millis count has overflowed between updates,
|
||||
// the difference will still be correct due to the way twos-complement arithmetic works.
|
||||
const uint32_t delta = (now - this->last_ms_) / 1000;
|
||||
this->last_ms_ = now;
|
||||
uint32_t delta = now - this->last_ms_;
|
||||
this->last_ms_ = now - delta % 1000; // save remainder for next update
|
||||
delta /= 1000;
|
||||
this->uptime_ += delta;
|
||||
auto uptime = this->uptime_;
|
||||
unsigned interval = this->get_update_interval() / 1000;
|
||||
|
Loading…
x
Reference in New Issue
Block a user