-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (48 loc) · 1.11 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
package main
import (
m "machine"
"time"
"github.com/s-fairchild/reef-controller/ato"
"github.com/s-fairchild/reef-controller/comms"
"github.com/s-fairchild/reef-controller/dosing"
"github.com/s-fairchild/reef-controller/ec"
"github.com/s-fairchild/reef-controller/rtc"
)
func main() {
c := rtc.New(&m.I2CConfig{
SDA: m.GP26,
SCL: m.GP27,
}, m.I2C1)
c.Init()
// c.Rtc.SetTime(time.Date(2023, 02, 23, 15, 15, 00, 00, time.UTC))
t, err := c.Rtc.ReadTime()
if err != nil {
panic(err)
}
println("Current Time:", t.Format(time.RFC3339))
wl := ato.New(m.GP17, m.GP13, m.GP15, m.LED)
wl.Init()
go wl.MonitorLevel()
magnesiumPump := dosing.New(m.GP18, dosing.Magnesium, c.Rtc)
err = magnesiumPump.Configure(&dosing.DosingConfig{
Ml: 30,
Interval: 24 * time.Hour,
})
if err != nil {
panic(err)
}
go magnesiumPump.Dose()
salinity := ec.New(m.ADC0, 3.3, ec.ResolutionScaled)
salinity.Configure()
for {
println(salinity.GetSalinity(25.5556)) // 78.0°F
time.Sleep(time.Minute)
}
// select {}
}
func init() {
err := comms.InitUART(m.UART0, true)
if err != nil {
println(err)
}
}