Mercurial > public > hwos_code
comparison src/adc_lightsensor.asm @ 472:4fdf6886004b
CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
NEW: Show battery type in information menu (T0:1.5V AA, T1:3.6V AA, T2:3.6V/0.8A LiIon, T3:Internal 18650, T4:Internal 16650)
author | heinrichsweikamp |
---|---|
date | Sun, 18 Dec 2016 18:20:39 +0100 |
parents | 408329337b8b |
children | 2880aa1264f5 |
comparison
equal
deleted
inserted
replaced
471:9edb1359ce43 | 472:4fdf6886004b |
---|---|
212 movwf lo | 212 movwf lo |
213 ; lo will be between 100 (Full) and 0 (empty) | 213 ; lo will be between 100 (Full) and 0 (empty) |
214 movf batt_percent,W | 214 movf batt_percent,W |
215 cpfsgt lo ; keep batt_percent on the lowest value found | 215 cpfsgt lo ; keep batt_percent on the lowest value found |
216 movff lo,batt_percent ; store value | 216 movff lo,batt_percent ; store value |
217 ; btfsc battery_is_36v ; but always use computed value for 3,6V battery | 217 btfsc battery_is_36v ; but always use computed value for 3,6V battery |
218 ; movff lo,batt_percent ; store value | 218 movff lo,batt_percent ; store value |
219 bcf adc_running ; =1: The ADC is in use | 219 bcf adc_running ; =1: The ADC is in use |
220 return | 220 return |
221 | 221 |
222 get_battery_voltage4: | 222 get_battery_voltage4: |
223 ; Use 1,5V battery voltage mode | 223 ; Use 1,5V battery voltage mode |
543 btfsc adc_running ; ADC in use? | 543 btfsc adc_running ; ADC in use? |
544 return ; Yes, return | 544 return ; Yes, return |
545 | 545 |
546 movlw b'00001001' ; left justified | 546 movlw b'00001001' ; left justified |
547 movwf ADCON2 | 547 movwf ADCON2 |
548 movlw b'00000000' ; Vref+ = Vdd | 548 ; movlw b'00000000' ; Vref+ = Vdd |
549 movwf ADCON1 | 549 clrf ADCON1 |
550 movlw b'00100101' ; power on ADC, select AN9 | 550 movlw b'00100101' ; power on ADC, select AN9 |
551 rcall wait_adc | 551 rcall wait_adc |
552 movff ADRESH,analog_sw2 | 552 movff ADRESH,analog_sw2 |
553 bcf analog_sw2_pressed | 553 bcf analog_sw2_pressed |
554 ; movlw .64 ; lower limit | 554 movff opt_cR_button_left,WREG ;20-100 |
555 ; cpfsgt ADRESH | 555 bcf STATUS,C |
556 ; bra sw2_pressed | 556 rrcf WREG ;/2 -> 10-50 |
557 movlw .135 ; upper limit | 557 bcf STATUS,C |
558 rrcf WREG ;/2 -> 5-25 | |
559 addlw .126 ;131-151 | |
558 cpfsgt ADRESH | 560 cpfsgt ADRESH |
559 bra get_analog_sw1 | 561 bra get_analog_sw1 |
560 sw2_pressed: | 562 sw2_pressed: |
561 bsf analog_sw2_pressed | 563 bsf analog_sw2_pressed |
562 get_analog_sw1: | 564 get_analog_sw1: |
563 movlw b'00101001' ; power on ADC, select AN10 | 565 movlw b'00101001' ; power on ADC, select AN10 |
564 rcall wait_adc | 566 rcall wait_adc |
565 movff ADRESH,analog_sw1 | 567 movff ADRESH,analog_sw1 |
566 bcf analog_sw1_pressed | 568 bcf analog_sw1_pressed |
567 ; movlw .64 ; lower limit | 569 bcf STATUS,C |
568 ; cpfsgt ADRESH | 570 rrcf WREG ;/2 -> 10-50 |
569 ; bra sw1_pressed | 571 bcf STATUS,C |
570 movlw .135 ; upper limit | 572 rrcf WREG ;/2 -> 5-25 |
573 addlw .126 ;131-151 | |
571 cpfsgt ADRESH | 574 cpfsgt ADRESH |
572 bra get_analog_sw_done | 575 bra get_analog_sw_done |
573 sw1_pressed: | 576 sw1_pressed: |
574 bsf analog_sw1_pressed | 577 bsf analog_sw1_pressed |
575 get_analog_sw_done: | 578 get_analog_sw_done: |