Refactor DALI command handling: streamline send methods and enhance scene color reporting
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
// Lightweight communicator for DALI gateway type 1 (USB UART new frame format).
|
||||
// Frames:
|
||||
// - Send: [0x10, addr, cmd]
|
||||
// - Ext: [0x11, addr, cmd] (sent twice with a small delay)
|
||||
// - Ext: [0x11, addr, cmd] (one logical send; gateway/transceiver handles any required repeat timing)
|
||||
// - Query: [0x12, addr, cmd] -> expects [0xFF, data] on success
|
||||
// COMPARE may also return [0xFD, data] when multiple devices reply together
|
||||
// Callers provide UART callbacks; this class only builds frames and parses basic responses.
|
||||
@@ -49,7 +49,7 @@ class DaliComm {
|
||||
|
||||
// Send standard command frame (0x10).
|
||||
bool sendCmd(uint8_t addr, uint8_t cmd) const;
|
||||
// Send extended command frame (0x11).
|
||||
// Send one logical extended command frame (0x11).
|
||||
bool sendExtCmd(uint8_t addr, uint8_t cmd) const;
|
||||
// Send query frame (0x12) and parse single-byte response. Returns nullopt on no/invalid response,
|
||||
// except COMPARE where 0xFD collisions are treated as a positive match.
|
||||
|
||||
+1
-1
@@ -73,6 +73,6 @@ class DaliDT5 {
|
||||
|
||||
bool enable();
|
||||
static int addrOf(int a);
|
||||
bool send(int a, int code, bool twice = false);
|
||||
bool send(int a, int code);
|
||||
std::optional<int> query(int a, int code);
|
||||
};
|
||||
+1
-1
@@ -124,7 +124,7 @@ class DaliDT6 {
|
||||
|
||||
bool enable();
|
||||
static int addrOf(int a);
|
||||
bool send(int a, int code, bool twice = false);
|
||||
bool send(int a, int code);
|
||||
std::optional<int> query(int a, int code);
|
||||
std::optional<bool> queryYesNo(int a, int code);
|
||||
};
|
||||
@@ -25,6 +25,20 @@ class ColorStatus {
|
||||
int status_ = 0;
|
||||
};
|
||||
|
||||
class ColorType {
|
||||
public:
|
||||
explicit ColorType(int type) : type_(type) {}
|
||||
|
||||
int raw() const { return type_; }
|
||||
bool xy() const { return (type_ & 0x10) != 0; }
|
||||
bool ct() const { return (type_ & 0x20) != 0; }
|
||||
bool primaryN() const { return (type_ & 0x40) != 0; }
|
||||
bool rgbWaf() const { return (type_ & 0x80) != 0; }
|
||||
|
||||
private:
|
||||
int type_ = 0;
|
||||
};
|
||||
|
||||
class ColorTypeFeature {
|
||||
public:
|
||||
explicit ColorTypeFeature(int features) : features_(features) {}
|
||||
@@ -41,6 +55,17 @@ class ColorTypeFeature {
|
||||
int features_ = 0;
|
||||
};
|
||||
|
||||
struct SceneColorReport {
|
||||
int brightness = 0;
|
||||
int colorTypeValue = 0;
|
||||
std::vector<double> xy;
|
||||
std::optional<int> colorTemperature;
|
||||
|
||||
ColorType colorType() const { return ColorType(colorTypeValue); }
|
||||
bool hasXy() const { return xy.size() == 2; }
|
||||
bool hasColorTemperature() const { return colorTemperature.has_value(); }
|
||||
};
|
||||
|
||||
class DaliDT8 {
|
||||
public:
|
||||
explicit DaliDT8(DaliBase& base);
|
||||
@@ -135,6 +160,7 @@ class DaliDT8 {
|
||||
std::optional<int> getPrimaryYRaw(int a, int n);
|
||||
std::optional<int> getPrimaryTy(int a, int n);
|
||||
|
||||
std::optional<SceneColorReport> getSceneColorReport(int a, int sense);
|
||||
std::vector<double> getSceneColor(int a, int sense);
|
||||
|
||||
// Store / config
|
||||
|
||||
Reference in New Issue
Block a user