mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +03:00
Merge pull request #3002 from jflyper/bfdev-smartaudiov1-fix-2
Support SmartAudio V1
This commit is contained in:
commit
15ac9f9d50
2 changed files with 46 additions and 11 deletions
|
@ -494,6 +494,8 @@ static void cmsMenuCountPage(displayPort_t *pDisplay)
|
||||||
pageCount = (p - currentCtx.menu->entries - 1) / MAX_MENU_ITEMS(pDisplay) + 1;
|
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)
|
long cmsMenuChange(displayPort_t *pDisplay, const void *ptr)
|
||||||
{
|
{
|
||||||
CMS_Menu *pMenu = (CMS_Menu *)ptr;
|
CMS_Menu *pMenu = (CMS_Menu *)ptr;
|
||||||
|
@ -522,8 +524,9 @@ long cmsMenuChange(displayPort_t *pDisplay, const void *ptr)
|
||||||
currentCtx.menu = pMenu;
|
currentCtx.menu = pMenu;
|
||||||
currentCtx.cursorRow = 0;
|
currentCtx.cursorRow = 0;
|
||||||
|
|
||||||
if (pMenu->onEnter)
|
if (pMenu->onEnter && (pMenu->onEnter() == MENU_CHAIN_BACK)) {
|
||||||
pMenu->onEnter();
|
return cmsMenuBack(pDisplay);
|
||||||
|
}
|
||||||
|
|
||||||
cmsMenuCountPage(pDisplay);
|
cmsMenuCountPage(pDisplay);
|
||||||
cmsPageSelect(pDisplay, 0);
|
cmsPageSelect(pDisplay, 0);
|
||||||
|
|
|
@ -695,7 +695,7 @@ bool vtxSmartAudioInit()
|
||||||
|
|
||||||
void vtxSAProcess(uint32_t now)
|
void vtxSAProcess(uint32_t now)
|
||||||
{
|
{
|
||||||
static bool initialSent = false;
|
static char initPhase = 0;
|
||||||
|
|
||||||
if (smartAudioSerialPort == NULL)
|
if (smartAudioSerialPort == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -708,12 +708,20 @@ void vtxSAProcess(uint32_t now)
|
||||||
// Re-evaluate baudrate after each frame reception
|
// Re-evaluate baudrate after each frame reception
|
||||||
saAutobaud();
|
saAutobaud();
|
||||||
|
|
||||||
if (!initialSent) {
|
switch (initPhase) {
|
||||||
|
case 0:
|
||||||
saGetSettings();
|
saGetSettings();
|
||||||
saSetFreq(SA_FREQ_GETPIT);
|
|
||||||
saSendQueue();
|
saSendQueue();
|
||||||
initialSent = true;
|
++initPhase;
|
||||||
return;
|
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)
|
if ((sa_outstanding != SA_CMD_NONE)
|
||||||
|
@ -876,7 +884,7 @@ uint16_t saCmsDeviceFreq = 0;
|
||||||
|
|
||||||
uint8_t saCmsDeviceStatus = 0;
|
uint8_t saCmsDeviceStatus = 0;
|
||||||
uint8_t saCmsPower;
|
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)
|
uint8_t saCmsFselMode; // Channel(0) or User defined(1)
|
||||||
|
|
||||||
uint16_t saCmsORFreq = 0; // POR frequency
|
uint16_t saCmsORFreq = 0; // POR frequency
|
||||||
|
@ -942,10 +950,12 @@ if (saCmsORFreq == 0 && saDevice.orfreq != 0)
|
||||||
if (saCmsUserFreq == 0 && saDevice.freq != 0)
|
if (saCmsUserFreq == 0 && saDevice.freq != 0)
|
||||||
saCmsUserFreq = saDevice.freq;
|
saCmsUserFreq = saDevice.freq;
|
||||||
|
|
||||||
if (saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE)
|
if (saDevice.version == 2) {
|
||||||
saCmsPitFMode = 1;
|
if (saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE)
|
||||||
else
|
saCmsPitFMode = 1;
|
||||||
saCmsPitFMode = 0;
|
else
|
||||||
|
saCmsPitFMode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
saCmsStatusString[0] = "-FR"[saCmsOpmodel];
|
saCmsStatusString[0] = "-FR"[saCmsOpmodel];
|
||||||
|
|
||||||
|
@ -1060,9 +1070,21 @@ static long saCmsConfigPitFModeByGvar(displayPort_t *pDisp, const void *self)
|
||||||
UNUSED(pDisp);
|
UNUSED(pDisp);
|
||||||
UNUSED(self);
|
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));
|
dprintf(("saCmsConfigPitFmodeByGbar: saCmsPitFMode %d\r\n", saCmsPitFMode));
|
||||||
|
|
||||||
if (saCmsPitFMode == 0) {
|
if (saCmsPitFMode == 0) {
|
||||||
|
// Bounce back
|
||||||
|
saCmsPitFMode = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saCmsPitFMode == 1) {
|
||||||
saSetMode(SA_MODE_SET_IN_RANGE_PITMODE);
|
saSetMode(SA_MODE_SET_IN_RANGE_PITMODE);
|
||||||
} else {
|
} else {
|
||||||
saSetMode(SA_MODE_SET_OUT_RANGE_PITMODE);
|
saSetMode(SA_MODE_SET_OUT_RANGE_PITMODE);
|
||||||
|
@ -1078,6 +1100,12 @@ static long saCmsConfigOpmodelByGvar(displayPort_t *pDisp, const void *self)
|
||||||
UNUSED(pDisp);
|
UNUSED(pDisp);
|
||||||
UNUSED(self);
|
UNUSED(self);
|
||||||
|
|
||||||
|
if (saDevice.version == 1) {
|
||||||
|
if (saCmsOpmodel != SACMS_OPMODEL_FREE)
|
||||||
|
saCmsOpmodel = SACMS_OPMODEL_FREE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t opmodel = saCmsOpmodel;
|
uint8_t opmodel = saCmsOpmodel;
|
||||||
|
|
||||||
dprintf(("saCmsConfigOpmodelByGvar: opmodel %d\r\n", opmodel));
|
dprintf(("saCmsConfigOpmodelByGvar: opmodel %d\r\n", opmodel));
|
||||||
|
@ -1163,6 +1191,7 @@ static const char * const saCmsFselModeNames[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char * const saCmsPitFModeNames[] = {
|
static const char * const saCmsPitFModeNames[] = {
|
||||||
|
"---",
|
||||||
"PIR",
|
"PIR",
|
||||||
"POR"
|
"POR"
|
||||||
};
|
};
|
||||||
|
@ -1227,6 +1256,9 @@ static long saCmsCommence(displayPort_t *pDisp, const void *self)
|
||||||
|
|
||||||
static long saCmsSetPORFreqOnEnter(void)
|
static long saCmsSetPORFreqOnEnter(void)
|
||||||
{
|
{
|
||||||
|
if (saDevice.version == 1)
|
||||||
|
return MENU_CHAIN_BACK;
|
||||||
|
|
||||||
saCmsORFreqNew = saCmsORFreq;
|
saCmsORFreqNew = saCmsORFreq;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue