Parcourir la source

feat(postprocessing): add ContinuousLastDigit option

Some water meters gear the last digit drum continuously to the first
analog pointer (drum = digit + pointer/10). The drum then shows the
next number while the pointer is still around 9.5..9.99, and the
transition logic in PointerEvalAnalogToDigitNew only corrects digits it
rounded up, so the raw value is one unit too high until the pointer
passes 0 (rejected as "Rate too high", value frozen meanwhile).

New per-number option main.ContinuousLastDigit (default false). When
enabled, the digit before the analog ROIs is evaluated as
round(digit - pointer/10), which tolerates +/-0.5 of combined reading
error, wraps 9 <-> 0 and needs no AnalogToDigitTransitionStart tuning.

Near its zero crossing the first pointer can be read on the wrong side
of 0 (e.g. 9.8 although the next pointer shows it has passed 0). The
analog evaluation already resolves this (eval_predecessors), so the
reading is moved to the side it decided on (9.8 evaluated as 0 -> -0.2,
0.1 evaluated as 9 -> 10.1) before applying the formula.

The flag is passed as a new last parameter with default false, so
existing callers and tests are unchanged. Adds unit tests (incl. both
zero-crossing directions and the two "digit runs with the analog
pointer" cases of test_doFlowPP3), the config page row and the
parameter documentation. The config page adds the option with its
default when config.ini lacks the line, because per-number parameters
without an enable checkbox are otherwise locked in existing configs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kimmo Hovi il y a 1 mois
Parent
commit
6c2f19a6a6

+ 34 - 5
code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp

@@ -37,7 +37,7 @@ ClassFlowCNNGeneral::ClassFlowCNNGeneral(ClassFlowAlignment *_flowalign, t_CNNTy
     imagesRetention = 5;
 }
 
-string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution, int prev, float _before_narrow_Analog, float AnalogToDigitTransitionStart) {
+string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution, int prev, float _before_narrow_Analog, float AnalogToDigitTransitionStart, bool ContinuousLastDigit) {
     string result = "";    
 
     if (GENERAL[_analog]->ROI.size() == 0) {
@@ -92,7 +92,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
             }
             else {
                 if (_before_narrow_Analog >= 0) {
-                    prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, _before_narrow_Analog, prev, true, AnalogToDigitTransitionStart);
+                    prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, _before_narrow_Analog, prev, true, AnalogToDigitTransitionStart, ContinuousLastDigit);
                 }
                 else {
                     prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev, prev);
@@ -146,10 +146,11 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
  * @param Analog_Predecessors false/true if the last ROI is an analog or digit ROI (default=false)
  *                              runs in special handling because analog is much less precise
  * @param digitAnalogTransitionStart start of the transitionlogic begins on number_of_predecessor (default=9.2)
+ * @param ContinuousLastDigit the digit before the analog ROIs rolls continuously with the first pointer (default=false)
  *
  * @return int the determined number of the current ROI
  */
-int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors, float digitAnalogTransitionStart) {
+int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors, float digitAnalogTransitionStart, bool ContinuousLastDigit) {
     int result;
     int result_after_decimal_point = ((int) floor(number * 10)) % 10;
     int result_before_decimal_point = ((int) floor(number) + 10) % 10;
@@ -169,7 +170,7 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred
     }
 
     if (Analog_Predecessors) {
-        result = PointerEvalAnalogToDigitNew(number, number_of_predecessors, eval_predecessors, digitAnalogTransitionStart);
+        result = PointerEvalAnalogToDigitNew(number, number_of_predecessors, eval_predecessors, digitAnalogTransitionStart, ContinuousLastDigit);
         LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - Analog predecessor, evaluation over PointerEvalAnalogNew = " + std::to_string(result) +
                                                     " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digit_Uncertainty = " +  std::to_string(Digit_Uncertainty));
         return result;
@@ -227,12 +228,40 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred
     return result;
 }
 
-int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral_preceder,  int eval_predecessors, float AnalogToDigitTransitionStart) {
+int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral_preceder,  int eval_predecessors, float AnalogToDigitTransitionStart, bool ContinuousLastDigit) {
     int result;
     int result_after_decimal_point = ((int) floor(number * 10)) % 10;
     int result_before_decimal_point = ((int) floor(number) + 10) % 10;
     bool roundedUp = false;
 
+    // Drum geared continuously to the first analog pointer: its position is digit + pointer/10
+    // (e.g. 7.6 at pointer 6), so there is no step to detect. Remove the pointer's share and round;
+    // this tolerates +/-0.5 of combined reading error and wraps 9 <-> 0 in both directions.
+    // AnalogToDigitTransitionStart is not used in this mode.
+    if (ContinuousLastDigit) {
+        float pointer = numeral_preceder;
+
+        // Near 0 the pointer reading can be on the wrong side (e.g. 9.8 although the next pointer shows
+        // it has passed 0). The analog evaluation already resolved this (eval_predecessors), so move the
+        // reading to that side: 9.8 evaluated as 0 -> -0.2, 0.1 evaluated as 9 -> 10.1.
+        if (eval_predecessors >= 0) {
+            int pointer_before_decimal_point = (int) floor(pointer);
+
+            if (pointer_before_decimal_point - eval_predecessors >= 5) {
+                pointer -= 10;
+            }
+            else if (eval_predecessors - pointer_before_decimal_point >= 5) {
+                pointer += 10;
+            }
+        }
+
+        result = ((int) round(number - pointer / 10.0) + 10) % 10;
+        LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Continuous last digit - Result = " + std::to_string(result) +
+                                                    " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder) +
+                                                    " eval_predecessors = " + std::to_string(eval_predecessors));
+        return result;
+    }
+
     // Within the digit inequalities 
     if ((result_after_decimal_point >= (10-Digit_Uncertainty * 10))     // Band around the digit --> Round off, as digit reaches inaccuracy in the frame
         || (eval_predecessors <= 4 && result_after_decimal_point>=6))  {   // or digit runs after (analogue =0..4, digit >=6)

+ 3 - 3
code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h

@@ -35,8 +35,8 @@ protected:
     bool SaveAllFiles;   
 
     int PointerEvalAnalogNew(float zahl, int numeral_preceder);
-    int PointerEvalAnalogToDigitNew(float zahl, float numeral_preceder,  int eval_predecessors, float AnalogToDigitTransitionStart);
-    int PointerEvalHybridNew(float zahl, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors = false, float AnalogToDigitTransitionStart=9.2);
+    int PointerEvalAnalogToDigitNew(float zahl, float numeral_preceder,  int eval_predecessors, float AnalogToDigitTransitionStart, bool ContinuousLastDigit = false);
+    int PointerEvalHybridNew(float zahl, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors = false, float AnalogToDigitTransitionStart=9.2, bool ContinuousLastDigit = false);
 
 
 
@@ -52,7 +52,7 @@ public:
     bool doFlow(string time);
 
     string getHTMLSingleStep(string host);
-    string getReadout(int _analog, bool _extendedResolution = false, int prev = -1, float _before_narrow_Analog = -1, float AnalogToDigitTransitionStart=9.2); 
+    string getReadout(int _analog, bool _extendedResolution = false, int prev = -1, float _before_narrow_Analog = -1, float AnalogToDigitTransitionStart=9.2, bool ContinuousLastDigit = false); 
 
     string getReadoutRawString(int _analog);  
 

+ 1 - 0
code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h

@@ -64,6 +64,7 @@ struct NumberPost {
     int DecimalShift;           // decimalShift; each increment shifts the decimal separator by one digit; value=value*10^decimalShift; pos. value shifts to the right
     int DecimalShiftInitial;    // decimalShiftInitial; same as decimalShift but is a const to reset decimalShift after calculations
     float AnalogToDigitTransitionStart; // AnalogToDigitTransitionStartValue; FIXME: need a better description; When is the digit > x.1, i.e. when does it start to tilt?
+    bool ContinuousLastDigit;   // continuousLastDigit; last digit drum rolls continuously with the first analog pointer (drum = digit + pointer/10)
     int Nachkomma;              // decimalPlaces; usually defined by the number of analog ROIs; affected by DecimalShift
 
     string DomoticzIdx;         // Domoticz counter Idx

+ 27 - 1
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp

@@ -453,6 +453,27 @@ void ClassFlowPostProcessing::handleIgnoreLeadingNaN(string _decsep, string _val
     }
 }
 
+void ClassFlowPostProcessing::handleContinuousLastDigit(string _decsep, string _value) {
+    string _digit;
+    int _pospunkt = _decsep.find_first_of(".");
+
+    if (_pospunkt > -1) {
+        _digit = _decsep.substr(0, _pospunkt);
+    }
+    else {
+        _digit = "default";
+    }
+
+    for (int j = 0; j < NUMBERS.size(); ++j) {
+        bool _zwdc = alphanumericToBoolean(_value);
+
+        // Set to default first (if nothing else is set)
+        if ((_digit == "default") || (NUMBERS[j]->name == _digit)) {
+            NUMBERS[j]->ContinuousLastDigit = _zwdc;
+        }
+    }
+}
+
 void ClassFlowPostProcessing::handleMaxRateType(string _decsep, string _value) {
     string _digit, _decpos;
     int _pospunkt = _decsep.find_first_of(".");
@@ -622,6 +643,10 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
             handleIgnoreLeadingNaN(splitted[0], splitted[1]);
         }
 
+        if ((toUpper(_param) == "CONTINUOUSLASTDIGIT") && (splitted.size() > 1)) {
+            handleContinuousLastDigit(splitted[0], splitted[1]);
+        }
+
         if ((toUpper(_param) == "PREVALUEAGESTARTUP") && (splitted.size() > 1)) {
             if (isStringNumeric(splitted[1])) {
                 PreValueAgeStartup = std::stoi(splitted[1]);
@@ -696,6 +721,7 @@ void ClassFlowPostProcessing::InitNUMBERS() {
         _number->DecimalShiftInitial = 0;
         _number->isExtendedResolution = false;
         _number->AnalogToDigitTransitionStart=9.2;
+        _number->ContinuousLastDigit = false;
         _number->ChangeRateThreshold = 2;
 
         _number->Value = 0; // last value read out, incl. corrections
@@ -815,7 +841,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) {
 
         if (NUMBERS[j]->digit_roi) {
             if (NUMBERS[j]->analog_roi) {
-                NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, NUMBERS[j]->analog_roi->ROI[0]->result_float, NUMBERS[j]->AnalogToDigitTransitionStart) + NUMBERS[j]->ReturnRawValue;
+                NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, NUMBERS[j]->analog_roi->ROI[0]->result_float, NUMBERS[j]->AnalogToDigitTransitionStart, NUMBERS[j]->ContinuousLastDigit) + NUMBERS[j]->ReturnRawValue;
             }
             else {
                 NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value);        // Extended Resolution only if there are no analogue digits

+ 1 - 0
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h

@@ -44,6 +44,7 @@ protected:
     void handleAnalogToDigitTransitionStart(string _decsep, string _value);
     void handleAllowNegativeRate(string _decsep, string _value);
     void handleIgnoreLeadingNaN(string _decsep, string _value);
+    void handleContinuousLastDigit(string _decsep, string _value);
     void handleChangeRateThreshold(string _decsep, string _value);
     void handlecheckDigitIncreaseConsistency(std::string _decsep, std::string _value);
 

+ 45 - 0
code/test/components/jomjol-flowcontroll/test_PointerEvalAnalogToDigitNew.cpp

@@ -102,3 +102,48 @@ void test_analogToDigit_Transition() {
     TEST_ASSERT_EQUAL_INT(1,  undertest->PointerEvalAnalogToDigitNew( 1.8, 7.8, 7, 7.7));
 
 }
+
+/**
+ * @brief Last digit drum geared continuously to the first analog pointer
+ * (drum = digit + pointer/10), evaluated with ContinuousLastDigit = true.
+ *
+ * Readings from a meter with such a drum (dig-cont / ana-cont models):
+ * the drum reads x.6 at pointer 6, x.8 at pointer 8 and a clean (x+1).0
+ * at pointer 9.5 .. 9.99, before the pointer has passed 0.
+ */
+void test_analogToDigit_ContinuousLastDigit() {
+    UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digit100);
+
+    // Drum already shows the next number while the pointer is just before 0.
+    // Default: dig=8.0, ana=9.88 => erg=8 (raw value 1 m³ too high)
+    TEST_ASSERT_EQUAL_INT(8,  undertest->PointerEvalAnalogToDigitNew( 8.0, 9.88, 9, 9.2));
+    // Continuous: 8.0 - 0.988 = 7.01 => erg=7
+    TEST_ASSERT_EQUAL_INT(7,  undertest->PointerEvalAnalogToDigitNew( 8.0, 9.88, 9, 9.2, true));
+
+    // Mid-turn, drum at x.6 .. x.8 with the pointer at 6 .. 7
+    // Default with AnalogToDigitTransitionStart 9.2: dig=7.8, ana=6.3 => erg=8
+    TEST_ASSERT_EQUAL_INT(8,  undertest->PointerEvalAnalogToDigitNew( 7.8, 6.3, 6, 9.2));
+    TEST_ASSERT_EQUAL_INT(7,  undertest->PointerEvalAnalogToDigitNew( 7.8, 6.3, 6, 9.2, true));
+    TEST_ASSERT_EQUAL_INT(7,  undertest->PointerEvalAnalogToDigitNew( 7.6, 6.0, 6, 9.2, true));
+
+    // After the pointer passed 0 the drum shows the new number
+    TEST_ASSERT_EQUAL_INT(8,  undertest->PointerEvalAnalogToDigitNew( 8.0, 0.1, 0, 9.2, true));
+    TEST_ASSERT_EQUAL_INT(8,  undertest->PointerEvalAnalogToDigitNew( 8.2, 2.2, 2, 9.2, true));
+
+    // Wrap around 9 <-> 0 in both directions
+    // Drum just below 0, pointer just past 0 => erg=0
+    TEST_ASSERT_EQUAL_INT(0,  undertest->PointerEvalAnalogToDigitNew( 9.996, 0.05, 0, 9.2, true));
+    // Drum just past 0, pointer not yet at 0 => erg=9
+    TEST_ASSERT_EQUAL_INT(9,  undertest->PointerEvalAnalogToDigitNew( 0.02, 9.9, 9, 9.2, true));
+
+    // AnalogToDigitTransitionStart has no effect in this mode
+    TEST_ASSERT_EQUAL_INT(7,  undertest->PointerEvalAnalogToDigitNew( 8.0, 9.88, 9, 6.0, true));
+
+    // Pointer read on the wrong side of 0; the analog evaluation (eval_predecessors) decides the side
+    // Pointer reads 9.8 but has passed 0 (eval 0): 9.0 - (-0.02) => erg=9 (not 8)
+    TEST_ASSERT_EQUAL_INT(9,  undertest->PointerEvalAnalogToDigitNew( 9.0, 9.8, 0, 9.2, true));
+    TEST_ASSERT_EQUAL_INT(0,  undertest->PointerEvalAnalogToDigitNew( 0.0, 9.8, 0, 9.2, true));
+    // Pointer reads 0.0 but has not passed 0 yet (eval 9): 8.98 - 1.0 => erg=8 (not 9)
+    TEST_ASSERT_EQUAL_INT(8,  undertest->PointerEvalAnalogToDigitNew( 8.98, 0.0, 9, 9.2, true));
+    TEST_ASSERT_EQUAL_INT(9,  undertest->PointerEvalAnalogToDigitNew( 9.98, 0.1, 9, 9.2, true));
+}

+ 7 - 0
code/test/components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp

@@ -166,3 +166,10 @@ void setAnalogdigitTransistionStart(UnderTestPost* _underTestPost, float _analog
         }       
     }
 }
+
+void setContinuousLastDigit(UnderTestPost* _underTestPost, bool _continuousLastDigit) {
+    std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
+    for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
+        (*NUMBERS)[_n]->ContinuousLastDigit = _continuousLastDigit;
+    }
+}

+ 8 - 0
code/test/components/jomjol-flowcontroll/test_flow_postrocess_helper.h

@@ -113,4 +113,12 @@ void setAnalogdigitTransistionStart(UnderTestPost* _underTestPost, float _analog
  */
 void setAllowNegatives(UnderTestPost* _underTestPost, bool _allowNegatives);
 
+/**
+ * @brief Set ContinuousLastDigit in testobject
+ * 
+ * @param _underTestPost the testobject  
+ * @param _continuousLastDigit true if the last digit drum rolls continuously with the first analog pointer
+ */
+void setContinuousLastDigit(UnderTestPost* _underTestPost, bool _continuousLastDigit);
+
 #endif // TEST_FLOW_H

+ 58 - 0
code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp

@@ -522,6 +522,64 @@ void test_doFlowPP3() {
         delete undertestPost;
 }
 
+/**
+ * @brief Whole readout with ContinuousLastDigit = true
+ */
+void test_doFlowPP_ContinuousLastDigit() {
+        // Last drum geared continuously to ana1 (water meter, dig-cont / ana-cont).
+        // Default result 998.9683 (Rate too high), true value 997.9683
+        std::vector<float> digits = { 0.0, 0.1, 9.1, 9.0, 8.0};
+        std::vector<float> analogs = { 9.88, 6.6, 8.3, 3.6};
+
+        std::string result = process_doFlow(analogs, digits, Digit100, false, false, 0);
+        TEST_ASSERT_EQUAL_STRING("998.9683", result.c_str());
+
+        UnderTestPost* undertestPost = init_do_flow(analogs, digits, Digit100, false, false, 0);
+        setContinuousLastDigit(undertestPost, true);
+        result = process_doFlow(undertestPost);
+        TEST_ASSERT_EQUAL_STRING("997.9683", result.c_str());
+        delete undertestPost;
+
+        // ana1 reads 9.8 just after passing 0; ana2 shows it has passed (true value 999.0000)
+        digits = { 0.0, 9.0, 9.0, 9.0};
+        analogs = { 9.8, 0.1, 0.1, 0.2};
+        undertestPost = init_do_flow(analogs, digits, Digit100, false, false, 0);
+        setContinuousLastDigit(undertestPost, true);
+        result = process_doFlow(undertestPost);
+        TEST_ASSERT_EQUAL_STRING("999.0000", result.c_str());
+        delete undertestPost;
+
+        // ana1 reads 0.0 just before passing 0; ana2 shows it has not (true value 998.9801)
+        digits = { 0.0, 0.1, 9.1, 9.0, 8.98};
+        analogs = { 0.0, 8.01, 0.1, 1.0};
+        undertestPost = init_do_flow(analogs, digits, Digit100, false, false, 0);
+        setContinuousLastDigit(undertestPost, true);
+        result = process_doFlow(undertestPost);
+        TEST_ASSERT_EQUAL_STRING("998.9801", result.c_str());
+        delete undertestPost;
+
+        // The two "last digit runs with the analog pointer" cases of test_doFlowPP3,
+        // solved there with AnalogToDigitTransitionStart = 7.7, give the same
+        // results with the default transition start and ContinuousLastDigit.
+        // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1262626388
+        digits = { 1.2, 6.8, 0.0, 0.0, 5.0, 2.8};
+        analogs = { 8.7};
+        undertestPost = init_do_flow(analogs, digits, Digit100, false, false, -3);
+        setContinuousLastDigit(undertestPost, true);
+        result = process_doFlow(undertestPost);
+        TEST_ASSERT_EQUAL_STRING("170.0528", result.c_str());
+        delete undertestPost;
+
+        // https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1282168030
+        digits = { 1.2, 7.0, 1.2, 2.0, 4.0, 1.8};
+        analogs = { 7.8};
+        undertestPost = init_do_flow(analogs, digits, Digit100, false, false, -3);
+        setContinuousLastDigit(undertestPost, true);
+        result = process_doFlow(undertestPost);
+        TEST_ASSERT_EQUAL_STRING("171.2417", result.c_str());
+        delete undertestPost;
+}
+
 void test_doFlowPP4() {
 
         // Fehler  V13.0.4 

+ 4 - 0
code/test/test_suite_flowcontroll.cpp

@@ -129,6 +129,8 @@ void task_UnityTesting(void *pvParameter)
         printf("---------------------------------------------------------------------------\n");
         RUN_TEST(test_analogToDigit_Transition);
         printf("---------------------------------------------------------------------------\n");
+        RUN_TEST(test_analogToDigit_ContinuousLastDigit);
+        printf("---------------------------------------------------------------------------\n");
 
         RUN_TEST(test_doFlowPP);
         printf("---------------------------------------------------------------------------\n");
@@ -138,6 +140,8 @@ void task_UnityTesting(void *pvParameter)
         printf("---------------------------------------------------------------------------\n");
         RUN_TEST(test_doFlowPP3);
         printf("---------------------------------------------------------------------------\n");
+        RUN_TEST(test_doFlowPP_ContinuousLastDigit);
+        printf("---------------------------------------------------------------------------\n");
         RUN_TEST(test_doFlowPP4);
     UNITY_END();
 

+ 21 - 0
param-docs/parameter-pages/PostProcessing/NUMBER.ContinuousLastDigit.md

@@ -0,0 +1,21 @@
+# Parameter `ContinuousLastDigit`
+Default Value: `false`
+
+Enable this if the last digit (the one directly before the analog pointers) does not jump, but turns
+continuously together with the first analog pointer: the digit is about halfway to the next number
+when the pointer is at 5, and already shows the next number shortly before the pointer reaches 0.
+
+With such a digit the normal transition logic gives a value that is one unit too high while the
+pointer is between about 9.5 and 0 (usually rejected as `Rate too high`). With this option the digit
+is calculated as `digit - pointer / 10`, rounded, which needs no tuning.
+[`AnalogToDigitTransitionStart`](NUMBER.AnalogToDigitTransitionStart) is not used when it is enabled.
+
+!!! Warning
+    Only enable it for digits that really turn continuously. For a digit that jumps to the next
+    number (even an early or late one) it gives wrong results.
+
+Only used on combination of digits and analog pointers, and needs a digit model with decimal output
+(e.g. `dig-cont`).
+
+!!! Note
+    If you edit the config file manually, you must prefix this parameter with `<NUMBER>` followed by a dot (eg. `main.ContinuousLastDigit`). The reason is that this parameter is specific for each `<NUMBER>` (`<NUMBER>` is the name of the number sequence defined in the ROI's).

+ 1 - 0
sd-card/config/config.ini

@@ -64,6 +64,7 @@ main.ana4 155 328 92 92 false
 [PostProcessing]
 main.DecimalShift = 0
 main.AnalogDigitTransitionStart = 9.2
+main.ContinuousLastDigit = false
 main.ChangeRateThreshold = 2
 PreValueUse = true
 PreValueAgeStartup = 720

+ 15 - 0
sd-card/html/edit_config_template.html

@@ -936,6 +936,19 @@
             <td>$TOOLTIP_PostProcessing_NUMBER.AnalogToDigitTransitionStart</td>
         </tr>
 
+        <tr>
+            <td class="indent2">
+                <label><class id="PostProcessing_ContinuousLastDigit_text" style="color:black;">Continuous Last Digit</class></label>
+            </td>
+            <td>
+                <select id="PostProcessing_ContinuousLastDigit_value1">
+                    <option value="true">enabled (true)</option>
+                    <option value="false" selected>disabled (false)</option>
+                </select>
+            </td>
+            <td>$TOOLTIP_PostProcessing_NUMBER.ContinuousLastDigit</td>
+        </tr>
+
         <tr>
             <td class="indent2">
                 <input type="checkbox" id="PostProcessing_MaxRateValue_enabled" value="1"  onclick = 'InvertEnableItem("PostProcessing", "MaxRateValue")' unchecked >
@@ -2249,6 +2262,7 @@ function UpdateInputIndividual(sel) {
         // ReadParameter(param, "PostProcessing", "PreValueUse", false, NUNBERSAkt);
         ReadParameter(param, "PostProcessing", "DecimalShift", true, NUNBERSAkt);
         ReadParameter(param, "PostProcessing", "AnalogToDigitTransitionStart", true, NUNBERSAkt);
+        ReadParameter(param, "PostProcessing", "ContinuousLastDigit", false, NUNBERSAkt);
         ReadParameter(param, "PostProcessing", "ChangeRateThreshold", true, NUNBERSAkt);
         ReadParameter(param, "PostProcessing", "MaxRateValue", true, NUNBERSAkt);
         ReadParameter(param, "PostProcessing", "MaxRateType", true, NUNBERSAkt);
@@ -2269,6 +2283,7 @@ function UpdateInputIndividual(sel) {
     // WriteParameter(param, category, "PostProcessing", "PreValueUse", false, NUNBERSAkt);
     WriteParameter(param, category, "PostProcessing", "DecimalShift", true, NUNBERSAkt);
     WriteParameter(param, category, "PostProcessing", "AnalogToDigitTransitionStart", true, NUNBERSAkt);
+    WriteParameter(param, category, "PostProcessing", "ContinuousLastDigit", false, NUNBERSAkt);
     WriteParameter(param, category, "PostProcessing", "ChangeRateThreshold", true, NUNBERSAkt);
     WriteParameter(param, category, "PostProcessing", "MaxRateValue", true, NUNBERSAkt);
     WriteParameter(param, category, "PostProcessing", "MaxRateType", true, NUNBERSAkt);

+ 11 - 0
sd-card/html/readconfigparam.js

@@ -170,6 +170,7 @@ function ParseConfig() {
     param[catname] = new Object();
     ParamAddValue(param, catname, "DecimalShift", 1, true, "0");
     ParamAddValue(param, catname, "AnalogToDigitTransitionStart", 1, true, "9.2");
+    ParamAddValue(param, catname, "ContinuousLastDigit", 1, true, "false");
     ParamAddValue(param, catname, "ChangeRateThreshold", 1, true, "2");
     // ParamAddValue(param, catname, "PreValueUse", 1, true, "true");
     ParamAddValue(param, catname, "PreValueUse");
@@ -353,6 +354,16 @@ function ParseConfig() {
         param["System"]["RSSIThreshold"]["enabled"] = false;
         param["System"]["RSSIThreshold"]["value1"] = "0";
     }
+
+    // Downward compatibility: Create ContinuousLastDigit for each number if not available.
+    // It has no enable checkbox, so a parameter missing in the config would stay locked in the UI.
+    for (var _num in NUMBERS) {
+        if (NUMBERS[_num]["PostProcessing"]["ContinuousLastDigit"]["found"] == false) {
+            NUMBERS[_num]["PostProcessing"]["ContinuousLastDigit"]["found"] = true;
+            NUMBERS[_num]["PostProcessing"]["ContinuousLastDigit"]["enabled"] = true;
+            NUMBERS[_num]["PostProcessing"]["ContinuousLastDigit"]["value1"] = "false";
+        }
+    }
 }
 
 function ParamAddValue(param, _cat, _param, _anzParam = 1, _isNUMBER = false, _defaultValue = "", _checkRegExList = null) {