refactoring - magic constant bad
This commit is contained in:
parent
334bf249ec
commit
656b8c3429
|
@ -30,6 +30,9 @@ typedef unsigned int time_t;
|
|||
#define DEFAULT_FUEL_LOAD_COUNT 16
|
||||
#define DEFAULT_IGN_LOAD_COUNT 16
|
||||
|
||||
#define TWO_STROKE_CYCLE_DURATION 360
|
||||
#define FOUR_STROKE_CYCLE_DURATION 720
|
||||
|
||||
// gasoline E0
|
||||
#define STOICH_RATIO 14.7f
|
||||
|
||||
|
|
|
@ -118,14 +118,14 @@ int TriggerWaveform::getTriggerWaveformSynchPointIndex() const {
|
|||
angle_t TriggerWaveform::getCycleDuration() const {
|
||||
switch (operationMode) {
|
||||
case FOUR_STROKE_THREE_TIMES_CRANK_SENSOR:
|
||||
return 720 / SYMMETRICAL_THREE_TIMES_CRANK_SENSOR_DIVIDER;
|
||||
return FOUR_STROKE_CYCLE_DURATION / SYMMETRICAL_THREE_TIMES_CRANK_SENSOR_DIVIDER;
|
||||
case FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR:
|
||||
return 720 / SYMMETRICAL_CRANK_SENSOR_DIVIDER;
|
||||
return FOUR_STROKE_CYCLE_DURATION / SYMMETRICAL_CRANK_SENSOR_DIVIDER;
|
||||
case FOUR_STROKE_CRANK_SENSOR:
|
||||
case TWO_STROKE:
|
||||
return 360;
|
||||
return TWO_STROKE_CYCLE_DURATION;
|
||||
default:
|
||||
return 720;
|
||||
return FOUR_STROKE_CYCLE_DURATION;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -303,6 +303,8 @@ private:
|
|||
operation_mode_e operationMode;
|
||||
};
|
||||
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
/**
|
||||
* Misc values calculated from TriggerWaveform
|
||||
*/
|
||||
|
@ -318,7 +320,7 @@ public:
|
|||
* this cache allows us to find a close-enough (with one degree precision) trigger wheel index by
|
||||
* given angle with fast constant speed. That's a performance optimization for event scheduling.
|
||||
*/
|
||||
uint16_t triggerIndexByAngle[720];
|
||||
uint16_t triggerIndexByAngle[MAX(TWO_STROKE_CYCLE_DURATION, FOUR_STROKE_CYCLE_DURATION)];
|
||||
};
|
||||
|
||||
void findTriggerPosition(
|
||||
|
|
Loading…
Reference in New Issue