This commit is contained in:
Bertrand Songis
2018-04-15 09:46:17 +02:00
committed by GitHub
parent bae00c0e20
commit 9c4a81a6ee
+8 -5
View File
@@ -96,7 +96,7 @@ unsigned int expou(unsigned int x, unsigned int k)
{ {
#if defined(EXTENDED_EXPO) #if defined(EXTENDED_EXPO)
bool extended; bool extended;
if (k>80) { if (k > 80) {
extended=true; extended=true;
} }
else { else {
@@ -122,9 +122,9 @@ unsigned int expou(unsigned int x, unsigned int k)
#endif #endif
value >>= 12; value >>= 12;
value += (uint32_t)(256-k)*x+128; value += (uint32_t)(256-k) * x + 128;
return value>>8; return value >> 8;
} }
int expo(int x, int k) int expo(int x, int k)
@@ -139,6 +139,9 @@ int expo(int x, int k)
if (neg) { if (neg) {
x = -x; x = -x;
} }
if (x > (int)RESXu) {
x = RESXu;
}
if (k < 0) { if (k < 0) {
y = RESXu - expou(RESXu-x, -k); y = RESXu - expou(RESXu-x, -k);
} }
@@ -793,7 +796,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
chans[md->destCh] = 0; chans[md->destCh] = 0;
} }
//========== PHASE && SWITCH ===== //========== FLIGHT MODE && SWITCH =====
bool mixCondition = (md->flightModes != 0 || md->swtch); bool mixCondition = (md->flightModes != 0 || md->swtch);
delayval_t mixEnabled = (!(md->flightModes & (1 << mixerCurrentFlightMode)) && getSwitch(md->swtch)) ? DELAY_POS_MARGIN+1 : 0; delayval_t mixEnabled = (!(md->flightModes & (1 << mixerCurrentFlightMode)) && getSwitch(md->swtch)) ? DELAY_POS_MARGIN+1 : 0;
@@ -1040,7 +1043,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
default: // MLTPX_ADD default: // MLTPX_ADD
*ptr += dv; //Mixer output add up to the line (dv + (dv>0 ? 100/2 : -100/2))/(100); *ptr += dv; //Mixer output add up to the line (dv + (dv>0 ? 100/2 : -100/2))/(100);
break; break;
} //endswitch md->mltpx } // endswitch md->mltpx
#ifdef PREVENT_ARITHMETIC_OVERFLOW #ifdef PREVENT_ARITHMETIC_OVERFLOW
/* /*
// a lot of assumptions must be true, for this kind of check; not really worth for only 4 bytes flash savings // a lot of assumptions must be true, for this kind of check; not really worth for only 4 bytes flash savings