Mercurial > public > hwos_code
comparison src/gaslist.asm @ 0:11d4fc797f74
init
| author | heinrichsweikamp |
|---|---|
| date | Wed, 24 Apr 2013 19:22:45 +0200 |
| parents | |
| children | 440e537e19d6 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:11d4fc797f74 |
|---|---|
| 1 ;============================================================================= | |
| 2 ; | |
| 3 ; File gaslist.asm | |
| 4 ; | |
| 5 ; Managing OSTC3 gas list | |
| 6 ; | |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
| 8 ;============================================================================= | |
| 9 ; HISTORY | |
| 10 ; 2011-08-11 : [jDG] Creation. | |
| 11 | |
| 12 #include "ostc3.inc" ; Mandatory header | |
| 13 #include "convert.inc" | |
| 14 #include "math.inc" ; div16x16 for MOD calculations | |
| 15 #include "strings.inc" | |
| 16 #include "tft.inc" | |
| 17 #include "tft_outputs.inc" | |
| 18 | |
| 19 #include "shared_definitions.h" | |
| 20 | |
| 21 CBLOCK tmp+0x40 ; Keep space for menu processor | |
| 22 gaslist_gas | |
| 23 gaslist_O2 | |
| 24 gaslist_He | |
| 25 gaslist_depth | |
| 26 gaslist_Type | |
| 27 ; Reserved to tmp+0x5F | |
| 28 ENDC | |
| 29 | |
| 30 extern convert_mbar_to_feet | |
| 31 | |
| 32 gui CODE | |
| 33 ;============================================================================= | |
| 34 ; Append gas description to current string. | |
| 35 ; Input: PRODL : gas number (0..4) | |
| 36 ; FSR2 : Current string position. | |
| 37 ; Output: Text appended into buffer pointed by FSR2. | |
| 38 extern customview_show_mix | |
| 39 global gaslist_strcat_gas | |
| 40 gaslist_strcat_gas: | |
| 41 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) | |
| 42 ; Retrieve gas definition: | |
| 43 gaslist_strcat_gas_0: | |
| 44 movf gaslist_gas,W | |
| 45 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
| 46 movff PLUSW1,gaslist_O2 | |
| 47 movf gaslist_gas,W | |
| 48 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
| 49 movff PLUSW1,gaslist_He | |
| 50 | |
| 51 movff gaslist_O2,lo | |
| 52 movff gaslist_He,hi | |
| 53 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
| 54 return | |
| 55 | |
| 56 | |
| 57 ;============================================================================= | |
| 58 ; Append current mix to current string (For divemode) | |
| 59 ; Input: FSR2 : Current string position. | |
| 60 ; Output: Text appended into buffer pointed by FSR2. | |
| 61 global gaslist_strcat_gasx | |
| 62 gaslist_strcat_gasx: ; Show current O2/He mix | |
| 63 STRCAT_TEXT tGas | |
| 64 STRCAT ": " | |
| 65 movff char_I_O2_ratio,lo | |
| 66 movff char_I_He_ratio,hi | |
| 67 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
| 68 return | |
| 69 | |
| 70 global gaslist_show_type | |
| 71 extern tGasDisabled | |
| 72 extern tDilDisabled | |
| 73 gaslist_show_type: | |
| 74 movf gaslist_gas,W | |
| 75 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
| 76 movff PLUSW1,gaslist_Type | |
| 77 STRCAT_TEXT tType | |
| 78 lfsr FSR1,tGasDisabled ; Base text number | |
| 79 btfsc ccr_diluent_setup ; In CCR setup? | |
| 80 lfsr FSR1,tDilDisabled ; Base text number | |
| 81 movff gaslist_Type,WREG ; 0-3 | |
| 82 rlncf WREG ; x2 | |
| 83 addwf FSR1L,F | |
| 84 movlw .0 | |
| 85 addwfc FSR1H,F | |
| 86 call strcat_text | |
| 87 return | |
| 88 | |
| 89 global gaslist_toggle_type | |
| 90 gaslist_toggle_type: | |
| 91 movf gaslist_gas,W | |
| 92 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
| 93 movff PLUSW1,gaslist_Type | |
| 94 incf gaslist_Type,F ; 0-3/0-2 | |
| 95 btfsc ccr_diluent_setup ; In CCR setup? | |
| 96 bra gaslist_toggle_type2 ; Yes | |
| 97 btfsc gaslist_Type,2 ; >3? | |
| 98 clrf gaslist_Type ; Clear to zero | |
| 99 movff gaslist_Type,PLUSW1 ; Copy back result | |
| 100 return | |
| 101 | |
| 102 gaslist_toggle_type2: | |
| 103 movlw .3 | |
| 104 cpfslt gaslist_Type ; >2? | |
| 105 clrf gaslist_Type ; Clear to zero | |
| 106 movf gaslist_gas,W | |
| 107 movff gaslist_Type,PLUSW1 ; Copy back result | |
| 108 return | |
| 109 | |
| 110 global gaslist_setSP | |
| 111 gaslist_setSP: | |
| 112 movff PRODL,gaslist_gas ; 0-4 | |
| 113 return | |
| 114 | |
| 115 extern tbar | |
| 116 global gaslist_strcat_setpoint | |
| 117 global gaslist_strcat_setpoint_0 | |
| 118 gaslist_strcat_setpoint: | |
| 119 call gaslist_setSP | |
| 120 gaslist_strcat_setpoint_0: | |
| 121 bsf leftbind | |
| 122 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
| 123 bra gaslist_strcat_setpoint2 ; Short version | |
| 124 STRCAT_TEXT tSP | |
| 125 incf gaslist_gas,W | |
| 126 movwf lo | |
| 127 output_8 | |
| 128 bcf leftbind | |
| 129 PUTC ":" | |
| 130 gaslist_strcat_setpoint2: ; Short version | |
| 131 lfsr FSR1,opt_gas_type | |
| 132 btfsc divemode | |
| 133 bra gaslist_strcat_setpoint4 ; no "*" in divemode | |
| 134 movf gaslist_gas,W | |
| 135 decf PLUSW1,W ; Type-1 into WREG | |
| 136 bnz gaslist_strcat_setpoint3 ; Not "first" | |
| 137 PUTC "*" | |
| 138 bra gaslist_strcat_setpoint4 | |
| 139 gaslist_strcat_setpoint3: | |
| 140 PUTC " " | |
| 141 gaslist_strcat_setpoint4: | |
| 142 movf gaslist_gas,W | |
| 143 lfsr FSR1,char_I_setpoint_cbar | |
| 144 movf PLUSW1,W | |
| 145 movwf lo | |
| 146 clrf hi | |
| 147 bsf leftbind | |
| 148 output_16dp d'3' | |
| 149 btfsc divemode | |
| 150 bra gaslist_strcat_setpoint5 ; Skip text in divemode | |
| 151 STRCAT_TEXT tbar | |
| 152 gaslist_strcat_setpoint5: | |
| 153 PUTC " " | |
| 154 ; Read switch depth | |
| 155 movf gaslist_gas,W | |
| 156 lfsr FSR1,char_I_setpoint_change | |
| 157 movff PLUSW1,lo | |
| 158 bra gaslist_strcat_4 ; And return... | |
| 159 | |
| 160 ;---------------------------------------------------------------------------- | |
| 161 ; Append gas description to current string. | |
| 162 ; Input: PRODL : gas number (0..4) | |
| 163 ; FSR2 : Current string position. | |
| 164 ; Output: Text appended into buffer pointed by FSR2. | |
| 165 ; | |
| 166 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. | |
| 167 | |
| 168 gaslist_strcat_gas_better: ; Yes, check if this is a "better gas" | |
| 169 movlw .0 | |
| 170 movff WREG,win_invert | |
| 171 incf gaslist_gas,W ; gaslist_gas+1 -> WREG | |
| 172 cpfseq better_gas_number ; 1-5 for OC/Bailout and 6-10 for diluents | |
| 173 return | |
| 174 movlw color_yellow ; show in yellow | |
| 175 call TFT_set_color | |
| 176 movlw .1 | |
| 177 movff WREG,win_invert ; and invert | |
| 178 return | |
| 179 | |
| 180 global gaslist_strcat_gas_mod | |
| 181 gaslist_strcat_gas_mod: | |
| 182 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) | |
| 183 | |
| 184 global gaslist_gastitle | |
| 185 gaslist_gastitle: | |
| 186 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
| 187 bra gaslist_gastitle2 ; Short version | |
| 188 STRCAT_TEXT tGas | |
| 189 incf gaslist_gas,W | |
| 190 movwf lo | |
| 191 bsf leftbind | |
| 192 output_8 | |
| 193 bcf leftbind | |
| 194 PUTC ":" | |
| 195 | |
| 196 gaslist_gastitle2: ; Short version | |
| 197 lfsr FSR1,opt_gas_type | |
| 198 btfsc divemode | |
| 199 bra gaslist_gastitle3 ; no "*" in divemode | |
| 200 movf gaslist_gas,W | |
| 201 decf PLUSW1,W ; Type-1 into WREG | |
| 202 bnz gaslist_gastitle1 ; Not "First" | |
| 203 PUTC "*" | |
| 204 bra gaslist_gastitle3 | |
| 205 gaslist_gastitle1: | |
| 206 PUTC " " | |
| 207 gaslist_gastitle3: ; Short version | |
| 208 call TFT_standard_color | |
| 209 | |
| 210 btfsc divemode ; In divemode? | |
| 211 rcall gaslist_strcat_gas_better ; Yes, check if this is a "better gas" | |
| 212 | |
| 213 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | |
| 214 movf PLUSW1,W | |
| 215 bnz gaslist_strcat_3 | |
| 216 call TFT_disabled_color | |
| 217 gaslist_strcat_3: | |
| 218 rcall gaslist_strcat_gas_0 | |
| 219 PUTC " " | |
| 220 ; Read switch depth | |
| 221 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | |
| 222 lfsr FSR1,char_I_deco_gas_change | |
| 223 movff PLUSW1,lo | |
| 224 rcall gaslist_calc_mod ; Compute MOD into WREG | |
| 225 cpfsgt lo | |
| 226 bra gaslist_strcat_4 | |
| 227 TFT_WARNINGS_COLOR ; Turn red if bigger | |
| 228 gaslist_strcat_4: | |
| 229 TSTOSS opt_units ; 0=Meters, 1=Feets | |
| 230 bra gaslist_strcat_3_metric | |
| 231 ;gaslist_strcat_3_imperial: | |
| 232 movf lo,W | |
| 233 mullw .100 ; convert meters to mbar | |
| 234 movff PRODL,lo | |
| 235 movff PRODH,hi | |
| 236 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
| 237 bsf leftbind | |
| 238 output_16_3 | |
| 239 STRCAT_TEXT tFeets ; "ft" | |
| 240 return | |
| 241 | |
| 242 gaslist_strcat_3_metric: | |
| 243 output_99 | |
| 244 STRCAT_TEXT tMeters ; "m" | |
| 245 return | |
| 246 | |
| 247 ;---------------------------------------------------------------------------- | |
| 248 ; Store current menu item, and display gas description later. | |
| 249 ; Input: PRODL : gas number (0..4) | |
| 250 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. | |
| 251 global gaslist_setgas | |
| 252 gaslist_setgas: | |
| 253 movff PRODL,gaslist_gas | |
| 254 movlw .5 | |
| 255 btfsc ccr_diluent_setup ; in CCR menus? | |
| 256 addwf gaslist_gas,F ; Yes, offset to gases 5-9 | |
| 257 return | |
| 258 | |
| 259 | |
| 260 global gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth | |
| 261 gaslist_cleanup_list: | |
| 262 bcf ignore_last_edited_gas | |
| 263 movlw .0 | |
| 264 btfsc ccr_diluent_setup ; In CCR-Menu? | |
| 265 addlw .5 ; Yes, adjust offset | |
| 266 subwf gaslist_gas,F | |
| 267 gaslist_cleanup_list1: | |
| 268 clrf lo | |
| 269 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
| 270 movlw .5 ; Check 5 gases | |
| 271 movwf hi | |
| 272 gaslist_cleanup_list2: | |
| 273 decf hi,w ; 0-4 | |
| 274 btfsc ccr_diluent_setup ; In CCR-Menu? | |
| 275 addlw .5 ; Yes, adjust offset | |
| 276 movff PLUSW1,hi_temp | |
| 277 movlw .1 | |
| 278 cpfseq hi_temp ; gas = first ? | |
| 279 bra gaslist_cleanup_list3 ; No | |
| 280 incf lo,F ; Yes, count "first gases" | |
| 281 | |
| 282 btfss ignore_last_edited_gas ; If we are not in the second-pass mode | |
| 283 bra gaslist_cleanup_list2b | |
| 284 | |
| 285 decf hi,w ; 0-4 | |
| 286 cpfseq gaslist_gas ; Do not disable last edited gas | |
| 287 gaslist_cleanup_list2b: | |
| 288 movff hi,lo_temp ; Keep the last "first gas" found | |
| 289 gaslist_cleanup_list3: | |
| 290 decfsz hi,F | |
| 291 bra gaslist_cleanup_list2 ; Loop | |
| 292 | |
| 293 tstfsz lo ; No gas active? | |
| 294 bra gaslist_cleanup_list4 ; No, at least one is active | |
| 295 | |
| 296 btfsc ccr_diluent_setup ; In CCR-Menu? | |
| 297 bra gaslist_cleanup_list3a ; Yes. | |
| 298 ; make gas1 first and zero | |
| 299 movlw .1 ; First | |
| 300 movwf lo_temp | |
| 301 movwf INDF1 | |
| 302 bra gaslist_cleanup_list5 ; Set change depth to zero | |
| 303 | |
| 304 gaslist_cleanup_list3a: | |
| 305 movlw .5 | |
| 306 addwf FSR1L,F | |
| 307 movlw .0 | |
| 308 addwfc FSR1H,F ; Setup to Diluents | |
| 309 ; make dil1 first and zero | |
| 310 movlw .1 ; First | |
| 311 movwf lo_temp | |
| 312 movwf INDF1 | |
| 313 bra gaslist_cleanup_list5 ; Set change depth to zero | |
| 314 | |
| 315 gaslist_cleanup_list4: | |
| 316 movlw .1 | |
| 317 cpfsgt lo ; More then one "first gas"? | |
| 318 bra gaslist_cleanup_list5 ; No, done. | |
| 319 ; More then one Gas is "first gas" | |
| 320 ; Disable last found "first gas" but keep it's change depth | |
| 321 decf lo_temp,W ; 0-4 | |
| 322 cpfseq gaslist_gas ; Do not disable last edited gas | |
| 323 bra gaslist_cleanup_list4b | |
| 324 ; Do not disable last edited gas | |
| 325 ; search again but ignore last edited gas | |
| 326 bsf ignore_last_edited_gas | |
| 327 bra gaslist_cleanup_list1 ; Loop until only one "first gas" is left | |
| 328 | |
| 329 gaslist_cleanup_list4b: | |
| 330 btfsc ccr_diluent_setup ; In CCR-Menu? | |
| 331 addlw .5 ; Yes, adjust offset | |
| 332 clrf PLUSW1 ; Disable gas | |
| 333 bra gaslist_cleanup_list ; Loop until only one "first gas" is left | |
| 334 | |
| 335 gaslist_cleanup_list5: | |
| 336 lfsr FSR1,char_I_deco_gas_change | |
| 337 decf lo_temp,W | |
| 338 btfsc ccr_diluent_setup ; In CCR-Menu? | |
| 339 addlw .5 ; Yes, adjust offset | |
| 340 clrf PLUSW1 ; Set First gas to zero m | |
| 341 return | |
| 342 | |
| 343 ;---------------------------------------------------------------------------- | |
| 344 ; Increment/Decrement O2 ratio | |
| 345 global gaslist_pO2 | |
| 346 gaslist_pO2: | |
| 347 movf gaslist_gas,W | |
| 348 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
| 349 movff PLUSW1,gaslist_He | |
| 350 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
| 351 movff PLUSW1,gaslist_O2 | |
| 352 | |
| 353 incf gaslist_O2,F ; O2++ | |
| 354 movf gaslist_He,W | |
| 355 addwf gaslist_O2,W | |
| 356 movwf lo | |
| 357 movlw .101 | |
| 358 cpfslt lo ; O2+He<101? | |
| 359 decf gaslist_O2,F ; O2-- (Unchanged) | |
| 360 | |
| 361 movf gaslist_gas,W | |
| 362 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG] | |
| 363 return | |
| 364 | |
| 365 global gaslist_mO2 | |
| 366 gaslist_mO2: | |
| 367 movf gaslist_gas,W | |
| 368 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
| 369 movff PLUSW1,gaslist_O2 | |
| 370 | |
| 371 decf gaslist_O2,F | |
| 372 movlw gaslist_min_o2 | |
| 373 cpfslt gaslist_O2 | |
| 374 bra gaslist_mO2_1 | |
| 375 movlw gaslist_min_o2 | |
| 376 movwf gaslist_O2 | |
| 377 gaslist_mO2_1: | |
| 378 movf gaslist_gas,W | |
| 379 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG] | |
| 380 return | |
| 381 | |
| 382 ;---------------------------------------------------------------------------- | |
| 383 ; Increment/Decrement He ratio | |
| 384 global gaslist_pHe | |
| 385 gaslist_pHe: | |
| 386 movf gaslist_gas,W | |
| 387 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
| 388 movff PLUSW1,gaslist_O2 | |
| 389 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
| 390 movff PLUSW1,gaslist_He | |
| 391 | |
| 392 incf gaslist_He,F ; He++ | |
| 393 movf gaslist_He,W | |
| 394 addwf gaslist_O2,W | |
| 395 movwf lo | |
| 396 movlw .101 | |
| 397 cpfslt lo ; O2+He<101? | |
| 398 decf gaslist_He,F ; Yes, He-- (Unchanged) | |
| 399 | |
| 400 movf gaslist_gas,W | |
| 401 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG] | |
| 402 return | |
| 403 | |
| 404 global gaslist_mHe | |
| 405 gaslist_mHe: | |
| 406 movf gaslist_gas,W | |
| 407 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
| 408 movff PLUSW1,gaslist_He | |
| 409 | |
| 410 decf gaslist_He,F | |
| 411 bnn gaslist_mHe_1 | |
| 412 clrf gaslist_He | |
| 413 gaslist_mHe_1: | |
| 414 movf gaslist_gas,W | |
| 415 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG] | |
| 416 return | |
| 417 | |
| 418 ;---------------------------------------------------------------------------- | |
| 419 ; Increment/Decrement switch depth | |
| 420 global gaslist_pDepth | |
| 421 gaslist_pDepth: | |
| 422 movf gaslist_gas,W | |
| 423 lfsr FSR1,char_I_deco_gas_change | |
| 424 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG] | |
| 425 | |
| 426 incf gaslist_O2,F | |
| 427 movlw gaslist_max_change_depth | |
| 428 cpfsgt gaslist_O2 | |
| 429 bra gaslist_pDepth_1 | |
| 430 movlw gaslist_max_change_depth | |
| 431 movwf gaslist_O2 | |
| 432 gaslist_pDepth_1: | |
| 433 movf gaslist_gas,W | |
| 434 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | |
| 435 return | |
| 436 | |
| 437 global gaslist_mDepth | |
| 438 gaslist_mDepth: | |
| 439 movf gaslist_gas,W | |
| 440 lfsr FSR1,char_I_deco_gas_change | |
| 441 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG] | |
| 442 | |
| 443 decf gaslist_O2,F | |
| 444 btfsc STATUS,N | |
| 445 clrf gaslist_O2 | |
| 446 | |
| 447 movf gaslist_gas,W | |
| 448 movff gaslist_O2,PLUSW1 ; And write back to char_I_deco_gas_change[WREG] | |
| 449 return | |
| 450 | |
| 451 global gaslist_spplus | |
| 452 gaslist_spplus: | |
| 453 movf gaslist_gas,W | |
| 454 lfsr FSR1,char_I_setpoint_cbar | |
| 455 movff PLUSW1,lo ; Read char_I_setpoint_cbar[WREG] | |
| 456 movlw gaslist_sp_stepsize | |
| 457 addwf lo,F | |
| 458 movlw gaslist_sp_max | |
| 459 cpfsgt lo | |
| 460 bra gaslist_spplus2 | |
| 461 movlw gaslist_sp_min | |
| 462 movwf lo | |
| 463 gaslist_spplus2: | |
| 464 movf gaslist_gas,W | |
| 465 movff lo,PLUSW1 ; Write back to char_I_setpoint_cbar | |
| 466 return | |
| 467 | |
| 468 global gaslist_spdepthplus | |
| 469 gaslist_spdepthplus: | |
| 470 movf gaslist_gas,W | |
| 471 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | |
| 472 lfsr FSR1,char_I_setpoint_change | |
| 473 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG] | |
| 474 incf gaslist_O2,F | |
| 475 movlw gaslist_max_change_depth | |
| 476 cpfsgt gaslist_O2 | |
| 477 bra gaslist_spdepthplus_1 | |
| 478 movlw gaslist_max_change_depth | |
| 479 movwf gaslist_O2 | |
| 480 gaslist_spdepthplus_1: | |
| 481 movf gaslist_gas,W | |
| 482 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | |
| 483 return | |
| 484 | |
| 485 gaslist_spdepthplus3: | |
| 486 movlw .0 | |
| 487 movff WREG,char_I_setpoint_change+0 ; Reset to 0m | |
| 488 return | |
| 489 | |
| 490 global gaslist_spdepthminus | |
| 491 gaslist_spdepthminus: | |
| 492 movf gaslist_gas,W | |
| 493 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | |
| 494 lfsr FSR1,char_I_setpoint_change | |
| 495 movff PLUSW1,gaslist_O2 ; Read opt_gas_O2_ratio[WREG] | |
| 496 decf gaslist_O2,F | |
| 497 btfsc STATUS,N | |
| 498 clrf gaslist_O2 | |
| 499 movf gaslist_gas,W | |
| 500 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG] | |
| 501 return | |
| 502 | |
| 503 ;---------------------------------------------------------------------------- | |
| 504 ; Compute MOD from ppO2 Max and current O2 Ratio. | |
| 505 ; | |
| 506 ; Input: gaslist_gas = current gas index. | |
| 507 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio | |
| 508 ; Output: WREG = MOD [m] | |
| 509 ; | |
| 510 gaslist_calc_mod: | |
| 511 movf gaslist_gas,W ; Read current gas O2 ratio | |
| 512 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
| 513 movf PLUSW1,W | |
| 514 | |
| 515 btfsc divemode ; In divemode? | |
| 516 bra gaslist_calc_mod_divemode ; Yes. | |
| 517 | |
| 518 ; Pamb max = ppO2 Max / O2 ratio | |
| 519 movwf xB+0 | |
| 520 clrf xB+1 | |
| 521 | |
| 522 movff opt_ppO2_max,WREG | |
| 523 mullw .10 | |
| 524 movff PRODL,xA+0 | |
| 525 movff PRODH,xA+1 | |
| 526 call div16x16 | |
| 527 | |
| 528 ; Prof = Pamb - 1bar. | |
| 529 movf xC+0,W | |
| 530 addlw -.10 | |
| 531 return | |
| 532 | |
| 533 gaslist_calc_mod_divemode: | |
| 534 extern TFT_color_code1 | |
| 535 movwf hi ; Copy O2% | |
| 536 movlw warn_gas_in_gaslist | |
| 537 call TFT_color_code1 ; Color-code current row in Gaslist (%O2 in hi), opt_ppO2_max as threshold | |
| 538 return | |
| 539 ;---------------------------------------------------------------------------- | |
| 540 global gaslist_MOD_END | |
| 541 gaslist_MOD_END: | |
| 542 rcall gaslist_calc_mod ; Compute MOD into WREG | |
| 543 movwf lo ; Copy to lo | |
| 544 STRCAT_TEXT tEAD ; EAD: | |
| 545 TSTOSS opt_units ; 0=Meters, 1=Feets | |
| 546 bra gaslist_MOD_metric | |
| 547 ;gaslist_MOD_imperial: | |
| 548 movf lo,W | |
| 549 mullw .100 ; convert meters to mbar | |
| 550 movff PRODL,lo | |
| 551 movff PRODH,hi | |
| 552 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
| 553 bsf leftbind | |
| 554 output_16_3 | |
| 555 STRCAT_TEXT tFeets ; "ft" | |
| 556 bra gaslist_MOD_common | |
| 557 gaslist_MOD_metric: | |
| 558 output_8 | |
| 559 STRCAT_TEXT tMeters ; m | |
| 560 gaslist_MOD_common: | |
| 561 PUTC "/" | |
| 562 STRCAT_TEXT tEND ; END: | |
| 563 rcall gaslist_calc_mod ; Output: WREG = MOD [m] | |
| 564 addlw .10 ; MOD=MOD+10m | |
| 565 movwf xB+0 | |
| 566 clrf xB+1 | |
| 567 movlw d'100' | |
| 568 movwf xA+0 | |
| 569 movf gaslist_He,W ; He value in % -> WREG | |
| 570 subwf xA+0,F ; xA+0 = 100 - He Value in % | |
| 571 clrf xA+1 | |
| 572 call mult16x16 ; xA*xB=xC | |
| 573 movff xC+0,xA+0 | |
| 574 movff xC+1,xA+1 | |
| 575 movlw d'100' | |
| 576 movwf xB+0 | |
| 577 clrf xB+1 | |
| 578 call div16x16 ; xA/xB=xC with xA as remainder | |
| 579 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 | |
| 580 movlw d'10' | |
| 581 subwf xC+0,F ; Subtract 10m... | |
| 582 movff xC+0,lo | |
| 583 ; END 8Bit only | |
| 584 ; movlw d'0' | |
| 585 ; subwfb xC+1,F | |
| 586 ; movff xC+1,hi | |
| 587 TSTOSS opt_units ; 0=Meters, 1=Feets | |
| 588 bra gaslist_END_metric | |
| 589 ;gaslist_END_imperial: | |
| 590 movf lo,W | |
| 591 mullw .100 ; convert meters to mbar | |
| 592 movff PRODL,lo | |
| 593 movff PRODH,hi | |
| 594 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
| 595 bsf leftbind | |
| 596 output_16_3 | |
| 597 STRCAT_TEXT tFeets ; "ft" | |
| 598 return | |
| 599 gaslist_END_metric: | |
| 600 output_8 | |
| 601 STRCAT_TEXT tMeters ; m | |
| 602 return | |
| 603 | |
| 604 ;---------------------------------------------------------------------------- | |
| 605 global gaslist_reset_mod_title | |
| 606 gaslist_reset_mod_title: | |
| 607 STRCAT_TEXT tDepthReset | |
| 608 | |
| 609 gaslist_reset_mod_title2: | |
| 610 rcall gaslist_calc_mod ; Compute MOD into WREG | |
| 611 movwf lo ; Copy to lo | |
| 612 | |
| 613 movf gaslist_gas,W ; Compare to switch depth | |
| 614 lfsr FSR1,char_I_deco_gas_change | |
| 615 movf PLUSW1,W | |
| 616 cpfslt lo | |
| 617 bra gaslist_strcat_4 ; And return... | |
| 618 TFT_WARNINGS_COLOR ; Turn red if bigger ! | |
| 619 bra gaslist_strcat_4 ; And return... | |
| 620 | |
| 621 ;---------------------------------------------------------------------------- | |
| 622 global gaslist_reset_mod | |
| 623 gaslist_reset_mod: | |
| 624 rcall gaslist_calc_mod ; Compute MOD | |
| 625 movwf gaslist_depth | |
| 626 | |
| 627 movf gaslist_gas,W ; Read current gas O2 ratio | |
| 628 lfsr FSR1,char_I_deco_gas_change | |
| 629 movff gaslist_depth,PLUSW1 ; And save new change depth | |
| 630 return | |
| 631 ;---------------------------------------------------------------------------- | |
| 632 END |
