Mercurial > public > hwos_code
comparison src/options.asm @ 608:d866684249bd
work on 2.99 stable
| author | heinrichsweikamp |
|---|---|
| date | Mon, 07 Jan 2019 21:13:43 +0100 |
| parents | ca4556fb60b9 |
| children | c40025d8e750 |
comparison
equal
deleted
inserted
replaced
| 607:c5151a490d88 | 608:d866684249bd |
|---|---|
| 1 ;============================================================================= | 1 ;============================================================================= |
| 2 ; | 2 ; |
| 3 ; File options.asm REFACTORED VERSION V2.99e | 3 ; File options.asm REFACTORED VERSION V2.99g |
| 4 ; | 4 ; |
| 5 ; Manage all options data. | 5 ; Manage all options data. |
| 6 ; | 6 ; |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
| 8 ;============================================================================= | 8 ;============================================================================= |
| 16 #include "ghostwriter.inc" | 16 #include "ghostwriter.inc" |
| 17 #include "eeprom_rs232.inc" | 17 #include "eeprom_rs232.inc" |
| 18 #include "external_flash.inc" | 18 #include "external_flash.inc" |
| 19 #include "wait.inc" | 19 #include "wait.inc" |
| 20 #include "shared_definitions.h" | 20 #include "shared_definitions.h" |
| 21 #include "gaslist.inc" | |
| 21 | 22 |
| 22 extern write_eeprom | 23 extern write_eeprom |
| 23 extern read_eeprom | 24 extern read_eeprom |
| 24 extern eeprom_serial_save,eeprom_opt_backup | 25 extern eeprom_serial_save,eeprom_opt_backup |
| 25 extern option_table_begin,option_table_end | 26 extern option_table_begin,option_table_end |
| 76 ; | 77 ; |
| 77 ; INPUT: none | 78 ; INPUT: none |
| 78 ; OUTPUT: none | 79 ; OUTPUT: none |
| 79 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 | 80 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 |
| 80 ; | 81 ; |
| 81 global option_check_all ; check all option and reset option if out of min/max boundary | 82 global option_check_all ; check all options and reset options if out of min/max boundary |
| 82 option_check_all: | 83 option_check_all: |
| 83 movlw LOW(option_table_begin) ; point to option table begin | 84 movlw LOW(option_table_begin) ; point to option table begin |
| 84 movwf FSR0L | 85 movwf FSR0L |
| 85 movlw HIGH(option_table_begin) | 86 movlw HIGH(option_table_begin) |
| 86 movwf FSR0H | 87 movwf FSR0H |
| 90 cpfseq FSR0L ; does it equal the current pointer position? | 91 cpfseq FSR0L ; does it equal the current pointer position? |
| 91 bra option_check_all_2 ; NO - more options to process | 92 bra option_check_all_2 ; NO - more options to process |
| 92 movlw HIGH(option_table_end) ; get high byte of end of table address | 93 movlw HIGH(option_table_end) ; get high byte of end of table address |
| 93 cpfseq FSR0H ; does it equal the current pointer position? | 94 cpfseq FSR0H ; does it equal the current pointer position? |
| 94 bra option_check_all_2 ; NO - more options to process | 95 bra option_check_all_2 ; NO - more options to process |
| 95 return ; YES to both - end of option table reached, done | 96 bra option_check_all_3 ; YES to both - end of option table reached |
| 96 option_check_all_2: | 97 option_check_all_2: |
| 97 rcall option_check ; check one option... | 98 rcall option_check ; check one option... |
| 98 bra option_check_all_1 ; ... and loop | 99 bra option_check_all_1 ; ... and loop |
| 100 | |
| 101 option_check_all_3: | |
| 102 bsf FLAG_diluent_setup ; setup checking diluents | |
| 103 call gaslist_cleanup_list ; check and correct multiple or none First diluent | |
| 104 bcf FLAG_diluent_setup ; setup checking gases | |
| 105 call gaslist_cleanup_list ; check and correct multiple or none First gas | |
| 106 call option_cleanup_oCCRMode ; check and correct sensor mode | |
| 107 call option_cleanup_GF ; check and correct GFlow <= GFhigh | |
| 108 return ; all done | |
| 99 | 109 |
| 100 ;============================================================================= | 110 ;============================================================================= |
| 101 ; Read option handle | 111 ; Read option handle |
| 102 ; INPUT: FSR0 = option handle | 112 ; INPUT: FSR0 = option handle |
| 103 ; OUTPUT: FSR1 = address of variable. | 113 ; OUTPUT: FSR1 = address of variable. |
| 370 movf opt_min,W | 380 movf opt_min,W |
| 371 option_inc_uint8_0: | 381 option_inc_uint8_0: |
| 372 movwf INDF1 | 382 movwf INDF1 |
| 373 option_inc_uint8_1: | 383 option_inc_uint8_1: |
| 374 ; Now some rather crude hack into this routine to make CCR Calibration more convenient: | 384 ; Now some rather crude hack into this routine to make CCR Calibration more convenient: |
| 375 movlw .149 ; EEPROM address of option CalGasO2 | 385 movlw .149 ; EEPROM address of option CalGasO2 |
| 376 cpfseq opt_eeprom ; editing CalGasO2 right now? | 386 cpfseq opt_eeprom ; editing CalGasO2 right now? |
| 377 return ; NO - done (or bra option_inc_uint8_2) | 387 bra option_inc_uint8_2 ; NO - check next option |
| 378 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR | 388 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR |
| 379 decfsz WREG,W ; - in CCR mode? | 389 decfsz WREG,W ; - in CCR mode? |
| 380 return ; NO - done | 390 return ; NO - done |
| 381 movlw .26 ; YES - | 391 movlw .26 ; YES - |
| 382 cpfseq INDF1 ; - option value = 26 ? | 392 cpfseq INDF1 ; - option value = 26 ? |
| 383 return ; NO - done | 393 return ; NO - done |
| 384 movlw .95 ; YES - advance it to 95 | 394 movlw .95 ; YES - advance it to 95 |
| 385 movwf INDF1 ; - store it | 395 movwf INDF1 ; - store it |
| 386 return | 396 return |
| 397 option_inc_uint8_2: | |
| 398 movlw .12 ; EEPROM address of option opt_GF_low | |
| 399 cpfseq opt_eeprom ; editing opt_GF_low right now? | |
| 400 bra option_inc_uint8_3 ; NO - check next option | |
| 401 movff opt_GF_high,WREG ; get value of associated GF high into WREG | |
| 402 cpfsgt INDF1 ; GF low > GF high? | |
| 403 return ; NO - setting ok, done | |
| 404 movff opt_min,INDF1 ; YES - wrap around to minimum value | |
| 405 return ; - done | |
| 406 option_inc_uint8_3: | |
| 407 movlw .13 ; EEPROM address of option opt_GF_high | |
| 408 cpfseq opt_eeprom ; editing opt_GF_high right now? | |
| 409 bra option_inc_uint8_4 ; NO - check next option | |
| 410 movff opt_GF_low,WREG ; get value of associated GF low into WREG | |
| 411 cpfslt INDF1 ; GF high < GF low? | |
| 412 return ; NO - setting ok, done | |
| 413 movwf INDF1 ; YES - rise GF high to GF low | |
| 414 return ; - done | |
| 415 option_inc_uint8_4: | |
| 416 movlw .17 ; EEPROM address of option opt_aGF_low | |
| 417 cpfseq opt_eeprom ; editing opt_aGF_low right now? | |
| 418 bra option_inc_uint8_5 ; NO - check next option | |
| 419 movff opt_aGF_high,WREG ; get value of associated GF high into WREG | |
| 420 cpfsgt INDF1 ; GF low > GF high? | |
| 421 return ; NO - setting ok, done | |
| 422 movff opt_min,INDF1 ; YES - wrap around to minimum value | |
| 423 return ; - done | |
| 424 option_inc_uint8_5: | |
| 425 movlw .18 ; EEPROM address of option opt_aGF_high | |
| 426 cpfseq opt_eeprom ; editing opt_aGF_high right now? | |
| 427 bra option_inc_uint8_6 ; NO - check next option | |
| 428 movff opt_aGF_low,WREG ; get value of associated GF low into WREG | |
| 429 cpfslt INDF1 ; GF high < GF low? | |
| 430 return ; NO - setting ok, done | |
| 431 movwf INDF1 ; YES - rise GF high to GF low | |
| 432 return ; - done | |
| 433 option_inc_uint8_6: | |
| 434 return ; all done | |
| 435 | |
| 387 | 436 |
| 388 option_inc_enum8: ; always +1 | 437 option_inc_enum8: ; always +1 |
| 389 incf INDF1,W | 438 incf INDF1,W |
| 390 cpfsgt opt_max | 439 cpfsgt opt_max |
| 391 clrf WREG | 440 clrf WREG |
| 493 clrf opt_ccr_mode ; - YES - set CCR mode to fixed SP (0) | 542 clrf opt_ccr_mode ; - YES - set CCR mode to fixed SP (0) |
| 494 option_cleanup_oCCRMode_exit: | 543 option_cleanup_oCCRMode_exit: |
| 495 banksel common ; back to bank common | 544 banksel common ; back to bank common |
| 496 return ; done | 545 return ; done |
| 497 | 546 |
| 547 option_cleanup_GF: | |
| 548 ; cleanup normal GF | |
| 549 movff opt_GF_high,WREG ; copy normal GF high to WREG | |
| 550 movff opt_GF_low,lo ; copy normal GF low to lo | |
| 551 cpfsgt lo ; GF low > GF high ? | |
| 552 bra option_cleanup_GF_2 ; NO - option ok, check next option | |
| 553 movwf lo ; YES - copy GF high to lo | |
| 554 movlw .100 ; - load GF low limit of 100% into WREG | |
| 555 cpfsgt lo ; - lo > 100 ? | |
| 556 bra option_cleanup_GF_1 ; NO - correct GF low to GF high | |
| 557 movwf lo ; YES - correct GF low to 100% | |
| 558 option_cleanup_GF_1: | |
| 559 movff lo,opt_GF_low ; store corrected GF low | |
| 560 option_cleanup_GF_2: | |
| 561 ; cleanup alternative GF | |
| 562 movff opt_aGF_high,WREG ; copy alternative GF high to WREG | |
| 563 movff opt_aGF_low,lo ; copy alternative GF low to lo | |
| 564 cpfsgt lo ; GF low > GF high ? | |
| 565 bra option_cleanup_GF_4 ; NO - option ok, check next option | |
| 566 movwf lo ; YES - copy GF high to lo | |
| 567 movlw .100 ; - load GF low limit of 100% into WREG | |
| 568 cpfsgt lo ; - lo > 100 ? | |
| 569 bra option_cleanup_GF_3 ; NO - correct GF low to GF high | |
| 570 movwf lo ; YES - correct GF low to 100% | |
| 571 option_cleanup_GF_3: | |
| 572 movff lo,opt_aGF_low ; store corrected GF low | |
| 573 option_cleanup_GF_4: | |
| 574 return ; done | |
| 575 | |
| 498 | 576 |
| 499 ;============================================================================= | 577 ;============================================================================= |
| 500 ; Strcat option into FSR2 buffer | 578 ; Strcat option into FSR2 buffer |
| 501 ; | 579 ; |
| 502 global option_draw ; STRCAT FRS0 option | 580 global option_draw ; STRCAT FRS0 option |
