You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
768 B

#pragma once
#include <cstdint>
#include <functional>
#include <driver/gpio.h>
#include <esp_timer.h>
class Backlight {
public:
Backlight();
~Backlight();
void RestoreBrightness();
void SetBrightness(uint8_t brightness, bool permanent = false);
inline uint8_t brightness() const { return brightness_; }
protected:
void OnTransitionTimer();
virtual void SetBrightnessImpl(uint8_t brightness) = 0;
esp_timer_handle_t transition_timer_ = nullptr;
uint8_t brightness_ = 0;
uint8_t target_brightness_ = 0;
uint8_t step_ = 1;
};
class PwmBacklight : public Backlight {
public:
PwmBacklight(gpio_num_t pin, bool output_invert = false);
~PwmBacklight();
void SetBrightnessImpl(uint8_t brightness) override;
};