-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menus.inc
284 lines (253 loc) · 6.92 KB
/
Menus.inc
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
;**************************************************************
;*
;* Menu Module
;*
;**************************************************************
;* Notes
;*
;*
;**************************************************************
.DSEG
.CSEG
rjmp IO_SETUP
SET_ROF:
rcall BTM_BUTTON_LOOP
inc BPS
rcall VALID_BPS
rcall CONVERT_BPS_TO_ROFi
rjmp M_ROF_LOOP
IF_SPECIFIC:
ldi Temp_1,0b00001111
and Temp_1,STATE
cpi Temp_1,0b00000010
breq M_BURST
cpi Temp_1,0b00001000
breq M_SOLENOID
ret
IF_ACE_ON:
ldi Temp_1,0b01000000
and Temp_1,STATE
cpi Temp_1,0b01000000
breq M_ACE_DELAY
ret
M_MODE:
rcall MODE_DISPLAY
rcall TRIGGER_LOOP
rcall TOP_BUTTON_LOOP ; Loop until top button is released
M_MODE_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_ROF ; Go to next menu
sbi PORTB,T_Lock
sbis PINB,T_Lock
rjmp LOCKED_MODE
sbis PIND,BTN_2 ; If Bottom Button is pushed
rjmp NEXT_MODE ; Go to next mode
LOCKED_MODE:
rcall MODE_DISPLAY
sbis PIND,TRIGGER ; If Trigger is pulled
rjmp IF_SPECIFIC ; Check if Burts or PR-T mode is selected
rjmp M_MODE_LOOP ; Loop
M_BURST:
rcall TRIGGER_LOOP ; Loop until top button is released
M_BURST_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_ROF ; Go to next menu
sbis PIND,BTN_2 ; If Bottom Button is pushed
rjmp SET_BURST ; Incrament the Rate of Fire
rcall BURST_DISPLAY
sbis PIND,TRIGGER ; If Trigger is pulled
ret ; Exit Menus
rjmp M_BURST_LOOP ; Loop
M_SOLENOID:
rcall TRIGGER_LOOP ; Loop until top button is released
M_SOLENOID_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_ROF ; Go to next menu
sbis PIND,BTN_2 ; If Bottom Button is pushed
rcall TOGGLE_SOLENOID ; Incrament the Rate of Fire
rcall SOLENOID_DISPLAY
sbis PIND,TRIGGER ; If Trigger is pulled
ret ; Exit Menus
rjmp M_SOLENOID_LOOP ; Loop
M_ROF:
rcall TOP_BUTTON_LOOP ; Loop until top button is released
M_ROF_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_ACE ; Go to next menu
sbi PORTB,T_Lock
sbis PINB,T_Lock
rjmp LOCKED_ROF
sbis PIND,BTN_2 ; If Bottom Button is pushed
rjmp SET_ROF ; Incrament the Rate of Fire
LOCKED_ROF:
rcall ROF_DISPLAY
sbis PIND,TRIGGER ; If Trigger is pulled
rjmp VALIDATE_FIXi
rjmp M_ROF_LOOP ; Loop
M_ACE:
rcall VALIDATE_FIXi
rcall TOP_BUTTON_LOOP ; Loop until top button is released
M_ACE_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_FIX ; Go to next menu
sbis PIND,BTN_2 ; If Bottom Button is pushed
rcall TOGGLE_ACE ; Toggle ACE enabled
rcall ACE_DISPLAY
sbis PIND,TRIGGER ; If Trigger is pulled
rjmp IF_ACE_ON ;
rjmp M_ACE_LOOP ; Loop
M_ACE_DELAY:
rcall TRIGGER_LOOP ; Loop until top button is released
M_ACE_DELAY_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_FIX ; Go to next menu
sbis PIND,BTN_2 ; If Bottom Button is pushed
rjmp SET_ACE_DELAY ; Incrament ACE delay
rcall DELAY_DISPLAY
sbis PIND,TRIGGER ; If Trigger is pulled
ret ; Exit Menus
rjmp M_ACE_DELAY_LOOP ; Loop
M_FIX:
sbi PORTB,T_Lock
sbis PINB,T_Lock
rjmp M_CALIBRATE
rcall TOP_BUTTON_LOOP ; Loop until top button is released
M_FIX_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_DWELL ; Go to next menu
sbis PIND,BTN_2 ; If Bottom Button is pushed
rjmp SET_FIX ; Incrament the FIX
rcall FIX_DISPLAY
sbis PIND,TRIGGER ; If Trigger is pulled
ret ; Exit Menus
rjmp M_FIX_LOOP ; Loop
M_DWELL:
rcall TOP_BUTTON_LOOP ; Loop until top button is released
M_DWELL_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_CALIBRATE ; Go to next menu
sbis PIND,BTN_2 ; If Bottom Button is pushed
rjmp SET_DWELL ; Incrament the Rate of Fire
rcall DWELL_DISPLAY
sbis PIND,TRIGGER ; If Trigger is pulled
rjmp VALIDATE_FIXi ; Exit Menus
rjmp M_DWELL_LOOP ; Loop
M_CALIBRATE:
rcall VALIDATE_FIXi
rcall TOP_BUTTON_LOOP ; Loop until top button is released
M_CALIBRATE_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_BRIGHTNESS ; Go to next menu
CHECK_TRIGGER:
sbic PIND,TRIGGER ; If Trigger is pulled
rjmp NO_TRG
ldi ZL,low(2*TRG1) ; Load low part of byte address into ZL
ldi ZH,high(2*TRG1) ; Load high part of byte address into ZH
rjmp CHECK_ACE
NO_TRG:
ldi ZL,low(2*TRG0) ; Load low part of byte address into ZL
ldi ZH,high(2*TRG0) ; Load high part of byte address into ZH
CHECK_ACE:
rcall LOAD_CHARACTER ; Load Message to display
sbis PINB, ACE ;
rjmp NO_ACE
ldi ZL,low(2*ACE1) ; Load low part of byte address into ZL
ldi ZH,high(2*ACE1) ; Load high part of byte address into ZH
rjmp END_CALIBRATE
NO_ACE:
ldi ZL,low(2*ACE0) ; Load low part of byte address into ZL
ldi ZH,high(2*ACE0) ; Load high part of byte address into ZH
END_CALIBRATE:
rcall DISPLAY
rjmp M_CALIBRATE_LOOP ; Loop:
M_BRIGHTNESS:
rcall TOP_BUTTON_LOOP ; Loop until top button is released
M_BRIGHTNESS_LOOP:
sbis PIND,BTN_1 ; If Top Button is pushed
rjmp M_MODE ; Go to next menu
sbis PIND,BTN_2 ; If Bottom Button is pushed
rcall SET_BRIGHTNESS ; Incrament Brightness delay
rcall BRIGHTNESS_DISPLAY
sbis PIND,TRIGGER ; If Trigger is pulled
ret ; Exit Menus
rjmp M_BRIGHTNESS_LOOP ; Loop
;Subroutines
SET_ACE_DELAY:
rcall BTM_BUTTON_LOOP
inc ACEi
rcall VALID_ACE_DELAY
rjmp M_ACE_DELAY_LOOP
SET_BURST:
rcall BTM_BUTTON_LOOP
inc Optns
rcall VALID_BURST
rjmp M_BURST_LOOP
TOGGLE_SOLENOID:
rcall BTM_BUTTON_LOOP
sbrc STATE,SOL ; If Solenoid is on
rjmp SOL_OFF
ori STATE,0b00100000 ; Turn it on
ret
SOL_OFF:
andi STATE,0b11011111 ; Turn it off
ret
TOGGLE_ACE:
rcall BTM_BUTTON_LOOP
sbrc STATE,ACE ; If ACE is on
rjmp ACE_OFF
ori STATE,0b01000000 ; Turn it on
ret
ACE_OFF:
andi STATE,0b10111111 ; Turn it off
ret
SET_BRIGHTNESS:
rcall BTM_BUTTON_LOOP
;100% 0b11111110
; 80% 0b01111110
; 47% 0b00111110
; 18% 0b00011110
lsr DS_BR
ldi Temp_1,0b11111111
sbrs DS_BR,4
mov DS_BR,Temp_1
dec DS_BR
rcall DS1_AWAKE
ret
SET_FIX:
rcall BTM_BUTTON_LOOP
inc FIXi
mov Temp_1,ROFi
sub Temp_1,SOLi
cp Temp_1,FIXi
brsh FIX_VALID_1
clr FIXi
FIX_VALID_1:
ldi Temp_1,95 ; This Line Defines the Maximum FIX Timer Value
cp Temp_1,FIXi
brsh FIX_VALID_2
clr FIXi
FIX_VALID_2:
rjmp M_FIX_LOOP
SET_DWELL:
rcall BTM_BUTTON_LOOP
inc SOLi
ldi Temp_1,30 ; This Line Defines Maximum Solenoid Dwell
cp Temp_1,SOLi
brsh DWELL_VALID
ldi Temp_1,5 ; This Line Defines Minimum Solenoid Dwell
mov SOLi,Temp_1
DWELL_VALID:
rjmp M_DWELL_LOOP
NEXT_MODE:
rcall BTM_BUTTON_LOOP
inc STATE
; ldi Temp_1,0b00001000 ; These lines are used when there are exactly 8 modes
; sbrc STATE, 3 ;
; sub STATE,Temp_1 ;
ldi Temp_1,0b00001111 ; These Lines Are added to skip mode slots (10-16)
and Temp_1,STATE ;
cpi Temp_1,0b00001001 ;
brne NEXT_MODE_END ;
sub STATE,Temp_1 ;
NEXT_MODE_END: ;
rjmp M_MODE_LOOP