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