Skip to content
Snippets Groups Projects
Commit 3a986474 authored by Andrew Tridgell's avatar Andrew Tridgell
Browse files

Plane: added RSSI_RANGE parameter

parent 6b12f13d
No related branches found
No related tags found
No related merge requests found
...@@ -180,6 +180,7 @@ public: ...@@ -180,6 +180,7 @@ public:
k_param_rssi_pin, k_param_rssi_pin,
k_param_battery_volt_pin, // unused k_param_battery_volt_pin, // unused
k_param_battery_curr_pin, // unused - 169 k_param_battery_curr_pin, // unused - 169
k_param_rssi_range,
// //
// 170: Radio settings // 170: Radio settings
...@@ -411,6 +412,7 @@ public: ...@@ -411,6 +412,7 @@ public:
AP_Int8 flap_2_percent; AP_Int8 flap_2_percent;
AP_Int8 flap_2_speed; AP_Int8 flap_2_speed;
AP_Int8 rssi_pin; AP_Int8 rssi_pin;
AP_Float rssi_range; // allows to set max voltage for rssi pin such as 5.0, 3.3 etc.
AP_Int8 inverted_flight_ch; // 0=disabled, 1-8 is channel for inverted flight trigger AP_Int8 inverted_flight_ch; // 0=disabled, 1-8 is channel for inverted flight trigger
AP_Int8 stick_mixing; AP_Int8 stick_mixing;
AP_Float takeoff_throttle_min_speed; AP_Float takeoff_throttle_min_speed;
......
...@@ -753,6 +753,14 @@ const AP_Param::Info var_info[] PROGMEM = { ...@@ -753,6 +753,14 @@ const AP_Param::Info var_info[] PROGMEM = {
// @User: Standard // @User: Standard
GSCALAR(rssi_pin, "RSSI_PIN", -1), GSCALAR(rssi_pin, "RSSI_PIN", -1),
// @Param: RSSI_RANGE
// @DisplayName: Receiver RSSI voltage range
// @Description: Receiver RSSI voltage range
// @Units: Volt
// @Values: 3.3:3.3V, 5.0:5V
// @User: Standard
GSCALAR(rssi_range, "RSSI_RANGE", 5.0),
// @Param: INVERTEDFLT_CH // @Param: INVERTEDFLT_CH
// @DisplayName: Inverted flight channel // @DisplayName: Inverted flight channel
// @Description: A RC input channel number to enable inverted flight. If this is non-zero then the APM will monitor the correcponding RC input channel and will enable inverted flight when the channel goes above 1750. // @Description: A RC input channel number to enable inverted flight. If this is non-zero then the APM will monitor the correcponding RC input channel and will enable inverted flight when the channel goes above 1750.
......
...@@ -83,12 +83,16 @@ static void read_battery(void) ...@@ -83,12 +83,16 @@ static void read_battery(void)
// RC_CHANNELS_SCALED message // RC_CHANNELS_SCALED message
void read_receiver_rssi(void) void read_receiver_rssi(void)
{ {
rssi_analog_source->set_pin(g.rssi_pin); // avoid divide by zero
float ret = rssi_analog_source->voltage_average() * 50; if (g.rssi_range <= 0) {
receiver_rssi = constrain_int16(ret, 0, 255); receiver_rssi = 0;
}else{
rssi_analog_source->set_pin(g.rssi_pin);
float ret = rssi_analog_source->voltage_average() * 255 / g.rssi_range;
receiver_rssi = constrain_int16(ret, 0, 255);
}
} }
/* /*
return current_loc.alt adjusted for ALT_OFFSET return current_loc.alt adjusted for ALT_OFFSET
This is useful during long flights to account for barometer changes This is useful during long flights to account for barometer changes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment