From f01b0f27722e9e5e6d8e1e7b4c3ed53267525645 Mon Sep 17 00:00:00 2001 From: richardclli Date: Sat, 8 Apr 2023 18:17:40 +0800 Subject: [PATCH] fix(AFHDS3): Incorrect channel scaling (#3449) * Fixed IRM301/FRM303 channels scaling problem. * Add back the remarks for calculation. --- radio/src/pulses/afhds3.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/radio/src/pulses/afhds3.cpp b/radio/src/pulses/afhds3.cpp index 911ba5340dc..cc2339806e0 100644 --- a/radio/src/pulses/afhds3.cpp +++ b/radio/src/pulses/afhds3.cpp @@ -811,7 +811,15 @@ void ProtoState::applyConfigFromModel() inline int16_t ProtoState::convert(int channelValue) { - return ::limit(AFHDS3_FAILSAFE_MIN, channelValue * 14.65, AFHDS3_FAILSAFE_MAX); + //pulseValue = limit(0, 988 + ((channelValue + 1024) / 2), 0xfff); + //988 - 750 = 238 + //238 * 20 = 4760 + //2250 - 2012 = 238 + //238 * 20 = 4760 + // 988 ---- 2012 + //-10240 ---- 10240 + //-1024 ---- 1024 + return ::limit(AFHDS3_FAILSAFE_MIN, channelValue * 10, AFHDS3_FAILSAFE_MAX); } uint8_t ProtoState::setFailSafe(int16_t* target, uint8_t rfchannelsCount )