Mercurial > public > hwos_code
comparison src/surfmode.asm @ 604:ca4556fb60b9
bump to 2.99beta, work on 3.00 stable
| author | heinrichsweikamp |
|---|---|
| date | Thu, 22 Nov 2018 19:47:26 +0100 |
| parents | e81cf407261a |
| children | 1ad0531e9078 |
comparison
equal
deleted
inserted
replaced
| 603:00b24fb4324d | 604:ca4556fb60b9 |
|---|---|
| 1 ;============================================================================= | 1 ;============================================================================= |
| 2 ; | 2 ; |
| 3 ; File surfmode.asm REFACTORED VERSION V2.97 SP1 | 3 ; File surfmode.asm REFACTORED VERSION V2.99e |
| 4 ; | 4 ; |
| 5 ; Surfacemode | 5 ; Surfacemode |
| 6 ; | 6 ; |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
| 8 ;============================================================================= | 8 ;============================================================================= |
| 27 #include "i2c.inc" | 27 #include "i2c.inc" |
| 28 #include "comm.inc" | 28 #include "comm.inc" |
| 29 #include "eeprom_rs232.inc" | 29 #include "eeprom_rs232.inc" |
| 30 #include "calibrate.inc" | 30 #include "calibrate.inc" |
| 31 | 31 |
| 32 IFDEF _rx_functions | |
| 33 #include "rx_ops.inc" | |
| 34 ENDIF | |
| 35 | |
| 32 extern do_main_menu | 36 extern do_main_menu |
| 33 extern color_image | 37 extern TFT_sensor_mV |
| 38 extern TFT_surface_compass_heading | |
| 39 extern check_cns_violation | |
| 40 extern check_warn_battery | |
| 41 extern check_and_store_gf_violation | |
| 42 extern check_mbubbles | |
| 43 | |
| 44 IFDEF _osct_logo | |
| 45 extern ostc_logo_block | |
| 46 ENDIF | |
| 34 | 47 |
| 35 | 48 |
| 36 ;---- Private local variables ------------------------------------------------- | 49 ;---- Private local variables ------------------------------------------------- |
| 37 | 50 |
| 38 CBLOCK local1 ; max size is 16 Byte !!! | 51 CBLOCK local1 ; max size is 16 Byte !!! |
| 39 ; currently not used | 52 ; currently not used |
| 40 ENDC ; used: 0 byte, remaining: 16 byte | 53 ENDC ; used: 0 byte, remaining: 16 byte |
| 41 | 54 |
| 42 | 55 |
| 43 #DEFINE menu_pos_row .215 | 56 #DEFINE menu_pos_row .215 |
| 44 #DEFINE menu_pos_column .1 | 57 #DEFINE menu_pos_column .1 |
| 45 #DEFINE view_row .215 | 58 #DEFINE view_row .215 |
| 46 #DEFINE view_column .124 | 59 #DEFINE view_column .124 |
| 47 | 60 |
| 48 gui CODE | 61 sfmode CODE |
| 49 | 62 |
| 50 ;============================================================================= | 63 ;============================================================================= |
| 51 ; Boot tasks for all modes | 64 ; Boot tasks for all modes |
| 65 | |
| 52 global surfloop | 66 global surfloop |
| 53 surfloop: | 67 surfloop: |
| 54 call speed_normal | 68 call speed_normal |
| 55 bcf no_sensor_int ; Normal pressure mode | 69 bcf no_sensor_int ; normal pressure mode |
| 56 | 70 |
| 57 bcf LEDr | 71 bcf LEDr |
| 58 | 72 |
| 59 clrf CCP1CON ; stop PWM | 73 clrf CCP1CON ; stop PWM |
| 60 bcf PORTC,2 ; Pull PWM output to GND | 74 bcf PORTC,2 ; pull PWM output to GND |
| 61 call TFT_boot ; Initialize TFT (includes clear screen) | 75 call TFT_boot ; initialize TFT (includes clear screen) |
| 62 bcf restore_deco_data | 76 bcf restore_deco_data |
| 63 | 77 |
| 64 WIN_TOP .50 | 78 WIN_TOP .40 |
| 65 WIN_LEFT .10 | 79 WIN_LEFT .10 |
| 66 movlw LOW 0x1E000 | 80 TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block ; show heinrichsweikamp logo |
| 67 movwf TBLPTRL | 81 |
| 68 movlw HIGH 0x1E000 | 82 IFDEF _ostc_logo |
| 69 movwf TBLPTRH | 83 WIN_TOP .100 |
| 70 movlw UPPER 0x1E000 | |
| 71 movwf TBLPTRU | |
| 72 call color_image ; Show logo | |
| 73 | |
| 74 WIN_TOP .100 | |
| 75 WIN_LEFT .34 | 84 WIN_LEFT .34 |
| 76 extern ostc_logo_block | 85 TFT_WRITE_PROM_IMAGE_BY_LABEL ostc_logo_block ; show OSTC logo |
| 77 movlw LOW ostc_logo_block | 86 ELSE |
| 78 movwf TBLPTRL | 87 WIN_COLOR color_white |
| 79 movlw HIGH ostc_logo_block ; &0xFFFF | 88 WIN_STD .30,.90 ; column, row |
| 80 movwf TBLPTRH | 89 STRCPY_PRINT "Open Source" ; show OSTC banner text, line 1 |
| 81 movlw UPPER ostc_logo_block | 90 WIN_STD .20,.130 ; column, row |
| 82 movwf TBLPTRU | 91 STRCPY_PRINT "Tauch-Computer" ; show OSTC banner text, line 2 |
| 83 call color_image | 92 ENDIF |
| 84 call TFT_Display_FadeIn ; Show splash | 93 |
| 85 call TFT_serial ; Show serial and firmware version | 94 WIN_COLOR color_white |
| 95 WIN_SMALL .35,.180 | |
| 96 PUTC "v" ; print v | |
| 97 call TFT_cat_firmware ; print x.y | |
| 98 PUTC " " ; print _ | |
| 99 call TFT_cat_beta_release ; print BetaZ or Release | |
| 100 STRCAT_PRINT "" ; finalize output | |
| 101 bcf win_invert ; clean up eventual color-coding | |
| 102 call TFT_standard_color ; ditto | |
| 103 | |
| 104 call TFT_Display_FadeIn ; show splash | |
| 86 | 105 |
| 87 ;---- Do any useful initializes that takes time ------------------------- | 106 ;---- Do any useful initializes that takes time ------------------------- |
| 88 call restart_set_modes_and_flags ; Sets deco mode flags | 107 |
| 108 call restart_set_modes_and_flags ; sets deco mode flags | |
| 89 bcf pressure_refresh | 109 bcf pressure_refresh |
| 90 call I2C_init_compass | 110 call I2C_sleep_compass |
| 91 call I2C_init_accelerometer | 111 call I2C_sleep_accelerometer |
| 92 clrf ext_flash_address+0 | 112 clrf ext_flash_address+0 |
| 93 clrf ext_flash_address+1 | 113 clrf ext_flash_address+1 |
| 94 clrf ext_flash_address+2 | 114 clrf ext_flash_address+2 |
| 95 | 115 |
| 96 movlw surface_sp ; in cbar | 116 movlw surface_sp ; in cbar |
| 97 call transmit_setpoint ; Transmit current setpoint from WREG (in cbar) to external electronics | 117 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics |
| 98 | 118 |
| 99 clrf timeout_counter2 | 119 clrf timeout_counter2 |
| 100 ; clrf timeout_counter3 ; not used / required [rl] | 120 ; clrf timeout_counter3 ; not used / required [rl] |
| 101 bcf menubit ; clear menu flag | 121 bcf menubit ; clear menu flag |
| 102 bcf premenu | 122 bcf premenu |
| 103 clrf last_pressure+0 | 123 clrf last_pressure+0 |
| 104 clrf last_pressure+1 | 124 clrf last_pressure+1 |
| 105 bcf is_bailout ; =1: Bailout | 125 bcf FLAG_bailout_mode ; =1: Bailout |
| 106 bcf ccr_diluent_setup ; Use OC gases for gaslist routine | 126 bcf FLAG_diluent_setup ; use OC gases for gaslist routine |
| 107 | 127 |
| 108 bcf simulatormode_active ; Quit simulator mode (if active) | 128 bcf simulatormode_active ; quit simulator mode (if active) |
| 129 | |
| 130 call wait_1s ; wait <= 1 second | |
| 131 call wait_1s ; wait 1 second | |
| 132 call wait_1s ; wait 1 second | |
| 109 | 133 |
| 110 ;---- Fade to standard surface view -------------------------------------- | 134 ;---- Fade to standard surface view -------------------------------------- |
| 111 ; Wait 1 second | 135 |
| 112 bcf onesecupdate | 136 call TFT_Display_FadeOut ; go to black screen |
| 113 btfss onesecupdate | 137 call TFT_ClearScreen ; then change everything |
| 114 bra $-2 | 138 WIN_TOP .0 |
| 115 ; Wait 1 second | |
| 116 bcf onesecupdate | |
| 117 btfss onesecupdate | |
| 118 bra $-2 | |
| 119 | |
| 120 call TFT_Display_FadeOut ; Go to black screen | |
| 121 call TFT_ClearScreen ; Then change everything | |
| 122 WIN_TOP .0 | |
| 123 WIN_LEFT .0 | 139 WIN_LEFT .0 |
| 124 WIN_FONT FT_SMALL | 140 WIN_FONT FT_SMALL |
| 125 bcf win_invert ; Reset invert flag | 141 bcf win_invert ; reset invert flag |
| 126 | 142 |
| 127 WIN_COLOR color_lightblue | 143 WIN_COLOR color_lightblue |
| 128 WIN_SMALL menu_pos_column,menu_pos_row | 144 WIN_SMALL menu_pos_column,menu_pos_row |
| 129 STRCPY_TEXT_PRINT tMenu ;"<Menu" | 145 STRCPY_TEXT_PRINT tMenu ;"<Menu" |
| 130 WIN_SMALL view_column,view_row | 146 WIN_SMALL view_column,view_row |
| 131 STRCPY_TEXT_PRINT tView ;"View>" | 147 STRCPY_TEXT_PRINT tView ;"View>" |
| 132 call TFT_standard_color | 148 call TFT_standard_color |
| 133 | 149 |
| 134 ; Logo | 150 ; Logo |
| 135 WIN_TOP .0 | 151 IFDEF _ostc_logo |
| 152 WIN_TOP .0 | |
| 136 WIN_LEFT .70 | 153 WIN_LEFT .70 |
| 137 movlw LOW ostc_logo_block | 154 TFT_WRITE_PROM_IMAGE_BY_LABEL ostc_logo_block ; show OSTC logo |
| 138 movwf TBLPTRL | 155 ELSE |
| 139 movlw HIGH ostc_logo_block ; &0xFFFF | 156 WIN_COLOR color_white |
| 140 movwf TBLPTRH | 157 WIN_STD .100,.0 |
| 141 movlw UPPER ostc_logo_block | 158 STRCPY_PRINT "OSTC" ; show "OSTC" |
| 142 movwf TBLPTRU | 159 WIN_COLOR color_cyan |
| 143 call color_image | 160 WIN_TINY .140,.0 |
| 161 STRCPY_PRINT "hwOS" ; show "hwOS" | |
| 162 WIN_TINY .139,.12 | |
| 163 STRCPY_PRINT "tech" ; show "tech" | |
| 164 ENDIF | |
| 144 | 165 |
| 145 call TFT_clock ; display time | 166 call TFT_clock ; display time |
| 146 call update_surfloop60 | 167 call update_surfloop60 |
| 147 call get_battery_voltage ; get battery voltage | 168 call get_battery_voltage ; get battery voltage |
| 148 call TFT_update_batt_voltage ; display battery voltage | 169 call TFT_update_batt_voltage ; display battery voltage |
| 149 call TFT_update_surf_press ; display surface pressure | 170 call TFT_update_surf_press ; display surface pressure |
| 150 call TFT_temp_surfmode ; Displays temperature | 171 call TFT_temp_surfmode ; display temperature |
| 151 call TFT_display_decotype_surface | 172 call TFT_display_decotype_surface |
| 152 call calc_deko_divemode_sensor | 173 call calc_deko_divemode_sensor |
| 153 | 174 |
| 154 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR | 175 TSTOSS opt_dive_mode ; in OC ? (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR) |
| 155 tstfsz lo | 176 call TFT_show_OC_startgas_surface; YES - show first gas and "OSTC2-like" active gases |
| 156 bra surfloop_no_oc ; Not OC | 177 |
| 157 call TFT_show_OC_startgas_surface; Show first gas and "OSTC2-like" active gases | 178 movff customview_surfmode,menupos3; reload last custom view |
| 158 surfloop_no_oc: | 179 call surf_customview_mask ; redraw last custom view |
| 159 movff customview_surfmode,menupos3; Reload last customview | 180 |
| 160 call surf_customview_mask ; Update #menupos3 view | 181 call TFT_Display_FadeIn ; display resulting surface screen |
| 161 | |
| 162 call TFT_Display_FadeIn ; Display resulting surface screen. | |
| 163 | 182 |
| 164 bcf switch_left | 183 bcf switch_left |
| 165 bcf switch_right | 184 bcf switch_right |
| 166 | 185 |
| 167 ;---- Late initializations ----------------------------------------------- | 186 ;---- Late initializations ----------------------------------------------- |
| 168 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine | 187 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine |
| 169 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values | 188 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values |
| 170 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine | 189 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine |
| 171 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values | 190 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values |
| 172 movff last_surfpressure_30min+0,last_surfpressure+0 ; Use 30min old airpressure | 191 movff last_surfpressure_30min+0,last_surfpressure+0 ; use 30min old air pressure |
| 173 movff last_surfpressure_30min+1,last_surfpressure+1 ; Use 30min old airpressure | 192 movff last_surfpressure_30min+1,last_surfpressure+1 ; use 30min old air pressure |
| 174 | 193 |
| 175 movff opt_GF_low,char_I_GF_Low_percentage | 194 movff opt_GF_low,char_I_GF_Low_percentage |
| 176 movff opt_GF_high,char_I_GF_High_percentage | 195 movff opt_GF_high,char_I_GF_High_percentage |
| 177 | 196 |
| 178 ; Startup tasks for all modes | 197 ; Startup tasks for all modes |
| 180 ; int_I_pres_surface | 199 ; int_I_pres_surface |
| 181 ; char_I_desaturation_multiplier | 200 ; char_I_desaturation_multiplier |
| 182 call deco_calc_desaturation_time ; calculate desaturation time | 201 call deco_calc_desaturation_time ; calculate desaturation time |
| 183 banksel common | 202 banksel common |
| 184 | 203 |
| 185 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | 204 IFDEF _screendump |
| 186 call enable_rs232 ; Also sets to speed_normal ... | 205 btfsc enable_screen_dumps ; =1: ignore vin_usb, wait for "l" command (Screen dump) |
| 206 call enable_rs232 ; also sets to speed_normal | |
| 207 ENDIF | |
| 187 | 208 |
| 188 surfloop_loop: | 209 surfloop_loop: |
| 189 btfss onesecupdate ; do every second tasks? | 210 btfss onesecupdate ; do every second tasks? |
| 190 bra surfloop_loop2 ; no, loop | 211 bra surfloop_loop2 ; NO - loop |
| 191 | 212 |
| 192 ; One Second tasks for all modes | 213 ; one second tasks for all modes |
| 193 call speed_normal | 214 call speed_normal |
| 194 ;call TFT_debug_output | 215 ;call TFT_debug_output |
| 195 call TFT_clock ; update clock | 216 call TFT_clock ; update clock |
| 196 call timeout_surfmode ; check timeout | 217 call timeout_surfmode ; check timeout |
| 197 call get_battery_voltage ; get battery voltage | 218 call get_battery_voltage ; get battery voltage |
| 198 call TFT_update_batt_voltage ; display battery voltage | 219 call TFT_update_batt_voltage ; display battery voltage |
| 199 call set_dive_modes ; tests if depth>threshold | 220 call set_dive_modes ; tests if depth > threshold |
| 200 btfss secs,0 ; Every two seconds... | 221 btfss secs,0 ; every two seconds... |
| 201 call TFT_temp_surfmode ; Displays temperature | 222 call TFT_temp_surfmode ; ... displays temperature |
| 202 btfss secs,0 ; Every two seconds... | 223 btfss secs,0 ; every two seconds... |
| 203 call surfmode_check_for_warnings ; ... check for warnings (and display/update) them | 224 call surfmode_check_for_warnings ; ... check for warnings (and display/update) them |
| 204 bcf onesecupdate ; every second tasks done | 225 bcf onesecupdate ; every second tasks done |
| 205 | 226 |
| 206 surfloop_loop2: | 227 IFDEF _rx_functions |
| 207 ; Tasks approx. every 50ms for all modes | 228 btfss FLAG_tr_enabled ; YES - TR functions enabled? |
| 229 bra surfloop_loop2 ; NO - skip tank pressure part | |
| 230 call get_pressure_readings ; YES - get pressure readings | |
| 231 call TFT_surface_tank_pres ; - update first gas/diluent pressure | |
| 232 movlw .10 ; - number of tank data custom view | |
| 233 cpfseq menupos3 ; - in tank data custom view? | |
| 234 bra surfloop_loop2 ; NO - skip | |
| 235 call TFT_surface_tankdata ; YES - update tank data custom view | |
| 236 ENDIF | |
| 237 | |
| 238 surfloop_loop2: | |
| 239 ; tasks approx. every 50 ms for all modes | |
| 208 call test_switches_surfmode ; check switches | 240 call test_switches_surfmode ; check switches |
| 209 call TFT_debug_output | 241 ;call TFT_debug_output |
| 210 | 242 |
| 211 ; One minute tasks for all modes | 243 ; one minute tasks for all modes |
| 212 btfsc oneminupdate ; do every minute tasks | 244 btfsc oneminupdate ; do every minute tasks |
| 213 call update_surfloop60 ; yes, e.g. update time and date | 245 call update_surfloop60 ; yes, e.g. update time and date |
| 214 | 246 |
| 215 ; Mode tasks | 247 ; mode tasks |
| 216 btfsc divemode ; Divemode active? | 248 btfsc divemode ; divemode active? |
| 217 goto diveloop ; Yes, switch into Divemode! | 249 goto diveloop ; YES - switch into divemode! |
| 218 | 250 |
| 219 btfsc menubit ; Menu? | 251 btfsc menubit ; shall enter menu? |
| 220 goto do_main_menu ; Menu! | 252 goto do_main_menu ; YES - enter menu |
| 221 | 253 |
| 222 btfsc pressure_refresh ; new pressure available? | 254 btfsc pressure_refresh ; new pressure available? |
| 223 call TFT_update_surf_press ; display surface pressure | 255 call TFT_update_surf_press ; display surface pressure |
| 224 bcf pressure_refresh ; until new pressure is available | 256 bcf pressure_refresh ; until new pressure is available |
| 225 | 257 |
| 226 ; Updates every 1/4 second | 258 ; updates every 1/4 second |
| 227 btfss quarter_second_update | 259 btfss quarter_second_update |
| 228 bra surfloop_loop2b | 260 bra surfloop_loop2b |
| 229 | 261 |
| 230 bcf quarter_second_update | 262 bcf quarter_second_update |
| 231 | 263 |
| 232 ; Update Sensors | 264 ; update sensors |
| 233 call calc_deko_divemode_sensor | 265 call calc_deko_divemode_sensor |
| 234 | 266 |
| 235 btfsc FLAG_ccr_mode ; In CCR mode? | 267 btfsc FLAG_ccr_mode ; in CCR mode? |
| 236 bra surfloop_loop2a1 ; Yes. | 268 bra surfloop_loop2a1 ; YES |
| 237 btfss FLAG_pscr_mode ; In PSCR mode? | 269 btfsc FLAG_pscr_mode ; in pSCR mode? |
| 238 bra surfloop_loop2a ; No, skip | 270 bra surfloop_loop2a1 ; YES |
| 271 bra surfloop_loop2a ; NO to both | |
| 239 | 272 |
| 240 surfloop_loop2a1: | 273 surfloop_loop2a1: |
| 241 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP | 274 movff opt_ccr_mode,WREG ; =0: fixed SP, =1: sensor, =2: auto SP |
| 242 sublw .1 ; opt_ccr_mode = 1 (Sensor)? | 275 decfsz WREG ; opt_ccr_mode = 1 (sensor)? |
| 243 bnz surfloop_loop2a ; No, skip | 276 bra surfloop_loop2a ; NO - skip sensor readings |
| 244 | 277 |
| 245 call TFT_surface_sensor ; ...update sensor data in surface mode | 278 call TFT_surface_sensor ; ...update sensor data in surface mode |
| 246 call TFT_sensor_surface_warning ; Show a warning arrow-down behind sensor readings when sensor is end-of-life | 279 call TFT_sensor_surface_warning ; show a warning arrow-down behind sensor readings when sensor is end-of-life |
| 247 movlw .9 | 280 movlw .9 |
| 248 cpfseq menupos3 ; in Sensor mV surface custom view? | 281 cpfseq menupos3 ; in sensor mV surface custom view? |
| 249 bra surfloop_loop2a ; No | 282 bra surfloop_loop2a ; NO |
| 250 extern TFT_sensor_mV | 283 call TFT_sensor_mV ; YES - update mV readings (Each 1/4 second and not each second as in customview.asm) |
| 251 call TFT_sensor_mV ; Yes, update mV readings (Each 1/4 second and not each second as in customview.asm) | |
| 252 | 284 |
| 253 surfloop_loop2a: | 285 surfloop_loop2a: |
| 254 movlw .6 | 286 movlw .6 |
| 255 cpfseq menupos3 ; in compass view? | 287 cpfseq menupos3 ; in compass view? |
| 256 bra surfloop_loop2b ; No | 288 bra surfloop_loop2b ; NO |
| 257 extern TFT_surface_compass_heading | 289 call TFT_surface_compass_heading ; YES - update compass heading value |
| 258 call TFT_surface_compass_heading ; Yes, update compass heading value | |
| 259 | 290 |
| 260 surfloop_loop2b: | 291 surfloop_loop2b: |
| 261 btfsc toggle_customview ; Next view? | 292 btfsc toggle_customview ; next view? |
| 262 call surf_customview_toggle ; Yes, show next customview (and delete this flag) | 293 call surf_customview_toggle ; YES - show next customview (and delete this flag) |
| 263 | 294 |
| 264 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | 295 IFDEF _screendump |
| 265 bra surfloop_loop3 | 296 btfsc enable_screen_dumps ; screendump enabled? |
| 266 | 297 call TFT_dump_screen_check ; YES - check if requested and do it |
| 267 ;btfsc vusb_in ; USB plugged in? | 298 ENDIF |
| 268 ;call comm_mode ; Start COMM mode | 299 |
| 269 | 300 ;btfsc vusb_in ; USB plugged in? | commented out - do not start COMM mode when charging in surface mode |
| 270 bra surfloop_loop4 | 301 ;call comm_mode ; YES - start COMM mode | |
| 271 | 302 |
| 272 surfloop_loop3: | 303 btfss sleepmode ; shall we go into sleep mode? |
| 273 btfss vusb_in ; USB (still) plugged in? | 304 bra surfloop_loop ; NO - loop in surface mode |
| 274 bcf enable_screen_dumps ; No, clear flag | 305 movff menupos3,customview_surfmode; YES - save last custom view |
| 275 call rs232_get_byte | 306 goto sleeploop ; switch into sleep mode |
| 276 btfsc rs232_receive_overflow | |
| 277 bra surfloop_loop4 | |
| 278 movlw "l" | |
| 279 cpfseq RCREG1 | |
| 280 bra surfloop_loop4 | |
| 281 call TFT_dump_screen ; Dump the screen contents | |
| 282 | |
| 283 surfloop_loop4: | |
| 284 btfss sleepmode ; shall we go into sleepmode? | |
| 285 bra surfloop_loop ; NO - loop in surfacemode | |
| 286 movff menupos3,customview_surfmode; YES - save last customview | |
| 287 goto sleeploop ; switch into sleepmode | |
| 288 | |
| 289 | 307 |
| 290 update_surfloop60: | 308 update_surfloop60: |
| 291 ; One minute tasks for all modes | 309 ; one minute tasks for all modes |
| 292 call TFT_date ; Update date | 310 call TFT_date ; update date |
| 293 | 311 |
| 294 call deco_calc_dive_interval_1min; calculate deco in surface mode. int_I_pres_surface gets updated by | 312 call deco_calc_dive_interval_1min; calculate deco in surface mode. int_I_pres_surface gets updated by |
| 295 call deco_calc_desaturation_time ; TFT_update_surf_press when amb_pressure has changed by >= 10 mbar | 313 call deco_calc_desaturation_time ; TFT_update_surf_press when amb_pressure has changed by >= 10 mbar |
| 296 banksel common | 314 banksel common |
| 297 | 315 |
| 298 ; update tissue diagram if it is on display | 316 ; update tissue diagram if it is on display |
| 299 movlw .5 ; number of tissue custom view | 317 movlw .5 ; number of tissue custom view |
| 300 cpfseq menupos3 ; is this the current customview? | 318 cpfseq menupos3 ; is this the current custom view? |
| 301 bra update_surfloop60_1 ; NO | 319 bra update_surfloop60_1 ; NO |
| 302 call TFT_standard_color ; YES - set standard color | 320 call TFT_standard_color ; YES - set standard color |
| 303 call TFT_surface_tissues ; show tissue diagram | 321 call TFT_surface_tissues ; show tissue diagram |
| 304 | 322 |
| 305 update_surfloop60_1: | 323 update_surfloop60_1: |
| 306 ; update last dive info if it is on display | 324 ; update last dive info if it is on display |
| 307 movlw .8 ; number of the last dive info customview | 325 movlw .8 ; number of the last dive info custom view |
| 308 cpfseq menupos3 ; is this the current customview? | 326 cpfseq menupos3 ; is this the current custom view? |
| 309 bra update_surfloop60_2 ; NO | 327 bra update_surfloop60_2 ; NO |
| 310 call TFT_standard_color ; YES - set standard color | 328 call TFT_standard_color ; YES - set standard color |
| 311 call TFT_surface_lastdive ; show last dive infos | 329 call TFT_surface_lastdive ; show last dive infos |
| 312 | 330 |
| 313 update_surfloop60_2: | 331 update_surfloop60_2: |
| 314 bcf oneminupdate | 332 bcf oneminupdate |
| 315 return | 333 return |
| 316 | 334 |
| 317 extern check_cns_violation,check_warn_battery,check_and_store_gf_violation | |
| 318 surfmode_check_for_warnings: | 335 surfmode_check_for_warnings: |
| 319 bcf warning_active ; Clear flag | 336 bcf message_attention ; clear flag for messages of level attention |
| 320 clrf warning_counter ; Clear counter | 337 bcf message_warning ; clear flag for messages of level warning |
| 321 | 338 clrf message_counter ; clear message counter |
| 322 ; Warnings for all modes | 339 |
| 323 call check_warn_battery ; Check if the battery level should be displayed/warned | 340 ; warnings for all modes |
| 324 | 341 call check_warn_battery ; check if the battery level should be displayed/warned |
| 325 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode | 342 |
| 343 btfsc FLAG_apnoe_mode ; done for Apnoe or Gauge mode | |
| 326 bra surfmode_check_for_warnings2 | 344 bra surfmode_check_for_warnings2 |
| 327 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode | 345 btfsc FLAG_gauge_mode ; done for Apnoe or Gauge mode |
| 328 bra surfmode_check_for_warnings2 | 346 bra surfmode_check_for_warnings2 |
| 329 | 347 |
| 330 ; Warnings only in deco modes | 348 ; warnings only in deco modes |
| 331 rcall surfmode_check_for_desat ; Check if desat time should be shown | 349 rcall surfmode_check_for_desat ; check if desat time should be shown |
| 332 rcall surfmode_check_for_nofly ; Check if nofly time should be shown | 350 rcall surfmode_check_for_nofly ; check if nofly time should be shown |
| 333 call check_cns_violation ; Check CNS value and display it, if required | 351 call check_cns_violation ; check CNS value and display it, if required |
| 334 call check_and_store_gf_violation; Check GF value and display it, if required | 352 call check_and_store_gf_violation; check GF value and display it, if required |
| 335 | 353 call check_mbubbles ; check for micro bubbles |
| 336 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings | |
| 337 btfsc WREG,mbubble_warning_lock ; do we have a microbubbles warning? | |
| 338 extern warn_mbubbles | |
| 339 call warn_mbubbles ; YES | |
| 340 | 354 |
| 341 surfmode_check_for_warnings2: | 355 surfmode_check_for_warnings2: |
| 342 ; Setup warning_page number | 356 ; setup message page number |
| 343 incf warning_page,F | 357 incf message_page,F |
| 344 bcf STATUS,C | 358 bcf STATUS,C |
| 345 rlcf warning_page,W ; *2 | 359 rlcf message_page,W ; *2 |
| 346 cpfsgt warning_counter ; > warning_counter | 360 cpfsgt message_counter ; > message_counter? |
| 347 clrf warning_page ; No, clear | 361 clrf message_page ; NO - clear |
| 348 | 362 |
| 349 ; Clear both rows of warnings if there is nothing to show at all | 363 ; clear both rows of warnings if there is nothing to show at all |
| 350 tstfsz warning_counter ; any warnings? | 364 tstfsz message_counter ; any warnings? |
| 351 bra surfmode_check_for_warnings3; YES - look if second row needs to be cleared | 365 bra surfmode_check_for_warnings3; YES - look if second row needs to be cleared |
| 352 call TFT_clear_warning_text ; NO - clear complete warnings area | 366 call TFT_clear_warning_text ; NO - clear complete warnings area |
| 353 return | 367 return |
| 354 | 368 |
| 355 surfmode_check_for_warnings3: | 369 surfmode_check_for_warnings3: |
| 356 ; Clear 2nd row of warnings if there is nothing to show (on this page) | 370 ; clear 2nd row of warnings if there is nothing to show (on this page) |
| 357 btfss second_row_warning ; =1: The second row contains a warning | 371 btfss second_row_warning ; =1: The second row contains a warning |
| 358 call TFT_clear_warning_text_2nd_row ; No, clear this row | 372 call TFT_clear_warning_text_2nd_row ; NO - clear this row |
| 359 return ; Done. | 373 return ; Done. |
| 360 | 374 |
| 361 surfmode_check_for_desat: | 375 surfmode_check_for_desat: |
| 362 banksel int_O_desaturation_time | 376 banksel int_O_desaturation_time |
| 363 movf int_O_desaturation_time+0,W ; is nofly-time null ? | 377 movf int_O_desaturation_time+0,W |
| 364 iorwf int_O_desaturation_time+1,W | 378 iorwf int_O_desaturation_time+1,W |
| 365 banksel common | 379 banksel common |
| 366 bnz surfmode_check_for_desat_1 ; NO | 380 bnz surfmode_check_for_desat_1 ; is the desat-time > 0 ? |
| 367 return | 381 return ; NO |
| 368 surfmode_check_for_desat_1: ; YES | 382 surfmode_check_for_desat_1: ; YES |
| 369 incf warning_counter,F ; increase counter | 383 incf message_counter,F ; increase counter |
| 370 call TFT_desaturation_time ; show desaturation time | 384 call TFT_desaturation_time ; show desaturation time |
| 371 return | 385 return |
| 372 | 386 |
| 373 surfmode_check_for_nofly: | 387 surfmode_check_for_nofly: |
| 374 banksel int_O_nofly_time | 388 banksel int_O_nofly_time |
| 375 movf int_O_nofly_time+0,W ; is nofly-time null ? | 389 movf int_O_nofly_time+0,W |
| 376 iorwf int_O_nofly_time+1,W | 390 iorwf int_O_nofly_time+1,W |
| 377 banksel common | 391 banksel common |
| 378 bnz surfmode_check_for_nofly_1 ; No... | 392 bnz surfmode_check_for_nofly_1 ; is the nofly-time > 0 ? |
| 379 return | 393 return ; NO |
| 380 surfmode_check_for_nofly_1: ; YES | 394 surfmode_check_for_nofly_1: ; YES |
| 381 incf warning_counter,F ; increase counter | 395 incf message_counter,F ; increase counter |
| 382 call TFT_nofly_time ; show nofly-time | 396 call TFT_nofly_time ; show nofly-time |
| 383 return | 397 return |
| 384 | 398 |
| 385 | 399 |
| 386 ;============================================================================= | 400 ;============================================================================= |
| 387 | 401 |
| 388 test_switches_surfmode: ; checks switches in surfacemode | 402 test_switches_surfmode: ; check switches in surfacemode |
| 389 btfsc switch_right | 403 btfsc switch_right |
| 390 bra test_switches_surfmode2 | 404 bra test_switches_surfmode2 |
| 391 btfsc switch_left | 405 btfsc switch_left |
| 392 bra test_switches_surfmode3 | 406 bra test_switches_surfmode3 |
| 393 ; No button pressed | 407 ; no button pressed |
| 394 return | 408 return |
| 395 | 409 |
| 396 test_switches_surfmode3: | 410 test_switches_surfmode3: |
| 397 movlw .6 | 411 movlw .6 |
| 398 cpfseq menupos3 ; in compass view? | 412 cpfseq menupos3 ; in compass view? |
| 399 bra test_switches_surfmode3a ; No | 413 bra test_switches_surfmode3a ; NO |
| 400 | 414 |
| 401 btfsc premenu ; already shown "Bearing" | 415 btfsc premenu ; "Bearing" already shown? |
| 402 bra test_switches_surfmode3b ; Yes, remove it | 416 bra test_switches_surfmode3b ; YES - remove it |
| 403 | 417 call TFT_surf_set_bearing ; NO - show it |
| 404 extern TFT_surf_set_bearing | |
| 405 call TFT_surf_set_bearing ; Yes. | |
| 406 bcf switch_left | 418 bcf switch_left |
| 407 return | 419 return |
| 408 | 420 |
| 409 test_switches_surfmode3a: | 421 test_switches_surfmode3a: |
| 410 bcf switch_left | 422 bcf switch_left |
| 411 bcf compass_bearing_set ; clear bearing on entering menu | 423 bcf compass_bearing_set ; clear bearing on entering menu |
| 412 bsf menubit ; Enter Menu! | 424 bsf menubit ; enter the main menu |
| 413 return | 425 return |
| 414 | 426 |
| 415 test_switches_surfmode3b: | 427 test_switches_surfmode3b: |
| 416 ; Clear "Heading?" | 428 ; clear "Bearing" |
| 417 WIN_BOX_BLACK .158,.190, .15, .99 ; top, bottom, left, right | 429 WIN_BOX_BLACK .158,.190, .15, .99 ; top, bottom, left, right |
| 418 bcf premenu | 430 bcf premenu |
| 419 bcf switch_left | 431 bcf switch_left |
| 420 return | 432 return |
| 421 | 433 |
| 422 test_switches_surfmode2: | 434 test_switches_surfmode2: |
| 423 movlw .6 | 435 movlw .6 |
| 424 cpfseq menupos3 ; in compass view? | 436 cpfseq menupos3 ; in compass view? |
| 425 bra test_switches_surfmode2a ; No | 437 bra test_switches_surfmode2a ; NO |
| 426 btfss premenu ; "Heading?" shown? | 438 btfss premenu ; "Heading?" shown? |
| 427 bra test_switches_surfmode2a ; No | 439 bra test_switches_surfmode2a ; NO |
| 428 ; Set new heading | 440 ; set new heading |
| 429 bcf premenu | 441 bcf premenu |
| 430 bsf compass_bearing_set | 442 bsf compass_bearing_set |
| 431 movff compass_heading_shown+0,compass_bearing+0 | 443 movff compass_heading_shown+0,compass_bearing+0 |
| 432 movff compass_heading_shown+1,compass_bearing+1 | 444 movff compass_heading_shown+1,compass_bearing+1 |
| 433 bcf switch_right | 445 bcf switch_right |
| 440 clrf timeout_counter2 ; and reset timeout | 452 clrf timeout_counter2 ; and reset timeout |
| 441 return | 453 return |
| 442 | 454 |
| 443 global timeout_surfmode | 455 global timeout_surfmode |
| 444 timeout_surfmode: | 456 timeout_surfmode: |
| 445 movlw timeout_surfacemode ; [s] Default timeout | 457 movlw timeout_surfacemode ; load default timeout |
| 446 btfsc menu_show_sensors2 ; In the "Calibrate" menu? | 458 btfsc menu_update_sensor_mv ; in the "Calibrate" menu? |
| 447 movlw timeout_calibrate_menu ; [s] CCR Calibrate Menu timeout | 459 movlw timeout_calibrate_menu ; YES - replace with CCR Calibrate Menu timeout |
| 448 btfsc menubit ; in Menu? | 460 IFDEF _rx_functions |
| 449 bra timeout_testmode ; No, done. | 461 btfsc FLAG_pairing_mode ; in the "Setup Tank" menu? |
| 450 ; Must be in surface mode | 462 movlw timeout_tanksetup_menu ; YES - replace with Tank Setup Menu timeout |
| 451 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active | 463 ENDIF |
| 452 bra timeout_testmode ; No, not CCR | 464 btfsc menubit ; in menu? |
| 453 movlw timeout_ccr_surface ; [s] CCR Surface mode timeout | 465 bra timeout_testmode ; NO - done |
| 466 ; must be in surface mode | |
| 467 btfss FLAG_ccr_mode ; in CCR mode? (fixed ppO2 or sensor) | |
| 468 bra timeout_testmode ; NO - not CCR | |
| 469 movlw timeout_ccr_surface ; YES - replace with CCR surface mode timeout | |
| 454 | 470 |
| 455 global timeout_testmode | 471 global timeout_testmode |
| 456 timeout_testmode: | 472 timeout_testmode: |
| 457 incf timeout_counter2,F ; increase timeout counter | 473 incf timeout_counter2,F ; increase timeout counter |
| 458 cpfsgt timeout_counter2 ; Compare with timeout limit | 474 cpfsgt timeout_counter2 ; compare with timeout limit |
| 459 return ; return, no timeout | 475 return ; return, no timeout |
| 460 bsf sleepmode ; Set Flag | 476 bsf sleepmode ; set flag |
| 461 return ; Return | 477 return ; return |
| 462 | 478 |
| 463 END | 479 END |
