changed rounding for gModelMax.

This should prevent counting THROTTLE faster than 100%, if
ACCURAT_THROTTLE_STATS is set to NO and ATMEL based Transmitters are used.
This commit is contained in:
openfsguruh
2014-04-02 21:29:00 +02:00
parent 7ec8392c81
commit 30099dc5cd
2 changed files with 3 additions and 3 deletions
+1 -2
View File
@@ -127,9 +127,8 @@ CORRECT_NEGATIVE_VALUES = YES
ARITHMETIC_OVERFLOW_CHECK = NO
# increases resolution for throttle statistics and throttle counting, in very rare cases.
# most important effect is, it prevents throttle counting faster than actual time for 100%.
# this will be only true if an output channel is used for throttle calculation, and this chanenel has changed limits, e.g. -90% to +80%
# if you use standard limits for throttle or directly the throttle stick you do not bother about this option
# if you use standard limits for throttle or directly the throttle stick you do not need to bother about this option
# not valid for ARM based transmitters like Taranis, They do not have this rounding issue at all
# Values = YES, NO
ACCURAT_THROTTLE_STATS = NO
+2 -1
View File
@@ -4204,9 +4204,10 @@ void doMixerCalculations()
// usually max is 1024 min is -1024 --> max-min = 2048 full range
#ifdef ACCURAT_THROTTLE_TIMER
if (gModelMax!=0 && gModelMax!=2048) val = (int32_t) (val << 11) / (gModelMax); // recaling only needed if Min, Max differs
if (gModelMax!=0 && gModelMax!=2048) val = (int32_t) (val << 11) / (gModelMax); // rescaling only needed if Min, Max differs
#else
// @@@ open.20.fsguruh optimized calculation; now *8 /8 instead of 10 base; (*16/16 already cause a overrun; unsigned calculation also not possible, because v may be negative)
gModelMax+=255; // force rounding up --> gModelMax is bigger --> val is smaller
gModelMax >>= (10-2);
if (gModelMax!=0 && gModelMax!=8) {