Issue #773 fixed (+ non regression tests added)

This commit is contained in:
bsongis
2014-03-17 16:34:48 +01:00
parent 0a70142067
commit ded73341e8
3 changed files with 81 additions and 37 deletions
+8 -3
View File
@@ -2983,6 +2983,8 @@ void resetTimer(uint8_t idx)
timerState.val_10ms = 0 ;
}
bool s_mixer_first_run_done = false;
void resetAll()
{
static bool firstReset = true;
@@ -3001,6 +3003,7 @@ void resetAll()
}
s_last_switch_value = 0;
s_mixer_first_run_done = false;
SKIP_AUTOMATIC_PROMPTS();
@@ -3855,21 +3858,21 @@ void perOut(uint8_t mode, uint8_t tick10ms)
// the unit of the stored value is the value from md->speedUp or md->speedDown divide SLOW_STEP seconds; e.g. value 4 means 4/SLOW_STEP = 2 seconds for CPU64
// because we get a tick each 10msec, we need 100 ticks for one second
// the value in md->speedXXX gives the time it should take to do a full movement from -100 to 100 therefore 200%. This equals 2048 in recalculated internal range
if (tick10ms) {
if (tick10ms || !s_mixer_first_run_done) {
// only if already time is passed add or substract a value according the speed configured
int32_t rate = (int32_t) tick10ms << (DEL_MULT_SHIFT+11); // = DEL_MULT*2048*tick10ms
// rate equals a full range for one second; if less time is passed rate is accordingly smaller
// if one second passed, rate would be 2048 (full motion)*256(recalculated weight)*100(100 ticks needed for one second)
int32_t currentValue = ((int32_t) v<<DEL_MULT_SHIFT);
if (diff > 0) {
if (md->speedUp > 0) {
if (s_mixer_first_run_done && md->speedUp > 0) {
// if a speed upwards is defined recalculate the new value according configured speed; the higher the speed the smaller the add value is
int32_t newValue = tact+rate/((int16_t)(100/SLOW_STEP)*md->speedUp);
if (newValue<currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination
}
}
else { // if is <0 because ==0 is not possible
if (md->speedDown > 0) {
if (s_mixer_first_run_done && md->speedDown > 0) {
// see explanation in speedUp
int32_t newValue = tact-rate/((int16_t)(100/SLOW_STEP)*md->speedDown);
if (newValue>currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination
@@ -4092,6 +4095,8 @@ void doMixerCalculations()
perOut(e_perout_mode_normal, tick10ms);
}
s_mixer_first_run_done = true;
//========== FUNCTIONS ===============
// must be done after mixing because some functions use the inputs/channels values
// must be done before limits because of the applyLimit function: it checks for safety switches which would be not initialized otherwise