-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
138 lines (115 loc) · 3.88 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Copyright (c) 2021-2022 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"log"
"github.com/Dadido3/D3iot/light/drivers/wiz"
"github.com/Dadido3/D3iot/light/emission"
)
func main() {
light, err := wiz.NewLight("wiz-d47cf3:38899")
if err != nil {
log.Printf("wiz.NewLight() failed: %v", err)
return
}
/*if err := light.Pulse(50, 100*time.Millisecond); err != nil {
log.Printf("light.Pulse() failed: %v", err)
}*/
/*if result, err := light.GetSystemConfig(); err != nil {
log.Printf("light.GetSystemConfig() failed: %v", err)
} else {
log.Printf("%#v", result)
}*/
/*if info, err := light.GetDeviceInfo(); err != nil {
log.Printf("light.GetDeviceInfo() failed: %v", err)
} else {
log.Printf("%#v", info)
}*/
/*if info, err := light.GetUserConfig(); err != nil {
log.Printf("light.GetUserConfig() failed: %v", err)
} else {
log.Printf("%#v", info)
}*/
/*if favs, err := light.GetFavs(); err != nil {
log.Printf("light.GetFavs() failed: %v", err)
} else {
log.Printf("Favs: %v", favs)
}*/
/*if product, err := light.Product(); err != nil {
log.Printf("light.Product() failed: %v", err)
} else {
log.Printf("Product: %v", product)
}*/
/*//scene := wiz.SceneBedtime
//temp := uint(4200)
r := uint8(255)
dimming := uint(10)
pilot := wiz.Pilot{
State: true,
Dimming: &dimming,
R: &r,
//Scene: &scene,
}*/
//pilot := wiz.NewPilotWithRGBW(100, 0, 0, 0, 50, 0)
//pilot := wiz.NewPilot(false)
//pilot := wiz.NewPilotWithScene(wiz.SceneCozy, 20, 0)
/*if err := light.SetPilot(pilot); err != nil {
log.Printf("light.SetPilot() failed: %v", err)
}
log.Printf("Set pilot to %v", pilot)*/
/*for {
if result, err := light.GetPilot(); err != nil {
log.Printf("query failed: %v", err)
} else {
log.Printf("%s", result)
}
time.Sleep(1 * time.Second)
}*/
/*if err := light.SetPilot(wiz.Pilot{}.WithRGBW(0, 0, 0, 50, 0)); err != nil {
log.Printf("light.SetPilot() failed: %v", err)
}*/
/*if err := light.SetPilot(wiz.Pilot{}.WithScene(wiz.SceneClub, 6000, 50, 50)); err != nil {
log.Printf("light.SetPilot() failed: %v", err)
}*/
//emissionValue := emission.CIE1931XYZRel{X: 0.95047, Y: 1, Z: 1.08883}
//emissionValue := light.ColorProfiles()[0].WhitePoint().Scaled(200.0 / 1521)
//emissionValue := emission.NoWhiteOptimization{emission.StandardIlluminantA.Absolute(200)}
emissionValue := emission.StandardIlluminantA.Absolute(200)
//emissionValue := emission.StandardIlluminantD50.Absolute(600)
//emissionValue := emission.StandardIlluminantD50.Absolute(500)
//emissionValue := emission.BlackBodyFixed{Temperature: 5000, Luminance: 200}
//emissionValue := emission.BlackBodyArea{Temperature: 5000, Area: 0.004}
//emissionValue := emission.DCSVector{0.7, 0.5, 0.4, 0, 0}
//emissionValue := emission.DCSVector{0, 0, 0, 0.3, 0}
//emissionValue := emission.StandardRGB{R: 0.7, G: 0.0, B: 0.0}
//emissionValue := emission.DCSVector{1, 1, 1, 0, 0}
//emissionValue := light.ColorProfiles()[0].ChannelPoints()[3]
if err := light.SetColors(emissionValue); err != nil {
log.Printf("light.SetColors() failed: %v", err)
}
var res emission.CIE1931XYZAbs
if err := light.GetColors(&res); err != nil {
log.Printf("light.GetColors() failed: %v", err)
} else {
log.Printf("Returned colors: %v", res)
}
if pilot, err := light.GetPilot(); err != nil {
log.Printf("light.GetPilot() failed: %v", err)
} else {
log.Printf("Returned pilot: %v", pilot)
}
/*frequency := 0.05 // In 1/s
startTime := time.Now()
for {
seconds := time.Since(startTime).Seconds()
sineWave := math.Sin(frequency * 2 * math.Pi * seconds)
temp := 2800 + 1000*sineWave
emissionValue := emission.BlackBodyArea{Temperature: temp, Area: 0.004}
if err := light.SetColors(emissionValue); err != nil {
log.Printf("light.SetColors() failed: %v", err)
}
time.Sleep(10 * time.Millisecond)
}*/
}