-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhelmet.go
51 lines (42 loc) · 1.09 KB
/
helmet.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
package gopherhelmet
import (
"image/color"
"machine"
)
type BLECallback func(string)
const (
// BackpackLEDCount is how many WS2812 LEDs are on the backpack, aka
// the Circuit Playground Express.
BackpackLEDCount = 10
TopLEDCount = 10
VisorWidth = 17
VisorHeight = 5
)
var (
adcInitComplete = false
i2cInitComplete = false
Red = color.RGBA{255, 0, 0, 255}
Green = color.RGBA{0, 255, 0, 255}
Blue = color.RGBA{0, 0, 255, 255}
Yellow = color.RGBA{255, 255, 0, 255}
Magenta = color.RGBA{255, 0, 255, 255}
Cyan = color.RGBA{0, 255, 255, 255}
White = color.RGBA{255, 255, 255, 255}
Black = color.RGBA{0, 0, 0, 255}
)
// EnsureADCInit makes sure that the Gopherbot ADC has been initialized, but
// is only initialized once.
func EnsureADCInit() {
if !adcInitComplete {
machine.InitADC()
adcInitComplete = true
}
}
// EnsureI2CInit makes sure that the Gopherbot I2C has been initialized, but
// is only initialized once.
func EnsureI2CInit() {
if !i2cInitComplete {
machine.I2C1.Configure(machine.I2CConfig{SCL: sclPin, SDA: sdaPin})
i2cInitComplete = true
}
}