1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-28 16:12:24 +01:00

Reduce number of calls to fetch time in the main loop (#8804)

This commit is contained in:
J. Nick Koston
2025-05-18 15:48:57 -04:00
committed by GitHub
parent e47741d471
commit 574aabdede
36 changed files with 107 additions and 53 deletions

View File

@@ -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;