/
types.go
36 lines (31 loc) · 837 Bytes
/
types.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
package main
import (
"github.com/swedishborgie/starlamp/lightctl"
"time"
)
type SleepState int
const (
StateUnknown SleepState = 0
StateAwake SleepState = 1
StateAsleep SleepState = 2
)
type State struct {
AwakeTime string `json:"awakeTime"`
AsleepTime string `json:"asleepTime"`
NextAwakeTime time.Time `json:"nextAwakeTime"`
NextAsleepTime time.Time `json:"nextAsleepTime"`
AwakeColor lightctl.LightState `json:"awakeColor"`
AsleepColor lightctl.LightState `json:"asleepColor"`
CurrentState SleepState `json:"currentState"`
CurrentColor lightctl.LightState `json:"currentColor"`
}
func (s SleepState) String() string {
switch s {
case StateAwake:
return "awake"
case StateAsleep:
return "asleep"
default:
return "unknown"
}
}