trigger refactoring: we are long overdue for better api, also reducing CRANK_MODE_MULTIPLIER crazy

This commit is contained in:
Andrey 2023-05-13 14:59:17 -04:00
parent 3c2c2cc1d7
commit 56a327c6be
4 changed files with 16 additions and 20 deletions

View File

@ -210,8 +210,6 @@ typedef enum __attribute__ ((__packed__)) {
PI_PULLDOWN = 2
} pin_input_mode_e;
#define CRANK_MODE_MULTIPLIER 2.0f
/**
* @see getCycleDuration
* @see getEngineCycle

View File

@ -9,9 +9,11 @@
#include "trigger_gm.h"
#define GM_60_W 6
static float addTooth(float offset, TriggerWaveform *s) {
s->addToothRiseFall(offset / 2 + 3, 3, TriggerWheel::T_SECONDARY);
return offset + CRANK_MODE_MULTIPLIER * 6;
s->addToothRiseFall(offset + GM_60_W / 2, GM_60_W / 2, TriggerWheel::T_SECONDARY);
return offset + GM_60_W;
}
/**
@ -23,37 +25,35 @@ void configureGm60_2_2_2(TriggerWaveform *s) {
s->isSynchronizationNeeded = false;
s->isSecondWheelCam = true;
float m = CRANK_MODE_MULTIPLIER;
int offset = 1 * m;
int offset = 1;
for (int i=0;i<12;i++) {
offset = addTooth(offset, s);
}
offset += m * 2 * 6;
offset += 2 * GM_60_W;
for (int i=0;i<18;i++) {
offset = addTooth(offset, s);
}
offset += m * 2 * 6;
offset += 2 * GM_60_W;
for (int i=0;i<18;i++) {
offset = addTooth(offset, s);
}
offset += m * 2 * 6;
offset += 2 * GM_60_W;
for (int i=0;i<5;i++) {
offset = addTooth(offset, s);
}
s->addEventAngle(m * (360 - 6), TriggerValue::RISE);
s->addEvent360(360 - GM_60_W, TriggerValue::RISE);
offset = addTooth(offset, s);
s->addEventAngle(m * (360), TriggerValue::FALL);
s->addEvent360(360, TriggerValue::FALL);
}

View File

@ -69,12 +69,6 @@ void configureOnePlus16(TriggerWaveform *s) {
s->isSynchronizationNeeded = false;
}
static void kseriesTooth(TriggerWaveform* s, float end) {
// for VR we only handle rises so width does not matter much
s->addEvent360(end - 4, TriggerValue::RISE, TriggerWheel::T_PRIMARY);
s->addEvent360(end , TriggerValue::FALL, TriggerWheel::T_PRIMARY);
}
// TT_HONDA_K_CRANK_12_1
void configureHondaK_12_1(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_CRANK_SENSOR, SyncEdge::RiseOnly);
@ -87,11 +81,14 @@ void configureHondaK_12_1(TriggerWaveform *s) {
int count = 12;
float tooth = 360 / count; // hint: tooth = 30
// for VR we only handle rises so width does not matter much
int width = 4;
// Extra "+1" tooth happens 1/3 of the way between first two teeth
kseriesTooth(s, tooth / 3);
s->addToothRiseFall(tooth / 3, width);
for (int i = 1; i <= count; i++) {
kseriesTooth(s, tooth * i);
s->addToothRiseFall(tooth * i, width);
}
}

View File

@ -225,6 +225,7 @@ void TriggerWaveform::addEvent720(angle_t angle, TriggerValue const state, Trigg
void TriggerWaveform::addEvent360(angle_t angle, TriggerValue const state, TriggerWheel const channelIndex) {
efiAssertVoid(ObdCode::CUSTOM_OMODE_UNDEF, operationMode == FOUR_STROKE_CAM_SENSOR || operationMode == FOUR_STROKE_CRANK_SENSOR, "Not a mode for 360");
#define CRANK_MODE_MULTIPLIER 2.0f
addEvent(CRANK_MODE_MULTIPLIER * angle / FOUR_STROKE_CYCLE_DURATION, state, channelIndex);
}