Mercurial > public > hwos_code
comparison src/surfmode.asm @ 634:4050675965ea
3.10 stable release
author | heinrichsweikamp |
---|---|
date | Tue, 28 Apr 2020 17:34:31 +0200 |
parents | 185ba2f91f59 |
children | 2737ddc643bb |
comparison
equal
deleted
inserted
replaced
633:690c48db7b5b | 634:4050675965ea |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File surfmode.asm next combined generation V3.08.8 | 3 ; File surfmode.asm * next combined generation V3.09.5 |
4 ; | 4 ; |
5 ; Surface Mode | 5 ; Surface Mode |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
9 ; HISTORY | 9 ; HISTORY |
10 ; 2011-08-07 : [mH] moving from OSTC code | 10 ; 2011-08-07 : [mH] moving from OSTC code |
11 | 11 |
12 #include "hwos.inc" ; Mandatory header | 12 #include "hwos.inc" ; mandatory header |
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | 13 #include "shared_definitions.h" ; mailbox from/to p2_deco.c |
14 #include "start.inc" | 14 #include "start.inc" |
15 #include "tft.inc" | 15 #include "tft.inc" |
16 #include "tft_outputs.inc" | 16 #include "tft_outputs.inc" |
17 #include "adc_lightsensor.inc" | 17 #include "adc_lightsensor.inc" |
18 #include "menu_processor.inc" | |
19 #include "strings.inc" | 18 #include "strings.inc" |
20 #include "sleepmode.inc" | 19 #include "sleepmode.inc" |
21 #include "wait.inc" | 20 #include "wait.inc" |
22 #include "external_flash.inc" | |
23 #include "customview.inc" | 21 #include "customview.inc" |
24 #include "divemode.inc" | 22 #include "divemode.inc" |
25 #include "mcp.inc" ; RX | |
26 #include "i2c.inc" | 23 #include "i2c.inc" |
27 #include "comm.inc" | 24 #include "comm.inc" |
28 #include "eeprom_rs232.inc" | 25 #include "colorschemes.inc" |
26 | |
27 IFDEF _rx_functions | |
28 #include "rx_ops.inc" | |
29 ENDIF | |
30 | |
31 IFDEF _external_sensor | |
29 #include "calibrate.inc" | 32 #include "calibrate.inc" |
30 #include "rx_ops.inc" | 33 ENDIF |
31 | 34 |
32 | 35 |
33 extern do_main_menu | 36 extern main_menu |
34 extern check_cns_violation | 37 extern check_cns_violation_now |
35 extern check_warn_battery | 38 extern check_battery |
36 extern check_and_store_sat_violation | 39 extern check_saturation |
37 extern check_mbubbles | 40 extern check_mbubbles |
38 | 41 |
39 IFDEF _osct_logo | |
40 extern ostc_logo_block | |
41 ENDIF | |
42 | 42 |
43 IFDEF _compass | 43 IFDEF _compass |
44 extern TFT_surface_compass_heading | 44 extern TFT_surface_compass_heading |
45 ENDIF | 45 ENDIF |
46 | 46 |
55 #DEFINE menu_pos_row .215 | 55 #DEFINE menu_pos_row .215 |
56 #DEFINE menu_pos_column .1 | 56 #DEFINE menu_pos_column .1 |
57 #DEFINE view_row .215 | 57 #DEFINE view_row .215 |
58 #DEFINE view_column .124 | 58 #DEFINE view_column .124 |
59 | 59 |
60 | 60 ;============================================================================= |
61 sfmode CODE | 61 sfmode1 CODE |
62 | 62 ;============================================================================= |
63 ;============================================================================= | 63 |
64 ; Boot tasks for all modes | 64 ;----------------------------------------------------------------------------- |
65 ; Entry Point for Surface Mode | |
65 ; | 66 ; |
66 ; called after restart via the battery selection, after compass calibration, | 67 ; called after restart via the battery selection, after compass calibration, |
67 ; and via ghostwriter at the end of a dive | 68 ; and via ghostwriter at the end of a dive |
68 ; | 69 ; |
69 global surfloop | 70 global surfloop |
70 surfloop: | 71 surfloop: |
71 clrf STKPTR ; clear return addresses stack | 72 clrf STKPTR ; clear return addresses stack |
72 ; clrf CCP1CON ; stop PWM | 73 ; clrf CCP1CON ; stop PWM |
73 ; bcf PORTC,2 ; pull PWM output to GND | 74 ; bcf PORTC,2 ; pull PWM output to GND |
74 ; clrf CCPR1L ; backlight off | 75 ; clrf CCPR1L ; backlight off |
75 call TFT_boot ; initialize TFT (includes clear screen) | 76 call TFT_boot ; initialize TFT (includes clear screen) |
76 | 77 |
77 btfsc restart_fast ; shall make a fast restart? | 78 btfsc restart_fast ; shall make a fast restart? |
78 bra surfloop_1 ; YES | 79 bra surfloop_1 ; YES |
79 | 80 |
80 ; show heinrichsweikamp logo | 81 ; show heinrichsweikamp logo |
81 WIN_TOP .40 | 82 WIN_TOP .40 |
82 WIN_LEFT .10 | 83 WIN_LEFT .10 |
83 TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block | 84 TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block |
84 | 85 |
86 ; set font color | |
87 FONT_COLOR color_white | |
88 | |
85 ; show textual OSTC logo | 89 ; show textual OSTC logo |
86 WIN_COLOR color_white | 90 WIN_STD .30,.90 ; column, row |
87 WIN_STD .30,.90 ; column, row | 91 STRCPY_PRINT "Open Source" ; show OSTC banner text, line 1 |
88 STRCPY_PRINT "Open Source" ; show OSTC banner text, line 1 | 92 WIN_STD .20,.130 ; column, row |
89 WIN_STD .20,.130 ; column, row | 93 STRCPY_PRINT "Tauch-Computer" ; show OSTC banner text, line 2 |
90 STRCPY_PRINT "Tauch-Computer" ; show OSTC banner text, line 2 | 94 |
91 | 95 ; show firmware version |
92 WIN_COLOR color_white | |
93 WIN_SMALL .35,.180 | 96 WIN_SMALL .35,.180 |
94 PUTC "v" ; print v | 97 PUTC "v" ; print "v" |
95 call TFT_cat_firmware ; print x.y | 98 call TFT_print_firmware ; print full firmware version (may change the font color) |
96 PUTC " " ; print _ | 99 call TFT_Display_FadeIn ; dim up the display |
97 call TFT_cat_beta_release ; print BetaZ or Release | |
98 STRCAT_PRINT "" ; finalize output | |
99 bcf win_invert ; clean up eventual color-coding | |
100 call TFT_standard_color ; ditto | |
101 call TFT_Display_FadeIn ; dim up the display | |
102 | 100 |
103 surfloop_1: | 101 surfloop_1: |
104 ;---- Do all useful initializations that take time ----------------------- | 102 |
103 ;---- do all useful initializations that take time ----------------------- | |
105 | 104 |
106 ; set deco mode flags | 105 ; set deco mode flags |
107 call restart_set_modes_and_flags | 106 call restart_set_modes_and_flags |
108 | 107 |
109 bsf trigger_pres_cur_changed; set flag to have pressure written to display on first round of surface loop | 108 bsf trigger_pres_cur_changed ; set flag to have pressure written to display on first round of surface loop |
110 bsf trigger_temp_changed ; set flag to have temperature written to display on first round of surface loop | 109 bsf trigger_temp_changed ; set flag to have temperature written to display on first round of surface loop |
111 | 110 |
112 call I2C_sleep_compass ; shut down compass | 111 call I2C_sleep_compass ; shut down compass |
113 | |
114 CLRT ext_flash_address | |
115 | |
116 | 112 |
117 IFDEF _ccr_pscr | 113 IFDEF _ccr_pscr |
118 movlw surface_sp ; load default surface setpoint (in cbar) | 114 movlw surface_sp ; load default surface setpoint (in cbar) |
119 movff WREG,char_I_const_ppO2 ; store it as current setpoint | 115 movff WREG,char_I_const_ppO2 ; store it as current setpoint |
120 ENDIF | 116 ENDIF |
121 | 117 |
122 IFDEF _external_sensor | 118 IFDEF _external_sensor |
123 call transmit_setpoint ; transmit current setpoint (in cbar) via S8 digital interface (currently disabled) | 119 call transmit_setpoint ; transmit current setpoint (in cbar) via S8 digital interface (currently disabled) |
124 ENDIF | 120 ENDIF |
125 | 121 |
126 bcf surfmode_menu ; not in surface menu (any more) | 122 bcf surfmode_menu ; not in surface menu (any more) |
127 bcf compass_menu ; not in "set bearing" selection (any more) | 123 bcf compass_menu ; not in "set bearing" selection (any more) |
128 | 124 |
129 bcf switch_left ; clear intermediate button event since start/restart | 125 bcf switch_left ; clear intermediate button event since start/restart |
130 bcf switch_right ; clear intermediate button event since start/restart | 126 bcf switch_right ; clear intermediate button event since start/restart |
131 | 127 |
132 btfsc restart_fast ; shall make a fast restart? | 128 btfsc restart_fast ; shall make a fast restart? |
133 bra surfloop_2 ; YES | 129 bra surfloop_2 ; YES |
134 | 130 |
135 call deco_calc_desaturation_time ; calculate desaturation and no-fly/no-altitude time (C-code) | 131 call deco_calc_desaturation_time ; calculate desaturation and no-fly/no-altitude time (C-code) |
136 banksel common ; back to bank common | 132 banksel common ; back to bank common |
137 | 133 |
138 call wait_1s ; wait <= 1 second | 134 WAITS .2 ; wait 2 seconds |
139 call wait_1s ; wait 1 second | 135 |
140 call wait_1s ; wait 1 second | 136 ;---- fade to standard surface view -------------------------------------- |
141 | 137 |
142 ;---- Fade to standard surface view -------------------------------------- | 138 call TFT_Display_FadeOut ; dim down display to black screen |
143 | 139 call TFT_ClearScreen ; clear screen |
144 call TFT_Display_FadeOut ; dim down display to black screen | |
145 call TFT_ClearScreen ; clear screen | |
146 | 140 |
147 surfloop_2: | 141 surfloop_2: |
148 WIN_TOP .0 | 142 |
149 WIN_LEFT .0 | 143 call TFT_load_std_color_pallet ; load standard color pallet |
150 WIN_FONT FT_SMALL | 144 |
151 bcf win_invert ; clear flag for inverted text | 145 ;---- button functionalities --------------------------------------------- |
152 | 146 |
153 ; show button functionalities | 147 FONT_COLOR color_lightblue ; set font color |
154 WIN_COLOR color_lightblue | 148 WIN_SMALL menu_pos_column,menu_pos_row ; set font size and output position |
155 WIN_SMALL menu_pos_column,menu_pos_row | 149 STRCPY_TEXT_PRINT tMenu ; print "<Menu" |
156 STRCPY_TEXT_PRINT tMenu ; show "<Menu" | 150 WIN_SMALL view_column,view_row ; set font size and output position |
157 WIN_SMALL view_column,view_row | 151 STRCPY_TEXT_PRINT tView ; print "View>" |
158 STRCPY_TEXT_PRINT tView ; show "View>" | 152 |
159 call TFT_standard_color | 153 |
160 | 154 ;---- logo in upper right corner ----------------------------------------- |
161 | |
162 ;---- Logo in upper right corner ----------------------------------------- | |
163 | 155 |
164 ; show textual OSTC logo | 156 ; show textual OSTC logo |
165 WIN_COLOR color_white ; set text color to white | |
166 WIN_STD .100,.2 ; set output position | 157 WIN_STD .100,.2 ; set output position |
158 FONT_COLOR color_white ; set text color to white | |
167 STRCPY_PRINT "OSTC" ; show "OSTC" | 159 STRCPY_PRINT "OSTC" ; show "OSTC" |
168 WIN_COLOR color_cyan ; set text color to cyan | 160 |
161 FONT_COLOR color_cyan ; set text color to cyan | |
169 WIN_TINY .138,.2 ; set output position | 162 WIN_TINY .138,.2 ; set output position |
170 STRCPY_PRINT "hwOS" ; show "hwOS" | 163 STRCPY_PRINT "hwOS" ; show "hwOS" |
171 WIN_TINY .137,.14 ; set output position | 164 WIN_TINY .137,.14 ; set output position |
172 IFDEF _hwos_sport | 165 IFDEF _hwos_sport |
173 STRCPY_PRINT "sport" ; show "sport" | 166 STRCPY_PRINT "sport" ; show "sport" |
174 ELSE | 167 ELSE |
175 STRCPY_PRINT "tech" ; show "tech" | 168 STRCPY_PRINT "tech" ; show "tech" |
176 ENDIF | 169 ENDIF |
170 | |
171 ; firmware version | |
177 WIN_TINY .100,.32 ; set output position | 172 WIN_TINY .100,.32 ; set output position |
178 call TFT_show_firmware ; show firmware version | 173 FONT_COLOR color_white ; set text color to white |
174 call TFT_print_firmware ; show firmware version (long format) | |
179 | 175 |
180 | 176 |
181 ;---- fill screen -------------------------------------------------------- | 177 ;---- fill screen -------------------------------------------------------- |
182 call get_battery_voltage ; get battery voltage | 178 |
183 call TFT_batt_surfmode ; display battery voltage | 179 call get_battery_voltage ; get battery voltage |
184 call TFT_time_surfmode ; display time | 180 call TFT_surfmode_batt ; show battery voltage |
185 call TFT_date_surfmode ; display date | 181 call TFT_surfmode_time ; show time |
186 call TFT_pres_surfmode ; display surface pressure | 182 call TFT_surfmode_date ; show date |
187 call TFT_temp_surfmode ; display temperature | 183 call TFT_surfmode_pres ; show surface pressure |
188 call TFT_decotype_surface ; display deco mode | 184 call TFT_surfmode_temp ; show temperature |
189 | 185 call TFT_surfmode_decotype ; show deco mode |
190 TSTOSS opt_dive_mode ; in OC? (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR) | 186 |
191 call TFT_show_OC_startgas_surface ; YES - show first gas and "OSTC2-like" active gases | 187 TSTOSS opt_dive_mode ; in OC? (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR) |
188 call TFT_surfmode_startgas ; YES - show first gas and "OSTC2-like" active gases | |
192 | 189 |
193 ; configure tissue graphics | 190 ; configure tissue graphics |
194 bcf tissue_graphic_mode ; select surface mode | 191 bcf tissue_graphic_mode ; select surface mode |
195 bsf tissue_graphic_cns ; show CNS value | 192 bsf tissue_graphic_cns ; show CNS value |
196 | 193 |
197 bsf tissue_graphic_layout ; default to N2+He | 194 bsf tissue_graphic_layout ; default to N2+He |
198 TSTOSS opt_tissue_graphics ; shall show press+sat? | 195 TSTOSS opt_tissue_graphics ; shall show press+sat? |
199 bcf tissue_graphic_layout ; YES - show press+sat | 196 bcf tissue_graphic_layout ; YES - show press+sat |
200 | 197 |
201 bcf tissue_graphic_gf ; default to none-GF | 198 bcf tissue_graphic_gf ; default to none-GF |
202 TSTOSC char_I_model ; GF factors enabled? | 199 TSTOSC char_I_model ; GF factors enabled? |
203 bsf tissue_graphic_gf ; YES - show GF lines | 200 bsf tissue_graphic_gf ; YES - show GF lines |
204 | 201 |
205 movff customview_surfmode,active_customview ; reload last custom view | 202 movff customview_surfmode,active_customview ; reload last custom view |
206 call surf_customview_mask ; redraw last custom view | 203 call surf_customview_mask ; redraw last custom view |
207 | 204 |
208 call TFT_Display_FadeIn ; display resulting surface screen | 205 call TFT_Display_FadeIn ; show resulting surface screen |
209 | 206 |
210 IFDEF _screendump | 207 IFDEF _screendump |
211 btfsc screen_dump_avail ; screen dump function enabled? | 208 btfsc screen_dump_avail ; screen dump function enabled? |
212 call enable_rs232 ; YES - activate RS232 (also sets CPU to normal speed) | 209 call enable_rs232 ; YES - activate RS232 (also sets CPU to normal speed) |
213 ENDIF | 210 ENDIF |
214 | 211 |
215 bcf restart_fast ; clear flag for fast restart | 212 bcf restart_fast ; clear flag for fast restart |
216 bsf imprint_surfmode_data ; start imprinting surface mode data | 213 bsf imprint_surfmode_data ; start imprinting surface mode data |
217 | 214 |
218 bcf switch_left ; clear pending left button event | 215 bcf switch_left ; clear pending left button event |
219 bcf switch_right ; clear pending right button event | 216 bcf switch_right ; clear pending right button event |
220 | 217 |
221 rcall reset_timeout_surfmode ; reset timeout | 218 rcall reset_timeout_surfmode ; reset timeout |
222 | 219 |
223 surfloop_loop: | 220 surfloop_loop: |
224 ; call TFT_debug_output ; optional debug output | 221 ; call TFT_debug_output ; optional debug output |
225 | 222 |
226 call test_switches_surfmode ; check switches | 223 call test_switches_surfmode ; check switches |
227 | 224 |
228 btfsc request_next_custview ; shall show next custom view? | 225 btfsc request_next_custview ; shall show next custom view? |
229 call surf_customview_toggle ; YES - show next custom view (and clear this flag) | 226 call surf_customview_toggle ; YES - show next custom view (and clear this flag) |
230 | 227 |
231 btfss surfmode_menu ; shall enter surface menu? | 228 btfss surfmode_menu ; shall enter surface menu? |
232 bra surfloop_loop_1 ; NO | 229 bra surfloop_loop_1 ; NO |
233 bcf imprint_surfmode_data ; YES - stop imprinting surface mode data | 230 bcf imprint_surfmode_data ; YES - stop imprinting surface mode data |
234 goto do_main_menu ; - goto surface menu | 231 goto main_menu ; - goto surface menu |
235 | 232 |
236 surfloop_loop_1: | 233 surfloop_loop_1: |
237 rcall housekeeping ; handle data imprinting, screen dump request, timeout and entering dive mode | 234 call housekeeping ; handle data imprinting, screen dump request, timeout and entering dive mode |
238 bra surfloop_loop ; loop in surface mode | 235 bra surfloop_loop ; loop in surface mode |
239 | 236 |
240 | 237 |
241 surfmode_check_for_warnings: | 238 ;----------------------------------------------------------------------------- |
242 clrf message_counter ; clear message counter | 239 ; Surface Mode HMI Operations |
243 | 240 ; |
244 ; warnings for all modes | |
245 call check_warn_battery ; check if the battery level should be displayed/warned | |
246 | |
247 btfsc FLAG_apnoe_mode ; done for Apnoe or Gauge mode | |
248 bra surfmode_check_for_warnings2 | |
249 btfsc FLAG_gauge_mode ; done for Apnoe or Gauge mode | |
250 bra surfmode_check_for_warnings2 | |
251 | |
252 ; warnings only in deco modes | |
253 call check_and_store_sat_violation ; check/show tissue saturation | |
254 call check_cns_violation ; check/show CNS value | |
255 call check_mbubbles ; check/show micro bubbles warning | |
256 movff int_O_lead_supersat+1,WREG ; get upper byte of leading tissue's supersaturation | |
257 btfsc WREG,int_warning_flag ; check if the warning flag is set | |
258 bra surfmode_check_for_warnings2 ; YES - outside model | |
259 rcall surfmode_check_for_desat ; NO - check/display desaturation time | |
260 rcall surfmode_check_for_nofly ; NO - check/display no-fly time | |
261 | |
262 surfmode_check_for_warnings2: | |
263 ; setup message page number | |
264 incf message_page,F ; increment page number | |
265 bcf STATUS,C ; clear carry bit | |
266 rlcf message_page,W ; each page can take two messages | |
267 cpfsgt message_counter ; number of actual messages > message capacity ? | |
268 clrf message_page ; NO - all messages could be shown, restart from first page next time | |
269 | |
270 ; clear both rows if there is nothing to show at all | |
271 tstfsz message_counter ; any message to show? | |
272 bra surfmode_check_for_warnings3 ; YES - look if second row needs to be cleared | |
273 goto TFT_clear_message_window ; NO - clear complete message area and return | |
274 | |
275 surfmode_check_for_warnings3: | |
276 ; clear 2nd row of messages if there is nothing to show (on this page) | |
277 btfss message_2nd_row_used ; does the 2nd row contain a message? | |
278 goto TFT_clear_message_window_row2 ; NO - clear the 2nd row and return | |
279 return ; YES - done | |
280 | |
281 | |
282 surfmode_check_for_desat: | |
283 banksel int_O_desaturation_time | |
284 movf int_O_desaturation_time+0,W | |
285 iorwf int_O_desaturation_time+1,W | |
286 banksel common ; back to bank common | |
287 bnz surfmode_check_for_desat_1 ; is the desat-time > 0 ? | |
288 return ; NO - done | |
289 surfmode_check_for_desat_1: | |
290 incf message_counter,F ; YES - increase counter | |
291 call TFT_desaturation_time ; - show desaturation time | |
292 return ; - done | |
293 | |
294 surfmode_check_for_nofly: | |
295 banksel int_O_nofly_time | |
296 movf int_O_nofly_time+0,W | |
297 iorwf int_O_nofly_time+1,W | |
298 banksel common ; back to bank common | |
299 bnz surfmode_check_for_nofly_1 ; is the nofly-time > 0 ? | |
300 return ; NO - done | |
301 surfmode_check_for_nofly_1: | |
302 incf message_counter,F ; YES - increase counter | |
303 call TFT_nofly_time ; - show nofly-time | |
304 return ; - done | |
305 | |
306 | |
307 ;============================================================================= | |
308 | |
309 test_switches_surfmode: ; check buttons in surface mode | 241 test_switches_surfmode: ; check buttons in surface mode |
310 btfsc switch_right ; right button pressed? | 242 btfsc switch_right ; right button pressed? |
311 bra test_switches_surfmode2 ; YES | 243 bra test_switches_surfmode2 ; YES |
312 btfsc switch_left ; left button pressed? | 244 btfsc switch_left ; left button pressed? |
313 bra test_switches_surfmode3 ; YES | 245 bra test_switches_surfmode3 ; YES |
338 movlw .6 ; coding for surface custom view compass | 270 movlw .6 ; coding for surface custom view compass |
339 cpfseq active_customview ; in compass view? | 271 cpfseq active_customview ; in compass view? |
340 bra test_switches_surfmode3a ; NO | 272 bra test_switches_surfmode3a ; NO |
341 btfsc compass_menu ; YES - "set course" selection already shown? | 273 btfsc compass_menu ; YES - "set course" selection already shown? |
342 bra test_switches_surfmode3b ; YES - remove it | 274 bra test_switches_surfmode3b ; YES - remove it |
343 call TFT_surf_set_bearing ; NO - show it | 275 call TFT_surf_cv_compass_bearing ; NO - show it |
344 return ; - done | 276 return ; - done |
345 ENDIF | 277 ENDIF |
346 test_switches_surfmode3a: | 278 test_switches_surfmode3a: |
347 bcf compass_bearing_set ; clear course on entering menu | 279 bcf compass_bearing_set ; clear course on entering menu |
348 bsf surfmode_menu ; flag that the surface menu shall be entered | 280 bsf surfmode_menu ; flag that the surface menu shall be entered |
354 bcf compass_menu ; clear flag for "set course" selection | 286 bcf compass_menu ; clear flag for "set course" selection |
355 return | 287 return |
356 ENDIF | 288 ENDIF |
357 | 289 |
358 | 290 |
359 ; handle data imprinting, screen dump request, timeout and entering dive mode | 291 ;----------------------------------------------------------------------------- |
292 ; Helper Function - Reset and Restart Timeout for Surface Mode | |
293 ; | |
294 global reset_timeout_surfmode | |
295 reset_timeout_surfmode: | |
296 movlw surfmode_timeout_default ; load default timeout value | |
297 btfss battery_is_36v ; running on a 3.6 V battery? | |
298 movlw surfmode_timeout_aa_15v ; NO - replace by timeout for 1.5V battery | |
299 btfsc simulatormode ; currently in simulator (deco calculator) mode? | |
300 movlw surfmode_timeout_simulator ; YES - replace with simulator timeout | |
301 ;bra restart_timeout_time ; restart timeout | |
302 | |
303 global restart_timeout_time | |
304 restart_timeout_time: ; entry point with timeout value in WREG | |
305 movwf isr_timeout_reload ; copy WREG to isr_timeout_reload | |
306 bsf restart_timeout ; request ISR to restart the timeout | |
307 bcf trigger_timeout ; clear any pending timeout trigger | |
308 return ; done | |
309 | |
310 | |
311 ;============================================================================= | |
312 sfmode2 CODE | |
313 ;============================================================================= | |
314 | |
315 ;----------------------------------------------------------------------------- | |
316 ; Helper Function - Check all possible Surface Mode Warning Conditions | |
317 ; | |
318 surfmode_check_warnings: | |
319 clrf message_counter ; clear message counter | |
320 | |
321 ; warnings for all modes | |
322 call check_battery ; check if the battery level should be displayed/warned | |
323 | |
324 btfsc FLAG_apnoe_mode ; done for Apnoe or Gauge mode | |
325 bra surfmode_check_warnings2 | |
326 btfsc FLAG_gauge_mode ; done for Apnoe or Gauge mode | |
327 bra surfmode_check_warnings2 | |
328 | |
329 ; warnings only in deco modes | |
330 call check_saturation ; check/show tissue saturation | |
331 call check_cns_violation_now ; check/show current CNS value | |
332 call check_mbubbles ; check/show micro bubbles | |
333 movff int_O_lead_supersat+1,WREG ; get upper byte of leading tissue's supersaturation | |
334 btfsc WREG,int_warning_flag ; check if the warning flag is set | |
335 bra surfmode_check_warnings2 ; YES - outside of the model | |
336 rcall surfmode_check_for_desat ; NO - check/show desaturation time | |
337 rcall surfmode_check_for_nofly ; - check/show no-fly time | |
338 | |
339 surfmode_check_warnings2: | |
340 ; setup message page number | |
341 incf message_page,F ; increment page number | |
342 bcf STATUS,C ; clear carry bit | |
343 rlcf message_page,W ; each page can take two messages | |
344 cpfsgt message_counter ; number of actual messages > message capacity ? | |
345 clrf message_page ; NO - all messages could be shown, restart from first page next time | |
346 | |
347 ; clear both rows if there is nothing to show at all | |
348 tstfsz message_counter ; any message to show? | |
349 bra surfmode_check_warnings3 ; YES - look if second row needs to be cleared | |
350 goto TFT_clear_message_window ; NO - clear complete message area and return | |
351 | |
352 surfmode_check_warnings3: | |
353 ; clear 2nd row of messages if there is nothing to show (on this page) | |
354 btfss message_2nd_row_used ; does the 2nd row contain a message? | |
355 goto TFT_clear_message_window_row2 ; NO - clear the 2nd row and return | |
356 return ; YES - done | |
357 | |
358 | |
359 ;----------------------------------------------------------------------------- | |
360 ; Helper Function - check if still in Desaturation, if yes show a Message | |
361 ; | |
362 surfmode_check_for_desat: | |
363 banksel int_O_desaturation_time | |
364 movf int_O_desaturation_time+0,W | |
365 iorwf int_O_desaturation_time+1,W | |
366 banksel common ; back to bank common | |
367 bnz surfmode_check_for_desat_1 ; is the desat-time > 0 ? | |
368 return ; NO - done | |
369 surfmode_check_for_desat_1: | |
370 incf message_counter,F ; YES - increase counter | |
371 call TFT_surf_mesg_desat ; - show desaturation time | |
372 return ; - done | |
373 | |
374 | |
375 ;----------------------------------------------------------------------------- | |
376 ; Helper Function - check if still in no-fly, if yes show a Message | |
377 ; | |
378 surfmode_check_for_nofly: | |
379 banksel int_O_nofly_time | |
380 movf int_O_nofly_time+0,W | |
381 iorwf int_O_nofly_time+1,W | |
382 banksel common ; back to bank common | |
383 bnz surfmode_check_for_nofly_1 ; is the nofly-time > 0 ? | |
384 return ; NO - done | |
385 surfmode_check_for_nofly_1: | |
386 incf message_counter,F ; YES - increase counter | |
387 call TFT_surf_mesg_nofly ; - show nofly-time | |
388 return ; - done | |
389 | |
390 | |
391 ;============================================================================= | |
392 sfmode3 CODE | |
393 ;============================================================================= | |
394 | |
395 ;----------------------------------------------------------------------------- | |
396 ; Data Imprinting, Screen Dump request, Timeout and Entering Dive Mode | |
397 ; | |
360 global housekeeping | 398 global housekeeping |
361 housekeeping: | 399 housekeeping: |
362 btfss trigger_full_second ; new 1/1 second begun? | 400 btfss trigger_full_second ; new 1/1 second begun? |
363 bra housekeeping_1 ; NO | 401 bra housekeeping_1 ; NO |
364 | 402 |
365 ; tasks any new second | 403 ;---- tasks any new second --------- |
404 | |
366 bcf trigger_full_second ; YES - clear flag | 405 bcf trigger_full_second ; YES - clear flag |
367 call get_battery_voltage ; - get battery voltage | 406 call get_battery_voltage ; - get battery voltage |
368 | 407 |
369 btfsc imprint_time_date ; - shall imprint the current time & date? | 408 btfsc imprint_time_date ; - shall imprint the current time & date? |
370 call TFT_show_time_date_menu ; YES - imprint time and date on display (copies running time to latch registers) | 409 call TFT_imprint_time_date ; YES - imprint time and date on display (copies running time to latch registers) |
410 | |
411 btfsc imprint_color_schemes ; - shall imprint color scheme demo? | |
412 call TFT_imprint_color_schemes ; YES - update the color schemes | |
371 | 413 |
372 IFDEF _rx_functions | 414 IFDEF _rx_functions |
373 btfsc tr_functions_activated ; - TR functions activated? | 415 btfsc tr_functions_activated ; - TR functions activated? |
374 call I2C_get_tankdata ; YES - get new transmitter data | 416 call I2C_get_tankdata ; YES - get new transmitter data |
375 | 417 |
376 btfsc imprint_xmitter_pres ; - shall imprint transmitter ID and pressure? | 418 btfsc imprint_xmitter_pres ; - shall imprint transmitter ID and pressure? |
377 call TFT_menu_tank_pres ; YES - imprint transmitter ID and pressure | 419 call TFT_imprint_tank_pres ; YES - imprint transmitter ID and pressure |
378 ENDIF | 420 ENDIF |
379 | 421 |
380 btfss imprint_surfmode_data ; - shall imprint all surface mode data? | 422 btfss imprint_surfmode_data ; - shall imprint all surface mode data? |
381 bra housekeeping_0 ; NO | 423 bra housekeeping_0 ; NO |
382 call TFT_time_surfmode ; YES - update displayed time | 424 call TFT_surfmode_time ; YES - update displayed time |
383 call TFT_batt_surfmode ; - update displayed battery voltage | 425 call TFT_surfmode_batt ; - update displayed battery voltage |
384 btfss timebase_1sec,0 ; - on even second? | 426 btfss timebase_1sec,0 ; - on even second? |
385 call surfmode_check_for_warnings ; YES - check for warnings and display/update them | 427 call surfmode_check_warnings ; YES - check for warnings and display/update them |
386 | 428 |
387 IFDEF _rx_functions | 429 IFDEF _rx_functions |
388 btfss tr_functions_activated ; - TR functions activated? | 430 btfss tr_functions_activated ; - TR functions activated? |
389 bra housekeeping_0 ; NO - skip tank pressure part | 431 bra housekeeping_0 ; NO - skip tank pressure part |
390 | 432 |
391 call get_pressure_readings ; YES - get pressure readings | 433 call get_pressure_readings ; YES - get pressure readings |
392 call TFT_surface_tank_pres ; - update first gas/diluent pressure | 434 call TFT_surfmode_tankpres ; - update first gas/diluent pressure |
393 | 435 |
394 movf active_customview,W ; - get current custom view | 436 movf active_customview,W ; - get current custom view |
395 xorlw .10 ; - coding of tank data custom view | 437 xorlw .10 ; - coding of tank data custom view |
396 btfsc STATUS,Z ; - equal? | 438 btfsc STATUS,Z ; - equal? |
397 call TFT_surface_tankdata ; YES - update tank data custom view | 439 call TFT_surf_cv_tankdata ; YES - update tank data custom view |
398 ENDIF | 440 ENDIF |
399 | 441 |
400 housekeeping_0: | 442 housekeeping_0: |
401 bsf restart_fast ; default to doing a fast restart (no logos) | 443 bsf restart_fast ; default to doing a fast restart (no logos) |
402 call set_dive_modes ; check if dive mode needs to be entered, will set dive mode flag if yes | 444 call check_dive_modes_surf ; check if dive mode needs to be entered, will set dive mode flag if yes |
403 btfsc simulatormode ; in simulator mode? | 445 btfsc simulatormode ; in simulator mode? |
404 bra housekeeping_1 ; YES - can't restart or go to sleep without prior cleanup | 446 bra housekeeping_1 ; YES - can't restart or go to sleep without prior cleanup |
405 btfsc divemode ; NO - need to enter dive mode? | 447 btfsc divemode ; NO - need to enter dive mode? |
406 goto restart ; YES - restart, will proceed to dive mode | 448 goto restart ; YES - restart, will proceed to dive mode |
407 btfss trigger_timeout ; NO - timeout? | 449 btfss trigger_timeout ; NO - timeout? |
413 | 455 |
414 housekeeping_1: | 456 housekeeping_1: |
415 btfss trigger_quarter_second ; new 1/4 second begun? | 457 btfss trigger_quarter_second ; new 1/4 second begun? |
416 bra housekeeping_2 ; NO | 458 bra housekeeping_2 ; NO |
417 | 459 |
418 ; tasks any new 1/4 second | 460 ;---- tasks any new 1/4 second ----- |
461 | |
419 bcf trigger_quarter_second ; YES - clear flag | 462 bcf trigger_quarter_second ; YES - clear flag |
420 IFDEF _external_sensor | 463 IFDEF _external_sensor |
421 btfsc imprint_sensor_mv ; - shall imprint sensor mV data? | 464 btfsc imprint_sensor_mv ; - shall imprint sensor mV data? |
422 call TFT_menu_calibrate ; YES - imprint sensor mV data | 465 call TFT_imprint_menu_mV ; YES - imprint sensor mV data |
423 ENDIF ; _external_sensor | 466 ENDIF ; _external_sensor |
424 btfss imprint_surfmode_data ; - shall imprint all surface mode data? | 467 btfss imprint_surfmode_data ; - shall imprint all surface mode data? |
425 bra housekeeping_2 ; NO | 468 bra housekeeping_2 ; NO |
426 btfsc trigger_pres_cur_changed ; YES - pressure changed? | 469 btfsc trigger_pres_cur_changed ; YES - pressure changed? |
427 call TFT_pres_surfmode ; YES - display surface pressure | 470 call TFT_surfmode_pres_fast ; YES - display surface pressure, but only if change > threshold |
428 bcf trigger_pres_cur_changed ; - clear flag (anyhow) | 471 bcf trigger_pres_cur_changed ; - clear flag (anyhow) |
429 IFDEF _compass | 472 IFDEF _compass |
430 movf active_customview,W ; - get current custom view | 473 movf active_customview,W ; - get current custom view |
431 xorlw .6 ; - coding of compass custom view | 474 xorlw .6 ; - coding of compass custom view |
432 btfsc STATUS,Z ; - equal? | 475 btfsc STATUS,Z ; - equal? |
436 btfsc FLAG_ccr_mode ; - in CCR mode? | 479 btfsc FLAG_ccr_mode ; - in CCR mode? |
437 bra housekeeping_1a ; - YES - handle sensors | 480 bra housekeeping_1a ; - YES - handle sensors |
438 btfsc FLAG_pscr_mode ; - in pSCR mode? | 481 btfsc FLAG_pscr_mode ; - in pSCR mode? |
439 bra housekeeping_1a ; YES - handle sensors | 482 bra housekeeping_1a ; YES - handle sensors |
440 bra housekeeping_2 ; NO to both | 483 bra housekeeping_2 ; NO to both |
484 | |
441 housekeeping_1a: ; handle sensors | 485 housekeeping_1a: ; handle sensors |
442 movff opt_ccr_mode,WREG ; =0: fixed SP, =1: sensor, =2: autoSP | 486 movff opt_ccr_mode,WREG ; =0: fixed SP, =1: sensor, =2: autoSP |
443 decfsz WREG ; opt_ccr_mode = 1 (sensor)? | 487 decfsz WREG ; opt_ccr_mode = 1 (sensor)? |
444 bra housekeeping_2 ; NO - skip sensor readings | 488 bra housekeeping_2 ; NO - skip sensor readings |
445 call calc_deko_divemode_sensor ; YES - read & calculate sensor data | 489 call calc_deko_divemode_sensor ; YES - read & calculate sensor data |
446 call TFT_surface_sensor ; - update displayed sensor data | 490 call TFT_imprint_surf_ppO2 ; - update displayed sensor data |
447 call TFT_sensor_surface_warning ; - show a down-arrow behind sensor readings when sensor is at end-of-life | 491 call TFT_imprint_surf_sensor_eol ; - show a down-arrow behind sensor readings when sensor is at end-of-life |
448 movf active_customview,W ; - get current custom view | 492 movf active_customview,W ; - get current custom view |
449 xorlw .9 ; - coding of sensor mV readings custom view | 493 xorlw .9 ; - coding of sensor mV readings custom view |
450 btfsc STATUS,Z ; - equal? | 494 btfsc STATUS,Z ; - equal? |
451 call TFT_sensor_mV ; YES - update mV readings | 495 call TFT_imprint_surf_mV ; YES - update mV readings |
452 ENDIF ; _external_sensor | 496 ENDIF ; _external_sensor |
497 | |
453 housekeeping_2: | 498 housekeeping_2: |
454 btfss trigger_full_minute ; new 1/1 minute begun? | 499 btfss trigger_full_minute ; new 1/1 minute begun? |
455 bra housekeeping_3 ; NO | 500 bra housekeeping_3 ; NO |
456 | 501 |
457 ; tasks any new minute | 502 ;---- tasks any new minute --------- |
503 | |
458 bcf trigger_full_minute ; YES - clear flag | 504 bcf trigger_full_minute ; YES - clear flag |
505 | |
506 btfss imprint_surfmode_data ; - shall imprint all surface mode data? | |
507 bra housekeeping_2a ; NO | |
508 btfsc trigger_pres_cur_changed ; YES - pressure changed? | |
509 call TFT_surfmode_pres ; YES - display surface pressure | |
510 bcf trigger_pres_cur_changed ; - clear flag (anyhow) | |
511 | |
512 housekeeping_2a: | |
459 btfsc simulatormode ; - in simulator mode? | 513 btfsc simulatormode ; - in simulator mode? |
460 bra housekeeping_2a ; YES - real tissues are in the vault, skip desaturation calculations | 514 bra housekeeping_2b ; YES - real tissues are in the vault, skip desaturation calculations |
461 call deco_calc_dive_interval_1min; NO - calculate 1 minute at surface conditions (C-code) | 515 call deco_calc_dive_interval_1min; NO - calculate 1 minute at surface conditions (C-code) |
462 call deco_calc_desaturation_time ; - calculate desaturation and no-fly/no-altitude time (C-code) | 516 call deco_calc_desaturation_time ; - calculate desaturation and no-fly/no-altitude time (C-code) |
463 banksel common ; - back to bank common | 517 banksel common ; - back to bank common |
464 housekeeping_2a: | 518 |
519 housekeeping_2b: | |
465 btfss imprint_surfmode_data ; - shall imprint all surface mode data? | 520 btfss imprint_surfmode_data ; - shall imprint all surface mode data? |
466 bra housekeeping_3 ; NO | 521 bra housekeeping_3 ; NO |
467 call TFT_date_surfmode ; YES - update displayed date | 522 call TFT_surfmode_date ; YES - update displayed date |
468 | 523 |
469 btfsc trigger_temp_changed ; - temperature changed? | 524 btfsc trigger_temp_changed ; - temperature changed? |
470 call TFT_temp_surfmode ; YES - display temperature | 525 call TFT_surfmode_temp ; YES - display temperature |
471 bcf trigger_temp_changed ; - clear flag (anyhow) | 526 bcf trigger_temp_changed ; - clear flag (anyhow) |
472 | 527 |
473 movf active_customview,W ; - get current custom view | 528 movf active_customview,W ; - get current custom view |
474 xorlw .5 ; - coding of tissue custom view | 529 xorlw .5 ; - coding of tissue custom view |
475 btfsc STATUS,Z ; - equal? | 530 btfsc STATUS,Z ; - equal? |
476 call TFT_surface_tissues ; YES - update tissue diagram | 531 call TFT_surf_cv_tissues ; YES - update tissue diagram |
477 | 532 |
478 movf active_customview,W ; - get current custom view | 533 movf active_customview,W ; - get current custom view |
479 xorlw .8 ; - coding of last dive info custom view | 534 xorlw .8 ; - coding of last dive info custom view |
480 btfsc STATUS,Z ; - equal? | 535 btfsc STATUS,Z ; - equal? |
481 call TFT_surface_lastdive ; YES - update last dive infos | 536 call TFT_surf_cv_lastdive ; YES - update last dive infos |
482 | 537 |
483 housekeeping_3: | 538 housekeeping_3: |
484 ; tasks any round | 539 |
540 ;---- tasks any round -------------- | |
541 | |
485 IFDEF _screendump | 542 IFDEF _screendump |
486 btfsc screen_dump_avail ; screen dump function enabled? | 543 btfsc screen_dump_avail ; screen dump function enabled? |
487 call TFT_dump_screen_check ; YES - check if requested and do it | 544 call TFT_dump_screen_check ; YES - check if requested and do it |
488 ELSE | 545 ELSE |
489 btfsc comm_mode_disabled ; COMM mode disabled? | 546 btfsc comm_mode_disabled ; COMM mode disabled? |
503 ENDIF | 560 ENDIF |
504 btfss ble_available ; skip "USB" check in all Bluetooth models (required for very old OSTC sport) | 561 btfss ble_available ; skip "USB" check in all Bluetooth models (required for very old OSTC sport) |
505 goto comm_mode_usb ; YES / NO - proceed to COMM mode, will also set CPU to speed normal | 562 goto comm_mode_usb ; YES / NO - proceed to COMM mode, will also set CPU to speed normal |
506 return | 563 return |
507 | 564 |
508 | |
509 global reset_timeout_surfmode | |
510 reset_timeout_surfmode: | |
511 movlw surfmode_timeout_default ; load default timeout value | |
512 btfss battery_is_36v ; running on a 3.6 V battery? | |
513 movlw surfmode_timeout_aa_15v ; NO - replace by timeout for 1.5V battery | |
514 btfsc simulatormode ; currently in simulator (deco calculator) mode? | |
515 movlw surfmode_timeout_simulator ; YES - replace with simulator timeout | |
516 ;bra reset_timeout_time ; set timeout value | |
517 | |
518 ; btfsc imprint_sensor_mv ; currently imprinting O2 sensor mV data? | |
519 ; movlw surfmode_timeout_calibrate ; YES - replace with CCR Calibrate Menu timeout | |
520 ; IFDEF _rx_functions | |
521 ; btfsc imprint_xmitter_ID ; currently selecting pressure transmitter? | |
522 ; movlw surfmode_timeout_xmitter ; YES - replace with transmitter selection timeout | |
523 ; ENDIF ; _rx_functions | |
524 ; IFDEF _external_sensor | |
525 ; btfsc surfmode_menu ; in surface menu? | |
526 ; bra reset_timeout_time ; YES - keep timeout value | |
527 ; btfsc FLAG_ccr_mode ; NO - in CCR mode? | |
528 ; bra reset_timeout_surfmode_loop ; YES - continue checking if in sensor mode | |
529 ; btfsc FLAG_ccr_mode ; NO - in pSCR mode? | |
530 ; bra reset_timeout_surfmode_loop ; YES - continue checking if in sensor mode | |
531 ; bra reset_timeout_time ; NO - keep timeout value | |
532 ;reset_timeout_surfmode_loop: | |
533 ; movff opt_ccr_mode,lo ; get loop mode (=0: fixed/calculated SP, =1: sensor, =2: auto SP) | |
534 ; decfsz lo,f ; in sensor mode? | |
535 ; bra reset_timeout_time ; NO - keep timeout value | |
536 ; movlw surfmode_timeout_sensor ; YES - replace with sensor mode timeout | |
537 ; ENDIF ; _external_sensor | |
538 ; ;bra reset_timeout_time ; set timeout value | |
539 | |
540 | |
541 global reset_timeout_time | |
542 reset_timeout_time: ; entry point with timeout value in WREG | |
543 movwf isr_timeout_reload ; copy WREG to isr_timeout_reload | |
544 bsf reset_timeout ; request ISR to reset the timeout | |
545 bcf trigger_timeout ; clear any pending timeout trigger | |
546 return ; done | |
547 | |
548 ;----------------------------------------------------------------------------- | 565 ;----------------------------------------------------------------------------- |
549 | 566 |
550 END | 567 END |