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