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