forked from xiaozhi/xiaozhi-esp32
Fix atoms3 backlight control (#959)
This commit is contained in:
@@ -229,7 +229,7 @@ public:
|
||||
}
|
||||
|
||||
virtual Backlight* GetBacklight() override {
|
||||
static PwmBacklight backlight(DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT);
|
||||
static PwmBacklight backlight(DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, 256);
|
||||
return &backlight;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -81,12 +81,12 @@ void Backlight::OnTransitionTimer() {
|
||||
}
|
||||
}
|
||||
|
||||
PwmBacklight::PwmBacklight(gpio_num_t pin, bool output_invert) : Backlight() {
|
||||
PwmBacklight::PwmBacklight(gpio_num_t pin, bool output_invert, uint32_t freq_hz) : Backlight() {
|
||||
const ledc_timer_config_t backlight_timer = {
|
||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.duty_resolution = LEDC_TIMER_10_BIT,
|
||||
.timer_num = LEDC_TIMER_0,
|
||||
.freq_hz = 25000, //背光pwm频率需要高一点,防止电感啸叫
|
||||
.freq_hz = freq_hz, //背光pwm频率需要高一点,防止电感啸叫
|
||||
.clk_cfg = LEDC_AUTO_CLK,
|
||||
.deconfigure = false
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ protected:
|
||||
|
||||
class PwmBacklight : public Backlight {
|
||||
public:
|
||||
PwmBacklight(gpio_num_t pin, bool output_invert = false);
|
||||
PwmBacklight(gpio_num_t pin, bool output_invert = false, uint32_t freq_hz = 25000);
|
||||
~PwmBacklight();
|
||||
|
||||
void SetBrightnessImpl(uint8_t brightness) override;
|
||||
|
||||
Reference in New Issue
Block a user