hue hue hue

This commit is contained in:
2022-08-28 21:39:36 +02:00
parent d1f42d932b
commit e00fe2a4d2
16 changed files with 1300 additions and 77 deletions
+11 -11
View File
@@ -32,43 +32,43 @@ func (f SupportFlags) HasAll(d SupportFlags) bool {
return bits.OnesCount32(uint32(f&d)) == bits.OnesCount32(uint32(d))
}
// ColorFlag is primarily to detect warm-white lights, as XY/RGB/HS/HSK can convert without trouble.
type ColorFlag uint32
// ColorFlags is primarily to detect warm-white lights, as XY/RGB/HS/HSK can convert without trouble.
type ColorFlags uint32
const (
CFlagXY ColorFlag = 1 << iota
CFlagXY ColorFlags = 1 << iota
CFlagRGB
CFlagHS
CFlagHSK
CFlagKelvin
)
var colorFlags = []ColorFlag{CFlagXY, CFlagRGB, CFlagHS, CFlagHSK, CFlagKelvin}
var colorFlags = []ColorFlags{CFlagXY, CFlagRGB, CFlagHS, CFlagHSK, CFlagKelvin}
func (f ColorFlag) String() string {
func (f ColorFlags) String() string {
return gentools.FlagString(f, colorFlags, []string{"XY", "RGB", "HS", "HSK", "K"})
}
func (f ColorFlag) IsColor() bool {
func (f ColorFlags) IsColor() bool {
return f.HasAny(CFlagXY | CFlagRGB | CFlagHS | CFlagHSK)
}
func (f ColorFlag) IsWarmWhite() bool {
func (f ColorFlags) IsWarmWhite() bool {
return f&CFlagKelvin == CFlagKelvin
}
func (f ColorFlag) IsColorOnly() bool {
func (f ColorFlags) IsColorOnly() bool {
return f.IsColor() && !f.IsWarmWhite()
}
func (f ColorFlag) IsWarmWhiteOnly() bool {
func (f ColorFlags) IsWarmWhiteOnly() bool {
return f.IsWarmWhite() && !f.IsColor()
}
func (f ColorFlag) HasAny(d ColorFlag) bool {
func (f ColorFlags) HasAny(d ColorFlags) bool {
return (f & d) != 0
}
func (f ColorFlag) HasAll(d ColorFlag) bool {
func (f ColorFlags) HasAll(d ColorFlags) bool {
return bits.OnesCount32(uint32(f&d)) == bits.OnesCount32(uint32(d))
}
+19
View File
@@ -0,0 +1,19 @@
package device
import (
"git.aiterp.net/lucifer3/server/internal/color"
)
// Info is
type Info struct {
ID string `json:"id"`
Name string `json:"name"`
InternalName string `json:"internalName,omitempty"`
Aliases []string `json:"aliases"`
SupportFlags SupportFlags `json:"supportFlags"`
ColorFlags ColorFlags `json:"colorFlags"`
Buttons []string `json:"buttons"`
DesiredState *State `json:"desiredState"`
HardwareState *State `json:"hardwareState"`
ColorGamut *color.Gamut `json:"colorGamut,omitempty"`
}