Closed AlexanderTonn closed 11 months ago
I'm not clearly sure what the issue was, but i suppose that I did something wrong with the declaration and the including of the template function in "Util.h" and "util.ino".
I had the same issue again with following Terminal Output:
bool xTrigBatteryFull = edgeDetection(fBatteryVoltage,
fTrigBatteryFullPrevious,
edgeType::RISING_EDGE,
fTargetVoltageInverter); // Battery is full after reaching 100%
bool xTrigBatteryEmpty = edgeDetection(fBatteryVoltage, fTrigBatteryEmptyPrevious, edgeType::FALLING_EDGE, fTargetVoltageMppt); // Battery should charged if dropped down to 50%
Serial.print("xTrigBatteryFull: ");
Serial.println(xTrigBatteryFull);
Serial.print("xTrigBatteryEmpty: ");
Serial.println(xTrigBatteryEmpty);
xTrigBatteryFull: 0
xTrigBatteryEmpty: 0
edgeDetection()
function is returning this values if no if-loop is passed. In this case the function would not return true or false and the value of the variable which is initialized with this function can be have any valuetemplate<typename T1, typename T2, typename T3 >
auto edgeDetection (T1 TinputSignal, T2 &TpreviousSignal, edgeType Type, T3 Ttrigger ) -> bool {
// RISING EDGE detection
switch(Type)
{
case edgeType::RISING_EDGE :
if (TinputSignal >= Ttrigger && TpreviousSignal < Ttrigger ) {
TpreviousSignal = TinputSignal;
return true;
}
// Resetting the signal if Ttrigger was reached
else if ((TinputSignal >= Ttrigger && TpreviousSignal >= Ttrigger)
|| (TinputSignal < Ttrigger && TpreviousSignal >= Ttrigger)) {
TpreviousSignal = TinputSignal;
return false;
}
+ else
+ return false;
break;
:bug: Describe the bug
xTrigBatteryFull
returning183
:bangbang: To Reproduce**
Steps to reproduce the behavior:
sctMeasuring()
function, the return value is gettingxTrigBatteryFull=76
:interrobang: Expected behavior
:camera: Screenshots
Serial monitor
:computer: Desktop (please complete the following information):**
:iphone: Smartphone (please complete the following information):**
Additional context