fome-fw/firmware/controllers/core/EfiWave.cpp

59 lines
1.1 KiB
C++
Raw Normal View History

2014-08-29 07:52:33 -07:00
/**
* @file EfiWave.cpp
*
* @date May 18, 2014
2015-01-12 15:04:10 -08:00
* @author Andrey Belomutskiy, (c) 2012-2015
2014-08-29 07:52:33 -07:00
*/
#include "main.h"
#include "EfiWave.h"
#include "trigger_structure.h"
single_wave_s::single_wave_s() {
init(NULL);
}
2015-01-20 20:07:37 -08:00
single_wave_s::single_wave_s(pin_state_t *ps) {
2014-08-29 07:52:33 -07:00
init(ps);
}
2015-01-20 20:07:37 -08:00
void single_wave_s::init(pin_state_t *pinStates) {
2014-08-29 07:52:33 -07:00
this->pinStates = pinStates;
}
2015-02-27 17:09:56 -08:00
void multi_wave_s::baseConstructor() {
2015-02-26 08:07:06 -08:00
waves = NULL;
switchTimes = NULL;
2015-02-24 13:08:35 -08:00
reset();
2014-08-29 07:52:33 -07:00
}
2015-02-27 17:09:56 -08:00
multi_wave_s::multi_wave_s() {
baseConstructor();
}
multi_wave_s::multi_wave_s(float *switchTimes, single_wave_s *waves) {
baseConstructor();
2014-08-29 07:52:33 -07:00
init(switchTimes, waves);
}
void multi_wave_s::init(float *switchTimes, single_wave_s *waves) {
this->switchTimes = switchTimes;
this->waves = waves;
}
void multi_wave_s::reset(void) {
waveCount = 0;
}
float multi_wave_s::getSwitchTime(int index) const {
return switchTimes[index];
}
void checkSwitchTimes2(int size, float *switchTimes) {
for (int i = 0; i < size - 1; i++) {
if (switchTimes[i] >= switchTimes[i + 1]) {
firmwareError("invalid switchTimes @%d: %f/%f", i, switchTimes[i], switchTimes[i + 1]);
}
}
}