214 lines
7.8 KiB
C++
214 lines
7.8 KiB
C++
#pragma once
|
|
|
|
#include "base.hpp"
|
|
#include "color.hpp"
|
|
|
|
#include <optional>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
class ColorStatus {
|
|
public:
|
|
explicit ColorStatus(int status) : status_(status) {}
|
|
|
|
int raw() const { return status_; }
|
|
bool xyOutOfRange() const { return (status_ & 0x01) != 0; }
|
|
bool ctOutOfRange() const { return (status_ & 0x02) != 0; }
|
|
bool autoCalibrationActive() const { return (status_ & 0x04) != 0; }
|
|
bool autoCalibrationSuccess() const { return (status_ & 0x08) != 0; }
|
|
bool xyActive() const { return (status_ & 0x10) != 0; }
|
|
bool ctActive() const { return (status_ & 0x20) != 0; }
|
|
bool primaryNActive() const { return (status_ & 0x40) != 0; }
|
|
bool rgbwafActive() const { return (status_ & 0x80) != 0; }
|
|
|
|
private:
|
|
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) {}
|
|
|
|
int features() const { return features_; }
|
|
bool xyCapable() const { return (features_ & 0x01) != 0; }
|
|
bool ctCapable() const { return (features_ & 0x02) != 0; }
|
|
int primaryCount() const { return (features_ >> 2) & 0x07; }
|
|
int rgbwafChannels() const { return (features_ >> 5) & 0x07; }
|
|
bool primaryNCapable() const { return primaryCount() > 0; }
|
|
bool rgbwafCapable() const { return rgbwafChannels() > 0; }
|
|
|
|
private:
|
|
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(); }
|
|
};
|
|
|
|
struct Dt8LevelColorReport {
|
|
int level = 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(); }
|
|
};
|
|
|
|
enum class Dt8SceneStoreColorMode {
|
|
disabled,
|
|
colorTemperature,
|
|
rgb,
|
|
};
|
|
|
|
class DaliDT8 {
|
|
public:
|
|
explicit DaliDT8(DaliBase& base);
|
|
|
|
bool enableDT8();
|
|
std::optional<ColorTypeFeature> getColorTypeFeature(int a);
|
|
std::optional<ColorStatus> getColorStatus(int a);
|
|
|
|
std::optional<int> getColTempRaw(int a, int type = 2);
|
|
bool setColTempRaw(int a, int value);
|
|
bool setColorTemperature(int addr, int kelvin);
|
|
std::optional<int> getColorTemperature(int a);
|
|
std::optional<int> getMinColorTemperature(int a);
|
|
std::optional<int> getMaxColorTemperature(int a);
|
|
std::optional<int> getPhysicalMinColorTemperature(int a);
|
|
std::optional<int> getPhysicalMaxColorTemperature(int a);
|
|
std::optional<int> getColourTempLimitRaw(int address, int limitType);
|
|
std::optional<int> getColourTempLimit(int address, int limitType);
|
|
|
|
bool setColourRaw(int addr, int x1, int y1);
|
|
|
|
// Temporary setters
|
|
bool setTemporaryColourXRaw(int addr, int x1);
|
|
bool setTemporaryColourYRaw(int addr, int y1);
|
|
bool setTemporaryColourXY(int a, double x, double y);
|
|
bool setTemporaryColourTemperature(int a, int kelvin);
|
|
bool setTemporaryPrimaryDimLevel(int a, int n, double level);
|
|
bool setTemporaryRGBDimLevels(int a, int r, int g, int b);
|
|
bool setTemporaryWAFDimLevels(int a, int w, int amber, int freecolour);
|
|
bool setTemporaryRGBWAFControl(int a, int control);
|
|
bool setTemporaryColourMask(int a);
|
|
bool copyReportToTemporary(int a);
|
|
|
|
// Step commands
|
|
bool stepXUp(int a);
|
|
bool stepXDown(int a);
|
|
bool stepYUp(int a);
|
|
bool stepYDown(int a);
|
|
bool stepTcCooler(int a);
|
|
bool stepTcWarmer(int a);
|
|
|
|
bool setColourRGBRaw(int addr, int r, int g, int b);
|
|
bool setColour(int a, double x, double y);
|
|
std::optional<int> getColourRaw(int a, int type);
|
|
std::vector<double> getColour(int a);
|
|
bool setColourRGB(int addr, int r, int g, int b);
|
|
std::vector<int> getColourRGB(int a);
|
|
|
|
bool activateTemporaryColour(int a);
|
|
|
|
// Active-type queries
|
|
std::optional<int> getPrimaryDimLevel(int a, int n);
|
|
std::optional<int> getRedDimLevel(int a);
|
|
std::optional<int> getGreenDimLevel(int a);
|
|
std::optional<int> getBlueDimLevel(int a);
|
|
std::optional<int> getWhiteDimLevel(int a);
|
|
std::optional<int> getAmberDimLevel(int a);
|
|
std::optional<int> getFreecolourDimLevel(int a);
|
|
std::optional<int> getRGBWAFControl(int a);
|
|
|
|
// Temporary colour queries
|
|
std::optional<int> getTemporaryXRaw(int a);
|
|
std::optional<int> getTemporaryYRaw(int a);
|
|
std::optional<int> getTemporaryColourTemperatureRaw(int a);
|
|
std::optional<int> getTemporaryPrimaryDimLevel(int a, int n);
|
|
std::optional<int> getTemporaryRedDimLevel(int a);
|
|
std::optional<int> getTemporaryGreenDimLevel(int a);
|
|
std::optional<int> getTemporaryBlueDimLevel(int a);
|
|
std::optional<int> getTemporaryWhiteDimLevel(int a);
|
|
std::optional<int> getTemporaryAmberDimLevel(int a);
|
|
std::optional<int> getTemporaryFreecolourDimLevel(int a);
|
|
std::optional<int> getTemporaryRGBWAFControl(int a);
|
|
std::optional<int> getTemporaryColourType(int a);
|
|
std::vector<double> getTemporaryColour(int a);
|
|
std::optional<int> getTemporaryColorTemperature(int a);
|
|
|
|
// Report colour queries
|
|
std::optional<int> getReportXRaw(int a);
|
|
std::optional<int> getReportYRaw(int a);
|
|
std::optional<int> getReportColourTemperatureRaw(int a);
|
|
std::optional<int> getReportPrimaryDimLevel(int a, int n);
|
|
std::optional<int> getReportRedDimLevel(int a);
|
|
std::optional<int> getReportGreenDimLevel(int a);
|
|
std::optional<int> getReportBlueDimLevel(int a);
|
|
std::optional<int> getReportWhiteDimLevel(int a);
|
|
std::optional<int> getReportAmberDimLevel(int a);
|
|
std::optional<int> getReportFreecolourDimLevel(int a);
|
|
std::optional<int> getReportRGBWAFControl(int a);
|
|
std::optional<int> getReportColourType(int a);
|
|
std::vector<double> getReportColour(int a);
|
|
std::optional<int> getReportColorTemperature(int a);
|
|
|
|
std::optional<int> getNumberOfPrimaries(int a);
|
|
std::optional<int> getPrimaryXRaw(int a, int n);
|
|
std::optional<int> getPrimaryYRaw(int a, int n);
|
|
std::optional<int> getPrimaryTy(int a, int n);
|
|
|
|
std::optional<SceneColorReport> getSceneColorReport(int a, int sense, int gateway = -1);
|
|
std::vector<double> getSceneColor(int a, int sense, int gateway = -1);
|
|
|
|
// Store / config
|
|
bool storePrimaryTy(int a, int n, int ty);
|
|
bool storePrimaryXY(int a, int n, double x, double y);
|
|
bool storeSceneSnapshot(int address, int scene, int brightness,
|
|
Dt8SceneStoreColorMode colorMode = Dt8SceneStoreColorMode::disabled,
|
|
int colorTemperature = 0, int red = 0, int green = 0, int blue = 0,
|
|
int gateway = -1);
|
|
bool storePowerOnLevelSnapshot(int address, int level);
|
|
bool storeSystemFailureLevelSnapshot(int address, int level);
|
|
std::optional<Dt8LevelColorReport> getPowerOnLevelColorReport(int a);
|
|
std::optional<Dt8LevelColorReport> getSystemFailureLevelColorReport(int a);
|
|
bool storeColourTempLimitRaw(int a, int limitType, int mirek);
|
|
bool storeColourTempLimit(int a, int limitType, int kelvin);
|
|
bool setGearAutoActivate(int a, bool enable);
|
|
bool assignColourToLinkedChannels(int a, int colourId);
|
|
bool startAutoCalibration(int a);
|
|
|
|
// Direct queries
|
|
std::optional<int> getGearFeaturesStatus(int a);
|
|
std::optional<int> getRGBWAFControlDirect(int a);
|
|
std::optional<int> getAssignedColourForChannel(int a, int channelId);
|
|
std::optional<int> getExtendedVersion(int a);
|
|
|
|
private:
|
|
std::optional<Dt8LevelColorReport> buildLevelColorReport(int a, std::optional<int> level);
|
|
|
|
DaliBase& base_;
|
|
};
|