#635 refactoring: better name
This commit is contained in:
parent
90448f1271
commit
881fad4e59
|
@ -9,23 +9,23 @@
|
|||
#include "EfiWave.h"
|
||||
#include "trigger_structure.h"
|
||||
|
||||
single_wave_s::single_wave_s() {
|
||||
SingleWave::SingleWave() {
|
||||
init(NULL);
|
||||
}
|
||||
|
||||
single_wave_s::single_wave_s(pin_state_t *ps) {
|
||||
SingleWave::SingleWave(pin_state_t *ps) {
|
||||
init(ps);
|
||||
}
|
||||
|
||||
void single_wave_s::init(pin_state_t *pinStates) {
|
||||
void SingleWave::init(pin_state_t *pinStates) {
|
||||
this->pinStates = pinStates;
|
||||
}
|
||||
|
||||
int single_wave_s::getState(int index) {
|
||||
int SingleWave::getState(int index) {
|
||||
return pinStates[index];
|
||||
}
|
||||
|
||||
void single_wave_s::setState(int index, int state) {
|
||||
void SingleWave::setState(int index, int state) {
|
||||
pinStates[index] = state;
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,12 @@ MultiWave::MultiWave() {
|
|||
baseConstructor();
|
||||
}
|
||||
|
||||
MultiWave::MultiWave(float *switchTimes, single_wave_s *waves) {
|
||||
MultiWave::MultiWave(float *switchTimes, SingleWave *waves) {
|
||||
baseConstructor();
|
||||
init(switchTimes, waves);
|
||||
}
|
||||
|
||||
void MultiWave::init(float *switchTimes, single_wave_s *waves) {
|
||||
void MultiWave::init(float *switchTimes, SingleWave *waves) {
|
||||
this->switchTimes = switchTimes;
|
||||
this->waves = waves;
|
||||
}
|
||||
|
|
|
@ -30,11 +30,10 @@ typedef int8_t pin_state_t;
|
|||
*
|
||||
* @brief PWM configuration for the specific output pin
|
||||
*/
|
||||
// todo: rename to SingleWave
|
||||
class single_wave_s {
|
||||
class SingleWave {
|
||||
public:
|
||||
single_wave_s();
|
||||
single_wave_s(pin_state_t *pinStates);
|
||||
SingleWave();
|
||||
SingleWave(pin_state_t *pinStates);
|
||||
void init(pin_state_t *pinStates);
|
||||
/**
|
||||
* todo: confirm that we only deal with two states here, no magic '-1'?
|
||||
|
@ -55,8 +54,8 @@ class MultiWave {
|
|||
public:
|
||||
void baseConstructor();
|
||||
MultiWave();
|
||||
MultiWave(float *switchTimes, single_wave_s *waves);
|
||||
void init(float *switchTimes, single_wave_s *waves);
|
||||
MultiWave(float *switchTimes, SingleWave *waves);
|
||||
void init(float *switchTimes, SingleWave *waves);
|
||||
void reset(void);
|
||||
float getSwitchTime(int phaseIndex) const;
|
||||
void setSwitchTime(int phaseIndex, float value);
|
||||
|
@ -70,7 +69,7 @@ public:
|
|||
* Number of signal wires
|
||||
*/
|
||||
int waveCount;
|
||||
single_wave_s *waves;
|
||||
SingleWave *waves;
|
||||
//private:
|
||||
/**
|
||||
* values in the (0..1] range which refer to points within the period at at which pin state should be changed
|
||||
|
|
|
@ -45,12 +45,12 @@ PwmConfig::PwmConfig() {
|
|||
baseConstructor();
|
||||
}
|
||||
|
||||
PwmConfig::PwmConfig(float *st, single_wave_s *waves) {
|
||||
PwmConfig::PwmConfig(float *st, SingleWave *waves) {
|
||||
baseConstructor();
|
||||
multiWave.init(st, waves);
|
||||
}
|
||||
|
||||
void PwmConfig::init(float *st, single_wave_s *waves) {
|
||||
void PwmConfig::init(float *st, SingleWave *waves) {
|
||||
multiWave.init(st, waves);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ typedef enum {
|
|||
class PwmConfig {
|
||||
public:
|
||||
PwmConfig();
|
||||
PwmConfig(float *switchTimes, single_wave_s *waves);
|
||||
PwmConfig(float *switchTimes, SingleWave *waves);
|
||||
void baseConstructor();
|
||||
void init(float *switchTimes, single_wave_s *waves);
|
||||
void init(float *switchTimes, SingleWave *waves);
|
||||
|
||||
void weComplexInit(const char *msg,
|
||||
int phaseCount, float *swithcTimes, int waveCount, pin_state_t **pinStates,
|
||||
|
@ -108,10 +108,10 @@ public:
|
|||
SimplePwm();
|
||||
void setSimplePwmDutyCycle(float dutyCycle);
|
||||
pin_state_t pinStates[2];
|
||||
single_wave_s sr[1];
|
||||
SingleWave sr[1];
|
||||
float _switchTimes[2];
|
||||
private:
|
||||
single_wave_s waveInstance;
|
||||
SingleWave waveInstance;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,9 +72,9 @@ void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIn
|
|||
static pin_state_t pinStates1[PWM_PHASE_MAX_COUNT];
|
||||
static pin_state_t pinStates2[PWM_PHASE_MAX_COUNT];
|
||||
static pin_state_t pinStates3[PWM_PHASE_MAX_COUNT];
|
||||
static single_wave_s waves[PWM_PHASE_MAX_WAVE_PER_PWM] = { single_wave_s(pinStates1), single_wave_s(pinStates2),
|
||||
single_wave_s(pinStates3) };
|
||||
static single_wave_s sr[PWM_PHASE_MAX_WAVE_PER_PWM] = { waves[0], waves[1], waves[2] };
|
||||
static SingleWave waves[PWM_PHASE_MAX_WAVE_PER_PWM] = { SingleWave(pinStates1), SingleWave(pinStates2),
|
||||
SingleWave(pinStates3) };
|
||||
static SingleWave sr[PWM_PHASE_MAX_WAVE_PER_PWM] = { waves[0], waves[1], waves[2] };
|
||||
|
||||
static float switchTimesBuffer[PWM_PHASE_MAX_COUNT];
|
||||
|
||||
|
|
|
@ -355,7 +355,7 @@ void TriggerShape::addEvent(bool useOnlyRisingEdgeForTrigger, angle_t angle, tri
|
|||
if (privateTriggerDefinitionSize == 0) {
|
||||
privateTriggerDefinitionSize = 1;
|
||||
for (int i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) {
|
||||
single_wave_s *wave = &this->wave.waves[i];
|
||||
SingleWave *wave = &this->wave.waves[i];
|
||||
|
||||
if (wave->pinStates == NULL) {
|
||||
warning(CUSTOM_ERR_STATE_NULL, "wave pinStates is NULL");
|
||||
|
|
|
@ -37,7 +37,7 @@ class trigger_shape_helper {
|
|||
public:
|
||||
trigger_shape_helper();
|
||||
|
||||
single_wave_s waves[TRIGGER_CHANNEL_COUNT];
|
||||
SingleWave waves[TRIGGER_CHANNEL_COUNT];
|
||||
private:
|
||||
pin_state_t pinStates[TRIGGER_CHANNEL_COUNT][PWM_PHASE_MAX_COUNT];
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue