annotate code_part1/OSTC_code_asm_part1/surfmode.asm @ 785:b0c96aaa86e4

add ceiling display, no turkish language support anymore
author heinrichsweikamp
date Sun, 29 Jun 2014 15:13:32 +0200
parents 4452837aff37
children 380a07e4fc15
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1 ; OSTC - diving computer code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
4 ; This program is free software: you can redistribute it and/or modify
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
5 ; it under the terms of the GNU General Public License as published by
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
6 ; the Free Software Foundation, either version 3 of the License, or
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
7 ; (at your option) any later version.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
8
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
9 ; This program is distributed in the hope that it will be useful,
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
12 ; GNU General Public License for more details.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
13
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
14 ; You should have received a copy of the GNU General Public License
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
17
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
18 ; routines for Surface mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
20 ; written: 10/01/05
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
21 ; last updated: 080905
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
22 ; known bugs:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
23 ; ToDo:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
24
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
25 surfloop:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
26 ; Boot tasks for all modes
720
4452837aff37 Vault date and time during update
heinrichsweikamp
parents: 717
diff changeset
27 call DISPLAY_boot
4452837aff37 Vault date and time during update
heinrichsweikamp
parents: 717
diff changeset
28 surfloop_no_display_init:
4452837aff37 Vault date and time during update
heinrichsweikamp
parents: 717
diff changeset
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
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
32 clrf lo
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
33 movff lo,char_I_const_ppO2 ; reset to standard mode, OSTC assumes Air breathing at the surface!
720
4452837aff37 Vault date and time during update
heinrichsweikamp
parents: 717
diff changeset
34 call I2CReset
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
35 call DISP_brightness_full ; max. brightness
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
36 call DISP_serial ; Show OSTC serial and firmware version
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
37 call DISP_clock ; display time
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
38 call update_date ; display date
495
a5235ae970af Turkish language added
heinrichsweikamp
parents: 486
diff changeset
39 call get_battery_voltage ; get battery voltage
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
40 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
41 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
42 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
43 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
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
3f4d60385f9c custom view default for surfacemode
heinrichsweikamp
parents: 125
diff changeset
49
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
50 btfsc gauge_mode ; Ignore in gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
51 bra surfloop1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
52 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
53 bra surfloop1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
54
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
55 ; Startup tasks for decompression modes
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
56 call DISP_display_cns_surface ; Update surface CNS display (If allowed by CF15)
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
57 call DISP_desaturation_time ; display desaturation time
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
58 call DISP_nofly_time ; display nofly time
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
59
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
60 call DISP_active_gas_surfmode ; Show start gas
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
61
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
62 surfloop1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
63 btfss gauge_mode ; Display only in gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
64 bra surfloop2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
65 DISPLAYTEXT d'103' ; Gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
66 surfloop2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
67 btfss FLAG_apnoe_mode ; Display only in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
68 bra surfloop3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
69 DISPLAYTEXT d'116' ; Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
70
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
71 surfloop3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
72 ; Startup tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
73 clrf timeout_counter2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
74 clrf timeout_counter3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
75 bcf premenu ; clear premenu flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
76 bcf menubit ; clear menu flag
474
c083f5b9168c Reset sensor state when waking up
heinrichsweikamp
parents: 469
diff changeset
77 clrf timer1int_counter2 ; reset state counter
482
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
78 bcf pressure_refresh ; Start new sensor run
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
79 clrf last_pressure+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
80 clrf last_pressure+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
81 clrf last_temperature+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
82 clrf last_temperature+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
83
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
84 movlw d'5'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
85 movwf timeout_counter ; reload counter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
86
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
87 bcf LED_blue
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
88 bcf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
89 bcf simulatormode_active ; Quit simulator mode (if active)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
90 bcf standalone_simulator ; Quit simulator mode (if active)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
91 WIN_TOP .0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
92 WIN_LEFT .0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
93 WIN_FONT FT_SMALL
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
94 WIN_INVERT .0 ; Init new Wordprocessor
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
95 call DISP_standard_color
3
3cf8af30b36e v1.51 beta
heinrichsweikamp
parents: 0
diff changeset
96
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
97 bcf switch_left
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
98 bcf switch_right
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
99 call DISP_active_gas_surfmode ; Show start gas / SetPoint
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
100 call DISP_custom_text ; Displays custom text
100
db4a20b413df Checking all CF values at once.
JeanDo
parents: 94
diff changeset
101 clrf cf_checker_counter ; next cf to check
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
102 ostc_debug 'G' ; Sends debug-information to screen if debugmode active
233
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
103
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
104 ; Desaturation time needs:
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
105 ; int_I_pres_surface
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
106 ; char_I_desaturation_multiplier
469
f53aa96ff2f4 SPI for sensor in 32MHz
heinrichsweikamp
parents: 453
diff changeset
107 movlw d'0'
f53aa96ff2f4 SPI for sensor in 32MHz
heinrichsweikamp
parents: 453
diff changeset
108 movff WREG,char_I_deco_model ; ZH-L16
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
109 GETCUSTOM8 d'12' ; Desaturation multiplier %
233
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
110 movff WREG,char_I_desaturation_multiplier
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
111
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents: 110
diff changeset
112 call deco_calc_desaturation_time ; calculate desaturation time
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
113 movlb b'00000001' ; select ram bank 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
114 ostc_debug 'H' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
115
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
116 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
117
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
118 surfloop_loop:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
119 btfss onesecupdate ; do every second tasks?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
120 bra surfloop_loop2 ; no, loop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
121
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
122 btfss FLAG_const_ppO2_mode ; are we in const. ppO2 mode?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
123 bra surfloop_loop1 ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
124 ; One Second tasks for ppO2 modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
125
285
8874b6cd8f36 small fix for the battery sign
heinrichsweikamp
parents: 283
diff changeset
126 bra surfloop_loop1 ;
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
127
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
128 surfloop_loop1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
129 ; One Second tasks for all modes
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
130 call DISP_clock ; update clock
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
131 call test_charger ; check if charger IC is active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
132 call timeout_surfmode ; check timeout
519
154b1d1c489e NEW added GF surface display.
JeanDo
parents: 499
diff changeset
133 call update_batt_voltage ; display battery voltage
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
134 call timeout_premenu ; timeout premenu
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
135 call set_leds_surfmode ; Sets Warning and No-Fly LEDs
94
ce3283064cde Check all CF in surfacemode, pop warning is oobounds
JeanDo
parents: 86
diff changeset
136 call check_customfunctions ; Checks CF functions and displays warning symbol if something critical is wrong
107
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
137 call surfcustomview_second ; Do every-second tasks for the custom view area
519
154b1d1c489e NEW added GF surface display.
JeanDo
parents: 499
diff changeset
138
154b1d1c489e NEW added GF surface display.
JeanDo
parents: 499
diff changeset
139 ; Every 2 seconds, overwrite with GF value (if needed to display)
154b1d1c489e NEW added GF surface display.
JeanDo
parents: 499
diff changeset
140 btfsc secs,1 ; Alternating every 2sec (if needed)
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
141 call DISP_display_cns_surface ; Display CNS (if > CF15).
519
154b1d1c489e NEW added GF surface display.
JeanDo
parents: 499
diff changeset
142 btfss secs,1
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
143 call DISP_display_gf_surface ; Display GF (if > CF8).
519
154b1d1c489e NEW added GF surface display.
JeanDo
parents: 499
diff changeset
144
154b1d1c489e NEW added GF surface display.
JeanDo
parents: 499
diff changeset
145 btfsc enter_error_sleep ; Enter Fatal Error Routine?
154b1d1c489e NEW added GF surface display.
JeanDo
parents: 499
diff changeset
146 call fatal_error_sleep ; Yes (In Sleepmode.asm!)
154b1d1c489e NEW added GF surface display.
JeanDo
parents: 499
diff changeset
147 bcf onesecupdate ; every second tasks done
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
148
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
149 surfloop_loop2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
150 ; Tasks approx. every 50ms for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
151 call test_switches_surfmode ; check switches
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
152
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
153 ; Sensor tasks for all modes
482
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
154 btfss pressure_refresh ; new pressure available?
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
155 bra surfloop_loop2a ; no
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
156
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
157 btfss s_unlock_after_sleep ; sensor results locked?
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
158 bra surfloop_loop3 ; Yes, ignore
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
159
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
160 ; New sensor value available
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
161 call update_surf_press ; display surface pressure
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
162 call DISP_temp_surfmode ; Displays temperature
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
163 call set_dive_modes ; tests if depth>threshold
125
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
164 call altimeter_calc
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
165 movf menupos3,W ; Get customview status.
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
166 bnz surfloop_loop3 ; Already used ?
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
167 call altimeter_display
482
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
168 call get_battery_voltage ; get battery voltage
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
169
125
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
170 surfloop_loop3:
482
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
171 bsf s_unlock_after_sleep ; unlock sensor results
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
172 bcf pressure_refresh ; until new pressure is available
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
173
482
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
174 surfloop_loop2a:
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
175 ; One minute tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
176 btfsc oneminupdate ; do every minute tasks
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
177 call update_surfloop60 ; yes, e.g. update time and date
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
178
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
179 ; Mode tasks
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
180 btfsc menubit ; Menu?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
181 goto menu ; Menu!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
182 btfsc divemode ; Divemode active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
183 goto diveloop ; Yes, switch into Divemode!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
184 btfsc sleepmode ; Sleepmode active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
185 goto sleeploop ; Yes, switch into sleepmode!
107
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
186
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
187 btfsc toggle_customview ; Next view?
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
188 call surfcustomview_toggle ; Yes, show next customview (and delete this flag)
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
189
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
190 ; Check for the different UART flags
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
191 btfsc dump_external_eeprom ; Start interface (dumps EEPROM BANK 0 + additional data)?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
192 goto menu_interface ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
193 btfsc uart_settime ; Sync clock with PC?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
194 goto sync_clock ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
195 btfsc internal_eeprom_write ; Access internal EEPROM BANK 0 via UART module
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
196 goto internal_eeprom_access_b0 ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
197 btfsc internal_eeprom_write2 ; Access internal EEPROM BANK 1 via UART module
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
198 goto internal_eeprom_access_b1 ; Yes!
578
fbd5e2b75a63 adding access to CF64-CF95
heinrichsweikamp
parents: 576
diff changeset
199 btfsc internal_eeprom_write3 ; Access internal EEPROM BANK 2 via UART module
fbd5e2b75a63 adding access to CF64-CF95
heinrichsweikamp
parents: 576
diff changeset
200 goto internal_eeprom_access_b2 ; Yes!
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
201 btfsc uart_send_hash ; Send MD2 hash values
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
202 goto send_md2_hash ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
203 btfsc uart_send_int_eeprom ; Send internal EEPROM BANK 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
204 goto send_int_eeprom_b0 ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
205 btfsc uart_reset_decodata ; Reset Deco Data?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
206 goto reset_decodata ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
207 btfsc uart_send_int_eeprom2 ; Send internal EEPROM BANK 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
208 goto send_int_eeprom_b1 ; Yes!
578
fbd5e2b75a63 adding access to CF64-CF95
heinrichsweikamp
parents: 576
diff changeset
209 btfsc uart_send_int_eeprom3 ; Send internal EEPROM BANK 2
fbd5e2b75a63 adding access to CF64-CF95
heinrichsweikamp
parents: 576
diff changeset
210 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
211 btfsc uart_store_tissue_data ; Store tissue data?
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
212 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
213 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
214 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
215 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
216 goto reset_battery_stats ; Yes!
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
217
330
447390289f47 NEW screen_dump serial command (l)
JeanDo
parents: 297
diff changeset
218 btfsc uart_dump_screen ; Dumps screen contains ?
331
469f4861c7c1 Debug screen dump
JeanDo
parents: 330
diff changeset
219 call dump_screen ; Yes!
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
220
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
221 bra surfloop_loop ; loop surfacemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
222
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
223
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
224 update_surfloop60:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
225 ; One minute tasks for all modes
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
226 ; call DISP_active_gas_surfmode ; Show start gas / SetPoint
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
227 call update_date ; and date in divemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
228 call calc_deko_surfmode ; calculate desaturation every minute
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
229 call check_temp_extrema ; check for new temperature extremas
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
230 call DISP_custom_text ; Displays custom text
107
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
231 call surfcustomview_minute ; Do every-minute tasks for the custom view area
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
232
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
233 btfsc gauge_mode ; Ignore in gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
234 bra update_surfloop60_2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
235 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
236 bra update_surfloop60_2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
237
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
238 ; One Minute tasks for deco modes
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
239 call DISP_nofly_time ; display nofly time
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
240 call DISP_desaturation_time ; display desaturation time
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
241 btfsc premenu ; Not when "Menu?" is displayed!
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
242 bra update_surfloop60_2
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
243
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
244 update_surfloop60_2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
245 bcf oneminupdate
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
246 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
247
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
248 set_leds_surfmode:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
249 btfsc nofly_active
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
250 btg LED_blue
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
251 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
252
353
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
253 ;=============================================================================
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
254
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
255 calc_deko_surfmode:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
256 ostc_debug 'I' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
257
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
258 movff last_surfpressure+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
259 movff last_surfpressure+1,int_I_pres_surface+1
453
38b38b105782 compute desat based on 30min old surface pressure
heinrichsweikamp
parents: 416
diff changeset
260 calc_deko_surfmode2:
353
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
261 clrf WREG ; Use as buffer
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
262 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
263 movlw d'79' ; 79% N2
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
264 movff WREG,char_I_N2_ratio ; Air at the Surface
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
265
341
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 297
diff changeset
266 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
267 GETCUSTOM8 d'11' ; Saturation multiplier %
236
3dbeacf42e9e BUGFIX missing deko init in reboot code.
JeanDo
parents: 233
diff changeset
268 movff WREG,char_I_saturation_multiplier
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
269 GETCUSTOM8 d'12' ; Desaturation multiplier %
236
3dbeacf42e9e BUGFIX missing deko init in reboot code.
JeanDo
parents: 233
diff changeset
270 movff WREG,char_I_desaturation_multiplier
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
271
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents: 110
diff changeset
272 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
273 movlb b'00000001' ; select ram bank 1
521
33abbc08f01e Minor cleanups for TESTING=1 emulator mode.
JeanDo
parents: 519
diff changeset
274
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
275 ostc_debug 'J' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
276 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
277
353
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
278 ;=============================================================================
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
279
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
280 test_charger:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
281 bcf TRISC,1 ; CHRG_OUT output
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
282 bsf CHRG_OUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
283
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
284 bcf cc_active ; Constant Current mode active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
285 btfss CHRG_IN ; If CHRG_IN=0 -> CC active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
286 bsf cc_active ; Constant Current mode Active!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
287
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
288 bcf CHRG_OUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
289 bsf TRISC,1 ; CHRG_OUT high impedance
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
290
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
291 WAIT10US d'10'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
292
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
293 bcf cv_active ; Constant Voltage mode Active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
294 btfss CHRG_IN ; If CHRG_IN=0 -> CV active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
295 bsf cv_active ; Constant Voltage mode active!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
296
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
297 bcf TRISC,1 ; CHRG_OUT output
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
298 bcf CHRG_OUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
299
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
300 btfsc cc_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
301 bra show_cc_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
302 btfsc cv_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
303 bra show_cv_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
304
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
305 bsf TRISC,1 ; CHRG_OUT high impedance
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
306
416
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
307 ; -> Charger inactive or ready
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
308
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
309 ; Disable when no USB power is attached
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
310 btfsc RCSTA,7 ; RS232 already disabled
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
311 call disable_rs232 ; No, disable UART module
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
312
703
39e02673db4c some cleanup
heinrichsweikamp
parents: 681
diff changeset
313 clrf EEADRH
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
314 btfss charge_done ; charge done?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
315 bra test_charger2 ; No, add incomplete cycle!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
316
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
317 ; Yes, store all data for complete cycle
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
318 bcf charge_started ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
319 bcf charge_done ; Clear flag
583
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
320 ; Store incomplete cycles
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
321 read_int_eeprom d'50' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
322 movff EEDATA,temp1 ; Low byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
323 read_int_eeprom d'51' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
324 movff EEDATA,temp2 ; high byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
325 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
326 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
327 addwf temp1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
328 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
329 addwfc temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
330 movff temp1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
331 write_int_eeprom d'50' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
332 movff temp2,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
333 write_int_eeprom d'51' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
334
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
335 ; Store complete cycles
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
336 read_int_eeprom d'52' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
337 movff EEDATA,temp1 ; Low byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
338 read_int_eeprom d'53' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
339 movff EEDATA,temp2 ; high byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
340 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
341 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
342 addwf temp1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
343 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
344 addwfc temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
345 movff temp1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
346 write_int_eeprom d'52' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
347 movff temp2,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
348 write_int_eeprom d'53' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
349 ; Store date of complete cycle
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
350 movff month,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
351 write_int_eeprom d'47'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
352 movff day,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
353 write_int_eeprom d'48'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
354 movff year,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
355 write_int_eeprom d'49'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
356
583
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
357 ; Reset lowest battery seen
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
358 movlw LOW 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'40'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
361 movlw HIGH d'4200' ; reset to 4.2V
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
362 movwf EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
363 write_int_eeprom d'41'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
364 movff month,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
365 write_int_eeprom d'42'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
366 movff day,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
367 write_int_eeprom d'43'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
368 movff year,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
369 write_int_eeprom d'44'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
370 ; Reset temperature
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
371 SAFE_2BYTE_COPY temperature,lo
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
372 movff lo,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
373 write_int_eeprom d'45'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
374 movff hi,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
375 write_int_eeprom d'46'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
376 ; Reset temperature extremas
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
377 SAFE_2BYTE_COPY temperature,lo
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
378 movff lo,EEDATA ; Reset mimimum extrema
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
379 write_int_eeprom d'54'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
380 movff hi,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
381 write_int_eeprom d'55'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
382 movff month,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
383 write_int_eeprom d'56'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
384 movff day,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
385 write_int_eeprom d'57'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
386 movff year,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
387 write_int_eeprom d'58'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
388 movff lo,EEDATA ; Reset maximum extrema
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
389 write_int_eeprom d'59'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
390 movff hi,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
391 write_int_eeprom d'60'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
392 movff month,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
393 write_int_eeprom d'61'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
394 movff day,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
395 write_int_eeprom d'62'
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
396 movff year,EEDATA
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
397 write_int_eeprom d'63'
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
398 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
399
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
400 test_charger2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
401 btfss charge_started ; Did the charger ever start?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
402 return ; No, quit!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
403
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
404 bcf charge_started ; Clear flag
583
d14f72af4c07 Battery statistics reset when battery is fully charged
heinrichsweikamp
parents: 578
diff changeset
405 ; Store incomplete cycles
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
406 read_int_eeprom d'50' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
407 movff EEDATA,temp1 ; Low byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
408 read_int_eeprom d'51' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
409 movff EEDATA,temp2 ; high byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
410 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
411 movlw d'1'
703
39e02673db4c some cleanup
heinrichsweikamp
parents: 681
diff changeset
412 addwf temp1,F
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
413 movlw d'0'
703
39e02673db4c some cleanup
heinrichsweikamp
parents: 681
diff changeset
414 addwfc temp2,F
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
415 movff temp1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
416 write_int_eeprom d'50' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
417 movff temp2,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
418 write_int_eeprom d'51' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
419 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
420
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
421 show_cv_active: ; CV mode
486
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
422 ; Enable RS232 only when USB power attached
416
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
423 btfss RCSTA,7 ; RS232 already enabled?
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
424 call enable_rs232 ; No, start UART module
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
425 bsf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
426 WAITMS d'100'
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
427 bcf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
428 WAITMS d'100'
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
429 bsf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
430 bsf charge_done ; Charge cycle finished
703
39e02673db4c some cleanup
heinrichsweikamp
parents: 681
diff changeset
431 bsf charge_started ; Charger started in CV mode
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
432 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
433
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
434 show_cc_active: ; CC mode
416
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
435 ; Enable only when USB power attached
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
436 btfss RCSTA,7 ; RS232 already enabled?
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
437 call enable_rs232 ; No, start UART module
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
438 bsf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
439 bsf charge_started ; Charger started in CC mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
440 bcf charge_done ; Charge cycle not finished
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
441 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
442
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
443
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
444 timeout_premenu:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
445 btfss premenu ; is "Menu?" displayed?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
446 return ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
447 incf timeout_counter3,F ; Yes...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
448 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
449 cpfsgt timeout_counter3 ; ... longer then premenu_timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
450 return ; No!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
451 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
452
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
453 call DISP_topline_box_clear ; Clears Bar at the top
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
454
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
455 btfsc gauge_mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
456 bra timeout_premenu2 ; Skip in Gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
457 btfsc FLAG_apnoe_mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
458 bra timeout_premenu2 ; Skip in Apnoe mode
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
459
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
460 timeout_premenu2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
461 call update_surf_press ; rewrite serial number
681
6e456a6398e0 Hardware4 support
heinrichsweikamp
parents: 680
diff changeset
462 call DISP_serial ; rewrite serial number
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
463 clrf timeout_counter3 ; Also clear timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
464 bcf switch_left ; and debounce switches
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
465 bcf switch_right
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
466 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
467
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
468 test_switches_surfmode: ; checks switches in surfacemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
469 btfsc switch_left
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
470 bra test_switches_surfmode2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
471 btfsc switch_right
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
472 bra test_switches_surfmode3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
473
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
474 ; No button press, reset timer0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
475 bcf T0CON,TMR0ON ; Stop Timer 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
476 bcf INTCON,TMR0IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
477 clrf TMR0H
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
478 clrf TMR0L
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
479 bcf INTCON,INT0IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
480 bcf INTCON3,INT1IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
481 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
482
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
483 test_switches_surfmode3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
484 bcf switch_right
717
91ae251d379f "ostc3-style" menu titles
heinrichsweikamp
parents: 703
diff changeset
485 call DISP_topline_box_clear
91ae251d379f "ostc3-style" menu titles
heinrichsweikamp
parents: 703
diff changeset
486 call DISP_divemask_color
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
487 DISPLAYTEXT .4 ;Menu?
717
91ae251d379f "ostc3-style" menu titles
heinrichsweikamp
parents: 703
diff changeset
488 call DISP_standard_color
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
489 bsf premenu
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
490 clrf timeout_counter2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
491 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
492
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
493 test_switches_surfmode2:
576
ab2686087bce faster font display, code cleaning
heinrichsweikamp
parents: 521
diff changeset
494 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
495 btfss premenu
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
496 bra test_switches_surfmode4
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
497 bsf menubit ; Enter Menu!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
498 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
499
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
500 test_switches_surfmode4:
107
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
501 bsf toggle_customview ; Toggle customview (Cleared in customview.asm)
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
502 return
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
503
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
504 timeout_surfmode:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
505 incf timeout_counter2,F ; increase timeout counter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
506 GETCUSTOM8 d'3' ; loads surfloop_timeout into WREG
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
507 addlw d'5' ; adds five seconds in case timout=zero!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
508 btfsc STATUS,C ; > 255?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
509 movlw d'255' ; Set to 255...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
510 decf WREG,F ; Limit to 254
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
511 cpfsgt timeout_counter2 ; Compare with timeout_counter2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
512 return ; return, no timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
513 bsf sleepmode ; Set Flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
514 return ; Return