rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
fuel_schedule.h
Go to the documentation of this file.
1/**
2 * @file fuel_schedule.h
3 */
4
5#pragma once
6
7#include "global.h"
8#include "efi_gpio.h"
9#include "scheduler.h"
10#include "fl_stack.h"
11#include "trigger_structure.h"
12#include "wall_fuel.h"
13
14#define MAX_WIRES_COUNT 2
15
17public:
18 InjectionEvent() = default;
19
20 bool update();
21
22 // Call this every decoded trigger tooth. It will schedule any relevant events for this injector.
23 void onTriggerTooth(efitick_t nowNt, float currentPhase, float nextPhase);
24
26
27 void setIndex(uint8_t index) {
28 ownIndex = index;
29 }
30
31private:
32 // Update the injection start angle
34
35 // Compute the injection start angle, compensating for injection duration and injection phase settings.
36 expected<float> computeInjectionAngle() const;
37
38 /**
39 * This is a performance optimization for IM_SIMULTANEOUS fuel strategy.
40 * It's more efficient to handle all injectors together if that's the case
41 */
42 bool isSimultaneous = false;
43 uint8_t ownIndex = 0;
44 uint8_t cylinderNumber = 0;
45
47
48public:
49 // TODO: this should be private
50 InjectorOutputPin *outputs[MAX_WIRES_COUNT]{};
51 InjectorOutputPin *outputsStage2[MAX_WIRES_COUNT]{};
53};
54
56
57
58/**
59 * This class knows about when to inject fuel
60 */
62public:
64
65 // Call this function if something happens that requires a rebuild, like a change to the trigger pattern
66 void invalidate();
67
68 // Call this every trigger tooth. It will schedule all required injector events.
69 void onTriggerTooth(efitick_t nowNt, float currentPhase, float nextPhase);
70
71 /**
72 * this method schedules all fuel events for an engine cycle
73 * Calculate injector opening angle, pins, and mode for all injectors
74 */
75 void addFuelEvents();
76
77 static void resetOverlapping();
78
79 /**
80 * injection events, per cylinder
81 */
82 InjectionEvent elements[MAX_CYLINDER_COUNT];
83 bool isReady = false;
84};
85
InjectionEvent elements[MAX_CYLINDER_COUNT]
void onTriggerTooth(efitick_t nowNt, float currentPhase, float nextPhase)
static void resetOverlapping()
InjectorOutputPin * outputsStage2[MAX_WIRES_COUNT]
expected< float > computeInjectionAngle() const
WallFuel & getWallFuel()
void setIndex(uint8_t index)
WallFuel wallFuel
InjectionEvent()=default
void onTriggerTooth(efitick_t nowNt, float currentPhase, float nextPhase)
bool updateInjectionAngle()
InjectorOutputPin * outputs[MAX_WIRES_COUNT]
float injectionStartAngle
uint8_t cylinderNumber
EFI-related GPIO code.
Fixed-length stack.
void turnInjectionPinHigh(scheduler_arg_t arg)
FuelSchedule * getFuelSchedule()
Definition engine.cpp:600
uintptr_t scheduler_arg_t
Definition scheduler.h:21