From 30099dc5cd2f64e9cbcbb4ac8c7a2179ce37ba9d Mon Sep 17 00:00:00 2001 From: openfsguruh Date: Wed, 2 Apr 2014 21:29:00 +0200 Subject: [PATCH] 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. --- radio/src/Makefile | 3 +-- radio/src/opentx.cpp | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/radio/src/Makefile b/radio/src/Makefile index c27ae747c..e21c42da3 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -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 diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 6c8f55490..6a6ee4a6a 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -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) {