https://github.com/samthor/light
Controls a WebLight in Go
https://github.com/samthor/light
weblight
Last synced: about 2 months ago
JSON representation
Controls a WebLight in Go
- Host: GitHub
- URL: https://github.com/samthor/light
- Owner: samthor
- License: apache-2.0
- Created: 2018-04-26T02:11:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-10T22:52:19.000Z (about 8 years ago)
- Last Synced: 2025-12-27T00:02:41.671Z (6 months ago)
- Topics: weblight
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Go library to control a light.
Works with the [WebLight](https://github.com/sowbug/weblight).
# Usage
Run `light.Update()` in its own goroutine, perhaps with a short delay (sub-second).
```go
light.Add(light.Task{
Color: &light.Red,
})
color, err := light.Update()
if err != nil {
log.Fatal(err) // or ignore, whatever
}
log.Printf("set color: %+v", color)
```
To add colors that take priority expire after a time:
```go
light.Add(light.Task{
Priority: 100, // higher takes precedence
Color: &light.Red,
Duration: time.Second,
})
```
To cancel tasks:
```go
ref := light.Add(light.Task{
Priority: 10,
Color: &light.Color{128, 0, 255},
})
// later
ref.Cancel()
```