annotate code_part1/OSTC_code_asm_part1/surfmode.asm @ 1:210410f7c1b4

clean up
author heinrichsweikamp
date Tue, 12 Jan 2010 16:07:28 +0100
parents 96a35aeda5f2
children 3cf8af30b36e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2 ; OSTC - diving computer code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
5 ; This program is free software: you can redistribute it and/or modify
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
6 ; it under the terms of the GNU General Public License as published by
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
7 ; the Free Software Foundation, either version 3 of the License, or
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
8 ; (at your option) any later version.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
9
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
10 ; This program is distributed in the hope that it will be useful,
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
13 ; GNU General Public License for more details.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
14
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
15 ; You should have received a copy of the GNU General Public License
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
17
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
18
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
19 ; routines for Surface mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
21 ; written: 10/01/05
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
22 ; last updated: 080905
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
23 ; known bugs:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
24 ; ToDo:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
25
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
26 surfloop:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
27 ; Boot tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
28 call restart_set_modes_and_flags ; Sets decomode flags
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 enable_rs232
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
36 call PLED_boot
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
37 call PLED_serial ; Show OSTC serial and firmware version
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
38 call PLED_clock ; display time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
39 call update_date ; display date
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
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
45 btfsc gauge_mode ; Ignore in gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
46 bra surfloop1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
47 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
48 bra surfloop1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
49
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
50 ; Startup tasks for decompression modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
51 call PLED_desaturation_time ; display desaturation time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
52 call PLED_nofly_time ; display nofly time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
53 call PLED_tissue_saturation_graph ; display saturation graph
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
54 call PLED_active_gas_surfmode ; Show start gas
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
55 call PLED_display_decotype_surface ; Show deco mode (ZH-L16, const. ppO2 or Multi-GF)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
56
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
57 surfloop1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
58 btfss gauge_mode ; Display only in gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
59 bra surfloop2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
60 DISPLAYTEXT d'103' ; Gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
61 surfloop2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
62 btfss FLAG_apnoe_mode ; Display only in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
63 bra surfloop3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
64 DISPLAYTEXT d'116' ; Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
65
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
66 surfloop3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
67 ; Startup tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
68 clrf timeout_counter2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
69 clrf timeout_counter3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
70 bcf premenu ; clear premenu flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
71 bcf menubit ; clear menu flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
72 bcf pressure_refresh
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
73 clrf last_pressure+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
74 clrf last_pressure+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
75 clrf last_temperature+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
76 clrf last_temperature+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
77
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
78 movlw d'5'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
79 movwf timeout_counter ; reload counter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
81 call clear_LEDusb
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
82 call clear_LEDy
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
83 bcf simulatormode_active ; Quit simulator mode (if active)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
84 bcf standalone_simulator ; Quit simulator mode (if active)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
85 WIN_TOP .0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
86 WIN_LEFT .0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
87 WIN_FONT FT_SMALL
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
88 WIN_INVERT .0 ; Init new Wordprocessor
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
89 WIN_COLOR color_white
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
90 bcf switch_left
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
91 bcf switch_right
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
92 call PLED_custom_text ; Displays custom text
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
93 movlw d'1' ; next cf to check
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
94 movwf cf_checker_counter ;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
95 ostc_debug 'G' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
96 GETCUSTOM8 d'12' ; Desaturation multiplier %
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
97 movwf wait_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
98 movff wait_temp,char_I_desaturation_multiplier
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
99 GETCUSTOM8 d'11' ; Saturation multiplier %
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
100 movwf wait_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
101 movff wait_temp,char_I_saturation_multiplier
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
102 call deco_main_calc_desaturation_time; calculate desaturation time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
103 movlb b'00000001' ; select ram bank 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
104 ostc_debug 'H' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
105
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
106 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
107
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
108 surfloop_loop:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
109 btfss onesecupdate ; do every second tasks?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
110 bra surfloop_loop2 ; no, loop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
111
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
112 btfss FLAG_const_ppO2_mode ; are we in const. ppO2 mode?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
113 bra surfloop_loop1 ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
114 ; One Second tasks for ppO2 modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
115
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
116 bra surfloop_loop1 ; Do not search for sensor in CC mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
117
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
118
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
119 surfloop_loop1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
120 ; One Second tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
121 call PLED_clock ; update clock
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
122 call test_charger ; check if charger IC is active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
123 call timeout_surfmode ; check timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
124 call get_battery_voltage ; get battery voltage
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
125 call update_batt_voltage ; display battery voltage
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
126 call timeout_premenu ; timeout premenu
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
127 call set_leds_surfmode ; Sets Warning and No-Fly LEDs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
128 call custom_functions_check_surfmode ; Checks CF functions and displays warning symbol if something critical is wrong
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
129 call PLED_active_gas_surfmode ; Show start gas / SetPoint
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
130 call PLED_display_decotype_surface ; Show deco mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
131 btfsc enter_error_sleep ; Enter Fatal Error Routine?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
132 goto fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
133 bcf onesecupdate ; every second tasks done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
134
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
135 surfloop_loop2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
136 ; Tasks approx. every 50ms for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
137 call test_switches_surfmode ; check switches
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
138
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
139 ; Sensor tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
140 btfsc pressure_refresh ; new pressure available?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
141 call update_surf_press ; display surface pressure
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
142 btfsc pressure_refresh ; new temperature available?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
143 call PLED_temp_surfmode ; Displays temperature
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
144 btfsc pressure_refresh ; new pressure available?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
145 call set_dive_modes ; tests if depth>threshold
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
146 bcf pressure_refresh ; until new pressure is available
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
147
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
148 ; One minute tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
149 btfsc oneminupdate ; do every minute tasks
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
150 call update_surfloop60 ; yes, e.g. update time and date
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
151
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
152 ; Mode tasks
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
153 btfsc menubit ; Menu?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
154 goto menu ; Menu!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
155 btfsc divemode ; Divemode active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
156 goto diveloop ; Yes, switch into Divemode!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
157 btfsc sleepmode ; Sleepmode active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
158 goto sleeploop ; Yes, switch into sleepmode!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
159 ; Check for the different UART flags
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
160 btfsc dump_external_eeprom ; Start interface (dumps EEPROM BANK 0 + additional data)?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
161 goto menu_interface ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
162 btfsc uart_settime ; Sync clock with PC?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
163 goto sync_clock ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
164 btfsc internal_eeprom_write ; Access internal EEPROM BANK 0 via UART module
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
165 goto internal_eeprom_access_b0 ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
166 btfsc internal_eeprom_write2 ; Access internal EEPROM BANK 1 via UART module
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
167 goto internal_eeprom_access_b1 ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
168 btfsc uart_send_hash ; Send MD2 hash values
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
169 goto send_md2_hash ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
170 btfsc uart_compensate_temp ; Enter temp. compensation routine?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
171 goto compensate_temperature ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
172 btfsc uart_send_int_eeprom ; Send internal EEPROM BANK 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
173 goto send_int_eeprom_b0 ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
174 btfsc uart_reset_decodata ; Reset Deco Data?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
175 goto reset_decodata ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
176 btfsc uart_send_int_eeprom2 ; Send internal EEPROM BANK 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
177 goto send_int_eeprom_b1 ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
178 btfsc uart_store_tissue_data ; Store tissue data?`
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
179 goto uart_store_tissues ; Yes!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
180
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
181 bra surfloop_loop ; loop surfacemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
182
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
183
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
184 update_surfloop60:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
185 ; One minute tasks for all modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
186 call update_date ; and date in divemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
187 call calc_deko_surfmode ; calculate desaturation every minute
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
188 call check_temp_extrema ; check for new temperature extremas
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
189 call PLED_custom_text ; Displays custom text
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
190 call calc_surface_interval ; Increases Surface-Interval time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
191
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
192 btfsc gauge_mode ; Ignore in gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
193 bra update_surfloop60_2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
194 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
195 bra update_surfloop60_2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
196
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
197 ; One Minute tasks for deco modes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
198 call PLED_nofly_time ; display nofly time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
199 call PLED_desaturation_time ; display desaturation time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
200 btfss premenu ; Not when "Menu?" is displayed!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
201 call PLED_tissue_saturation_graph; display saturation graph
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
202
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
203 update_surfloop60_2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
204 call nofly_timeout60 ; checks if nofly time is > 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
205 bcf oneminupdate
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
206 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
207
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
208 nofly_timeout60:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
209 bsf nofly_active ; Set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
210 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
211 subwf nofly_time+0,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
212 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
213 subwfb nofly_time+1,F ; reduce by one
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
214 tstfsz nofly_time+0 ; =0?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
215 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
216 tstfsz nofly_time+1 ; =0?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
217 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
218 bcf nofly_active ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
219 call clear_LEDnofly
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
220 incf nofly_time+0,F ; =1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
221 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
222
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
223 calc_surface_interval:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
224 movff int_O_desaturation_time+0,lo ; divide by 60...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
225 movff int_O_desaturation_time+1,hi
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
226 tstfsz lo ;=0?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
227 bra calc_surface_interval2 ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
228 tstfsz hi ;=0?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
229 bra calc_surface_interval2 ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
230 clrf surface_interval+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
231 clrf surface_interval+1 ; Clear surface interval timer
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
232 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
233
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
234 calc_surface_interval2: ; Increase surface interval timer
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
235 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
236 addwf surface_interval+0,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
237 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
238 addwfc surface_interval+1,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
239 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
240
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
241 set_leds_surfmode:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
242 btfsc nofly_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
243 call toggle_LEDnofly
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
244 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
245
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
246 calc_deko_surfmode:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
247 call set_LEDg
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
248 ostc_debug 'I' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
249
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
250 movff last_surfpressure+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
251 movff last_surfpressure+1,int_I_pres_surface+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
252 clrf wait_temp ; Use as buffer
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
253 movff wait_temp,char_I_He_ratio ; No He at the Surface
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
254 movlw d'79' ; 79% N2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
255 movwf wait_temp ; Use as buffer
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
256 movff wait_temp,char_I_N2_ratio ; No He at the Surface
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
257
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
258 movff amb_pressure+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
259 movff amb_pressure+1,int_I_pres_respiration+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
260 GETCUSTOM8 d'11' ; Saturation multiplier %
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
261 movwf wait_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
262 movff wait_temp,char_I_saturation_multiplier
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
263 GETCUSTOM8 d'12' ; Desaturation multiplier %
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
264 movwf wait_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
265 movff wait_temp,char_I_desaturation_multiplier
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
266
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
267 call deco_main_calc_wo_deco_step_1_m ; calculate deco in surface mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
268 movlb b'00000001' ; select ram bank 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
269 ostc_debug 'J' ; Sends debug-information to screen if debugmode active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
270 call clear_LEDg
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
271 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
272
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
273
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
274 test_charger:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
275 bcf TRISC,1 ; CHRG_OUT output
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
276 bsf CHRG_OUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
277
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
278 bcf cc_active ; Constant Current mode active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
279 btfss CHRG_IN ; If CHRG_IN=0 -> CC active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
280 bsf cc_active ; Constant Current mode Active!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
281
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
282 bcf CHRG_OUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
283 bsf TRISC,1 ; CHRG_OUT high impedance
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
284
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
285 WAIT10US d'10'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
286
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
287 bcf cv_active ; Constant Voltage mode Active?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
288 btfss CHRG_IN ; If CHRG_IN=0 -> CV active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
289 bsf cv_active ; Constant Voltage mode active!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
290
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
291 bcf TRISC,1 ; CHRG_OUT output
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
292 bcf CHRG_OUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
293
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
294 btfsc cc_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
295 bra show_cc_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
296 btfsc cv_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
297 bra show_cv_active
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
298
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
299 bsf TRISC,1 ; CHRG_OUT high impedance
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
300
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
301 ; Charger inactive or ready
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
302 btfss charge_done ; charge done?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
303 bra test_charger2 ; No, add incomplete cycle!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
304
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
305 ; Yes, store all data for complete cycle
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
306 bcf charge_started ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
307 bcf charge_done ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
308 ; Store incomplete/total cycles
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
309 read_int_eeprom d'50' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
310 movff EEDATA,temp1 ; Low byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
311 read_int_eeprom d'51' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
312 movff EEDATA,temp2 ; high byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
313 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
314 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
315 addwf temp1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
316 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
317 addwfc temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
318 movff temp1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
319 write_int_eeprom d'50' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
320 movff temp2,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
321 write_int_eeprom d'51' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
322
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
323 ; Store complete cycles
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
324 read_int_eeprom d'52' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
325 movff EEDATA,temp1 ; Low byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
326 read_int_eeprom d'53' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
327 movff EEDATA,temp2 ; high byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
328 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
329 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
330 addwf temp1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
331 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
332 addwfc temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
333 movff temp1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
334 write_int_eeprom d'52' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
335 movff temp2,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
336 write_int_eeprom d'53' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
337 ; Store date of complete cycle
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
338 movff month,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
339 write_int_eeprom d'47'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
340 movff day,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
341 write_int_eeprom d'48'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
342 movff year,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
343 write_int_eeprom d'49'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
344
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
345 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
346
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
347 test_charger2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
348 btfss charge_started ; Did the charger ever start?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
349 return ; No, quit!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
350
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
351 bcf charge_started ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
352 ; Store incomplete/total cycles
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
353 read_int_eeprom d'50' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
354 movff EEDATA,temp1 ; Low byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
355 read_int_eeprom d'51' ; Read byte (stored in EEDATA)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
356 movff EEDATA,temp2 ; high byte
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
357 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
358 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
359 addwf temp1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
360 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
361 addwfc temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
362 movff temp1,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
363 write_int_eeprom d'50' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
364 movff temp2,EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
365 write_int_eeprom d'51' ; write byte stored in EEDATA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
366 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
367
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
368 show_cv_active: ; CV mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
369 call set_LEDr
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
370 WAITMS d'100'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
371 call clear_LEDr
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
372 WAITMS d'100'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
373 call set_LEDr
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
374 bsf charge_done ; Charge cycle finished
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
375 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
376
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
377 show_cc_active: ; CC mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
378 call set_LEDr
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
379 bsf charge_started ; Charger started in CC mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
380 bcf charge_done ; Charge cycle not finished
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
381 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
382
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
383
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
384 timeout_premenu:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
385 btfss premenu ; is "Menu?" displayed?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
386 return ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
387 incf timeout_counter3,F ; Yes...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
388 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
389 cpfsgt timeout_counter3 ; ... longer then premenu_timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
390 return ; No!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
391 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
392
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
393 call PLED_topline_box_clear ; Clears Bar at the top
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
394
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
395 btfsc gauge_mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
396 bra timeout_premenu2 ; Skip in Gauge mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
397 btfsc FLAG_apnoe_mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
398 bra timeout_premenu2 ; Skip in Apnoe mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
399 call PLED_tissue_saturation_graph ; rewrite graph
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
400 timeout_premenu2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
401 call update_surf_press ; rewrite serial number
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
402 call PLED_serial ; rewrite serial number
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
403 clrf timeout_counter3 ; Also clear timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
404 bcf switch_left ; and debounce switches
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
405 bcf switch_right
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
406 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
407
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
408 test_switches_surfmode: ; checks switches in surfacemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
409 btfsc switch_left
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
410 bra test_switches_surfmode2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
411 btfsc switch_right
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
412 bra test_switches_surfmode3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
413
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
414 ; No button press, reset timer0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
415 bcf T0CON,TMR0ON ; Stop Timer 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
416 bcf INTCON,TMR0IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
417 clrf TMR0H
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
418 clrf TMR0L
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
419 bcf INTCON,INT0IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
420 bcf INTCON3,INT1IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
421 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
422
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
423 test_switches_surfmode3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
424 bcf switch_right
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
425 call PLED_topline_box ; Write a filled bar at the top
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
426 WIN_INVERT .1 ; Init new Wordprocessor
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
427 DISPLAYTEXT .4 ;Menu?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
428 WIN_INVERT .0 ; Init new Wordprocessor
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
429 bsf premenu
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
430 clrf timeout_counter2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
431 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
432
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
433 test_switches_surfmode2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
434 bcf switch_left
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
435 btfss premenu
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
436 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
437 bsf menubit ; Enter Menu!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
438 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
439
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
440
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
441
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
442 timeout_surfmode:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
443 incf timeout_counter2,F ; increase timeout counter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
444 GETCUSTOM8 d'3' ; loads surfloop_timeout into WREG
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
445 addlw d'5' ; adds five seconds in case timout=zero!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
446 btfsc STATUS,C ; > 255?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
447 movlw d'255' ; Set to 255...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
448 decf WREG,F ; Limit to 254
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
449 cpfsgt timeout_counter2 ; Compare with timeout_counter2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
450 return ; return, no timeout
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
451 bsf sleepmode ; Set Flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
452 return ; Return