-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
73 lines (60 loc) · 1.24 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
71
72
73
package main
import (
"desktop-cycle/internal/util"
"github.com/go-vgo/robotgo"
"github.com/leaanthony/mewn"
"github.com/wailsapp/wails"
)
var deskCycleSerial *util.DeskCycleSerial
func getSpeed() float64 {
speed, err := deskCycleSerial.CurrentSpeed()
if err != nil {
panic(err)
}
return speed
}
func getCadence() float64 {
cadence, err := deskCycleSerial.CurrentCadence()
if err != nil {
panic(err)
}
return cadence
}
func keyUp(keyName string) {
robotgo.KeyToggle(keyName, "up")
}
func keyDown(keyName string) {
robotgo.KeyToggle(keyName, "down")
}
func tapKey(keyName string) {
robotgo.KeyTap(keyName)
}
func main() {
html := mewn.String("./frontend/dist/my-app/index.html")
js := mewn.String("./frontend/dist/my-app/main.js")
css := mewn.String("./frontend/dist/my-app/styles.css")
app := wails.CreateApp(&wails.AppConfig{
Width: 1024,
Height: 768,
Title: "Desktop Cycle",
HTML: html,
JS: js,
CSS: css,
Resizable: true,
})
// initialize desk cycle serial
var err error
deskCycleSerial, err = util.NewDeskCycleSerial()
if err != nil {
panic(err)
}
app.Bind(getSpeed)
app.Bind(getCadence)
app.Bind(tapKey)
app.Bind(keyDown)
app.Bind(keyUp)
err = app.Run()
if err != nil {
panic(err)
}
}