From 4b4b42d4c55a371d2b624d1a0dcea40b79f67c5b Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Fri, 26 Apr 2024 12:17:37 +0200 Subject: [PATCH] Modifcation to cover new test case https://github.com/jomjol/AI-on-the-edge-device/pull/2887#issuecomment-1941018311 --- .../jomjol_flowcontroll/ClassFlowCNNGeneral.cpp | 2 +- code/include/defines.h | 2 +- .../jomjol-flowcontroll/test_cnnflowcontroll.cpp | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp index 5ebd1c40..ae980e47 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp @@ -161,7 +161,7 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred return result; } - if ((number_of_predecessors >= Digital_Transition_Area_Predecessor ) && (number_of_predecessors <= (10.0 - Digital_Transition_Area_Predecessor))) + if ((number_of_predecessors > Digital_Transition_Area_Predecessor ) && (number_of_predecessors < (10.0 - Digital_Transition_Area_Predecessor))) { // no digit change, because predecessor is far enough away (0+/-DigitalTransitionRangePredecessor) --> number is rounded if ((result_after_decimal_point <= DigitalBand) || (result_after_decimal_point >= (10-DigitalBand))) // Band around the digit --> Round off, as digit reaches inaccuracy in the frame diff --git a/code/include/defines.h b/code/include/defines.h index 127b5a4e..27a4cc29 100644 --- a/code/include/defines.h +++ b/code/include/defines.h @@ -199,7 +199,7 @@ #define Digital_Uncertainty 0.2 #define DigitalBand 3 #define Digital_Transition_Range_Predecessor 2 - #define Digital_Transition_Area_Predecessor 0.7 // 9.3 - 0.7 + #define Digital_Transition_Area_Predecessor 1.0 // 9.0 - 1.0 #define Digital_Transition_Area_Forward 9.7 // Pre-run zero crossing only happens from approx. 9.7 onwards diff --git a/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp b/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp index c5c6c771..54913832 100644 --- a/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp +++ b/code/test/components/jomjol-flowcontroll/test_cnnflowcontroll.cpp @@ -108,9 +108,13 @@ void test_ZeigerEvalHybrid() { // pre = 9.9 (0.0 raw) // zahl = 1.8 - TEST_ASSERT_EQUAL(2, undertest.PointerEvalHybridNew(1.8, 9.0, 9)); - - // if a digit have an early transition and the pointer is < 9.0 + TEST_ASSERT_EQUAL(1, undertest.PointerEvalHybridNew(1.8, 9.0, 9)); + + // pre = 8.8 (0.0 raw) + // zahl = 1.8 + TEST_ASSERT_EQUAL(2, undertest.PointerEvalHybridNew(1.8, 8.9, 8)); + + // if a digit have an early transition and the pointer is < 9.0 // prev (pointer) = 6.2, but on digital readout = 6.0 (prev is int parameter) // zahl = 4.6 TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.6, 6.0, 6));