Dependencies: nRF51822
Diff: Source/main.cpp
- Revision:
- 47:a1e91dea282d
- Parent:
- 46:b85be1ccf179
- Child:
- 48:bb7d5118e03c
--- a/Source/main.cpp Fri Aug 21 14:33:15 2020 +0000 +++ b/Source/main.cpp Tue Aug 25 18:54:12 2020 +0000 @@ -77,6 +77,7 @@ uint16_t off_reading; uint16_t on_reading; +uint16_t off_threshold; // there are two cap off thresholds, normal use and EOL, this provides a variable for the proper value - FTD 08212020 typedef enum { INIT, @@ -110,12 +111,12 @@ //#if TEST_ON_NRF51_DK == 0 vdd_enable = 1; // enable analog power //wait(0.00075); - wait(0.0035); // increase wait time to allow full settling - FTD 11/21/2019 - off_reading = adc_read(ADC_CHAN_CAP_SENSE,2); + wait(CAP_LED_OFF_DELAY); // increase wait time to allow full settling - FTD 11/21/2019 + off_reading = adc_read(ADC_CHAN_CAP_SENSE,CAP_SAMPLES); cap_sense_led = 1; // enable led - wait(0.00075); + wait(CAP_LED_ON_DELAY); //wait(0.001); // increase wait time to allow full settling - FTD 11/21/2019 - on_reading = adc_read(ADC_CHAN_CAP_SENSE,2); + on_reading = adc_read(ADC_CHAN_CAP_SENSE,CAP_SAMPLES); // turn everything off cap_sense_led = 0; vdd_enable = 0; @@ -123,7 +124,7 @@ // switch cap state using hysteresis if(last_cap_off) { // cap was off - if(on_reading > off_reading+CAP_THRESHOLD_HI) + if(on_reading > off_reading + CAP_THRESHOLD_ON) { is_cap_off = 0; #if ENABLE_LED @@ -133,7 +134,12 @@ } else { // cap was on - if(on_reading < off_reading+CAP_THRESHOLD_LOW) + + // test for proper threshold needed for EOL - FTD 08212020 + if(NV_NOT_EOL) off_threshold = CAP_THRESHOLD_OFF; + else off_threshold = CAP_THRESHOLD_OFF_EOL; + + if(on_reading < off_reading + off_threshold) { is_cap_off = 1; #if ENABLE_LED