-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
70 lines (57 loc) · 1.34 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
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"github.com/bpoetzschke/tinygo-arduino/epd"
"github.com/bpoetzschke/tinygo-arduino/openweather"
"github.com/bpoetzschke/tinygo-arduino/wifi"
"machine"
"time"
)
const (
lat = 42.365250
long = -71.105011
DEBUG = false
)
var (
w wifi.Wifi
openWeatherClient = openweather.Client{Lat: lat, Long: long, ApiKey: openWeatherMapAPIKey}
currentWeather openweather.CurrentWeatherData
display = epd.Display{}
)
func main() {
waitSerial()
openWeatherClient.Setup()
err := w.Setup()
PrintErrIfNotNil(err)
err = w.ConnectToAP(ssid, pass)
PrintErrIfNotNil(err)
err = display.Setup(DEBUG)
PrintErrIfNotNil(err)
for {
//err := openWeatherClient.GetCurrentWeather(¤tWeather)
//PrintErrIfNotNil(err)
display.Clear()
//err := display.SetRectColor()
//PrintErrIfNotNil(err)
//display.DisplayCurrentWeather(¤tWeather, meteoicon.GetMeteoIcon(currentWeather.Weather.Icon), &meteoicon.MeteoIcon48pt)
//display.DisplayFrame()
err := display.Display()
PrintErrIfNotNil(err)
println("display done")
time.Sleep(time.Minute)
}
}
// Wait for user to open serial console
func waitSerial() {
for !machine.Serial.DTR() {
time.Sleep(100 * time.Millisecond)
}
}
func PrintErrIfNotNil(err error) {
if err == nil {
return
}
for {
println(err)
time.Sleep(time.Second)
}
}