1#ifndef SENSESP_SYSTEM_PWM_OUTPUT_H
2#define SENSESP_SYSTEM_PWM_OUTPUT_H
7#include "esp_arduino_version.h"
45 PWMOutput(
int pin = -1,
int pwm_channel = -1,
int channel_frequency = 5000,
46 int channel_resolution = 13) __attribute__((deprecated))
51 pwmrange_{
static_cast<int>((1 << channel_resolution) - 1)} {
62 virtual void set(
const float& new_value)
override {
set_pwm(new_value); }
70 static std::map<uint8_t, int8_t> channel_to_pin_;
71 return channel_to_pin_;
86 if (pwm_channel == -1) {
88 std::map<uint8_t, int8_t>::iterator it;
98 ESP_LOGD(__FILENAME__,
"PWM channel %d assigned to pin %d", pwm_channel,
101 pinMode(pin, OUTPUT);
102#if ESP_ARDUINO_VERSION_MAJOR > 2
107 ledcAttachPin(pin, pwm_channel);
119 std::map<uint8_t, int8_t>::iterator it;
122 int pin = it->second;
123 int const output_val = value *
pwmrange_;
126#if ESP_ARDUINO_VERSION_MAJOR > 2
132 ESP_LOGW(__FILENAME__,
133 "No pin assigned to channel %d. Ignoring set_pwm()",
void set_pwm(float value)
int assign_channel(int pin, int pwm_channel=-1)
PWMOutput(int pin=-1, int pwm_channel=-1, int channel_frequency=5000, int channel_resolution=13) __attribute__((deprecated))
virtual void set(const float &new_value) override
static std::map< uint8_t, int8_t > & channel_map()
A base class for piece of code (like a transform) that accepts data for input. ValueConsumers can acc...