1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 09:45:33 +03:00

Fix midrc MSP min/max checks

This commit is contained in:
Michel Pastor 2018-03-02 23:30:46 +01:00
parent d73c9db650
commit aaed7bd9aa
3 changed files with 7 additions and 9 deletions

View file

@ -1334,7 +1334,6 @@ static void mspFcDataFlashReadCommand(sbuf_t *dst, sbuf_t *src)
static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
{ {
uint32_t i; uint32_t i;
uint16_t tmp;
uint8_t rate; uint8_t rate;
const unsigned int dataSize = sbufBytesRemaining(src); const unsigned int dataSize = sbufBytesRemaining(src);
@ -1518,9 +1517,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
break; break;
case MSP_SET_MISC: case MSP_SET_MISC:
tmp = sbufReadU16(src); rxConfigMutable()->midrc = constrain(sbufReadU16(src), MIDRC_MIN, MIDRC_MAX);
if (tmp < 1600 && tmp > 1400)
rxConfigMutable()->midrc = tmp;
motorConfigMutable()->minthrottle = sbufReadU16(src); motorConfigMutable()->minthrottle = sbufReadU16(src);
motorConfigMutable()->maxthrottle = sbufReadU16(src); motorConfigMutable()->maxthrottle = sbufReadU16(src);
@ -1554,9 +1551,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
break; break;
case MSP2_INAV_SET_MISC: case MSP2_INAV_SET_MISC:
tmp = sbufReadU16(src); rxConfigMutable()->midrc = constrain(sbufReadU16(src), MIDRC_MIN, MIDRC_MAX);
if (tmp < 1600 && tmp > 1400)
rxConfigMutable()->midrc = tmp;
motorConfigMutable()->minthrottle = sbufReadU16(src); motorConfigMutable()->minthrottle = sbufReadU16(src);
motorConfigMutable()->maxthrottle = sbufReadU16(src); motorConfigMutable()->maxthrottle = sbufReadU16(src);

View file

@ -302,8 +302,8 @@ groups:
table: receiver_type table: receiver_type
- name: mid_rc - name: mid_rc
field: midrc field: midrc
min: 1200 min: MIDRC_MIN
max: 1700 max: MIDRC_MAX
- name: min_check - name: min_check
field: mincheck field: mincheck
min: PWM_RANGE_ZERO min: PWM_RANGE_ZERO

View file

@ -33,6 +33,9 @@
#define PWM_PULSE_MIN 750 // minimum PWM pulse width which is considered valid #define PWM_PULSE_MIN 750 // minimum PWM pulse width which is considered valid
#define PWM_PULSE_MAX 2250 // maximum PWM pulse width which is considered valid #define PWM_PULSE_MAX 2250 // maximum PWM pulse width which is considered valid
#define MIDRC_MIN 1200
#define MIDRC_MAX 1700
#define RXFAIL_STEP_TO_CHANNEL_VALUE(step) (PWM_PULSE_MIN + 25 * step) #define RXFAIL_STEP_TO_CHANNEL_VALUE(step) (PWM_PULSE_MIN + 25 * step)
#define CHANNEL_VALUE_TO_RXFAIL_STEP(channelValue) ((constrain(channelValue, PWM_PULSE_MIN, PWM_PULSE_MAX) - PWM_PULSE_MIN) / 25) #define CHANNEL_VALUE_TO_RXFAIL_STEP(channelValue) ((constrain(channelValue, PWM_PULSE_MIN, PWM_PULSE_MAX) - PWM_PULSE_MIN) / 25)
#define MAX_RXFAIL_RANGE_STEP ((PWM_PULSE_MAX - PWM_PULSE_MIN) / 25) #define MAX_RXFAIL_RANGE_STEP ((PWM_PULSE_MAX - PWM_PULSE_MIN) / 25)