18 LOG_SENSOR(
"",
"Duty Cycle Sensor",
this);
19 LOG_PIN(
" Pin: ", this->
pin_);
20 LOG_UPDATE_INTERVAL(
this);
34 on_time += now - last_interrupt;
36 const float total_time = float(now - this->
last_update_);
38 const float value = (on_time * 100.0f) / total_time;
39 ESP_LOGD(TAG,
"'%s' Got duty cycle=%.1f%%", LOG_STR_ARG(this->
get_log_name()), value);
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
DutyCycleSensorStore store_
void dump_config() override
void attach_interrupt(void(*func)(T *), T *arg, gpio::InterruptType type) const
bool digital_read() override
ISRInternalGPIOPin to_isr() const
void publish_state(float state)
Publish a new state to the front-end.
ESPHOME_LOG_TAG(TAG, "duty_cycle")
uint32_t IRAM_ATTR HOT micros()
Store data in a class that doesn't use multiple-inheritance (vtables in flash)
static void gpio_intr(DutyCycleSensorStore *arg)
volatile uint32_t last_interrupt
volatile uint32_t on_time