Skip to content

Instantly share code, notes, and snippets.

@the-kenny
Last active December 24, 2015 04:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
diff --git a/src/cli.c b/src/cli.c
index 6bb7c86..71f0436 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -147,6 +147,7 @@ const clivalue_t valueTable[] = {
{ "failsafe_off_delay", VAR_UINT8, &cfg.failsafe_off_delay, 0, 200 },
{ "failsafe_throttle", VAR_UINT16, &cfg.failsafe_throttle, 1000, 2000 },
{ "failsafe_detect_threshold", VAR_UINT16, &cfg.failsafe_detect_threshold, 100, 2000 },
+ { "rssi_aux_channel", VAR_INT8, &mcfg.rssi_aux_channel, 0, 4 },
{ "yaw_direction", VAR_INT8, &cfg.yaw_direction, -1, 1 },
{ "tri_unarmed_servo", VAR_INT8, &cfg.tri_unarmed_servo, 0, 1 },
{ "tri_yaw_middle", VAR_UINT16, &cfg.tri_yaw_middle, 0, 2000 },
diff --git a/src/config.c b/src/config.c
index a99c97f..b9586e8 100755
--- a/src/config.c
+++ b/src/config.c
@@ -209,6 +209,7 @@ static void resetConf(void)
// serial (USART1) baudrate
mcfg.serial_baudrate = 115200;
mcfg.looptime = 3500;
+ mcfg.rssi_aux_channel = 0;
cfg.pidController = 0;
cfg.P8[ROLL] = 40;
diff --git a/src/mw.c b/src/mw.c
index 5c4c5df..9212bc4 100755
--- a/src/mw.c
+++ b/src/mw.c
@@ -858,6 +858,14 @@ void loop(void)
}
}
+ // Read value of AUX channel as rssi
+ // 0 is disable, 1-4 is AUX{1..4}
+ 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];
+ rssi = (int)(constrain(rssiChannelData - 1000, 0, 1000) / 1000.0f * 1023.0f);
+ }
+
// PID - note this is function pointer set by setPIDController()
pid_controller();
diff --git a/src/mw.h b/src/mw.h
index b0436be..b31d56f 100755
--- a/src/mw.h
+++ b/src/mw.h
@@ -279,6 +279,8 @@ typedef struct master_t {
uint16_t maxcheck; // maximum rc end
uint8_t retarded_arm; // allow disarsm/arm on throttle down + roll left/right
+ uint8_t rssi_aux_channel; // Read rssi from channel. 1=AUX1, 0 to disable.
+
// gps-related stuff
uint8_t gps_type; // Type of GPS hardware. 0: NMEA 1: UBX 2+ ??
uint32_t gps_baudrate; // GPS baudrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment