Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/surfmode.asm @ 517:a73a452ca155
Backed out changeset: b498245da3f1
author | heinrichsweikamp |
---|---|
date | Mon, 05 Dec 2011 20:58:10 +0100 |
parents | 2ac77db9c150 |
children | 154b1d1c489e |
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 | |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
27 bcf s_unlock_after_sleep ; Lock sensor results |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
28 call restart_set_modes_and_flags ; Sets decomode flags |
0 | 29 clrf lo |
30 movff lo,char_I_const_ppO2 ; reset to standard mode, OSTC assumes Air breathing at the surface! | |
31 | |
499
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
497
diff
changeset
|
32 call PLED_brightness_full ; max. brightness |
0 | 33 |
34 call I2CReset | |
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 | |
495 | 39 call get_battery_voltage ; get battery voltage |
0 | 40 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine |
41 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values | |
42 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine | |
43 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values | |
44 | |
156 | 45 clrf menupos3 ; Reset Custom views (Default: No custom view) |
46 | |
0 | 47 btfsc gauge_mode ; Ignore in gauge mode |
48 bra surfloop1 | |
49 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
50 bra surfloop1 | |
51 | |
52 ; Startup tasks for decompression modes | |
43 | 53 call PLED_display_cns_surface ; Update surface CNS display (If allowed by CF15) |
0 | 54 call PLED_desaturation_time ; display desaturation time |
55 call PLED_nofly_time ; display nofly time | |
13 | 56 |
0 | 57 call PLED_active_gas_surfmode ; Show start gas |
58 call PLED_display_decotype_surface ; Show deco mode (ZH-L16, const. ppO2 or Multi-GF) | |
59 | |
60 surfloop1: | |
61 btfss gauge_mode ; Display only in gauge mode | |
62 bra surfloop2 | |
63 DISPLAYTEXT d'103' ; Gauge mode | |
64 surfloop2: | |
65 btfss FLAG_apnoe_mode ; Display only in Apnoe mode | |
66 bra surfloop3 | |
67 DISPLAYTEXT d'116' ; Apnoe mode | |
68 | |
69 surfloop3: | |
70 ; Startup tasks for all modes | |
71 clrf timeout_counter2 | |
72 clrf timeout_counter3 | |
73 bcf premenu ; clear premenu flag | |
74 bcf menubit ; clear menu flag | |
474 | 75 clrf timer1int_counter2 ; reset state counter |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
76 bcf pressure_refresh ; Start new sensor run |
0 | 77 clrf last_pressure+0 |
78 clrf last_pressure+1 | |
79 clrf last_temperature+0 | |
80 clrf last_temperature+1 | |
81 | |
82 movlw d'5' | |
83 movwf timeout_counter ; reload counter | |
84 | |
21 | 85 bcf LED_blue |
86 bcf LED_red | |
0 | 87 bcf simulatormode_active ; Quit simulator mode (if active) |
88 bcf standalone_simulator ; Quit simulator mode (if active) | |
89 WIN_TOP .0 | |
90 WIN_LEFT .0 | |
91 WIN_FONT FT_SMALL | |
92 WIN_INVERT .0 ; Init new Wordprocessor | |
3 | 93 call PLED_standard_color |
94 | |
0 | 95 bcf switch_left |
96 bcf switch_right | |
4 | 97 call PLED_active_gas_surfmode ; Show start gas / SetPoint |
0 | 98 call PLED_custom_text ; Displays custom text |
100 | 99 clrf cf_checker_counter ; next cf to check |
0 | 100 ostc_debug 'G' ; Sends debug-information to screen if debugmode active |
233 | 101 |
102 ; Desaturation time needs: | |
103 ; int_I_pres_surface | |
104 ; char_I_desaturation_multiplier | |
469 | 105 movlw d'0' |
106 movff WREG,char_I_deco_model ; ZH-L16 | |
0 | 107 GETCUSTOM8 d'12' ; Desaturation multiplier % |
233 | 108 movff WREG,char_I_desaturation_multiplier |
109 | |
116 | 110 call deco_calc_desaturation_time ; calculate desaturation time |
0 | 111 movlb b'00000001' ; select ram bank 1 |
112 ostc_debug 'H' ; Sends debug-information to screen if debugmode active | |
113 | |
114 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
115 | |
116 surfloop_loop: | |
117 btfss onesecupdate ; do every second tasks? | |
118 bra surfloop_loop2 ; no, loop | |
119 | |
120 btfss FLAG_const_ppO2_mode ; are we in const. ppO2 mode? | |
121 bra surfloop_loop1 ; No | |
122 ; One Second tasks for ppO2 modes | |
123 | |
285 | 124 bra surfloop_loop1 ; |
0 | 125 |
126 surfloop_loop1: | |
127 ; One Second tasks for all modes | |
128 call PLED_clock ; update clock | |
129 call test_charger ; check if charger IC is active | |
130 call timeout_surfmode ; check timeout | |
131 call update_batt_voltage ; display battery voltage | |
132 call timeout_premenu ; timeout premenu | |
133 call set_leds_surfmode ; Sets Warning and No-Fly LEDs | |
94 | 134 call check_customfunctions ; Checks CF functions and displays warning symbol if something critical is wrong |
0 | 135 call PLED_display_decotype_surface ; Show deco mode |
107 | 136 call surfcustomview_second ; Do every-second tasks for the custom view area |
110 | 137 call dive_type_icons ; Draw Air/Nitrox/Trimix color icon. |
0 | 138 btfsc enter_error_sleep ; Enter Fatal Error Routine? |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
70
diff
changeset
|
139 call fatal_error_sleep ; Yes (In Sleepmode.asm!) |
0 | 140 bcf onesecupdate ; every second tasks done |
141 | |
142 surfloop_loop2: | |
143 ; Tasks approx. every 50ms for all modes | |
144 call test_switches_surfmode ; check switches | |
145 | |
146 ; Sensor tasks for all modes | |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
147 btfss pressure_refresh ; new pressure available? |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
148 bra surfloop_loop2a ; no |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
149 |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
150 btfss s_unlock_after_sleep ; sensor results locked? |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
151 bra surfloop_loop3 ; Yes, ignore |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
152 |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
153 ; New sensor value available |
0 | 154 call update_surf_press ; display surface pressure |
155 call PLED_temp_surfmode ; Displays temperature | |
156 call set_dive_modes ; tests if depth>threshold | |
125 | 157 call altimeter_calc |
158 movf menupos3,W ; Get customview status. | |
159 bnz surfloop_loop3 ; Already used ? | |
160 call altimeter_display | |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
161 call get_battery_voltage ; get battery voltage |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
162 |
125 | 163 surfloop_loop3: |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
164 bsf s_unlock_after_sleep ; unlock sensor results |
0 | 165 bcf pressure_refresh ; until new pressure is available |
166 | |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
167 surfloop_loop2a: |
0 | 168 ; One minute tasks for all modes |
169 btfsc oneminupdate ; do every minute tasks | |
170 call update_surfloop60 ; yes, e.g. update time and date | |
171 | |
172 ; Mode tasks | |
173 btfsc menubit ; Menu? | |
174 goto menu ; Menu! | |
175 btfsc divemode ; Divemode active? | |
176 goto diveloop ; Yes, switch into Divemode! | |
177 btfsc sleepmode ; Sleepmode active? | |
178 goto sleeploop ; Yes, switch into sleepmode! | |
107 | 179 |
180 btfsc toggle_customview ; Next view? | |
181 call surfcustomview_toggle ; Yes, show next customview (and delete this flag) | |
182 | |
0 | 183 ; Check for the different UART flags |
184 btfsc dump_external_eeprom ; Start interface (dumps EEPROM BANK 0 + additional data)? | |
185 goto menu_interface ; Yes! | |
186 btfsc uart_settime ; Sync clock with PC? | |
187 goto sync_clock ; Yes! | |
188 btfsc internal_eeprom_write ; Access internal EEPROM BANK 0 via UART module | |
189 goto internal_eeprom_access_b0 ; Yes! | |
190 btfsc internal_eeprom_write2 ; Access internal EEPROM BANK 1 via UART module | |
191 goto internal_eeprom_access_b1 ; Yes! | |
192 btfsc uart_send_hash ; Send MD2 hash values | |
193 goto send_md2_hash ; Yes! | |
194 btfsc uart_send_int_eeprom ; Send internal EEPROM BANK 0 | |
195 goto send_int_eeprom_b0 ; Yes! | |
196 btfsc uart_reset_decodata ; Reset Deco Data? | |
197 goto reset_decodata ; Yes! | |
198 btfsc uart_send_int_eeprom2 ; Send internal EEPROM BANK 1 | |
199 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
|
200 btfsc uart_store_tissue_data ; Store tissue data? |
0 | 201 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
|
202 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
|
203 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
|
204 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
|
205 goto reset_battery_stats ; Yes! |
0 | 206 |
330 | 207 btfsc uart_dump_screen ; Dumps screen contains ? |
331 | 208 call dump_screen ; Yes! |
0 | 209 |
210 bra surfloop_loop ; loop surfacemode | |
211 | |
212 | |
213 update_surfloop60: | |
214 ; One minute tasks for all modes | |
4 | 215 ; call PLED_active_gas_surfmode ; Show start gas / SetPoint |
0 | 216 call update_date ; and date in divemode |
217 call calc_deko_surfmode ; calculate desaturation every minute | |
218 call check_temp_extrema ; check for new temperature extremas | |
219 call PLED_custom_text ; Displays custom text | |
107 | 220 call surfcustomview_minute ; Do every-minute tasks for the custom view area |
0 | 221 |
222 btfsc gauge_mode ; Ignore in gauge mode | |
223 bra update_surfloop60_2 | |
224 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
225 bra update_surfloop60_2 | |
226 | |
227 ; One Minute tasks for deco modes | |
43 | 228 call PLED_display_cns_surface ; Update surface CNS display (If allowed by CF15) |
0 | 229 call PLED_nofly_time ; display nofly time |
230 call PLED_desaturation_time ; display desaturation time | |
13 | 231 btfsc premenu ; Not when "Menu?" is displayed! |
232 bra update_surfloop60_2 | |
233 | |
0 | 234 update_surfloop60_2: |
235 bcf oneminupdate | |
236 return | |
237 | |
238 set_leds_surfmode: | |
239 btfsc nofly_active | |
21 | 240 btg LED_blue |
0 | 241 return |
242 | |
353
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
243 ;============================================================================= |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
244 |
0 | 245 calc_deko_surfmode: |
246 ostc_debug 'I' ; Sends debug-information to screen if debugmode active | |
247 | |
248 movff last_surfpressure+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine | |
249 movff last_surfpressure+1,int_I_pres_surface+1 | |
453
38b38b105782
compute desat based on 30min old surface pressure
heinrichsweikamp
parents:
416
diff
changeset
|
250 calc_deko_surfmode2: |
353
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
251 clrf WREG ; Use as buffer |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
252 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
|
253 movlw d'79' ; 79% N2 |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
254 movff WREG,char_I_N2_ratio ; Air at the Surface |
0 | 255 |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
297
diff
changeset
|
256 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine |
0 | 257 GETCUSTOM8 d'11' ; Saturation multiplier % |
236 | 258 movff WREG,char_I_saturation_multiplier |
0 | 259 GETCUSTOM8 d'12' ; Desaturation multiplier % |
236 | 260 movff WREG,char_I_desaturation_multiplier |
0 | 261 |
116 | 262 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode |
0 | 263 movlb b'00000001' ; select ram bank 1 |
264 ostc_debug 'J' ; Sends debug-information to screen if debugmode active | |
265 return | |
266 | |
353
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
267 ;============================================================================= |
0 | 268 |
269 test_charger: | |
270 bcf TRISC,1 ; CHRG_OUT output | |
271 bsf CHRG_OUT | |
272 | |
273 bcf cc_active ; Constant Current mode active? | |
274 btfss CHRG_IN ; If CHRG_IN=0 -> CC active | |
275 bsf cc_active ; Constant Current mode Active! | |
276 | |
277 bcf CHRG_OUT | |
278 bsf TRISC,1 ; CHRG_OUT high impedance | |
279 | |
280 WAIT10US d'10' | |
281 | |
282 bcf cv_active ; Constant Voltage mode Active? | |
283 btfss CHRG_IN ; If CHRG_IN=0 -> CV active | |
284 bsf cv_active ; Constant Voltage mode active! | |
285 | |
286 bcf TRISC,1 ; CHRG_OUT output | |
287 bcf CHRG_OUT | |
288 | |
289 btfsc cc_active | |
290 bra show_cc_active | |
291 btfsc cv_active | |
292 bra show_cv_active | |
293 | |
294 bsf TRISC,1 ; CHRG_OUT high impedance | |
295 | |
416
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
296 ; -> Charger inactive or ready |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
297 |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
298 ; Disable when no USB power is attached |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
299 btfsc RCSTA,7 ; RS232 already disabled |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
300 call disable_rs232 ; No, disable UART module |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
301 |
0 | 302 btfss charge_done ; charge done? |
303 bra test_charger2 ; No, add incomplete cycle! | |
304 | |
305 ; Yes, store all data for complete cycle | |
306 bcf charge_started ; Clear flag | |
307 bcf charge_done ; Clear flag | |
308 ; Store incomplete/total cycles | |
309 read_int_eeprom d'50' ; Read byte (stored in EEDATA) | |
310 movff EEDATA,temp1 ; Low byte | |
311 read_int_eeprom d'51' ; Read byte (stored in EEDATA) | |
312 movff EEDATA,temp2 ; high byte | |
313 bcf STATUS,C | |
314 movlw d'1' | |
315 addwf temp1 | |
316 movlw d'0' | |
317 addwfc temp2 | |
318 movff temp1,EEDATA | |
319 write_int_eeprom d'50' ; write byte stored in EEDATA | |
320 movff temp2,EEDATA | |
321 write_int_eeprom d'51' ; write byte stored in EEDATA | |
322 | |
323 ; Store complete cycles | |
324 read_int_eeprom d'52' ; Read byte (stored in EEDATA) | |
325 movff EEDATA,temp1 ; Low byte | |
326 read_int_eeprom d'53' ; Read byte (stored in EEDATA) | |
327 movff EEDATA,temp2 ; high byte | |
328 bcf STATUS,C | |
329 movlw d'1' | |
330 addwf temp1 | |
331 movlw d'0' | |
332 addwfc temp2 | |
333 movff temp1,EEDATA | |
334 write_int_eeprom d'52' ; write byte stored in EEDATA | |
335 movff temp2,EEDATA | |
336 write_int_eeprom d'53' ; write byte stored in EEDATA | |
337 ; Store date of complete cycle | |
338 movff month,EEDATA | |
339 write_int_eeprom d'47' | |
340 movff day,EEDATA | |
341 write_int_eeprom d'48' | |
342 movff year,EEDATA | |
343 write_int_eeprom d'49' | |
344 | |
345 return | |
346 | |
347 test_charger2: | |
348 btfss charge_started ; Did the charger ever start? | |
349 return ; No, quit! | |
350 | |
351 bcf charge_started ; Clear flag | |
352 ; Store incomplete/total cycles | |
353 read_int_eeprom d'50' ; Read byte (stored in EEDATA) | |
354 movff EEDATA,temp1 ; Low byte | |
355 read_int_eeprom d'51' ; Read byte (stored in EEDATA) | |
356 movff EEDATA,temp2 ; high byte | |
357 bcf STATUS,C | |
358 movlw d'1' | |
359 addwf temp1 | |
360 movlw d'0' | |
361 addwfc temp2 | |
362 movff temp1,EEDATA | |
363 write_int_eeprom d'50' ; write byte stored in EEDATA | |
364 movff temp2,EEDATA | |
365 write_int_eeprom d'51' ; write byte stored in EEDATA | |
366 return | |
367 | |
368 show_cv_active: ; CV mode | |
486
c7b663939737
making waitms speed-independent, desat-time fix
heinrichsweikamp
parents:
482
diff
changeset
|
369 ; Enable RS232 only when USB power attached |
416
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
370 btfss RCSTA,7 ; RS232 already enabled? |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
371 call enable_rs232 ; No, start UART module |
21 | 372 bsf LED_red |
0 | 373 WAITMS d'100' |
21 | 374 bcf LED_red |
0 | 375 WAITMS d'100' |
21 | 376 bsf LED_red |
0 | 377 bsf charge_done ; Charge cycle finished |
378 return | |
379 | |
380 show_cc_active: ; CC mode | |
416
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
381 ; Enable only when USB power attached |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
382 btfss RCSTA,7 ; RS232 already enabled? |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
383 call enable_rs232 ; No, start UART module |
21 | 384 bsf LED_red |
0 | 385 bsf charge_started ; Charger started in CC mode |
386 bcf charge_done ; Charge cycle not finished | |
387 return | |
388 | |
389 | |
390 timeout_premenu: | |
391 btfss premenu ; is "Menu?" displayed? | |
392 return ; No | |
393 incf timeout_counter3,F ; Yes... | |
394 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG | |
395 cpfsgt timeout_counter3 ; ... longer then premenu_timeout | |
396 return ; No! | |
397 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit | |
398 | |
399 call PLED_topline_box_clear ; Clears Bar at the top | |
400 | |
401 btfsc gauge_mode | |
402 bra timeout_premenu2 ; Skip in Gauge mode | |
403 btfsc FLAG_apnoe_mode | |
404 bra timeout_premenu2 ; Skip in Apnoe mode | |
13 | 405 |
0 | 406 timeout_premenu2: |
407 call update_surf_press ; rewrite serial number | |
408 call PLED_serial ; rewrite serial number | |
409 clrf timeout_counter3 ; Also clear timeout | |
410 bcf switch_left ; and debounce switches | |
411 bcf switch_right | |
412 return | |
413 | |
414 test_switches_surfmode: ; checks switches in surfacemode | |
415 btfsc switch_left | |
416 bra test_switches_surfmode2 | |
417 btfsc switch_right | |
418 bra test_switches_surfmode3 | |
419 | |
420 ; No button press, reset timer0 | |
421 bcf T0CON,TMR0ON ; Stop Timer 0 | |
422 bcf INTCON,TMR0IF ; Clear flag | |
423 clrf TMR0H | |
424 clrf TMR0L | |
425 bcf INTCON,INT0IF ; Clear flag | |
426 bcf INTCON3,INT1IF ; Clear flag | |
427 return | |
428 | |
429 test_switches_surfmode3: | |
430 bcf switch_right | |
431 call PLED_topline_box ; Write a filled bar at the top | |
432 WIN_INVERT .1 ; Init new Wordprocessor | |
433 DISPLAYTEXT .4 ;Menu? | |
434 WIN_INVERT .0 ; Init new Wordprocessor | |
435 bsf premenu | |
436 clrf timeout_counter2 | |
437 return | |
438 | |
439 test_switches_surfmode2: | |
440 bcf switch_left | |
441 btfss premenu | |
13 | 442 bra test_switches_surfmode4 |
0 | 443 bsf menubit ; Enter Menu! |
444 return | |
445 | |
13 | 446 test_switches_surfmode4: |
107 | 447 bsf toggle_customview ; Toggle customview (Cleared in customview.asm) |
13 | 448 return |
0 | 449 |
450 timeout_surfmode: | |
451 incf timeout_counter2,F ; increase timeout counter | |
452 GETCUSTOM8 d'3' ; loads surfloop_timeout into WREG | |
453 addlw d'5' ; adds five seconds in case timout=zero! | |
454 btfsc STATUS,C ; > 255? | |
455 movlw d'255' ; Set to 255... | |
456 decf WREG,F ; Limit to 254 | |
457 cpfsgt timeout_counter2 ; Compare with timeout_counter2 | |
458 return ; return, no timeout | |
459 bsf sleepmode ; Set Flag | |
460 return ; Return |