DualLedController/components/LedController/LedController.h

42 lines
1013 B
C
Raw Normal View History

2024-05-17 01:08:15 +08:00
#ifndef __LEDCONTROLLER_H__
#define __LEDCONTROLLER_H__
#include <driver/ledc.h>
class LedController {
public:
2024-06-05 22:59:04 +08:00
constexpr static ledc_timer_bit_t TimerBit = LEDC_TIMER_12_BIT;
constexpr static int32_t Resolution = 1 << LEDC_TIMER_12_BIT;
constexpr static int32_t MinimumColorTemp = 153;
constexpr static int32_t MaximumColorTemp = 500;
enum Channel {
Warm = 0,
Cold = 1,
};
2024-05-17 01:08:15 +08:00
static LedController *instance();
bool initialize();
2024-06-05 22:59:04 +08:00
int32_t brightness() const;
void setBrightness(int32_t brightness);
int32_t colorTemperature() const;
void setColorTemperature(int32_t temp);
bool enabled() const;
void setEnabled(bool enabled);
void setDuty(Channel channel, int32_t duty);
2024-05-17 01:08:15 +08:00
protected:
LedController();
2024-06-05 22:59:04 +08:00
void update();
2024-05-17 01:08:15 +08:00
ledc_channel_config_t m_channels[2];
2024-06-05 22:59:04 +08:00
private:
bool m_enabled = false;
int32_t m_brightness = 0;
int32_t m_colorTemp = 0;
2024-05-17 01:08:15 +08:00
};
#endif // __LEDCONTROLLER_H__