2021-11-18 11:27:21 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define TRIGGER_EVENT_UNDEFINED INT32_MAX
|
|
|
|
|
|
|
|
class TriggerScheduler : public EngineModule {
|
|
|
|
public:
|
2022-09-20 02:28:23 -07:00
|
|
|
bool scheduleOrQueue(AngleBasedEventOld *event,
|
|
|
|
uint32_t trgEventIndex,
|
|
|
|
efitick_t edgeTimestamp,
|
|
|
|
angle_t angle,
|
|
|
|
action_s action);
|
|
|
|
|
|
|
|
bool scheduleOrQueue(AngleBasedEventNew *event,
|
2021-11-18 11:27:21 -08:00
|
|
|
uint32_t trgEventIndex,
|
|
|
|
efitick_t edgeTimestamp,
|
|
|
|
angle_t angle,
|
2022-09-25 08:00:55 -07:00
|
|
|
action_s action,
|
|
|
|
float currentPhase, float nextPhase);
|
2021-11-18 11:27:21 -08:00
|
|
|
|
|
|
|
void scheduleEventsUntilNextTriggerTooth(int rpm,
|
|
|
|
uint32_t trgEventIndex,
|
2022-09-20 02:28:23 -07:00
|
|
|
efitick_t edgeTimestamp,
|
|
|
|
float currentPhase, float nextPhase);
|
2021-11-18 11:27:21 -08:00
|
|
|
|
|
|
|
// For unit tests
|
2022-09-20 02:28:23 -07:00
|
|
|
AngleBasedEventBase * getElementAtIndexForUnitTest(int index);
|
2021-11-18 11:27:21 -08:00
|
|
|
|
|
|
|
private:
|
2022-09-20 02:28:23 -07:00
|
|
|
bool assertNotInList(AngleBasedEventBase *head, AngleBasedEventBase *element);
|
2021-11-18 11:27:21 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* That's the linked list of pending events scheduled in relation to trigger
|
|
|
|
* At the moment we iterate over the whole list while looking for events for specific
|
|
|
|
* trigger index We can make it an array of lists per trigger index, but that would take
|
|
|
|
* some RAM and probably not needed yet.
|
|
|
|
*/
|
2022-09-20 02:28:23 -07:00
|
|
|
AngleBasedEventBase *m_angleBasedEventsHead = nullptr;
|
2021-11-18 11:27:21 -08:00
|
|
|
};
|