diff --git a/src/open9x.cpp b/src/open9x.cpp index 9718e3ccc..a94a46e28 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -1216,7 +1216,8 @@ void perOut(int16_t *chanOut, uint8_t phase) //========== MIXER LOOP =============== mixWarning = 0; - for(uint8_t i=0;idestCh==0) || (md->destCh>NUM_CHNOUT)) break; @@ -1237,7 +1238,7 @@ void perOut(int16_t *chanOut, uint8_t phase) uint8_t swTog; //swOn[i]=false; - if(!getSwitch(md->swtch,1)){ // switch on? if no switch selected => on + if (!getSwitch(md->swtch,1)) { // switch on? if no switch selected => on swTog = swOn[i]; swOn[i] = false; if(md->srcRaw!=MIX_MAX && md->srcRaw!=MIX_FULL) continue;// if not MAX or FULL - next loop @@ -1291,8 +1292,8 @@ void perOut(int16_t *chanOut, uint8_t phase) if (diff && (md->speedUp || md->speedDown)) { //rate = steps/sec => 32*1024/100*md->speedUp/Down //act[i] += diff>0 ? (32768)/((int16_t)100*md->speedUp) : -(32768)/((int16_t)100*md->speedDown); - //-100..100 => 32768 -> 100*83886/256 = 32768, For MAX we divide by 2 sincde it's asymmetrical - if(tick10ms) { + //-100..100 => 32768 -> 100*83886/256 = 32768, For MAX we divide by 2 since it's asymmetrical + if (tick10ms) { int32_t rate = (int32_t)DEL_MULT*2048*100; if(md->weight) rate /= abs(md->weight); // TODO port optim er9x by Mike @@ -1358,7 +1359,7 @@ void perOut(int16_t *chanOut, uint8_t phase) // at the end chans[i] = chans[i]/100 => -1024..1024 // interpolate value with min/max so we get smooth motion from center to stop // this limits based on v original values and min=-1024, max=1024 RESX=1024 - + //printf("chans%d=%d\n", i, chans[i]);fflush(stdout); int32_t q = chans[i];// + (int32_t)g_model.limitData[i].offset*100; // offset before limit chans[i] /= 100; // chans back to -1024..1024 @@ -1403,7 +1404,12 @@ void perMain() static uint16_t fp_act[MAX_PHASES] = {0}; static uint16_t delta = 0; static uint8_t s_fade_flight_phases = 0; - static uint8_t s_last_phase = 255; + static uint8_t s_last_phase = 255; +#ifdef PCBV4 + static int16_t s_fp_chans[NUM_CHNOUT][MAX_PHASES]; +#else + static int8_t s_fp_chans[NUM_CHNOUT][MAX_PHASES]; +#endif uint8_t phase = getFlightPhase(); if (s_last_phase != phase) { @@ -1431,11 +1437,21 @@ void perMain() int32_t sum_chans512[NUM_CHNOUT] = {0}; int32_t weight = 0; for (uint8_t p=0; p%d\n", p, fp_act[p], next_chans512[2]); + if (s_fade_flight_phases & (1<> 2; +#else + s_fp_chans[i][p] = chans[i] >> 10; +#endif sum_chans512[i] += (int32_t)next_chans512[i] * fp_act[p]; } weight += fp_act[p]; @@ -1454,7 +1470,7 @@ void perMain() for (uint8_t i=0; i