fome-fw/firmware/controllers/trigger/decoders/trigger_renix.cpp

44 lines
1.1 KiB
C++
Raw Normal View History

2020-04-18 19:20:17 -07:00
/**
* @file trigger_renix.cpp
*
* https://en.wikipedia.org/wiki/Renix
* Has something to do with AMC/Jeep
*
* @date Apr 18, 2020
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "pch.h"
2020-04-18 19:20:17 -07:00
#include "trigger_renix.h"
2020-04-19 11:54:02 -07:00
static void commonRenix(TriggerWaveform *s) {
2020-04-18 19:20:17 -07:00
// 44-2-2 is symmetrical so we only need to define one half
2020-04-19 11:23:01 -07:00
int count = 22;
float tooth = s->getCycleDuration() / count; // hint: tooth = 8.181818 degrees
2020-04-18 19:20:17 -07:00
float currentAngle = 0;
for (int i = 0;i < 20;i++) {
s->addEventAngle(currentAngle + tooth / 2, T_PRIMARY, TV_RISE);
s->addEventAngle(currentAngle + tooth, T_PRIMARY, TV_FALL);
currentAngle += tooth;
}
s->addEventAngle(currentAngle + tooth, T_PRIMARY, TV_RISE);
// float math error accumulates at this point so we have to spell out 180
2020-04-19 11:23:01 -07:00
s->addEventAngle(s->getCycleDuration(), T_PRIMARY, TV_FALL);
2020-04-19 11:54:02 -07:00
}
// TT_RENIX_44_2_2
void initializeRenix44_2_2(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR);
commonRenix(s);
}
2020-04-18 19:20:17 -07:00
2020-04-19 11:54:02 -07:00
// TT_RENIX_66_2_2_2
void initializeRenix66_2_2(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_THREE_TIMES_CRANK_SENSOR);
commonRenix(s);
2020-04-18 19:20:17 -07:00
}