Support SmartAudio V1
This commit is contained in:
parent
e5d1382f59
commit
f26144db72
|
@ -494,6 +494,8 @@ static void cmsMenuCountPage(displayPort_t *pDisplay)
|
|||
pageCount = (p - currentCtx.menu->entries - 1) / MAX_MENU_ITEMS(pDisplay) + 1;
|
||||
}
|
||||
|
||||
STATIC_UNIT_TESTED long cmsMenuBack(displayPort_t *pDisplay); // Forward; will be resolved after merging
|
||||
|
||||
long cmsMenuChange(displayPort_t *pDisplay, const void *ptr)
|
||||
{
|
||||
CMS_Menu *pMenu = (CMS_Menu *)ptr;
|
||||
|
@ -522,8 +524,9 @@ long cmsMenuChange(displayPort_t *pDisplay, const void *ptr)
|
|||
currentCtx.menu = pMenu;
|
||||
currentCtx.cursorRow = 0;
|
||||
|
||||
if (pMenu->onEnter)
|
||||
pMenu->onEnter();
|
||||
if (pMenu->onEnter && (pMenu->onEnter() == MENU_CHAIN_BACK)) {
|
||||
return cmsMenuBack(pDisplay);
|
||||
}
|
||||
|
||||
cmsMenuCountPage(pDisplay);
|
||||
cmsPageSelect(pDisplay, 0);
|
||||
|
|
|
@ -695,7 +695,7 @@ bool vtxSmartAudioInit()
|
|||
|
||||
void vtxSAProcess(uint32_t now)
|
||||
{
|
||||
static bool initialSent = false;
|
||||
static char initPhase = 0;
|
||||
|
||||
if (smartAudioSerialPort == NULL)
|
||||
return;
|
||||
|
@ -708,12 +708,20 @@ void vtxSAProcess(uint32_t now)
|
|||
// Re-evaluate baudrate after each frame reception
|
||||
saAutobaud();
|
||||
|
||||
if (!initialSent) {
|
||||
switch (initPhase) {
|
||||
case 0:
|
||||
saGetSettings();
|
||||
saSetFreq(SA_FREQ_GETPIT);
|
||||
saSendQueue();
|
||||
initialSent = true;
|
||||
++initPhase;
|
||||
return;
|
||||
|
||||
case 1:
|
||||
// Don't send SA_FREQ_GETPIT to V1 device; it act as plain SA_CMD_SET_FREQ,
|
||||
// and put the device into user frequency mode with uninitialized freq.
|
||||
if (saDevice.version == 2)
|
||||
saSetFreq(SA_FREQ_GETPIT);
|
||||
++initPhase;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((sa_outstanding != SA_CMD_NONE)
|
||||
|
@ -876,7 +884,7 @@ uint16_t saCmsDeviceFreq = 0;
|
|||
|
||||
uint8_t saCmsDeviceStatus = 0;
|
||||
uint8_t saCmsPower;
|
||||
uint8_t saCmsPitFMode; // In-Range or Out-Range
|
||||
uint8_t saCmsPitFMode; // Undef(0), In-Range(1) or Out-Range(2)
|
||||
uint8_t saCmsFselMode; // Channel(0) or User defined(1)
|
||||
|
||||
uint16_t saCmsORFreq = 0; // POR frequency
|
||||
|
@ -942,10 +950,12 @@ if (saCmsORFreq == 0 && saDevice.orfreq != 0)
|
|||
if (saCmsUserFreq == 0 && saDevice.freq != 0)
|
||||
saCmsUserFreq = saDevice.freq;
|
||||
|
||||
if (saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE)
|
||||
if (saDevice.version == 2) {
|
||||
if (saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE)
|
||||
saCmsPitFMode = 1;
|
||||
else
|
||||
else
|
||||
saCmsPitFMode = 0;
|
||||
}
|
||||
|
||||
saCmsStatusString[0] = "-FR"[saCmsOpmodel];
|
||||
|
||||
|
@ -1060,9 +1070,21 @@ static long saCmsConfigPitFModeByGvar(displayPort_t *pDisp, const void *self)
|
|||
UNUSED(pDisp);
|
||||
UNUSED(self);
|
||||
|
||||
if (saDevice.version == 1) {
|
||||
// V1 device doesn't support PIT mode; bounce back.
|
||||
saCmsPitFMode = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
dprintf(("saCmsConfigPitFmodeByGbar: saCmsPitFMode %d\r\n", saCmsPitFMode));
|
||||
|
||||
if (saCmsPitFMode == 0) {
|
||||
// Bounce back
|
||||
saCmsPitFMode = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (saCmsPitFMode == 1) {
|
||||
saSetMode(SA_MODE_SET_IN_RANGE_PITMODE);
|
||||
} else {
|
||||
saSetMode(SA_MODE_SET_OUT_RANGE_PITMODE);
|
||||
|
@ -1078,6 +1100,12 @@ static long saCmsConfigOpmodelByGvar(displayPort_t *pDisp, const void *self)
|
|||
UNUSED(pDisp);
|
||||
UNUSED(self);
|
||||
|
||||
if (saDevice.version == 1) {
|
||||
if (saCmsOpmodel != SACMS_OPMODEL_FREE)
|
||||
saCmsOpmodel = SACMS_OPMODEL_FREE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t opmodel = saCmsOpmodel;
|
||||
|
||||
dprintf(("saCmsConfigOpmodelByGvar: opmodel %d\r\n", opmodel));
|
||||
|
@ -1163,6 +1191,7 @@ static const char * const saCmsFselModeNames[] = {
|
|||
};
|
||||
|
||||
static const char * const saCmsPitFModeNames[] = {
|
||||
"---",
|
||||
"PIR",
|
||||
"POR"
|
||||
};
|
||||
|
@ -1227,6 +1256,9 @@ static long saCmsCommence(displayPort_t *pDisp, const void *self)
|
|||
|
||||
static long saCmsSetPORFreqOnEnter(void)
|
||||
{
|
||||
if (saDevice.version == 1)
|
||||
return MENU_CHAIN_BACK;
|
||||
|
||||
saCmsORFreqNew = saCmsORFreq;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue