/
hasp.go
72 lines (55 loc) · 1.08 KB
/
hasp.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
package goha
import (
"context"
"fmt"
)
type HASP struct {
BasePath string
ActivePage int
Brightness int
Pages []HASPPage
}
type HASPPage struct {
Buttons map[string]HASPButton
}
type HASPButton struct {
OnClick func(value string) error
Font int
BackgroundColorPri int
BackgroundColorSec int
ForegroundColorPri int
ForegroundColorSec int
HorizAlign string
VertAlign string
Text string
Wordwrap bool
}
func (hasp *HASP) Init(ctx context.Context) {
go func() {
for {
select {
case <-ctx.Done():
return
}
}
}()
}
func (hasp *HASP) boot() {
}
func (hasp *HASP) click() {
}
func (hasp *HASP) ColorFromHex(red int, green int, blue int) (int, error) {
if red > 255 || green > 255 || blue > 255 {
return 0, fmt.Errorf("value cannot be greater than 255")
}
return ((red >> 3) << 11) + ((green >> 2) << 5) + (blue >> 3), nil
}
func (hasp *HASP) Update() error {
return nil
}
func (hasp *HASP) Reboot() error {
return nil
}
func (hasp *HASP) FactoryReset() error {
return nil
}