Added function for reading RSSI from a analog singal (with RC-Filter)

Hello,

added function for reading RSSI from a analog singal (RC-Filter)

New Master-Config:
```c
- uint8_t rssi_adc_channel; // Read analog-rssi from RC-filter (RSSI-PWM to RSSI-Analog), RC_CH2 (unused when in CPPM mode, = 1), RC_CH8 (last channel in PWM mode, = 9), 0 to disable (disabled if rssi_aux_channel > 0 or rssi_adc_channel == power_adc_channel)
- uint16_t rssi_adc_max;	// max input voltage defined by RC-filter (is RSSI never 100% reduce the value) (1...4095)
- uint16_t rssi_adc_offset; // input offset defined by RC-filter (0...4095)
````
Tested with Frsky D4R-II

Example for a RC-filter:

     PWM-RSSI   ___
     D4R-II o--|___|-----o-----o RC_CH2/RC_CH8 NAZE32
                         |
                R1 10K   |
                        ---  C1
                        ---  47µF
                         |

rssi_adc_max = 2950
rssi_adc_offset = 160


----
#162 closed (sry my mistake)
You can add constrain step after the calculation - so its more obvious why
it's done.
No need to mix it into the calculation.
Plus if constrain is a macro (i forgot if it is or not), then it probably
has to re-evaluate at least some parts twice.

On Thu, Sep 25, 2014 at 6:17 PM, Julius <notifications@github.com> wrote:

> In src/sensors.c:
>
> > +
> > +    if (mcfg.rssi_aux_channel > 0) {
> > +        const int16_t rssiChannelData = rcData[AUX1 + mcfg.rssi_aux_channel - 1];
> > +        // Range of rssiChannelData is [1000;2000]. rssi should be in [0;1023];
> > +        value = (uint16_t)((constrain(rssiChannelData - 1000, 0, 1000) / 1000.0f) * 1023.0f);
> > +    } else if (mcfg.rssi_adc_channel > 0) {
> > +        value = adcGetChannel(ADC_RSSI);
> > +
> > +        if (value > mcfg.rssi_adc_offset) {
> > +            value = (((uint32_t)(value - mcfg.rssi_adc_offset)) * 1023L) / mcfg.rssi_adc_max;
> > +
> > +            if(value > 1023)
> > +                value = 1023;
> > +        } else {
> > +            value = 0;
> > +        }
>
> yes, that is intended but I can change to:
>
> } else if (mcfg.rssi_adc_channel > 0) {
>     value = constrain((((int32_t)(adcGetChannel(ADC_RSSI) - mcfg.rssi_adc_offset)) * 1023L) / mcfg.rssi_adc_max, 0, 1023);}
>
> is cleaner
> change it?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/multiwii/baseflight/pull/165/files#r18022015>.
>