10 extern bool ICACHE_RAM_ATTR
IsArmed();
14 static enum VtxSendState_e
16 VTXSS_UNKNOWN
, // Status of the remote side is unknown, so we should send immediately if connected
17 VTXSS_MODIFIED
, // Config is editied, should always be sent regardless of connect state
18 VTXSS_SENDING1
, VTXSS_SENDING2
, VTXSS_SENDING3
, VTXSS_SENDINGDONE
, // Send the config 3x
19 VTXSS_CONFIRMED
// Status of remote side is consistent with our config
24 VtxSendState
= VTXSS_MODIFIED
;
25 devicesTriggerEvent();
28 static void eepromWriteToMSPOut()
32 packet
.function
= MSP_EEPROM_WRITE
;
38 crsf
.AddMspMessage(&packet
);
41 static void VtxConfigToMSPOut()
43 DBGLN("Sending VtxConfig");
44 uint8_t vtxIdx
= (config
.GetVtxBand()-1) * 8 + config
.GetVtxChannel();
49 packet
.function
= MSP_SET_VTX_CONFIG
;
50 packet
.addByte(vtxIdx
);
52 packet
.addByte(config
.GetVtxPower());
53 packet
.addByte(config
.GetVtxPitmode());
55 crsf
.AddMspMessage(&packet
);
56 msp
.sendPacket(&packet
, &Serial
); // send to tx-backpack as MSP
61 if (VtxSendState
== VTXSS_MODIFIED
||
62 (VtxSendState
== VTXSS_UNKNOWN
&& connectionState
== connected
))
64 VtxSendState
= VTXSS_SENDING1
;
68 if (connectionState
== disconnected
)
69 VtxSendState
= VTXSS_UNKNOWN
;
71 return DURATION_NEVER
;
76 // 0 = off in the lua Band field
77 // Do not send while armed
78 if (config
.GetVtxBand() == 0 || IsArmed())
80 VtxSendState
= VTXSS_CONFIRMED
;
81 return DURATION_NEVER
;
86 VtxSendState
= (VtxSendState_e
)((int)VtxSendState
+ 1);
87 if (VtxSendState
< VTXSS_SENDINGDONE
)
88 return 500; // repeat send in 500ms
90 if (connectionState
== connected
)
92 // Connected while sending, assume the MSP got to the RX
93 VtxSendState
= VTXSS_CONFIRMED
;
94 eepromWriteToMSPOut();
98 VtxSendState
= VTXSS_UNKNOWN
;
99 // Never received a connection, clear the queue which now
100 // has multiple VTX config packets in it
101 crsf
.ResetMspQueue();
104 return DURATION_NEVER
;
107 device_t VTX_device
= {