Reduce number of calls to fetch time in the main loop (#8804)
This commit is contained in:
1 parent
e47741d471
commit
574aabdede
36 files changed
+107
-53
No files matched your search
@@ -1,5 +1,6 @@
|
||||
#include "uart_switch.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/application.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace uart {
|
||||
@@ -8,7 +9,7 @@ static const char *const TAG = "uart.switch";
|
||||
|
||||
void UARTSwitch::loop() {
|
||||
if (this->send_every_) {
|
||||
const uint32_t now = millis();
|
||||
const uint32_t now = App.get_loop_component_start_time();
|
||||
if (now - this->last_transmission_ > this->send_every_) {
|
||||
this->write_command_(this->state);
|
||||
this->last_transmission_ = now;
|
||||
|
||||
Reference in new issue
Block a user