Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/surfmode.asm @ 407:47b1135cbff3
BUGFIX: SetPoint recording for logbook
BUGFIX: Divetime seconds synced with stopwatch start
author | heinrichsweikamp |
---|---|
date | Thu, 07 Jul 2011 20:17:01 +0200 |
parents | 6f7965ec5f49 |
children | 3abf9d7dafae |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
3 | |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; routines for Surface mode | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 10/01/05 | |
21 ; last updated: 080905 | |
22 ; known bugs: | |
23 ; ToDo: | |
24 | |
25 surfloop: | |
26 ; Boot tasks for all modes | |
27 call restart_set_modes_and_flags ; Sets decomode flags | |
28 clrf lo | |
29 movff lo,char_I_const_ppO2 ; reset to standard mode, OSTC assumes Air breathing at the surface! | |
30 | |
31 call PLED_brightness_full ;max. brightness | |
32 | |
33 call I2CReset | |
34 call enable_rs232 | |
35 call PLED_boot | |
36 call PLED_serial ; Show OSTC serial and firmware version | |
37 call PLED_clock ; display time | |
38 call update_date ; display date | |
39 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine | |
40 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values | |
41 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine | |
42 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values | |
43 | |
156 | 44 clrf menupos3 ; Reset Custom views (Default: No custom view) |
45 | |
0 | 46 btfsc gauge_mode ; Ignore in gauge mode |
47 bra surfloop1 | |
48 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
49 bra surfloop1 | |
50 | |
51 ; Startup tasks for decompression modes | |
43 | 52 call PLED_display_cns_surface ; Update surface CNS display (If allowed by CF15) |
0 | 53 call PLED_desaturation_time ; display desaturation time |
54 call PLED_nofly_time ; display nofly time | |
13 | 55 |
0 | 56 call PLED_active_gas_surfmode ; Show start gas |
57 call PLED_display_decotype_surface ; Show deco mode (ZH-L16, const. ppO2 or Multi-GF) | |
58 | |
59 surfloop1: | |
60 btfss gauge_mode ; Display only in gauge mode | |
61 bra surfloop2 | |
62 DISPLAYTEXT d'103' ; Gauge mode | |
63 surfloop2: | |
64 btfss FLAG_apnoe_mode ; Display only in Apnoe mode | |
65 bra surfloop3 | |
66 DISPLAYTEXT d'116' ; Apnoe mode | |
67 | |
68 surfloop3: | |
69 ; Startup tasks for all modes | |
70 clrf timeout_counter2 | |
71 clrf timeout_counter3 | |
72 bcf premenu ; clear premenu flag | |
73 bcf menubit ; clear menu flag | |
74 bcf pressure_refresh | |
75 clrf last_pressure+0 | |
76 clrf last_pressure+1 | |
77 clrf last_temperature+0 | |
78 clrf last_temperature+1 | |
79 | |
80 movlw d'5' | |
81 movwf timeout_counter ; reload counter | |
82 | |
21 | 83 bcf LED_blue |
84 bcf LED_red | |
0 | 85 bcf simulatormode_active ; Quit simulator mode (if active) |
86 bcf standalone_simulator ; Quit simulator mode (if active) | |
87 WIN_TOP .0 | |
88 WIN_LEFT .0 | |
89 WIN_FONT FT_SMALL | |
90 WIN_INVERT .0 ; Init new Wordprocessor | |
3 | 91 call PLED_standard_color |
92 | |
0 | 93 bcf switch_left |
94 bcf switch_right | |
4 | 95 call PLED_active_gas_surfmode ; Show start gas / SetPoint |
0 | 96 call PLED_custom_text ; Displays custom text |
100 | 97 clrf cf_checker_counter ; next cf to check |
0 | 98 ostc_debug 'G' ; Sends debug-information to screen if debugmode active |
233 | 99 |
100 ; Desaturation time needs: | |
101 ; int_I_pres_surface | |
102 ; char_I_desaturation_multiplier | |
0 | 103 GETCUSTOM8 d'12' ; Desaturation multiplier % |
233 | 104 movff WREG,char_I_desaturation_multiplier |
105 | |
116 | 106 call deco_calc_desaturation_time ; calculate desaturation time |
0 | 107 movlb b'00000001' ; select ram bank 1 |
108 ostc_debug 'H' ; Sends debug-information to screen if debugmode active | |
109 | |
110 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
111 | |
112 surfloop_loop: | |
113 btfss onesecupdate ; do every second tasks? | |
114 bra surfloop_loop2 ; no, loop | |
115 | |
116 btfss FLAG_const_ppO2_mode ; are we in const. ppO2 mode? | |
117 bra surfloop_loop1 ; No | |
118 ; One Second tasks for ppO2 modes | |
119 | |
285 | 120 bra surfloop_loop1 ; |
0 | 121 |
122 surfloop_loop1: | |
123 ; One Second tasks for all modes | |
124 call PLED_clock ; update clock | |
125 call test_charger ; check if charger IC is active | |
126 call timeout_surfmode ; check timeout | |
127 call get_battery_voltage ; get battery voltage | |
128 call update_batt_voltage ; display battery voltage | |
129 call timeout_premenu ; timeout premenu | |
130 call set_leds_surfmode ; Sets Warning and No-Fly LEDs | |
94 | 131 call check_customfunctions ; Checks CF functions and displays warning symbol if something critical is wrong |
0 | 132 call PLED_display_decotype_surface ; Show deco mode |
107 | 133 call surfcustomview_second ; Do every-second tasks for the custom view area |
110 | 134 call dive_type_icons ; Draw Air/Nitrox/Trimix color icon. |
0 | 135 btfsc enter_error_sleep ; Enter Fatal Error Routine? |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
70
diff
changeset
|
136 call fatal_error_sleep ; Yes (In Sleepmode.asm!) |
0 | 137 bcf onesecupdate ; every second tasks done |
138 | |
139 surfloop_loop2: | |
140 ; Tasks approx. every 50ms for all modes | |
141 call test_switches_surfmode ; check switches | |
142 | |
143 ; Sensor tasks for all modes | |
144 btfsc pressure_refresh ; new pressure available? | |
145 call update_surf_press ; display surface pressure | |
146 btfsc pressure_refresh ; new temperature available? | |
147 call PLED_temp_surfmode ; Displays temperature | |
148 btfsc pressure_refresh ; new pressure available? | |
149 call set_dive_modes ; tests if depth>threshold | |
125 | 150 |
151 ; jDG TESTS ========================= | |
152 btfss pressure_refresh ; new pressure available? | |
153 bra surfloop_loop3 | |
154 call altimeter_calc | |
155 movf menupos3,W ; Get customview status. | |
156 bnz surfloop_loop3 ; Already used ? | |
157 call altimeter_display | |
158 surfloop_loop3: | |
159 ; jDG TESTS ========================= | |
160 | |
0 | 161 bcf pressure_refresh ; until new pressure is available |
162 | |
163 ; One minute tasks for all modes | |
164 btfsc oneminupdate ; do every minute tasks | |
165 call update_surfloop60 ; yes, e.g. update time and date | |
166 | |
167 ; Mode tasks | |
168 btfsc menubit ; Menu? | |
169 goto menu ; Menu! | |
170 btfsc divemode ; Divemode active? | |
171 goto diveloop ; Yes, switch into Divemode! | |
172 btfsc sleepmode ; Sleepmode active? | |
173 goto sleeploop ; Yes, switch into sleepmode! | |
107 | 174 |
175 btfsc toggle_customview ; Next view? | |
176 call surfcustomview_toggle ; Yes, show next customview (and delete this flag) | |
177 | |
0 | 178 ; Check for the different UART flags |
179 btfsc dump_external_eeprom ; Start interface (dumps EEPROM BANK 0 + additional data)? | |
180 goto menu_interface ; Yes! | |
181 btfsc uart_settime ; Sync clock with PC? | |
182 goto sync_clock ; Yes! | |
183 btfsc internal_eeprom_write ; Access internal EEPROM BANK 0 via UART module | |
184 goto internal_eeprom_access_b0 ; Yes! | |
185 btfsc internal_eeprom_write2 ; Access internal EEPROM BANK 1 via UART module | |
186 goto internal_eeprom_access_b1 ; Yes! | |
187 btfsc uart_send_hash ; Send MD2 hash values | |
188 goto send_md2_hash ; Yes! | |
189 btfsc uart_send_int_eeprom ; Send internal EEPROM BANK 0 | |
190 goto send_int_eeprom_b0 ; Yes! | |
191 btfsc uart_reset_decodata ; Reset Deco Data? | |
192 goto reset_decodata ; Yes! | |
193 btfsc uart_send_int_eeprom2 ; Send internal EEPROM BANK 1 | |
194 goto send_int_eeprom_b1 ; Yes! | |
283
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
257
diff
changeset
|
195 btfsc uart_store_tissue_data ; Store tissue data? |
0 | 196 goto uart_store_tissues ; Yes! |
283
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
257
diff
changeset
|
197 btfsc uart_115200_bootloader ; Look for 115200Baud bootloader? |
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
257
diff
changeset
|
198 goto uart_115k_bootloader ; Yes! |
297
ceedf078b2d8
Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents:
285
diff
changeset
|
199 btfsc uart_reset_battery_stats ; Reset Battery stats? |
ceedf078b2d8
Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents:
285
diff
changeset
|
200 goto reset_battery_stats ; Yes! |
0 | 201 |
330 | 202 btfsc uart_dump_screen ; Dumps screen contains ? |
331 | 203 call dump_screen ; Yes! |
0 | 204 |
205 bra surfloop_loop ; loop surfacemode | |
206 | |
207 | |
208 update_surfloop60: | |
209 ; One minute tasks for all modes | |
4 | 210 ; call PLED_active_gas_surfmode ; Show start gas / SetPoint |
0 | 211 call update_date ; and date in divemode |
212 call calc_deko_surfmode ; calculate desaturation every minute | |
213 call check_temp_extrema ; check for new temperature extremas | |
214 call PLED_custom_text ; Displays custom text | |
215 call calc_surface_interval ; Increases Surface-Interval time | |
107 | 216 call surfcustomview_minute ; Do every-minute tasks for the custom view area |
0 | 217 |
218 btfsc gauge_mode ; Ignore in gauge mode | |
219 bra update_surfloop60_2 | |
220 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
221 bra update_surfloop60_2 | |
222 | |
223 ; One Minute tasks for deco modes | |
43 | 224 call PLED_display_cns_surface ; Update surface CNS display (If allowed by CF15) |
0 | 225 call PLED_nofly_time ; display nofly time |
226 call PLED_desaturation_time ; display desaturation time | |
13 | 227 btfsc premenu ; Not when "Menu?" is displayed! |
228 bra update_surfloop60_2 | |
229 | |
0 | 230 update_surfloop60_2: |
231 call nofly_timeout60 ; checks if nofly time is > 0 | |
232 bcf oneminupdate | |
233 return | |
234 | |
235 nofly_timeout60: | |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
236 movf nofly_time+0,W ; Is nofly null ? |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
237 iorwf nofly_time+1,W |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
238 bnz nofly_timeout60_1 ; No... |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
239 |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
240 bcf nofly_active ; Clear flag |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
241 bcf LED_blue ; Clear led. |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
242 return |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
243 |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
244 nofly_timeout60_1: |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
245 bsf nofly_active ; Set flag |
0 | 246 movlw d'1' |
247 subwf nofly_time+0,F | |
248 movlw d'0' | |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
156
diff
changeset
|
249 subwfb nofly_time+1,F ; reduce by one |
0 | 250 return |
251 | |
252 calc_surface_interval: | |
253 movff int_O_desaturation_time+0,lo ; divide by 60... | |
254 movff int_O_desaturation_time+1,hi | |
255 tstfsz lo ;=0? | |
256 bra calc_surface_interval2 ; No | |
257 tstfsz hi ;=0? | |
258 bra calc_surface_interval2 ; No | |
259 clrf surface_interval+0 | |
260 clrf surface_interval+1 ; Clear surface interval timer | |
261 return | |
262 | |
263 calc_surface_interval2: ; Increase surface interval timer | |
264 movlw d'1' | |
265 addwf surface_interval+0,F | |
266 movlw d'0' | |
267 addwfc surface_interval+1,F | |
268 return | |
269 | |
270 set_leds_surfmode: | |
271 btfsc nofly_active | |
21 | 272 btg LED_blue |
0 | 273 return |
274 | |
353
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
275 ;============================================================================= |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
276 |
0 | 277 calc_deko_surfmode: |
278 ostc_debug 'I' ; Sends debug-information to screen if debugmode active | |
279 | |
280 movff last_surfpressure+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine | |
281 movff last_surfpressure+1,int_I_pres_surface+1 | |
353
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
282 clrf WREG ; Use as buffer |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
283 movff WREG,char_I_He_ratio ; No He at the Surface |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
284 movlw d'79' ; 79% N2 |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
285 movff WREG,char_I_N2_ratio ; Air at the Surface |
0 | 286 |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
297
diff
changeset
|
287 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine |
0 | 288 GETCUSTOM8 d'11' ; Saturation multiplier % |
236 | 289 movff WREG,char_I_saturation_multiplier |
0 | 290 GETCUSTOM8 d'12' ; Desaturation multiplier % |
236 | 291 movff WREG,char_I_desaturation_multiplier |
0 | 292 |
116 | 293 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode |
0 | 294 movlb b'00000001' ; select ram bank 1 |
295 ostc_debug 'J' ; Sends debug-information to screen if debugmode active | |
254 | 296 |
257
f8f869bafd92
Use timer TMR3 to limit loops in calc_hauptroutine_calc_deco()
JeanDo
parents:
254
diff
changeset
|
297 movff int_O_desaturation_time+0,desaturation_time_buffer+0 |
f8f869bafd92
Use timer TMR3 to limit loops in calc_hauptroutine_calc_deco()
JeanDo
parents:
254
diff
changeset
|
298 movff int_O_desaturation_time+1,desaturation_time_buffer+1 |
254 | 299 |
0 | 300 return |
301 | |
353
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
302 ;============================================================================= |
0 | 303 |
304 test_charger: | |
305 bcf TRISC,1 ; CHRG_OUT output | |
306 bsf CHRG_OUT | |
307 | |
308 bcf cc_active ; Constant Current mode active? | |
309 btfss CHRG_IN ; If CHRG_IN=0 -> CC active | |
310 bsf cc_active ; Constant Current mode Active! | |
311 | |
312 bcf CHRG_OUT | |
313 bsf TRISC,1 ; CHRG_OUT high impedance | |
314 | |
315 WAIT10US d'10' | |
316 | |
317 bcf cv_active ; Constant Voltage mode Active? | |
318 btfss CHRG_IN ; If CHRG_IN=0 -> CV active | |
319 bsf cv_active ; Constant Voltage mode active! | |
320 | |
321 bcf TRISC,1 ; CHRG_OUT output | |
322 bcf CHRG_OUT | |
323 | |
324 btfsc cc_active | |
325 bra show_cc_active | |
326 btfsc cv_active | |
327 bra show_cv_active | |
328 | |
329 bsf TRISC,1 ; CHRG_OUT high impedance | |
330 | |
331 ; Charger inactive or ready | |
332 btfss charge_done ; charge done? | |
333 bra test_charger2 ; No, add incomplete cycle! | |
334 | |
335 ; Yes, store all data for complete cycle | |
336 bcf charge_started ; Clear flag | |
337 bcf charge_done ; Clear flag | |
338 ; Store incomplete/total cycles | |
339 read_int_eeprom d'50' ; Read byte (stored in EEDATA) | |
340 movff EEDATA,temp1 ; Low byte | |
341 read_int_eeprom d'51' ; Read byte (stored in EEDATA) | |
342 movff EEDATA,temp2 ; high byte | |
343 bcf STATUS,C | |
344 movlw d'1' | |
345 addwf temp1 | |
346 movlw d'0' | |
347 addwfc temp2 | |
348 movff temp1,EEDATA | |
349 write_int_eeprom d'50' ; write byte stored in EEDATA | |
350 movff temp2,EEDATA | |
351 write_int_eeprom d'51' ; write byte stored in EEDATA | |
352 | |
353 ; Store complete cycles | |
354 read_int_eeprom d'52' ; Read byte (stored in EEDATA) | |
355 movff EEDATA,temp1 ; Low byte | |
356 read_int_eeprom d'53' ; Read byte (stored in EEDATA) | |
357 movff EEDATA,temp2 ; high byte | |
358 bcf STATUS,C | |
359 movlw d'1' | |
360 addwf temp1 | |
361 movlw d'0' | |
362 addwfc temp2 | |
363 movff temp1,EEDATA | |
364 write_int_eeprom d'52' ; write byte stored in EEDATA | |
365 movff temp2,EEDATA | |
366 write_int_eeprom d'53' ; write byte stored in EEDATA | |
367 ; Store date of complete cycle | |
368 movff month,EEDATA | |
369 write_int_eeprom d'47' | |
370 movff day,EEDATA | |
371 write_int_eeprom d'48' | |
372 movff year,EEDATA | |
373 write_int_eeprom d'49' | |
374 | |
375 return | |
376 | |
377 test_charger2: | |
378 btfss charge_started ; Did the charger ever start? | |
379 return ; No, quit! | |
380 | |
381 bcf charge_started ; Clear flag | |
382 ; Store incomplete/total cycles | |
383 read_int_eeprom d'50' ; Read byte (stored in EEDATA) | |
384 movff EEDATA,temp1 ; Low byte | |
385 read_int_eeprom d'51' ; Read byte (stored in EEDATA) | |
386 movff EEDATA,temp2 ; high byte | |
387 bcf STATUS,C | |
388 movlw d'1' | |
389 addwf temp1 | |
390 movlw d'0' | |
391 addwfc temp2 | |
392 movff temp1,EEDATA | |
393 write_int_eeprom d'50' ; write byte stored in EEDATA | |
394 movff temp2,EEDATA | |
395 write_int_eeprom d'51' ; write byte stored in EEDATA | |
396 return | |
397 | |
398 show_cv_active: ; CV mode | |
21 | 399 bsf LED_red |
0 | 400 WAITMS d'100' |
21 | 401 bcf LED_red |
0 | 402 WAITMS d'100' |
21 | 403 bsf LED_red |
0 | 404 bsf charge_done ; Charge cycle finished |
405 return | |
406 | |
407 show_cc_active: ; CC mode | |
21 | 408 bsf LED_red |
0 | 409 bsf charge_started ; Charger started in CC mode |
410 bcf charge_done ; Charge cycle not finished | |
411 return | |
412 | |
413 | |
414 timeout_premenu: | |
415 btfss premenu ; is "Menu?" displayed? | |
416 return ; No | |
417 incf timeout_counter3,F ; Yes... | |
418 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG | |
419 cpfsgt timeout_counter3 ; ... longer then premenu_timeout | |
420 return ; No! | |
421 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit | |
422 | |
423 call PLED_topline_box_clear ; Clears Bar at the top | |
424 | |
425 btfsc gauge_mode | |
426 bra timeout_premenu2 ; Skip in Gauge mode | |
427 btfsc FLAG_apnoe_mode | |
428 bra timeout_premenu2 ; Skip in Apnoe mode | |
13 | 429 |
0 | 430 timeout_premenu2: |
431 call update_surf_press ; rewrite serial number | |
432 call PLED_serial ; rewrite serial number | |
433 clrf timeout_counter3 ; Also clear timeout | |
434 bcf switch_left ; and debounce switches | |
435 bcf switch_right | |
436 return | |
437 | |
438 test_switches_surfmode: ; checks switches in surfacemode | |
439 btfsc switch_left | |
440 bra test_switches_surfmode2 | |
441 btfsc switch_right | |
442 bra test_switches_surfmode3 | |
443 | |
444 ; No button press, reset timer0 | |
445 bcf T0CON,TMR0ON ; Stop Timer 0 | |
446 bcf INTCON,TMR0IF ; Clear flag | |
447 clrf TMR0H | |
448 clrf TMR0L | |
449 bcf INTCON,INT0IF ; Clear flag | |
450 bcf INTCON3,INT1IF ; Clear flag | |
451 return | |
452 | |
453 test_switches_surfmode3: | |
454 bcf switch_right | |
455 call PLED_topline_box ; Write a filled bar at the top | |
456 WIN_INVERT .1 ; Init new Wordprocessor | |
457 DISPLAYTEXT .4 ;Menu? | |
458 WIN_INVERT .0 ; Init new Wordprocessor | |
459 bsf premenu | |
460 clrf timeout_counter2 | |
461 return | |
462 | |
463 test_switches_surfmode2: | |
464 bcf switch_left | |
465 btfss premenu | |
13 | 466 bra test_switches_surfmode4 |
0 | 467 bsf menubit ; Enter Menu! |
468 return | |
469 | |
13 | 470 test_switches_surfmode4: |
107 | 471 bsf toggle_customview ; Toggle customview (Cleared in customview.asm) |
13 | 472 return |
0 | 473 |
474 timeout_surfmode: | |
475 incf timeout_counter2,F ; increase timeout counter | |
476 GETCUSTOM8 d'3' ; loads surfloop_timeout into WREG | |
477 addlw d'5' ; adds five seconds in case timout=zero! | |
478 btfsc STATUS,C ; > 255? | |
479 movlw d'255' ; Set to 255... | |
480 decf WREG,F ; Limit to 254 | |
481 cpfsgt timeout_counter2 ; Compare with timeout_counter2 | |
482 return ; return, no timeout | |
483 bsf sleepmode ; Set Flag | |
484 return ; Return |