diff --git a/docs/Cli.md b/docs/Cli.md index 111272623f..1d3b1cc6a1 100644 --- a/docs/Cli.md +++ b/docs/Cli.md @@ -115,7 +115,7 @@ Re-apply any new defaults as desired. | max_check | 1900 | These are min/max values (in us) which, when a channel is smaller (min) or larger (max) than the value will activate various RC commands, such as arming, or stick configuration. Normally, every RC channel should be set so that min = 1000us, max = 2000us. On most transmitters this usually means 125% endpoints. Default check values are 100us above/below this value. | | rssi_channel | 0 | RX channel containing the RSSI signal | | rssi_scale | 30 | When using ADC RSSI, the raw ADC value will be divided by rssi_scale in order to get the RSSI percentage. RSSI scale is therefore the ADC raw value for 100% RSSI. | -| rssi_ppm_invert | OFF | | +| rssi_invert | OFF | | | rc_smoothing | ON | Interpolation of Rc data during looptimes when there are no new updates. This gives smoother RC input to PID controller and cleaner PIDsum | | input_filtering_mode | OFF | Output frequency (in Hz) for motor pins. Default is 400Hz for motor with motor_pwm_protocol set to STANDARD. For *SHOT (e.g. ONESHOT125) values of 1000 and 2000 have been tested by the development team and are supported. It may be possible to use higher values. For BRUSHED values of 8000 and above should be used. Setting to 8000 will use brushed mode at 8kHz switching frequency. Up to 32kHz is supported for brushed. Default is 16000 for boards with brushed motors. Note, that in brushed mode, minthrottle is offset to zero. For brushed mode, set max_throttle to 2000. | | min_throttle | 1150 | These are min/max values (in us) that are sent to esc when armed. Defaults of 1150/1850 are OK for everyone, for use with AfroESC, they could be set to 1064/1864. | diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index 51bba031d2..0ca4abaaf5 100644 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -557,7 +557,7 @@ static const clivalue_t valueTable[] = { { "max_check", VAR_UINT16 | MASTER_VALUE, .config.minmax = { PWM_RANGE_ZERO, PWM_RANGE_MAX }, PG_RX_CONFIG, offsetof(rxConfig_t, maxcheck) }, { "rssi_channel", VAR_INT8 | MASTER_VALUE, .config.minmax = { 0, MAX_SUPPORTED_RC_CHANNEL_COUNT }, PG_RX_CONFIG, offsetof(rxConfig_t, rssi_channel) }, { "rssi_scale", VAR_UINT8 | MASTER_VALUE, .config.minmax = { RSSI_SCALE_MIN, RSSI_SCALE_MAX }, PG_RX_CONFIG, offsetof(rxConfig_t, rssi_scale) }, - { "rssi_ppm_invert", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_CONFIG, offsetof(rxConfig_t, rssi_ppm_invert) }, + { "rssi_invert", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_CONFIG, offsetof(rxConfig_t, rssiInvert) }, { "rc_smoothing", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_CONFIG, offsetof(rxConfig_t, rcSmoothing) }, #ifdef SERIAL_RX { "serialrx_provider", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_SERIAL_RX }, PG_RX_CONFIG, offsetof(rxConfig_t, serialrx_provider) }, diff --git a/src/main/rx/rx.c b/src/main/rx/rx.c index a41e9ff090..7c7ba30d4b 100644 --- a/src/main/rx/rx.c +++ b/src/main/rx/rx.c @@ -119,7 +119,7 @@ PG_RESET_TEMPLATE(rxConfig_t, rxConfig, .rx_max_usec = 2115, // any of first 4 channels above this value will trigger rx loss detection .rssi_channel = 0, .rssi_scale = RSSI_SCALE_DEFAULT, - .rssi_ppm_invert = 0, + .rssiInvert = 0, .rcSmoothing = 1, .rxNoSignalThrottleBehavior = RX_NOSIGNAL_THROTTLE_HOLD, ); @@ -559,11 +559,6 @@ static void updateRSSIPWM(void) // Read value of AUX channel as rssi pwmRssi = rcData[rxConfig()->rssi_channel - 1]; - // RSSI_Invert option - if (rxConfig()->rssi_ppm_invert) { - pwmRssi = ((2000 - pwmRssi) + 1000); - } - // Range of rawPwmRssi is [1000;2000]. rssi should be in [0;1023]; rssi = (uint16_t)((constrain(pwmRssi - 1000, 0, 1000) / 1000.0f) * 1023.0f); } @@ -605,12 +600,18 @@ static void updateRSSIADC(timeUs_t currentTimeUs) void updateRSSI(timeUs_t currentTimeUs) { - + // Read RSSI if (rxConfig()->rssi_channel > 0) { updateRSSIPWM(); } else if (feature(FEATURE_RSSI_ADC)) { updateRSSIADC(currentTimeUs); } + + // Apply RSSI inversion + if (rxConfig()->rssiInvert) { + rssi = 1023 - rssi; + } + } uint16_t rxGetRefreshRate(void) diff --git a/src/main/rx/rx.h b/src/main/rx/rx.h index 717143466d..13ef5f6c5e 100644 --- a/src/main/rx/rx.h +++ b/src/main/rx/rx.h @@ -105,7 +105,7 @@ typedef struct rxConfig_s { uint8_t spektrum_sat_bind_autoreset; // whenever we will reset (exit) binding mode after hard reboot uint8_t rssi_channel; uint8_t rssi_scale; - uint8_t rssi_ppm_invert; + uint8_t rssiInvert; uint16_t midrc; // Some radios have not a neutral point centered on 1500. can be changed here uint16_t mincheck; // minimum rc end uint16_t maxcheck; // maximum rc end