-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackUpPowerControl.ic10
86 lines (67 loc) · 1.35 KB
/
BackUpPowerControl.ic10
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
74
75
76
77
78
79
80
81
82
83
84
85
86
# Constants
# Reads the Charge Percentage of all connected Station Batteries
# and writes it to the connected display
# Activates a Backup Generator when the Power falls too low
define cHighCharge 0.50
define cLowCharge 0.10
define BATTERYLARGE -1388288459
define BATTERY -400115994
# Device aliases
alias dBackupGenerator d0
alias dDisplay d1
alias dMem d2
# variables
alias vActivated r15
alias vCharge r14
alias vBatteryChargeAbs r13
alias vBatteryMax r12
# Set constants
main:
lb r0 BATTERYLARGE Charge 1
lb r1 BATTERY Charge 1
add vBatteryChargeAbs r0 r1
lb r0 BATTERYLARGE Maximum 1
lb r1 BATTERY Maximum 1
add vBatteryMax r0 r1
div vCharge vBatteryChargeAbs vBatteryMax
s db Setting vCharge
s db:0 Channel0 vCharge
s db:1 Channel0 vCharge
s d0:1 Channel0 vCharge
s d0:2 Channel0 vCharge
bdseal dDisplay display
bdseal dMem writeMem
bdns dBackupGenerator main
# activate chec
bge vCharge cHighCharge deactivate
ble vCharge cLowCharge activate
yield
j main
activate:
s dBackupGenerator On 1
yield
j main
deactivate:
s dBackupGenerator On 0
yield
j main
display:
s dDisplay Setting vCharge
s dDisplay Mode 1
bgt vCharge 0.99 maxCharge
bgt vCharge 0.80 highcharge
bgt vCharge 0.25 mediumcharge
s dDisplay Color 4
j ra
writeMem:
s dMem Setting vCharge
j ra
mediumcharge:
s dDisplay Color 5
j ra
highcharge:
s dDisplay Color 2
j ra
maxCharge:
s dDisplay Color 0
j ra