diff --git a/src/main/cms/cms.c b/src/main/cms/cms.c index 5cae422e9..14fb32fc7 100644 --- a/src/main/cms/cms.c +++ b/src/main/cms/cms.c @@ -230,20 +230,28 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) CLR_PRINTVALUE(p); } break; + case OME_Submenu: case OME_Funcall: if (IS_PRINTVALUE(p)) { - cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, ">"); - // Special case of sub menu entry with func used as a function - // returning a string to print on the right column. - if (p->type == OME_Submenu && p->func) { - if (p->flags & OPTSTRING) - cnt += displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay) + 1, row, ((CMSMenuOptFuncPtr)p->func)()); + int colPos = RIGHT_MENU_COLUMN(pDisplay); + + if ((p->type == OME_Submenu) && p->func && (p->flags & OPTSTRING)) { + + // Special case of sub menu entry with optional value display. + + char *str = ((CMSMenuOptFuncPtr)p->func)(); + cnt = displayWrite(pDisplay, colPos, row, str); + colPos += strlen(str); } + + cnt += displayWrite(pDisplay, colPos, row, ">"); + CLR_PRINTVALUE(p); } break; + case OME_Bool: if (IS_PRINTVALUE(p) && p->data) { if (*((uint8_t *)(p->data))) { @@ -254,7 +262,8 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) CLR_PRINTVALUE(p); } break; - case OME_TAB: { + + case OME_TAB: if (IS_PRINTVALUE(p)) { OSD_TAB_t *ptr = p->data; //cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay) - 5, row, (char *)ptr->names[*ptr->val]); @@ -262,7 +271,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) CLR_PRINTVALUE(p); } break; - } + #ifdef OSD case OME_VISIBLE: if (IS_PRINTVALUE(p) && p->data) { @@ -280,6 +289,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) } break; #endif + case OME_UINT8: if (IS_PRINTVALUE(p) && p->data) { OSD_UINT8_t *ptr = p->data; @@ -289,6 +299,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) CLR_PRINTVALUE(p); } break; + case OME_INT8: if (IS_PRINTVALUE(p) && p->data) { OSD_INT8_t *ptr = p->data; @@ -298,6 +309,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) CLR_PRINTVALUE(p); } break; + case OME_UINT16: if (IS_PRINTVALUE(p) && p->data) { OSD_UINT16_t *ptr = p->data; @@ -307,6 +319,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) CLR_PRINTVALUE(p); } break; + case OME_INT16: if (IS_PRINTVALUE(p) && p->data) { OSD_UINT16_t *ptr = p->data; @@ -316,6 +329,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) CLR_PRINTVALUE(p); } break; + case OME_FLOAT: if (IS_PRINTVALUE(p) && p->data) { OSD_FLOAT_t *ptr = p->data; @@ -325,6 +339,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) CLR_PRINTVALUE(p); } break; + case OME_Label: if (IS_PRINTVALUE(p) && p->data) { // A label with optional string, immediately following text @@ -332,10 +347,12 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) CLR_PRINTVALUE(p); } break; + case OME_OSD_Exit: case OME_END: case OME_Back: break; + case OME_MENU: // Fall through default: @@ -657,6 +674,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) res = BUTTON_PAUSE; } break; + case OME_Funcall: case OME_OSD_Exit: if (p->func && key == KEY_RIGHT) { @@ -664,10 +682,12 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) res = BUTTON_PAUSE; } break; + case OME_Back: cmsMenuBack(pDisplay); res = BUTTON_PAUSE; break; + case OME_Bool: if (p->data) { uint8_t *val = p->data; @@ -678,6 +698,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) SET_PRINTVALUE(p); } break; + #ifdef OSD case OME_VISIBLE: if (p->data) { @@ -694,6 +715,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) } break; #endif + case OME_UINT8: case OME_FLOAT: if (p->data) { @@ -712,6 +734,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) } } break; + case OME_TAB: if (p->type == OME_TAB) { OSD_TAB_t *ptr = p->data; @@ -729,6 +752,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) SET_PRINTVALUE(p); } break; + case OME_INT8: if (p->data) { OSD_INT8_t *ptr = p->data; @@ -746,6 +770,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) } } break; + case OME_UINT16: if (p->data) { OSD_UINT16_t *ptr = p->data; @@ -763,6 +788,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) } } break; + case OME_INT16: if (p->data) { OSD_INT16_t *ptr = p->data; @@ -780,11 +806,14 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) } } break; + case OME_String: break; + case OME_Label: case OME_END: break; + case OME_MENU: // Shouldn't happen break; diff --git a/src/main/cms/cms_menu_imu.c b/src/main/cms/cms_menu_imu.c index 24b988cb0..647be7733 100644 --- a/src/main/cms/cms_menu_imu.c +++ b/src/main/cms/cms_menu_imu.c @@ -360,14 +360,13 @@ static OSD_Entry cmsx_menuImuEntries[] = {"PID PROF", OME_UINT8, cmsx_profileIndexOnChange, &(OSD_UINT8_t){ &tmpProfileIndex, 1, MAX_PROFILE_COUNT, 1}, 0}, {"PID", OME_Submenu, cmsMenuChange, &cmsx_menuPid, 0}, - {"OTHER PP", OME_Submenu, cmsMenuChange, &cmsx_menuProfileOther, 0}, + {"MISC PP", OME_Submenu, cmsMenuChange, &cmsx_menuProfileOther, 0}, + {"FILT PP", OME_Submenu, cmsMenuChange, &cmsx_menuFilterPerProfile, 0}, {"RATE PROF", OME_UINT8, cmsx_rateProfileIndexOnChange, &(OSD_UINT8_t){ &tmpRateProfileIndex, 1, MAX_RATEPROFILES, 1}, 0}, {"RATE", OME_Submenu, cmsMenuChange, &cmsx_menuRateProfile, 0}, - {"FLT PP", OME_Submenu, cmsMenuChange, &cmsx_menuFilterPerProfile, 0}, - - {"FLT GLB", OME_Submenu, cmsMenuChange, &cmsx_menuFilterGlobal, 0}, + {"FILT GLB", OME_Submenu, cmsMenuChange, &cmsx_menuFilterGlobal, 0}, {"BACK", OME_Back, NULL, NULL, 0}, {NULL, OME_END, NULL, NULL, 0} diff --git a/src/main/io/vtx_smartaudio.c b/src/main/io/vtx_smartaudio.c index 565ea15bf..4e9de00e3 100644 --- a/src/main/io/vtx_smartaudio.c +++ b/src/main/io/vtx_smartaudio.c @@ -165,7 +165,10 @@ static smartAudioDevice_t saDevicePrev = { }; // XXX Possible compliance problem here. Need LOCK/UNLOCK menu? -static uint8_t saLockMode = SA_MODE_SET_UNLOCK; +static uint8_t saLockMode = SA_MODE_SET_UNLOCK; // saCms variable? + +// XXX Should be configurable by user? +static bool saDeferred = true; // saCms variable? // Receive frame reassembly buffer #define SA_MAX_RCVLEN 11 @@ -732,27 +735,29 @@ uint8_t saCmsRFState; // RF state; ACTIVE, PIR, POR XXX Not currently void saCmsUpdate(void) { +// XXX Take care of pit mode update somewhere??? + if (saCmsOpmodel == SA_OPMODEL_UNDEF) { // This is a first valid response to GET_SETTINGS. saCmsOpmodel = (saDevice.mode & SA_MODE_GET_PITMODE) ? SA_OPMODEL_PIT : SA_OPMODEL_FREE; - } - saCmsBand = (saDevice.chan / 8) + 1; - saCmsChan = (saDevice.chan % 8) + 1; - saCmsDeviceFreq = saFreqTable[saDevice.chan / 8][saDevice.chan % 8]; + saCmsBand = (saDevice.chan / 8) + 1; + saCmsChan = (saDevice.chan % 8) + 1; + saCmsDeviceFreq = saFreqTable[saDevice.chan / 8][saDevice.chan % 8]; - if ((saDevice.mode & SA_MODE_GET_PITMODE) == 0) { - saCmsRFState = SA_TXMODE_ACTIVE; - } else if (saDevice.mode & SA_MODE_GET_IN_RANGE_PITMODE) { - saCmsRFState = SA_TXMODE_PIT_INRANGE; - } else { - saCmsRFState = SA_TXMODE_PIT_OUTRANGE; - } + if ((saDevice.mode & SA_MODE_GET_PITMODE) == 0) { + saCmsRFState = SA_TXMODE_ACTIVE; + } else if (saDevice.mode & SA_MODE_GET_IN_RANGE_PITMODE) { + saCmsRFState = SA_TXMODE_PIT_INRANGE; + } else { + saCmsRFState = SA_TXMODE_PIT_OUTRANGE; + } - if (saDevice.version == 2) { - saCmsPower = saDevice.power + 1; // XXX Take care V1 - } else { - saCmsPower = saDacToPowerIndex(saDevice.power) + 1; + if (saDevice.version == 2) { + saCmsPower = saDevice.power + 1; // XXX Take care V1 + } else { + saCmsPower = saDacToPowerIndex(saDevice.power) + 1; + } } saUpdateStatusString(); @@ -826,13 +831,18 @@ static long saCmsConfigBandByGvar(displayPort_t *pDisp, const void *self) return 0; } +dprintf(("saCmsConfigBand: band req %d ", saCmsBand)); + if (saCmsBand == 0) { // Bouce back, no going back to undef state saCmsBand = 1; +dprintf(("--> %d\r\n", saCmsBand)); return 0; } +dprintf(("--> %d\r\n", saCmsBand)); - saSetBandChan(saCmsBand - 1, saCmsChan - 1); + if (!(saCmsOpmodel == SA_OPMODEL_FREE && saDeferred)) + saSetBandChan(saCmsBand - 1, saCmsChan - 1); return 0; } @@ -854,7 +864,8 @@ static long saCmsConfigChanByGvar(displayPort_t *pDisp, const void *self) return 0; } - saSetBandChan(saCmsBand - 1, saCmsChan - 1); + if (!(saCmsOpmodel == SA_OPMODEL_FREE && saDeferred)) + saSetBandChan(saCmsBand - 1, saCmsChan - 1); return 0; } @@ -1031,15 +1042,22 @@ static long saCmsConfigFreqModeByGvar(displayPort_t *pDisp, const void *self) return 0; } -static long saCmsClearPitMode(displayPort_t *pDisp, const void *self) +static long saCmsCommence(displayPort_t *pDisp, const void *self) { UNUSED(pDisp); UNUSED(self); - if (saCmsPitFMode == 0) - saSetMode(SA_MODE_CLR_PITMODE|SA_MODE_SET_IN_RANGE_PITMODE); - else - saSetMode(SA_MODE_CLR_PITMODE|SA_MODE_SET_OUT_RANGE_PITMODE); + if (saCmsOpmodel == SA_OPMODEL_PIT) { + if (saCmsPitFMode == 0) + saSetMode(SA_MODE_CLR_PITMODE|SA_MODE_SET_IN_RANGE_PITMODE); + else + saSetMode(SA_MODE_CLR_PITMODE|SA_MODE_SET_OUT_RANGE_PITMODE); + } else { + if (saCmsFreqMode == 0) + saSetBandChan(saCmsBand - 1, saCmsChan - 1); + else + saSetFreq(saCmsUserFreq); + } return 0; } @@ -1153,7 +1171,7 @@ static CMS_Menu menu_smartAudioConfig = { static OSD_Entry saCmsMenuCommenceEntries[] = { { "CONFIRM", OME_Label, NULL, NULL, 0 }, - { "YES", OME_Funcall, saCmsClearPitMode, NULL, 0 }, + { "YES", OME_Funcall, saCmsCommence, NULL, 0 }, { "BACK", OME_Back, NULL, NULL, 0 }, { NULL, OME_END, NULL, NULL, 0 } }; @@ -1172,7 +1190,7 @@ static OSD_Entry saCmsMenuFreqModeEntries[] = { { "", OME_Label, NULL, saCmsStatusString, DYNAMIC }, { "FREQ", OME_Submenu, cmsMenuChange, &saCmsMenuUserFreq, 0 }, { "POWER", OME_TAB, saCmsConfigPowerByGvar, &saCmsEntPower, 0 }, - { "START", OME_Submenu, cmsMenuChange, &saCmsMenuCommence, 0 }, + { "SET", OME_Submenu, cmsMenuChange, &saCmsMenuCommence, 0 }, { "CONFIG", OME_Submenu, cmsMenuChange, &menu_smartAudioConfig, 0 }, { "BACK", OME_Back, NULL, NULL, 0 }, { NULL, OME_END, NULL, NULL, 0 } @@ -1186,7 +1204,7 @@ static OSD_Entry saCmsMenuChanModeEntries[] = { "CHAN", OME_TAB, saCmsConfigChanByGvar, &saCmsEntChan, 0 }, { "(FREQ)", OME_UINT16, NULL, &saCmsEntFreq, DYNAMIC }, { "POWER", OME_TAB, saCmsConfigPowerByGvar, &saCmsEntPower, 0 }, - { "START", OME_Submenu, cmsMenuChange, &saCmsMenuCommence, 0 }, + { "SET", OME_Submenu, cmsMenuChange, &saCmsMenuCommence, 0 }, { "CONFIG", OME_Submenu, cmsMenuChange, &menu_smartAudioConfig, 0 }, { "BACK", OME_Back, NULL, NULL, 0 }, { NULL, OME_END, NULL, NULL, 0 }