testing calc enable

This commit is contained in:
Janosch
2022-10-14 13:08:23 +01:00
parent b45c29f89e
commit 100821e68c
7 changed files with 90 additions and 30 deletions
+31
View File
@@ -1,4 +1,5 @@
#include "my_math.h"
#include "errormessage.h"
#include "charger.h"
#ifdef TEST_COMMON_H
#include "../test/test_common.h"
@@ -177,3 +178,33 @@ void ResetValuesInOffMode()
}
}
void CalcEnable()
{
static int recheckCan = 10;
bool enablePol = Param::GetBool(Param::enablepol);
bool enable = DigIo::enable_in.Get() ^ enablePol;
enable &= !Param::GetBool(Param::cancontrol) || Param::GetBool(Param::canenable);
if (Param::GetBool(Param::cancontrol))
{
if (recheckCan == 0)
{
if (Param::GetInt(Param::canenable) == 3)
{
Param::SetInt(Param::canenable, 0);
ErrorMessage::Post(ERR_EXTCAN);
}
else
{
Param::SetInt(Param::canenable, 3); //Must be overwritten by CAN message within the next second
}
recheckCan = 10;
}
recheckCan--;
}
Param::SetInt(Param::enable, enable);
}