add std::function hooks to ignition

This commit is contained in:
Matthew Kennedy 2024-04-12 11:11:44 -07:00 committed by rusefillc
parent 6ff62e9ca0
commit 48feb535af
2 changed files with 16 additions and 0 deletions

View File

@ -55,6 +55,8 @@
#include "vvt.h"
#include "trip_odometer.h"
#include <functional>
#ifndef EFI_UNIT_TEST
#error EFI_UNIT_TEST must be defined!
#endif
@ -237,6 +239,8 @@ public:
#endif
#if EFI_UNIT_TEST
TestExecutor executor;
std::function<void(IgnitionEvent*, bool)> onIgnitionEvent;
#endif // EFI_UNIT_TEST
#if EFI_ENGINE_CONTROL

View File

@ -181,6 +181,12 @@ static void overFireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
}
void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
#if EFI_UNIT_TEST
if (engine->onIgnitionEvent) {
engine->onIgnitionEvent(event, false);
}
#endif
for (int i = 0; i< MAX_OUTPUTS_FOR_IGNITION;i++) {
IgnitionOutputPin *output = event->outputs[i];
@ -300,6 +306,12 @@ void turnSparkPinHighStartCharging(IgnitionEvent *event) {
efitick_t nowNt = getTimeNowNt();
#if EFI_UNIT_TEST
if (engine->onIgnitionEvent) {
engine->onIgnitionEvent(event, true);
}
#endif
#if EFI_TOOTH_LOGGER
LogTriggerCoilState(nowNt, true);
#endif // EFI_TOOTH_LOGGER