annotate code_part1/OSTC_code_asm_part1/surfmode.asm @ 494:e9b1f162799d

testing graphical velocity
author heinrichsweikamp
date Mon, 07 Nov 2011 08:39:21 +0100
parents c7b663939737
children a5235ae970af
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
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
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
29 clrf lo
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
30 movff lo,char_I_const_ppO2 ; reset to standard mode, OSTC assumes Air breathing at the surface!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
31
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
32 call PLED_brightness_full ;max. brightness
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
33
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
34 call I2CReset
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
35 call PLED_boot
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
36 call PLED_serial ; Show OSTC serial and firmware version
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
37 call PLED_clock ; display time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
38 call update_date ; display date
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
39 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
40 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
41 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
42 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
43
156
3f4d60385f9c custom view default for surfacemode
heinrichsweikamp
parents: 125
diff changeset
44 clrf menupos3 ; Reset Custom views (Default: No custom view)
3f4d60385f9c custom view default for surfacemode
heinrichsweikamp
parents: 125
diff changeset
45
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
46 btfsc gauge_mode ; Ignore in gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
47 bra surfloop1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
48 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
49 bra surfloop1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
50
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
51 ; Startup tasks for decompression modes
43
65d5b0c8da41 New CF48, changed CF15
heinrichsweikamp
parents: 21
diff changeset
52 call PLED_display_cns_surface ; Update surface CNS display (If allowed by CF15)
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
53 call PLED_desaturation_time ; display desaturation time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
54 call PLED_nofly_time ; display nofly time
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
55
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
56 call PLED_active_gas_surfmode ; Show start gas
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
57 call PLED_display_decotype_surface ; Show deco mode (ZH-L16, const. ppO2 or Multi-GF)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
58
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
59 surfloop1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
60 btfss gauge_mode ; Display only in gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
61 bra surfloop2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
62 DISPLAYTEXT d'103' ; Gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
63 surfloop2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
64 btfss FLAG_apnoe_mode ; Display only in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
65 bra surfloop3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
66 DISPLAYTEXT d'116' ; Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
67
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
68 surfloop3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
69 ; Startup tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
70 clrf timeout_counter2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
71 clrf timeout_counter3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
72 bcf premenu ; clear premenu flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
73 bcf menubit ; clear menu flag
474
c083f5b9168c Reset sensor state when waking up
heinrichsweikamp
parents: 469
diff changeset
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
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
76 clrf last_pressure+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
77 clrf last_pressure+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
78 clrf last_temperature+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
79 clrf last_temperature+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
81 movlw d'5'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
82 movwf timeout_counter ; reload counter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
83
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
84 bcf LED_blue
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
85 bcf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
86 bcf simulatormode_active ; Quit simulator mode (if active)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
87 bcf standalone_simulator ; Quit simulator mode (if active)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
88 WIN_TOP .0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
89 WIN_LEFT .0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
90 WIN_FONT FT_SMALL
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
91 WIN_INVERT .0 ; Init new Wordprocessor
3
3cf8af30b36e v1.51 beta
heinrichsweikamp
parents: 0
diff changeset
92 call PLED_standard_color
3cf8af30b36e v1.51 beta
heinrichsweikamp
parents: 0
diff changeset
93
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
94 bcf switch_left
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
95 bcf switch_right
4
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 3
diff changeset
96 call PLED_active_gas_surfmode ; Show start gas / SetPoint
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
97 call PLED_custom_text ; Displays custom text
100
db4a20b413df Checking all CF values at once.
JeanDo
parents: 94
diff changeset
98 clrf cf_checker_counter ; next cf to check
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
99 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
100
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
101 ; Desaturation time needs:
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
102 ; int_I_pres_surface
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
103 ; char_I_desaturation_multiplier
469
f53aa96ff2f4 SPI for sensor in 32MHz
heinrichsweikamp
parents: 453
diff changeset
104 movlw d'0'
f53aa96ff2f4 SPI for sensor in 32MHz
heinrichsweikamp
parents: 453
diff changeset
105 movff WREG,char_I_deco_model ; ZH-L16
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
106 GETCUSTOM8 d'12' ; Desaturation multiplier %
233
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
107 movff WREG,char_I_desaturation_multiplier
2cbaa01dac26 Hunting for NoFly (bug BB13)... not found yet...
JeanDo
parents: 229
diff changeset
108
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents: 110
diff changeset
109 call deco_calc_desaturation_time ; calculate desaturation time
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
110 movlb b'00000001' ; select ram bank 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
111 ostc_debug 'H' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
112
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
113 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
114
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
115 surfloop_loop:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
116 btfss onesecupdate ; do every second tasks?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
117 bra surfloop_loop2 ; no, loop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
118
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
119 btfss FLAG_const_ppO2_mode ; are we in const. ppO2 mode?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
120 bra surfloop_loop1 ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
121 ; One Second tasks for ppO2 modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
122
285
8874b6cd8f36 small fix for the battery sign
heinrichsweikamp
parents: 283
diff changeset
123 bra surfloop_loop1 ;
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
124
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
125 surfloop_loop1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
126 ; One Second tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
127 call PLED_clock ; update clock
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
128 call test_charger ; check if charger IC is active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
129 call timeout_surfmode ; check timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
130 call update_batt_voltage ; display battery voltage
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
131 call timeout_premenu ; timeout premenu
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
132 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
133 call check_customfunctions ; Checks CF functions and displays warning symbol if something critical is wrong
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
134 call PLED_display_decotype_surface ; Show deco mode
107
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
135 call surfcustomview_second ; Do every-second tasks for the custom view area
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents: 107
diff changeset
136 call dive_type_icons ; Draw Air/Nitrox/Trimix color icon.
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
137 btfsc enter_error_sleep ; Enter Fatal Error Routine?
86
b40a0a6284da adding custom functions with limits (jeando)
heinrichsweikamp
parents: 70
diff changeset
138 call fatal_error_sleep ; Yes (In Sleepmode.asm!)
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
139 bcf onesecupdate ; every second tasks done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
140
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
141 surfloop_loop2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
142 ; Tasks approx. every 50ms for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
143 call test_switches_surfmode ; check switches
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
144
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
145 ; Sensor tasks for all modes
482
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
146 btfss pressure_refresh ; new pressure available?
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
147 bra surfloop_loop2a ; no
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
148
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
149 btfss s_unlock_after_sleep ; sensor results locked?
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
150 bra surfloop_loop3 ; Yes, ignore
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
151
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
152 ; New sensor value available
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
153 call update_surf_press ; display surface pressure
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
154 call PLED_temp_surfmode ; Displays temperature
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
155 call set_dive_modes ; tests if depth>threshold
125
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
156 call altimeter_calc
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
157 movf menupos3,W ; Get customview status.
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
158 bnz surfloop_loop3 ; Already used ?
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
159 call altimeter_display
482
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
160 call get_battery_voltage ; get battery voltage
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
161
125
2907b42c195b Altimeter:
JeanDo
parents: 116
diff changeset
162 surfloop_loop3:
482
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
163 bsf s_unlock_after_sleep ; unlock sensor results
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
164 bcf pressure_refresh ; until new pressure is available
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
165
482
8e1fb9cdd62a lock sensor for surfacemode until value is stable
heinrichsweikamp
parents: 474
diff changeset
166 surfloop_loop2a:
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
167 ; One minute tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
168 btfsc oneminupdate ; do every minute tasks
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
169 call update_surfloop60 ; yes, e.g. update time and date
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
170
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
171 ; Mode tasks
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
172 btfsc menubit ; Menu?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
173 goto menu ; Menu!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
174 btfsc divemode ; Divemode active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
175 goto diveloop ; Yes, switch into Divemode!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
176 btfsc sleepmode ; Sleepmode active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
177 goto sleeploop ; Yes, switch into sleepmode!
107
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
178
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
179 btfsc toggle_customview ; Next view?
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
180 call surfcustomview_toggle ; Yes, show next customview (and delete this flag)
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
181
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
182 ; Check for the different UART flags
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
183 btfsc dump_external_eeprom ; Start interface (dumps EEPROM BANK 0 + additional data)?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
184 goto menu_interface ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
185 btfsc uart_settime ; Sync clock with PC?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
186 goto sync_clock ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
187 btfsc internal_eeprom_write ; Access internal EEPROM BANK 0 via UART module
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
188 goto internal_eeprom_access_b0 ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
189 btfsc internal_eeprom_write2 ; Access internal EEPROM BANK 1 via UART module
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
190 goto internal_eeprom_access_b1 ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
191 btfsc uart_send_hash ; Send MD2 hash values
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
192 goto send_md2_hash ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
193 btfsc uart_send_int_eeprom ; Send internal EEPROM BANK 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
194 goto send_int_eeprom_b0 ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
195 btfsc uart_reset_decodata ; Reset Deco Data?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
196 goto reset_decodata ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
197 btfsc uart_send_int_eeprom2 ; Send internal EEPROM BANK 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
198 goto send_int_eeprom_b1 ; Yes!
283
4ec488f046f4 Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents: 257
diff changeset
199 btfsc uart_store_tissue_data ; Store tissue data?
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
200 goto uart_store_tissues ; Yes!
283
4ec488f046f4 Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents: 257
diff changeset
201 btfsc uart_115200_bootloader ; Look for 115200Baud bootloader?
4ec488f046f4 Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents: 257
diff changeset
202 goto uart_115k_bootloader ; Yes!
297
ceedf078b2d8 Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents: 285
diff changeset
203 btfsc uart_reset_battery_stats ; Reset Battery stats?
ceedf078b2d8 Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents: 285
diff changeset
204 goto reset_battery_stats ; Yes!
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
205
330
447390289f47 NEW screen_dump serial command (l)
JeanDo
parents: 297
diff changeset
206 btfsc uart_dump_screen ; Dumps screen contains ?
331
469f4861c7c1 Debug screen dump
JeanDo
parents: 330
diff changeset
207 call dump_screen ; Yes!
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
208
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
209 bra surfloop_loop ; loop surfacemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
210
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
211
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
212 update_surfloop60:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
213 ; One minute tasks for all modes
4
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 3
diff changeset
214 ; call PLED_active_gas_surfmode ; Show start gas / SetPoint
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
215 call update_date ; and date in divemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
216 call calc_deko_surfmode ; calculate desaturation every minute
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
217 call check_temp_extrema ; check for new temperature extremas
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
218 call PLED_custom_text ; Displays custom text
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
219 call calc_surface_interval ; Increases Surface-Interval time
107
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
220 call surfcustomview_minute ; Do every-minute tasks for the custom view area
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
221
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
222 btfsc gauge_mode ; Ignore in gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
223 bra update_surfloop60_2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
224 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
225 bra update_surfloop60_2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
226
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
227 ; One Minute tasks for deco modes
43
65d5b0c8da41 New CF48, changed CF15
heinrichsweikamp
parents: 21
diff changeset
228 call PLED_display_cns_surface ; Update surface CNS display (If allowed by CF15)
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
229 call PLED_nofly_time ; display nofly time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
230 call PLED_desaturation_time ; display desaturation time
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
231 btfsc premenu ; Not when "Menu?" is displayed!
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
232 bra update_surfloop60_2
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
233
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
234 update_surfloop60_2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
235 call nofly_timeout60 ; checks if nofly time is > 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
236 bcf oneminupdate
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
237 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
238
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
239 nofly_timeout60:
486
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
240 movf desaturation_time_buffer+0,W; Is Desat null ?
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
241 iorwf desaturation_time_buffer+1,W
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
242 rcall nofly_timeout60_0 ; No...
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
243
229
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
244 movf nofly_time+0,W ; Is nofly null ?
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
245 iorwf nofly_time+1,W
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
246 bnz nofly_timeout60_1 ; No...
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
247
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
248 bcf nofly_active ; Clear flag
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
249 bcf LED_blue ; Clear led.
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
250 return
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
251
486
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
252 nofly_timeout60_0:
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
253 movlw d'1'
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
254 subwf desaturation_time_buffer+0,F
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
255 movlw d'0'
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
256 subwfb desaturation_time_buffer+1,F ; reduce by one
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
257 return
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
258
229
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
259 nofly_timeout60_1:
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
260 bsf nofly_active ; Set flag
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
261 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
262 subwf nofly_time+0,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
263 movlw d'0'
229
85ea09d3b9d8 Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents: 156
diff changeset
264 subwfb nofly_time+1,F ; reduce by one
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
265 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
266
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
267 calc_surface_interval:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
268 movff int_O_desaturation_time+0,lo ; divide by 60...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
269 movff int_O_desaturation_time+1,hi
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
270 tstfsz lo ;=0?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
271 bra calc_surface_interval2 ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
272 tstfsz hi ;=0?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
273 bra calc_surface_interval2 ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
274 clrf surface_interval+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
275 clrf surface_interval+1 ; Clear surface interval timer
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
276 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
277
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
278 calc_surface_interval2: ; Increase surface interval timer
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
279 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
280 addwf surface_interval+0,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
281 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
282 addwfc surface_interval+1,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
283 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
284
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
285 set_leds_surfmode:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
286 btfsc nofly_active
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
287 btg LED_blue
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
288 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
289
353
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
290 ;=============================================================================
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
291
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
292 calc_deko_surfmode:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
293 ostc_debug 'I' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
294
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
295 movff last_surfpressure+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
296 movff last_surfpressure+1,int_I_pres_surface+1
453
38b38b105782 compute desat based on 30min old surface pressure
heinrichsweikamp
parents: 416
diff changeset
297 calc_deko_surfmode2:
353
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
298 clrf WREG ; Use as buffer
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
299 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
300 movlw d'79' ; 79% N2
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
301 movff WREG,char_I_N2_ratio ; Air at the Surface
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
302
341
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 297
diff changeset
303 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
304 GETCUSTOM8 d'11' ; Saturation multiplier %
236
3dbeacf42e9e BUGFIX missing deko init in reboot code.
JeanDo
parents: 233
diff changeset
305 movff WREG,char_I_saturation_multiplier
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
306 GETCUSTOM8 d'12' ; Desaturation multiplier %
236
3dbeacf42e9e BUGFIX missing deko init in reboot code.
JeanDo
parents: 233
diff changeset
307 movff WREG,char_I_desaturation_multiplier
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
308
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents: 110
diff changeset
309 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
310 movlb b'00000001' ; select ram bank 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
311 ostc_debug 'J' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
312 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
313
353
b5b030c1ae7e Avoid spurious switch-depth stops with 3 or more gas.
JeanDo
parents: 344
diff changeset
314 ;=============================================================================
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
315
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
316 test_charger:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
317 bcf TRISC,1 ; CHRG_OUT output
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
318 bsf CHRG_OUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
319
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
320 bcf cc_active ; Constant Current mode active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
321 btfss CHRG_IN ; If CHRG_IN=0 -> CC active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
322 bsf cc_active ; Constant Current mode Active!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
323
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
324 bcf CHRG_OUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
325 bsf TRISC,1 ; CHRG_OUT high impedance
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
326
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
327 WAIT10US d'10'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
328
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
329 bcf cv_active ; Constant Voltage mode Active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
330 btfss CHRG_IN ; If CHRG_IN=0 -> CV active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
331 bsf cv_active ; Constant Voltage mode active!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
332
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
333 bcf TRISC,1 ; CHRG_OUT output
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
334 bcf CHRG_OUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
335
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
336 btfsc cc_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
337 bra show_cc_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
338 btfsc cv_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
339 bra show_cv_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
340
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
341 bsf TRISC,1 ; CHRG_OUT high impedance
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
342
416
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
343 ; -> Charger inactive or ready
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
344
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
345 ; Disable when no USB power is attached
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
346 btfsc RCSTA,7 ; RS232 already disabled
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
347 call disable_rs232 ; No, disable UART module
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
348
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
349 btfss charge_done ; charge done?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
350 bra test_charger2 ; No, add incomplete cycle!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
351
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
352 ; Yes, store all data for complete cycle
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
353 bcf charge_started ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
354 bcf charge_done ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
355 ; Store incomplete/total cycles
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
356 read_int_eeprom d'50' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
357 movff EEDATA,temp1 ; Low byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
358 read_int_eeprom d'51' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
359 movff EEDATA,temp2 ; high byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
360 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
361 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
362 addwf temp1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
363 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
364 addwfc temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
365 movff temp1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
366 write_int_eeprom d'50' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
367 movff temp2,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
368 write_int_eeprom d'51' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
369
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
370 ; Store complete cycles
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
371 read_int_eeprom d'52' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
372 movff EEDATA,temp1 ; Low byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
373 read_int_eeprom d'53' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
374 movff EEDATA,temp2 ; high byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
375 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
376 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
377 addwf temp1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
378 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
379 addwfc temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
380 movff temp1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
381 write_int_eeprom d'52' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
382 movff temp2,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
383 write_int_eeprom d'53' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
384 ; Store date of complete cycle
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
385 movff month,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
386 write_int_eeprom d'47'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
387 movff day,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
388 write_int_eeprom d'48'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
389 movff year,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
390 write_int_eeprom d'49'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
391
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
392 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
393
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
394 test_charger2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
395 btfss charge_started ; Did the charger ever start?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
396 return ; No, quit!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
397
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
398 bcf charge_started ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
399 ; Store incomplete/total cycles
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
400 read_int_eeprom d'50' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
401 movff EEDATA,temp1 ; Low byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
402 read_int_eeprom d'51' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
403 movff EEDATA,temp2 ; high byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
404 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
405 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
406 addwf temp1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
407 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
408 addwfc temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
409 movff temp1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
410 write_int_eeprom d'50' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
411 movff temp2,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
412 write_int_eeprom d'51' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
413 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
414
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
415 show_cv_active: ; CV mode
486
c7b663939737 making waitms speed-independent, desat-time fix
heinrichsweikamp
parents: 482
diff changeset
416 ; Enable RS232 only when USB power attached
416
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
417 btfss RCSTA,7 ; RS232 already enabled?
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
418 call enable_rs232 ; No, start UART module
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
419 bsf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
420 WAITMS d'100'
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
421 bcf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
422 WAITMS d'100'
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
423 bsf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
424 bsf charge_done ; Charge cycle finished
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
425 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
426
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
427 show_cc_active: ; CC mode
416
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
428 ; Enable only when USB power attached
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
429 btfss RCSTA,7 ; RS232 already enabled?
3abf9d7dafae diabling uart module when no USB is attached
heinrichsweikamp
parents: 397
diff changeset
430 call enable_rs232 ; No, start UART module
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 16
diff changeset
431 bsf LED_red
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
432 bsf charge_started ; Charger started in CC mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
433 bcf charge_done ; Charge cycle not finished
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
434 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
435
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
436
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
437 timeout_premenu:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
438 btfss premenu ; is "Menu?" displayed?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
439 return ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
440 incf timeout_counter3,F ; Yes...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
441 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
442 cpfsgt timeout_counter3 ; ... longer then premenu_timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
443 return ; No!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
444 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
445
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
446 call PLED_topline_box_clear ; Clears Bar at the top
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
447
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
448 btfsc gauge_mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
449 bra timeout_premenu2 ; Skip in Gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
450 btfsc FLAG_apnoe_mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
451 bra timeout_premenu2 ; Skip in Apnoe mode
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
452
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
453 timeout_premenu2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
454 call update_surf_press ; rewrite serial number
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
455 call PLED_serial ; rewrite serial number
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
456 clrf timeout_counter3 ; Also clear timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
457 bcf switch_left ; and debounce switches
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
458 bcf switch_right
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
459 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
460
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
461 test_switches_surfmode: ; checks switches in surfacemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
462 btfsc switch_left
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
463 bra test_switches_surfmode2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
464 btfsc switch_right
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
465 bra test_switches_surfmode3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
466
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
467 ; No button press, reset timer0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
468 bcf T0CON,TMR0ON ; Stop Timer 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
469 bcf INTCON,TMR0IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
470 clrf TMR0H
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
471 clrf TMR0L
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
472 bcf INTCON,INT0IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
473 bcf INTCON3,INT1IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
474 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
475
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
476 test_switches_surfmode3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
477 bcf switch_right
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
478 call PLED_topline_box ; Write a filled bar at the top
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
479 WIN_INVERT .1 ; Init new Wordprocessor
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
480 DISPLAYTEXT .4 ;Menu?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
481 WIN_INVERT .0 ; Init new Wordprocessor
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
482 bsf premenu
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
483 clrf timeout_counter2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
484 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
485
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
486 test_switches_surfmode2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
487 bcf switch_left
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
488 btfss premenu
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
489 bra test_switches_surfmode4
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
490 bsf menubit ; Enter Menu!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
491 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
492
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
493 test_switches_surfmode4:
107
a2b9eca1f396 customview for the surfacemode
heinrichsweikamp
parents: 100
diff changeset
494 bsf toggle_customview ; Toggle customview (Cleared in customview.asm)
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 4
diff changeset
495 return
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
496
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
497 timeout_surfmode:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
498 incf timeout_counter2,F ; increase timeout counter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
499 GETCUSTOM8 d'3' ; loads surfloop_timeout into WREG
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
500 addlw d'5' ; adds five seconds in case timout=zero!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
501 btfsc STATUS,C ; > 255?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
502 movlw d'255' ; Set to 255...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
503 decf WREG,F ; Limit to 254
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
504 cpfsgt timeout_counter2 ; Compare with timeout_counter2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
505 return ; return, no timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
506 bsf sleepmode ; Set Flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
507 return ; Return