-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (40 loc) · 901 Bytes
/
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
package main
import (
"flag"
"overlay/game"
"overlay/internal/route"
"overlay/internal/training"
"overlay/pkg/bluetooth"
"overlay/pkg/gpx"
)
var mock = flag.Bool("m", false, "Sets up a mock trainer instead of connecting to a real trainer")
func newDevice() (*bluetooth.Device, error) {
if *mock {
trainer := bluetooth.NewMockDevice()
return &trainer, nil
}
return bluetooth.Connect()
}
func main() {
flag.Parse()
trainer, err := newDevice()
if err != nil {
panic(err)
}
training := training.NewRandom()
helloWorldRoute := route.New()
fileChan := make(chan int)
trainer.Power.AddListener(fileChan)
gpxFile := gpx.New("Hello World Ride")
go func() {
for p := range fileChan {
tp := gpx.NewTrackpoint(
"23.3581890",
"54.9870280",
gpx.WithPower(p))
gpxFile.AddTrackpoint(tp)
}
}()
trainer.Listen()
game.Run(training, trainer, helloWorldRoute)
}