refactoring

This commit is contained in:
rusefi 2018-12-24 22:40:48 -05:00
parent fe85582767
commit 2df38cdd91
5 changed files with 26 additions and 7 deletions

View File

@ -128,7 +128,7 @@ static void applyAlternatorPinState(PwmConfig *state, int stateIndex) {
efiAssertVoid(CUSTOM_ERR_6643, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex");
efiAssertVoid(CUSTOM_IDLE_WAVE_CNT, state->multiWave.waveCount == 1, "invalid idle waveCount");
OutputPin *output = state->outputPins[0];
int value = state->multiWave.waves[0].pinStates[stateIndex];
int value = state->multiWave.waves[0].getState(stateIndex);
/**
* 'engine->isAlternatorControlEnabled' would be false is RPM is too low
*/

View File

@ -21,6 +21,14 @@ void single_wave_s::init(pin_state_t *pinStates) {
this->pinStates = pinStates;
}
int single_wave_s::getState(int index) {
return pinStates[index];
}
void single_wave_s::setState(int index, int state) {
pinStates[index] = state;
}
void MultiWave::baseConstructor() {
waves = NULL;
switchTimes = NULL;

View File

@ -7,7 +7,7 @@
#ifndef EFI_WAVE_H_
#define EFI_WAVE_H_
#include "engine_configuration.h"
#include "global.h"
#define PWM_PHASE_MAX_COUNT 252
#define PWM_PHASE_MAX_WAVE_PER_PWM 3
@ -22,6 +22,12 @@
typedef int8_t pin_state_t;
/**
* This class represents one channel of a digital signal state sequence
* Each element represents either a HIGH or LOW state - while at the moment this
* is not implemented using a bit array, it could absolutely be a bit array
*
* This sequence does not know anything about signal lengths - only signal state at a given index
*
* @brief PWM configuration for the specific output pin
*/
class single_wave_s {
@ -29,11 +35,17 @@ public:
single_wave_s();
single_wave_s(pin_state_t *pinStates);
void init(pin_state_t *pinStates);
/**
* todo: confirm that we only deal with two states here, no magic '-1'?
* @return HIGH or LOW state at given index
*/
int getState(int index);
void setState(int index, int state);
// todo: make this private
pin_state_t *pinStates;
};
class TriggerShape;
class MultiWave {
public:
void baseConstructor();

View File

@ -352,7 +352,7 @@ void TriggerShape::addEvent2(angle_t angle, trigger_wheel_e const waveIndex, tri
isFrontEvent[0] = TV_RISE == stateParam;
wave.setSwitchTime(0, angle);
wave.waves[waveIndex].pinStates[0] = state;
wave.waves[waveIndex].setState(0, state);
return;
}
@ -390,7 +390,7 @@ void TriggerShape::addEvent2(angle_t angle, trigger_wheel_e const waveIndex, tri
wave.waves[i].pinStates[index] = wave.getChannelState(i, index - 1);
}
wave.setSwitchTime(index, angle);
wave.waves[waveIndex].pinStates[index] = state;
wave.waves[waveIndex].setState(index, state);
}
angle_t TriggerShape::getSwitchAngle(int index) const {

View File

@ -10,7 +10,6 @@
#include "global.h"
#include "rusefi_enums.h"
#include "EfiWave.h"
#include "engine_configuration.h"