Skip to content

Commit

Permalink
vtx: wire AUX_FPV_SWITCH to pit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Jan 22, 2022
1 parent 6d33fcd commit 3cd8a0b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/drivers/drv_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void gpio_init() {
gpio_pin_init(&init, AUX_LED2PIN);
#endif

#if defined(FPV_SWITCH) && defined(FPV_PIN)
#if defined(FPV_PIN)
if (FPV_PIN == PIN_A13 || FPV_PIN == PIN_A14) {
//skip repurpose of swd pin @boot
} else {
Expand All @@ -62,7 +62,7 @@ void gpio_init() {

// init fpv pin separately because it may use SWDAT/SWCLK don't want to enable it right away
int gpio_init_fpv(uint8_t mode) {
#if defined(FPV_SWITCH) && defined(FPV_PIN)
#if defined(FPV_PIN)
// only repurpose the pin after rx/tx have bound if it is swd
// common settings to set ports
LL_GPIO_InitTypeDef init;
Expand Down
2 changes: 1 addition & 1 deletion src/main/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
#define RSSI AUX_CHANNEL_OFF
// *************switch for fpv / other, requires fet
// *************comment out to disable
#define FPV_SWITCH AUX_CHANNEL_OFF
#define FPV_SWITCH AUX_CHANNEL_ON

// *************RRD/LLD stick gesture aux start up state. Gesture aux is AUX_CHANNEL_GESTURE
//#define GESTURE_AUX_START_ON
Expand Down
17 changes: 14 additions & 3 deletions src/main/vtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "util.h"
#include "util/cbor_helper.h"

#if defined(FPV_SWITCH) && defined(FPV_PIN)
#if defined(FPV_PIN)
static int fpv_init = 0;
#endif

Expand Down Expand Up @@ -300,7 +300,7 @@ void vtx_init() {
void vtx_update() {
static volatile uint32_t delay_loops = 5000;

#if defined(FPV_SWITCH) && defined(FPV_PIN)
#if defined(FPV_PIN)
if (rx_aux_on(AUX_FPV_SWITCH)) {
// fpv switch on
if (!fpv_init && flags.rx_mode == RXMODE_NORMAL && flags.on_ground == 1) {
Expand Down Expand Up @@ -328,7 +328,7 @@ void vtx_update() {
return;
}

if (!flags.on_ground || flags.arm_state == 1) {
if (!flags.on_ground) {
// never try to do vtx stuff in-air
return;
}
Expand Down Expand Up @@ -450,6 +450,17 @@ void vtx_update() {
power_level_tries = 0;
}

if (!flags.usb_active &&
profile.receiver.aux[AUX_FPV_SWITCH] <= AUX_CHANNEL_11 &&
vtx_settings.pit_mode != VTX_PIT_MODE_NO_SUPPORT) {
// we got a aux switch set, switch pit_mode accordingly
if (rx_aux_on(AUX_FPV_SWITCH)) {
vtx_settings.pit_mode = 0;
} else {
vtx_settings.pit_mode = 1;
}
}

static uint8_t pit_mode_tries = 0;
if (actual.pit_mode != vtx_settings.pit_mode) {
if (pit_mode_tries >= VTX_APPLY_TRIES) {
Expand Down

0 comments on commit 3cd8a0b

Please sign in to comment.