ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
waveshare_io_ch32v003_output.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
3#include <algorithm>
4
6
7static const char *const TAG = "waveshare_io_ch32v003.output";
8
10 uint8_t pwm_value = static_cast<uint8_t>(state * 255.0f);
11 uint8_t final_pwm_value = std::clamp(pwm_value, this->pwm_min_value_, this->pwm_max_value_);
12 if (final_pwm_value != pwm_value) {
13 ESP_LOGVV(TAG, "Clamping PWM value %u to safe range [%u, %u]", pwm_value, this->pwm_min_value_,
14 this->pwm_max_value_);
15 }
16 this->parent_->set_pwm_value(final_pwm_value);
17}
18
19} // namespace esphome::waveshare_io_ch32v003
WaveshareIOCH32V003Component * parent_
Definition helpers.h:1886
bool state
Definition fan.h:2