GCC Code Coverage Report


Directory: ./
File: firmware/controllers/trigger/decoders/trigger_renix.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 38 0 38
Functions: 100.0% 5 0 5
Branches: 100.0% 6 0 6
Decisions: 100.0% 6 - 6

Line Branch Decision Exec Source
1 /**
2 * @file trigger_renix.cpp
3 *
4 * https://en.wikipedia.org/wiki/Renix
5 * Has something to do with AMC/Jeep
6 *
7 * @date Apr 18, 2020
8 * @author Andrey Belomutskiy, (c) 2012-2020
9 */
10
11 #include "pch.h"
12
13 #include "trigger_renix.h"
14
15 2 static void commonRenix(TriggerWaveform *s) {
16 // 44-2-2 is symmetrical so we only need to define one half
17 2 int count = 22;
18 2 float tooth = s->getCycleDuration() / count; // hint: tooth = 8.181818 degrees
19
20 2 float currentAngle = 0;
21
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
2/2
✓ Decision 'true' taken 40 times.
✓ Decision 'false' taken 2 times.
42 for (int i = 0;i < 20;i++) {
22 40 s->addEventAngle(currentAngle + tooth / 2, TriggerValue::RISE);
23 40 s->addEventAngle(currentAngle + tooth, TriggerValue::FALL);
24 40 currentAngle += tooth;
25 }
26
27 2 s->addEventAngle(currentAngle + tooth, TriggerValue::RISE);
28
29 // float math error accumulates at this point so we have to spell out 180
30 2 s->addEventAngle(s->getCycleDuration(), TriggerValue::FALL);
31 2 }
32
33 // TT_RENIX_44_2_2
34 1 void initializeRenix44_2_2(TriggerWaveform *s) {
35 1 s->initialize(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR, SyncEdge::RiseOnly);
36 1 commonRenix(s);
37 1 }
38
39 // TT_RENIX_66_2_2_2
40 1 void initializeRenix66_2_2(TriggerWaveform *s) {
41 1 s->initialize(FOUR_STROKE_THREE_TIMES_CRANK_SENSOR, SyncEdge::RiseOnly);
42 1 commonRenix(s);
43 1 }
44
45 // basically like the "normal" renix 22-2 pattern -> 66-2-2-2, except without the extra random tooth there in the middle.
46 // this is copied from vq35 36-2-2-2 pattern.
47 1 void JeepRenix66_2_2(TriggerWaveform* s, size_t halfCylinderCount, size_t totalWheel, size_t missing) {
48
49 1 auto toothAngle = 360.0f / totalWheel;
50
51 1 auto patternTeeth = totalWheel / halfCylinderCount;
52 1 auto toothCount = patternTeeth - missing;
53
54 1 float currentAngle = missing * toothAngle;
55
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 time.
2/2
✓ Decision 'true' taken 20 times.
✓ Decision 'false' taken 1 time.
21 for (size_t i = 0; i < toothCount; i++) {
56 20 currentAngle += toothAngle;
57 20 s->addEventAngle(currentAngle - (toothAngle/2), TriggerValue::RISE);
58
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 19 times.
2/2
✓ Decision 'true' taken 1 time.
✓ Decision 'false' taken 19 times.
20 if (i==toothCount-1) { // last event at 120
59 1 s->addEventAngle( s->getCycleDuration(), TriggerValue::FALL);
60 } else {
61 19 s->addEventAngle(currentAngle, TriggerValue::FALL);
62 }
63 }
64 1 }
65
66 // TT_JEEPRENIX_66_2_2_2
67 1 void initializeJeepRenix66_2_2(TriggerWaveform *s) {
68 1 s->initialize(FOUR_STROKE_THREE_TIMES_CRANK_SENSOR, SyncEdge::RiseOnly);
69
70 // 6 cylinder = 66 tooth wheel, missing 2 teeth in 3 spots
71 1 JeepRenix66_2_2(s, 3, 66, 2);
72 1 s->setTriggerSynchronizationGap3(/*gapIndex*/0, 0.2, 0.5);
73 1 s->setTriggerSynchronizationGap3(/*gapIndex*/1, 2, 4);
74 1 s->setTriggerSynchronizationGap3(/*gapIndex*/2, 0.6, 1.4);
75 1 }
76