Speeduino
Loading...
Searching...
No Matches
decoder_t.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
5
7static constexpr uint8_t TRIGGER_EDGE_NONE = 99;
8
11{
12 using callback_t = void(*)(void);
13
18
19 interrupt_t() = default;
25
28
30 void detach(uint8_t pin);
31
37 bool isTriggered(void) const;
38
40 bool isValid(void) const
41 {
42 return edge!=TRIGGER_EDGE_NONE
43 && callback!=nullptr
44 && _pin.isValid();
45 }
46
47 bool isPinHigh(void) const {
48 return _pin.isPinHigh();
49 }
50
52};
53
57enum class SyncStatus : uint8_t {
59 None,
63 Partial,
65 Full,
66};
67
74
75
89
95{
102
104
105 using getRPM_t = uint16_t(*)(void);
108
110
114
116
117 using setEndTeeth_t = void(*)(void);
120
122
123 using reset_t = void(*)(void);
126
128
140
142
143#pragma GCC diagnostic push
144#pragma GCC diagnostic ignored "-Wnoexcept-type"
145 using status_fun_t = decoder_status_t(*)(void)noexcept;
146#pragma GCC diagnostic pop
149
151
155};
To avoid circular header dependencies boardInputPin_t is a forward declared typedef; include this fil...
A class for input pin operations that is faster than standard Arduino digitalRead()
Definition fastInputPin.h:10
bool isValid(void) const noexcept
Is the pin set?
Definition fastInputPin.h:28
bool isPinHigh(void) const noexcept
Check if the pin is set high.
Definition fastInputPin.h:18
SyncStatus
The decoder trigger status.
Definition decoder_t.h:57
static constexpr uint8_t TRIGGER_EDGE_NONE
This constant represents no trigger edge.
Definition decoder_t.h:7
Definition array.h:14
Definition decoder_t.h:76
decoder_features_t(void)
‍Whether or not the decoder supports per-tooth ignition
Definition decoder_t.h:82
bool supportsPerToothIgnition
‍Whether or not the decoder supports fixed cranking timing
Definition decoder_t.h:80
bool supportsSequential
‍The use of the 2nd derivative calculation is limited to certain decoders.
Definition decoder_t.h:78
bool supports2ndDeriv
Definition decoder_t.h:77
bool hasFixedCrankingTiming
‍Whether or not the decoder supports sequential operation
Definition decoder_t.h:79
Current decoder status.
Definition decoder_t.h:69
SyncStatus syncStatus
‍Whether or not the triggerToothAngle variable is currently accurate. Some patterns have times when t...
Definition decoder_t.h:72
bool toothAngleIsCorrect
‍Is set true when the last trigger (Primary or secondary) was valid (ie passed filters)
Definition decoder_t.h:71
bool validTrigger
Definition decoder_t.h:70
This structure represents a decoder configuration.
Definition decoder_t.h:95
getCrankAngle_t getCrankAngle
The function to get the crank angle.
Definition decoder_t.h:112
reset_t reset
The function to reset the decoder. Called when the engine is stopped, or when the engine is started.
Definition decoder_t.h:124
feature_fun_t getFeatures
The function to get the current decoder feature set.
Definition decoder_t.h:153
interrupt_t tertiary
The tertiary interrupt configuration - for decoders that use a 3rd input. E.g. VVT.
Definition decoder_t.h:101
engine_running_t isEngineRunning
The function to test if the engine is running.
Definition decoder_t.h:138
setEndTeeth_t setEndTeeth
The function to set the end teeth for ignition calculations.
Definition decoder_t.h:118
getRPM_t getRPM
The function to get the RPM.
Definition decoder_t.h:106
interrupt_t secondary
The secondary interrupt configuration - usually the cam trigger.
Definition decoder_t.h:99
interrupt_t primary
The primary interrupt configuration - usually the crank trigger.
Definition decoder_t.h:97
status_fun_t getStatus
The function to get the current decoder status.
Definition decoder_t.h:147
This structure represents a trigger interrupt.
Definition decoder_t.h:11
void detach(uint8_t pin)
Detach the interrupt from a pin.
Definition decoder_t.cpp:27
uint8_t attach(uint8_t pin)
Attach the interrupt to a pin.
Definition decoder_t.cpp:13
uint8_t edge
The edge type for the interrupt. E.g. RISING, FALLING, CHANGE.
Definition decoder_t.h:17
callback_t callback
The callback function to be called on interrupt.
Definition decoder_t.h:15
boardInputPin_t _pin
Definition decoder_t.h:51
interrupt_t(callback_t _callback, uint8_t _edge)
Definition decoder_t.h:20
bool isValid(void) const
Is the interrupt configured correctly?
Definition decoder_t.h:40
bool isTriggered(void) const
Does the pin state match the edge setting?
Definition decoder_t.cpp:33
bool isPinHigh(void) const
Definition decoder_t.h:47
interrupt_t()=default