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