forked from Will1604/infinitive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconversions.go
70 lines (65 loc) · 1.07 KB
/
conversions.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
func rawModeToString(mode uint8) string {
switch mode {
case 0:
return "heat" // heat source: "system in control"
case 1:
return "cool"
case 2:
return "auto"
case 3:
return "electric" // electric heat only - fan coil system
// on a furnace system perhaps mode 3 is furnace only - untested
case 4:
return "heatpump" // heat pump only
case 5:
return "off"
default:
return "unknown"
}
}
func stringModeToRaw(mode string) uint8 {
switch mode {
case "heat":
return 0
case "cool":
return 1
case "auto":
return 2
case "off":
return 5
default:
return 5
}
}
func rawFanModeToString(mode uint8) string {
switch mode {
case 0:
return "auto"
case 1:
return "low"
case 2:
return "med"
case 3:
return "high"
default:
return "unknown"
}
}
func stringFanModeToRaw(mode string) (uint8, bool) {
switch mode {
case "auto":
return 0, true
case "low":
return 1, true
case "med":
return 2, true
case "high":
return 3, true
default:
return 0, false
}
}
func tempFtoC(tempF float32) float32 {
return (tempF - 32.0) * 5.0 / 9.0
}