Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/surfmode.asm @ 621:e7b675c28896
2.29beta release
author | heinrichsweikamp |
---|---|
date | Sun, 05 Aug 2012 12:20:29 +0200 |
parents | 227eaded4e1b |
children | bab5a9fc1b10 |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
3 | |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; routines for Surface mode | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 10/01/05 | |
21 ; last updated: 080905 | |
22 ; known bugs: | |
23 ; ToDo: | |
24 | |
25 surfloop: | |
26 ; Boot tasks for all modes | |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
27 bcf s_unlock_after_sleep ; Lock sensor results |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
28 call restart_set_modes_and_flags ; Sets decomode flags |
0 | 29 clrf lo |
30 movff lo,char_I_const_ppO2 ; reset to standard mode, OSTC assumes Air breathing at the surface! | |
31 | |
499
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
497
diff
changeset
|
32 call PLED_brightness_full ; max. brightness |
0 | 33 |
34 call I2CReset | |
35 call PLED_boot | |
36 call PLED_serial ; Show OSTC serial and firmware version | |
37 call PLED_clock ; display time | |
38 call update_date ; display date | |
495 | 39 call get_battery_voltage ; get battery voltage |
0 | 40 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine |
41 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values | |
42 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine | |
43 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values | |
44 | |
156 | 45 clrf menupos3 ; Reset Custom views (Default: No custom view) |
46 | |
0 | 47 btfsc gauge_mode ; Ignore in gauge mode |
48 bra surfloop1 | |
49 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
50 bra surfloop1 | |
51 | |
52 ; Startup tasks for decompression modes | |
43 | 53 call PLED_display_cns_surface ; Update surface CNS display (If allowed by CF15) |
0 | 54 call PLED_desaturation_time ; display desaturation time |
55 call PLED_nofly_time ; display nofly time | |
13 | 56 |
0 | 57 call PLED_active_gas_surfmode ; Show start gas |
58 | |
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 | |
519 | 130 call update_batt_voltage ; display battery voltage |
0 | 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 |
107 | 134 call surfcustomview_second ; Do every-second tasks for the custom view area |
110 | 135 call dive_type_icons ; Draw Air/Nitrox/Trimix color icon. |
519 | 136 |
137 ; Every 2 seconds, overwrite with GF value (if needed to display) | |
138 btfsc secs,1 ; Alternating every 2sec (if needed) | |
139 call PLED_display_cns_surface ; Display CNS (if > CF15). | |
140 btfss secs,1 | |
141 call PLED_display_gf_surface ; Display GF (if > CF8). | |
142 | |
143 btfsc enter_error_sleep ; Enter Fatal Error Routine? | |
144 call fatal_error_sleep ; Yes (In Sleepmode.asm!) | |
145 bcf onesecupdate ; every second tasks done | |
0 | 146 |
147 surfloop_loop2: | |
148 ; Tasks approx. every 50ms for all modes | |
149 call test_switches_surfmode ; check switches | |
150 | |
151 ; Sensor tasks for all modes | |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
152 btfss pressure_refresh ; new pressure available? |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
153 bra surfloop_loop2a ; no |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
154 |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
155 btfss s_unlock_after_sleep ; sensor results locked? |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
156 bra surfloop_loop3 ; Yes, ignore |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
157 |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
158 ; New sensor value available |
0 | 159 call update_surf_press ; display surface pressure |
160 call PLED_temp_surfmode ; Displays temperature | |
161 call set_dive_modes ; tests if depth>threshold | |
125 | 162 call altimeter_calc |
163 movf menupos3,W ; Get customview status. | |
164 bnz surfloop_loop3 ; Already used ? | |
165 call altimeter_display | |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
166 call get_battery_voltage ; get battery voltage |
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
167 |
125 | 168 surfloop_loop3: |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
169 bsf s_unlock_after_sleep ; unlock sensor results |
0 | 170 bcf pressure_refresh ; until new pressure is available |
171 | |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
474
diff
changeset
|
172 surfloop_loop2a: |
0 | 173 ; One minute tasks for all modes |
174 btfsc oneminupdate ; do every minute tasks | |
175 call update_surfloop60 ; yes, e.g. update time and date | |
176 | |
177 ; Mode tasks | |
178 btfsc menubit ; Menu? | |
179 goto menu ; Menu! | |
180 btfsc divemode ; Divemode active? | |
181 goto diveloop ; Yes, switch into Divemode! | |
182 btfsc sleepmode ; Sleepmode active? | |
183 goto sleeploop ; Yes, switch into sleepmode! | |
107 | 184 |
185 btfsc toggle_customview ; Next view? | |
186 call surfcustomview_toggle ; Yes, show next customview (and delete this flag) | |
187 | |
0 | 188 ; Check for the different UART flags |
189 btfsc dump_external_eeprom ; Start interface (dumps EEPROM BANK 0 + additional data)? | |
190 goto menu_interface ; Yes! | |
191 btfsc uart_settime ; Sync clock with PC? | |
192 goto sync_clock ; Yes! | |
193 btfsc internal_eeprom_write ; Access internal EEPROM BANK 0 via UART module | |
194 goto internal_eeprom_access_b0 ; Yes! | |
195 btfsc internal_eeprom_write2 ; Access internal EEPROM BANK 1 via UART module | |
196 goto internal_eeprom_access_b1 ; Yes! | |
578 | 197 btfsc internal_eeprom_write3 ; Access internal EEPROM BANK 2 via UART module |
198 goto internal_eeprom_access_b2 ; Yes! | |
0 | 199 btfsc uart_send_hash ; Send MD2 hash values |
200 goto send_md2_hash ; Yes! | |
201 btfsc uart_send_int_eeprom ; Send internal EEPROM BANK 0 | |
202 goto send_int_eeprom_b0 ; Yes! | |
203 btfsc uart_reset_decodata ; Reset Deco Data? | |
204 goto reset_decodata ; Yes! | |
205 btfsc uart_send_int_eeprom2 ; Send internal EEPROM BANK 1 | |
206 goto send_int_eeprom_b1 ; Yes! | |
578 | 207 btfsc uart_send_int_eeprom3 ; Send internal EEPROM BANK 2 |
208 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
|
209 btfsc uart_store_tissue_data ; Store tissue data? |
0 | 210 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
|
211 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
|
212 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
|
213 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
|
214 goto reset_battery_stats ; Yes! |
0 | 215 |
330 | 216 btfsc uart_dump_screen ; Dumps screen contains ? |
331 | 217 call dump_screen ; Yes! |
0 | 218 |
219 bra surfloop_loop ; loop surfacemode | |
220 | |
221 | |
222 update_surfloop60: | |
223 ; One minute tasks for all modes | |
4 | 224 ; call PLED_active_gas_surfmode ; Show start gas / SetPoint |
0 | 225 call update_date ; and date in divemode |
226 call calc_deko_surfmode ; calculate desaturation every minute | |
227 call check_temp_extrema ; check for new temperature extremas | |
228 call PLED_custom_text ; Displays custom text | |
107 | 229 call surfcustomview_minute ; Do every-minute tasks for the custom view area |
0 | 230 |
231 btfsc gauge_mode ; Ignore in gauge mode | |
232 bra update_surfloop60_2 | |
233 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
234 bra update_surfloop60_2 | |
235 | |
236 ; One Minute tasks for deco modes | |
237 call PLED_nofly_time ; display nofly time | |
238 call PLED_desaturation_time ; display desaturation time | |
13 | 239 btfsc premenu ; Not when "Menu?" is displayed! |
240 bra update_surfloop60_2 | |
241 | |
0 | 242 update_surfloop60_2: |
243 bcf oneminupdate | |
244 return | |
245 | |
246 set_leds_surfmode: | |
247 btfsc nofly_active | |
21 | 248 btg LED_blue |
0 | 249 return |
250 | |
353
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
251 ;============================================================================= |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
252 |
0 | 253 calc_deko_surfmode: |
254 ostc_debug 'I' ; Sends debug-information to screen if debugmode active | |
255 | |
256 movff last_surfpressure+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine | |
257 movff last_surfpressure+1,int_I_pres_surface+1 | |
453
38b38b105782
compute desat based on 30min old surface pressure
heinrichsweikamp
parents:
416
diff
changeset
|
258 calc_deko_surfmode2: |
353
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
259 clrf WREG ; Use as buffer |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
260 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
|
261 movlw d'79' ; 79% N2 |
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
262 movff WREG,char_I_N2_ratio ; Air at the Surface |
0 | 263 |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
297
diff
changeset
|
264 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine |
0 | 265 GETCUSTOM8 d'11' ; Saturation multiplier % |
236 | 266 movff WREG,char_I_saturation_multiplier |
0 | 267 GETCUSTOM8 d'12' ; Desaturation multiplier % |
236 | 268 movff WREG,char_I_desaturation_multiplier |
0 | 269 |
116 | 270 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode |
0 | 271 movlb b'00000001' ; select ram bank 1 |
521 | 272 |
0 | 273 ostc_debug 'J' ; Sends debug-information to screen if debugmode active |
274 return | |
275 | |
353
b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents:
344
diff
changeset
|
276 ;============================================================================= |
0 | 277 |
278 test_charger: | |
279 bcf TRISC,1 ; CHRG_OUT output | |
280 bsf CHRG_OUT | |
281 | |
282 bcf cc_active ; Constant Current mode active? | |
283 btfss CHRG_IN ; If CHRG_IN=0 -> CC active | |
284 bsf cc_active ; Constant Current mode Active! | |
285 | |
286 bcf CHRG_OUT | |
287 bsf TRISC,1 ; CHRG_OUT high impedance | |
288 | |
289 WAIT10US d'10' | |
290 | |
291 bcf cv_active ; Constant Voltage mode Active? | |
292 btfss CHRG_IN ; If CHRG_IN=0 -> CV active | |
293 bsf cv_active ; Constant Voltage mode active! | |
294 | |
295 bcf TRISC,1 ; CHRG_OUT output | |
296 bcf CHRG_OUT | |
297 | |
298 btfsc cc_active | |
299 bra show_cc_active | |
300 btfsc cv_active | |
301 bra show_cv_active | |
302 | |
303 bsf TRISC,1 ; CHRG_OUT high impedance | |
304 | |
416
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
305 ; -> Charger inactive or ready |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
306 |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
307 ; Disable when no USB power is attached |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
308 btfsc RCSTA,7 ; RS232 already disabled |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
309 call disable_rs232 ; No, disable UART module |
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
310 |
0 | 311 btfss charge_done ; charge done? |
312 bra test_charger2 ; No, add incomplete cycle! | |
313 | |
314 ; Yes, store all data for complete cycle | |
315 bcf charge_started ; Clear flag | |
316 bcf charge_done ; Clear flag | |
583
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
317 ; Store incomplete cycles |
0 | 318 read_int_eeprom d'50' ; Read byte (stored in EEDATA) |
319 movff EEDATA,temp1 ; Low byte | |
320 read_int_eeprom d'51' ; Read byte (stored in EEDATA) | |
321 movff EEDATA,temp2 ; high byte | |
322 bcf STATUS,C | |
323 movlw d'1' | |
324 addwf temp1 | |
325 movlw d'0' | |
326 addwfc temp2 | |
327 movff temp1,EEDATA | |
328 write_int_eeprom d'50' ; write byte stored in EEDATA | |
329 movff temp2,EEDATA | |
330 write_int_eeprom d'51' ; write byte stored in EEDATA | |
331 | |
332 ; Store complete cycles | |
333 read_int_eeprom d'52' ; Read byte (stored in EEDATA) | |
334 movff EEDATA,temp1 ; Low byte | |
335 read_int_eeprom d'53' ; Read byte (stored in EEDATA) | |
336 movff EEDATA,temp2 ; high byte | |
337 bcf STATUS,C | |
338 movlw d'1' | |
339 addwf temp1 | |
340 movlw d'0' | |
341 addwfc temp2 | |
342 movff temp1,EEDATA | |
343 write_int_eeprom d'52' ; write byte stored in EEDATA | |
344 movff temp2,EEDATA | |
345 write_int_eeprom d'53' ; write byte stored in EEDATA | |
346 ; Store date of complete cycle | |
347 movff month,EEDATA | |
348 write_int_eeprom d'47' | |
349 movff day,EEDATA | |
350 write_int_eeprom d'48' | |
351 movff year,EEDATA | |
352 write_int_eeprom d'49' | |
353 | |
583
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
354 ; Reset lowest battery seen |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
355 movlw LOW d'4200' ; reset to 4.2V |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
356 movwf EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
357 write_int_eeprom d'40' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
358 movlw HIGH d'4200' ; reset to 4.2V |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
359 movwf EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
360 write_int_eeprom d'41' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
361 movff month,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
362 write_int_eeprom d'42' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
363 movff day,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
364 write_int_eeprom d'43' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
365 movff year,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
366 write_int_eeprom d'44' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
367 ; Reset temperature |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
368 SAFE_2BYTE_COPY temperature,lo |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
369 movff lo,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
370 write_int_eeprom d'45' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
371 movff hi,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
372 write_int_eeprom d'46' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
373 ; Reset temperature extremas |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
374 SAFE_2BYTE_COPY temperature,lo |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
375 movff lo,EEDATA ; Reset mimimum extrema |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
376 write_int_eeprom d'54' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
377 movff hi,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
378 write_int_eeprom d'55' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
379 movff month,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
380 write_int_eeprom d'56' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
381 movff day,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
382 write_int_eeprom d'57' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
383 movff year,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
384 write_int_eeprom d'58' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
385 movff lo,EEDATA ; Reset maximum extrema |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
386 write_int_eeprom d'59' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
387 movff hi,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
388 write_int_eeprom d'60' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
389 movff month,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
390 write_int_eeprom d'61' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
391 movff day,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
392 write_int_eeprom d'62' |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
393 movff year,EEDATA |
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
394 write_int_eeprom d'63' |
0 | 395 return |
396 | |
397 test_charger2: | |
398 btfss charge_started ; Did the charger ever start? | |
399 return ; No, quit! | |
400 | |
401 bcf charge_started ; Clear flag | |
583
d14f72af4c07
Battery statistics reset when battery is fully charged
heinrichsweikamp
parents:
578
diff
changeset
|
402 ; Store incomplete cycles |
0 | 403 read_int_eeprom d'50' ; Read byte (stored in EEDATA) |
404 movff EEDATA,temp1 ; Low byte | |
405 read_int_eeprom d'51' ; Read byte (stored in EEDATA) | |
406 movff EEDATA,temp2 ; high byte | |
407 bcf STATUS,C | |
408 movlw d'1' | |
409 addwf temp1 | |
410 movlw d'0' | |
411 addwfc temp2 | |
412 movff temp1,EEDATA | |
413 write_int_eeprom d'50' ; write byte stored in EEDATA | |
414 movff temp2,EEDATA | |
415 write_int_eeprom d'51' ; write byte stored in EEDATA | |
416 return | |
417 | |
418 show_cv_active: ; CV mode | |
486
c7b663939737
making waitms speed-independent, desat-time fix
heinrichsweikamp
parents:
482
diff
changeset
|
419 ; Enable RS232 only when USB power attached |
416
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 WAITMS d'100' |
21 | 424 bcf LED_red |
0 | 425 WAITMS d'100' |
21 | 426 bsf LED_red |
0 | 427 bsf charge_done ; Charge cycle finished |
428 return | |
429 | |
430 show_cc_active: ; CC mode | |
416
3abf9d7dafae
diabling uart module when no USB is attached
heinrichsweikamp
parents:
397
diff
changeset
|
431 ; Enable only when USB power attached |
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 bsf charge_started ; Charger started in CC mode |
436 bcf charge_done ; Charge cycle not finished | |
437 return | |
438 | |
439 | |
440 timeout_premenu: | |
441 btfss premenu ; is "Menu?" displayed? | |
442 return ; No | |
443 incf timeout_counter3,F ; Yes... | |
444 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG | |
445 cpfsgt timeout_counter3 ; ... longer then premenu_timeout | |
446 return ; No! | |
447 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit | |
448 | |
449 call PLED_topline_box_clear ; Clears Bar at the top | |
450 | |
451 btfsc gauge_mode | |
452 bra timeout_premenu2 ; Skip in Gauge mode | |
453 btfsc FLAG_apnoe_mode | |
454 bra timeout_premenu2 ; Skip in Apnoe mode | |
13 | 455 |
0 | 456 timeout_premenu2: |
457 call update_surf_press ; rewrite serial number | |
458 call PLED_serial ; rewrite serial number | |
459 clrf timeout_counter3 ; Also clear timeout | |
460 bcf switch_left ; and debounce switches | |
461 bcf switch_right | |
462 return | |
463 | |
464 test_switches_surfmode: ; checks switches in surfacemode | |
465 btfsc switch_left | |
466 bra test_switches_surfmode2 | |
467 btfsc switch_right | |
468 bra test_switches_surfmode3 | |
469 | |
470 ; No button press, reset timer0 | |
471 bcf T0CON,TMR0ON ; Stop Timer 0 | |
472 bcf INTCON,TMR0IF ; Clear flag | |
473 clrf TMR0H | |
474 clrf TMR0L | |
475 bcf INTCON,INT0IF ; Clear flag | |
476 bcf INTCON3,INT1IF ; Clear flag | |
477 return | |
478 | |
479 test_switches_surfmode3: | |
480 bcf switch_right | |
481 call PLED_topline_box ; Write a filled bar at the top | |
482 WIN_INVERT .1 ; Init new Wordprocessor | |
483 DISPLAYTEXT .4 ;Menu? | |
484 WIN_INVERT .0 ; Init new Wordprocessor | |
485 bsf premenu | |
486 clrf timeout_counter2 | |
487 return | |
488 | |
489 test_switches_surfmode2: | |
576 | 490 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! |
0 | 491 btfss premenu |
13 | 492 bra test_switches_surfmode4 |
0 | 493 bsf menubit ; Enter Menu! |
494 return | |
495 | |
13 | 496 test_switches_surfmode4: |
107 | 497 bsf toggle_customview ; Toggle customview (Cleared in customview.asm) |
13 | 498 return |
0 | 499 |
500 timeout_surfmode: | |
501 incf timeout_counter2,F ; increase timeout counter | |
502 GETCUSTOM8 d'3' ; loads surfloop_timeout into WREG | |
503 addlw d'5' ; adds five seconds in case timout=zero! | |
504 btfsc STATUS,C ; > 255? | |
505 movlw d'255' ; Set to 255... | |
506 decf WREG,F ; Limit to 254 | |
507 cpfsgt timeout_counter2 ; Compare with timeout_counter2 | |
508 return ; return, no timeout | |
509 bsf sleepmode ; Set Flag | |
510 return ; Return |