-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdouble-axis-solar.s
119 lines (109 loc) · 2.22 KB
/
double-axis-solar.s
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
alias daylight r0
alias horiangle r1
alias vertangle r2
alias state r3
alias hrotate r4
alias hpark r5
alias vpark r6
alias ratio r7
alias maxratio r8
alias maxindex r9
define heavy HASH("StructureSolarPanelReinforced")
define heavydual HASH("StructureSolarPanelDualReinforced")
define normal HASH("StructureSolarPanel")
define normaldual HASH("StructureSolarPanelDual")
define daylightsensor HASH("StructureDaylightSensor")
init:
move state 6
move hrotate 0
move hpark 0
move vpark 0
move ratio 0
move maxratio 0
move maxindex 0
main:
jal loadDevices
bnez daylight day
night:
bnez state day
move horiangle hpark
move vertangle vpark
day:
beq state 6 waitForDay
beq state 5 stackHRotateToRatio
beq state 4 setHRotateByMaxRatio
beq state 3 waitForNight
beq state 2 waitForDay
beq state 1 setPark
returnToMain:
jal setDevices
j main
stackHRotateToRatio:
move sp 0
move maxratio 0
pushRatio:
jal loadDevices
move hrotate sp
mul hrotate hrotate 90
jal setDevices
sleep 15
lb ratio heavy Ratio Maximum
max maxratio maxratio ratio
lb ratio heavydual Ratio Maximum
max maxratio maxratio ratio
lb ratio normal Ratio Maximum
max maxratio maxratio ratio
lb ratio normaldual Ratio Maximum
max maxratio maxratio ratio
push maxratio
blt sp 4 pushRatio
sub state state 1
j returnToMain
setHRotateByMaxRatio:
move maxratio 0
findMax:
ble sp 0 foundMax
pop ratio
max maxratio maxratio ratio
beq ratio maxratio findMaxSet
j findMax
findMaxSet:
move maxratio ratio
move maxindex sp
j findMax
foundMax:
mul hrotate maxindex 90
sub state state 1
j returnToMain
waitForNight:
bgtz daylight returnToMain
sub state state 1
j returnToMain
waitForDay:
blez daylight returnToMain
sub state state 1
j returnToMain
setPark:
move hpark horiangle
move vpark vertangle
sub state state 1
j returnToMain
loadDevices:
lb daylight daylightsensor Activate 3
lb horiangle daylightsensor Horizontal 3
lb vertangle daylightsensor Vertical 3
j ra
setDevices:
add horiangle horiangle hrotate
sub vertangle 90 vertangle
sb heavy Horizontal horiangle
sb heavy Vertical vertangle
sb heavydual Horizontal horiangle
sb heavydual Vertical vertangle
sb normal Horizontal horiangle
sb normal Vertical vertangle
sb normaldual Horizontal horiangle
sb normaldual Vertical vertangle
s db Setting state
yield
j ra