I have an FRSKY futaba compatible receiver which has a PWM RSSI output.
I tried to add PWM RSSI reading:
in config.h added:
Code: Select all
#define RX_PWM_RSSI
#define PWM_RSSI_PIN 46
in def.h added:
Code: Select all
#define PWM_RSSI_PINMODE pinMode(PWM_RSSI_PIN, INPUT);
in void setup() added:
Code: Select all
PWM_RSSI_PINMODE;
in Multiwii.ino added:
Code: Select all
void PWM_RSSI_Read() {
static uint8_t ind = 0;
static uint16_t rvec[RSSI_SMOOTH], rsum;
uint16_t r = pulseIn(PWM_RSSI_PIN, HIGH) >> 2;
#if RSSI_SMOOTH == 1
analog.rssi = r;
#else
rsum += r;
rsum -= rvec[ind];
rvec[ind++] = r;
ind %= RSSI_SMOOTH;
r = rsum / RSSI_SMOOTH;
analog.rssi = r;
#endif
}
in Multiwii.ino taskOrder added:
Code: Select all
case 5:
taskOrder++;
#if defined(RX_PWM_RSSI)
PWM_RSSI_Read();
#endif
break;
Of course this line must be modified from this:
Code: Select all
if(taskOrder>4) taskOrder-=5;
to this:
Code: Select all
if(taskOrder>5) taskOrder-=6;
I'm sure this is not the most elegant way and also maybe NOT MATCH the Multiwii coding rules, but I'm not familiar with port handling.
Could someone help making PWM RSSI reading compatible with Multiwii coding?
BR
Adrian