v1.19 Release

Dependencies:   nRF51822

Revision:
54:bc0199198178
Parent:
50:8dca54c1e3fd
Child:
55:a66f86bbfc9f
--- a/Source/main.cpp	Fri Sep 11 19:27:20 2020 +0000
+++ b/Source/main.cpp	Thu Oct 22 18:45:19 2020 +0000
@@ -65,6 +65,8 @@
 volatile int16_t on_reading_peak = 0;
 
 volatile uint16_t cap_threshold_on = CAP_THRESHOLD_ON_INITIAL;
+volatile uint16_t cap_threshold_off = CAP_THRESHOLD_OFF;
+volatile uint16_t cap_threshold_eol = CAP_THRESHOLD_OFF_EOL;
 
 typedef  enum {
     INIT,
@@ -120,12 +122,12 @@
     }
     else
     { // cap was on
-        uint16_t off_threshold; // there are two cap off thresholds, normal use and EOL, this provides a variable for the proper value - FTD 08212020
+/*        uint16_t off_threshold; // there are two cap off thresholds, normal use and EOL, this provides a variable for the proper value - FTD 08212020
         // 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)
+        else    off_threshold = CAP_THRESHOLD_OFF_EOL;  -- Assignment moved to EOL state - FTD 10052020 
+*/        
+        if(on_reading < off_reading + cap_threshold_off)
         { // cap is now off
             is_cap_off = 1;
             #if ENABLE_LED        
@@ -144,7 +146,9 @@
         if(on_reading_filtered > on_reading_peak)
         { // new higher diff value found
             on_reading_peak = on_reading_filtered;
-            cap_threshold_on = CAP_THRESHOLD_PERCENT_OF_PEAK*on_reading_peak/256;             
+            cap_threshold_on = CAP_THRESHOLD_PERCENT_OF_PEAK*on_reading_peak/256;
+            cap_threshold_off = CAP_THRESHOLD_OFF_PERCENT_OF_PEAK*on_reading_peak/256;
+            cap_threshold_eol = CAP_THRESHOLD_TRIGGER_MULT*cap_threshold_off;             
         }
     }
     
@@ -389,6 +393,7 @@
                     if(log_code_count(EVENT_CAP_ON)>= EOL_MAX_USES) 
                     { // EOL detected due to maximum uses
                         if(NV_NOT_EOL) nv_clear(NV_NOT_EOL_ADDR); 
+                        cap_threshold_off = cap_threshold_eol;  // Change Cap Off threshold to EOL limit to ensure advertising without removing cap - FTD 1005020
                     }
                     
                     set_radio(true);
@@ -538,6 +543,10 @@
                     BLE_UART_xmit(on_reading_peak);
                     BLE_UART_xmit(", ");
                     BLE_UART_xmit(cap_threshold_on);
+                    BLE_UART_xmit(", ");
+                    BLE_UART_xmit(cap_threshold_off);
+                    BLE_UART_xmit(", ");
+                    BLE_UART_xmit(cap_threshold_eol);
                     BLE_UART_xmit("\n");
                     break;
             }