working version 1
This commit is contained in:
@@ -11,6 +11,7 @@ struct LightInfo {
|
||||
const std::string baseTopic = "studiotj/smart-rgb/light";
|
||||
const std::string availabilityTopic = "studiotj/smart-rgb/light/status";
|
||||
const std::string stateTopic = "studiotj/smart-rgb/light/state";
|
||||
const std::string jsonAttributesTopic = "studiotj/smart-rgb/light/attributes";
|
||||
const std::string stateValueTemplate = "{{ value_json.state }}";
|
||||
const std::string commandTopic = "studiotj/smart-rgb/light/state/set";
|
||||
const std::string brightnessCommandTopic = "studiotj/smart-rgb/light/brightness/set";
|
||||
@@ -57,6 +58,11 @@ enum LightType {
|
||||
rgbww,
|
||||
};
|
||||
|
||||
enum ActiveMode {
|
||||
modeRgb,
|
||||
modeCct
|
||||
};
|
||||
|
||||
class Light {
|
||||
public:
|
||||
Light(Pin* pinR, Pin* pinG, Pin* pinB, Mqtt* mqttClient, std::string uniqueId);
|
||||
@@ -68,20 +74,23 @@ public:
|
||||
void setHsl(uint8_t h, uint8_t s, uint8_t l);
|
||||
void setColorTemperature(uint16_t temperature);
|
||||
void setBrightness(uint8_t brightness);
|
||||
void turnOn();
|
||||
void turnOff();
|
||||
|
||||
private:
|
||||
void handleCommand(const std::string& command);
|
||||
void operatePin();
|
||||
uint32_t correctGamma(uint32_t originalPwm);
|
||||
uint8_t r = 255; // Default to white
|
||||
uint8_t g = 255; // Default to white
|
||||
uint8_t b = 255; // Default to white
|
||||
void applyKelvin(uint32_t kelvin);
|
||||
uint8_t r = 0; // Default to white
|
||||
uint8_t g = 0; // Default to white
|
||||
uint8_t b = 0; // Default to white
|
||||
uint8_t cw = 255; // Default to white
|
||||
uint8_t ww = 255; // Default to white
|
||||
const uint32_t cwTempKelvin = 6000;
|
||||
const uint32_t wwTempKelvin = 3000;
|
||||
uint16_t colorTemperature;
|
||||
uint8_t brightness;
|
||||
uint32_t maxPwm;
|
||||
bool isOn = false;
|
||||
Pin* pinR;
|
||||
Pin* pinG;
|
||||
@@ -92,4 +101,5 @@ private:
|
||||
LightInfo lightInfo;
|
||||
DeviceInfo deviceInfo;
|
||||
LightType lightType = onOff; // Default light type
|
||||
ActiveMode activeMode = modeRgb;
|
||||
};
|
||||
Reference in New Issue
Block a user