1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-17 10:42:21 +01:00

Fix rp2040 pwm to use pico-sdk, not mbed (#4059)

This commit is contained in:
Jesse Hills
2022-11-22 12:19:52 +13:00
committed by GitHub
parent 2b032e8606
commit 621771e1ee
2 changed files with 24 additions and 10 deletions

View File

@@ -7,11 +7,11 @@
#include "esphome/core/component.h"
#include "esphome/core/hal.h"
#include "drivers/PwmOut.h"
namespace esphome {
namespace rp2040_pwm {
static bool frequency_changed_ = false;
class RP2040PWM : public output::FloatOutput, public Component {
public:
void set_pin(InternalGPIOPin *pin) { pin_ = pin; }
@@ -19,6 +19,7 @@ class RP2040PWM : public output::FloatOutput, public Component {
/// Dynamically update frequency
void update_frequency(float frequency) override {
this->set_frequency(frequency);
frequency_changed_ = true;
this->write_state(this->last_output_);
}
@@ -31,8 +32,9 @@ class RP2040PWM : public output::FloatOutput, public Component {
protected:
void write_state(float state) override;
void setup_pwm_();
InternalGPIOPin *pin_;
mbed::PwmOut *pwm_;
float frequency_{1000.0};
/// Cache last output level for dynamic frequency updating
float last_output_{0.0};