Skip to content

Commit

Permalink
Stdlcd UI for Lemon-Rx DSMP
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic committed Mar 21, 2022
1 parent e341120 commit ae29df9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
18 changes: 16 additions & 2 deletions radio/src/gui/128x64/model_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ void menuModelSetup(event_t event)
g_model.moduleData[moduleIdx].type = reusableBuffer.moduleSetup.newType;
reusableBuffer.moduleSetup.previousType = reusableBuffer.moduleSetup.newType;
setModuleType(moduleIdx, g_model.moduleData[moduleIdx].type);
storageDirty(EE_MODEL);
}
else if (g_model.moduleData[moduleIdx].type == MODULE_TYPE_NONE) {
g_model.moduleData[moduleIdx].type = reusableBuffer.moduleSetup.newType;
Expand All @@ -987,7 +988,7 @@ void menuModelSetup(event_t event)
}
else
#endif
reusableBuffer.moduleSetup.newType = checkIncDec(event, reusableBuffer.moduleSetup.newType, MODULE_TYPE_NONE, MODULE_TYPE_MAX, EE_MODEL,
reusableBuffer.moduleSetup.newType = checkIncDec(event, reusableBuffer.moduleSetup.newType, MODULE_TYPE_NONE, MODULE_TYPE_MAX, 0,
isExternalModuleAvailable);
break;

Expand Down Expand Up @@ -1450,6 +1451,7 @@ void menuModelSetup(event_t event)
lcdDrawText(lcdNextPos + 2, y, STR_MODULE_RANGE, l_posHorz == 2 ? attr : 0);
}
uint8_t newFlag = 0;
uint8_t oldFlag = moduleState[moduleIdx].mode;
#if defined(MULTIMODULE)
if (isModuleMultimodule(moduleIdx) &&
getMultiBindStatus(moduleIdx) == MULTI_BIND_FINISHED) {
Expand Down Expand Up @@ -1479,7 +1481,7 @@ void menuModelSetup(event_t event)
startBindMenu(moduleIdx);
continue;
}
if (moduleState[moduleIdx].mode == MODULE_MODE_BIND) {
if (oldFlag == MODULE_MODE_BIND) {
newFlag = MODULE_MODE_BIND;
}
else {
Expand All @@ -1491,6 +1493,12 @@ void menuModelSetup(event_t event)
else {
newFlag = MODULE_MODE_BIND;
}

if (!event && (oldFlag != newFlag) &&
(oldFlag == MODULE_MODE_NORMAL)) {
// Bind mode switched off from somewhere else
s_editMode = 0;
}
}
else if (l_posHorz == 2) {
newFlag = MODULE_MODE_RANGECHECK;
Expand All @@ -1513,6 +1521,12 @@ void menuModelSetup(event_t event)
setMultiBindStatus(moduleIdx, MULTI_BIND_INITIATED);
}
#endif
if (isModuleDSMP(moduleIdx) &&
(oldFlag != newFlag) &&
(oldFlag == MODULE_MODE_BIND)) {
// Restart DSMP module when exiting bind mode
restartModule(moduleIdx);
}
}
}
break;
Expand Down
18 changes: 16 additions & 2 deletions radio/src/gui/212x64/model_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ void menuModelSetup(event_t event)
g_model.moduleData[EXTERNAL_MODULE].type = reusableBuffer.moduleSetup.newType;
reusableBuffer.moduleSetup.previousType = reusableBuffer.moduleSetup.newType;
setModuleType(EXTERNAL_MODULE, g_model.moduleData[EXTERNAL_MODULE].type);
storageDirty(EE_MODEL);
}
else if (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE) {
g_model.moduleData[EXTERNAL_MODULE].type = reusableBuffer.moduleSetup.newType;
Expand All @@ -945,7 +946,7 @@ void menuModelSetup(event_t event)
if (s_editMode > 0) {
switch (menuHorizontalPosition) {
case 0:
reusableBuffer.moduleSetup.newType = checkIncDec(event, reusableBuffer.moduleSetup.newType, MODULE_TYPE_NONE, MODULE_TYPE_MAX, EE_MODEL, isExternalModuleAvailable);
reusableBuffer.moduleSetup.newType = checkIncDec(event, reusableBuffer.moduleSetup.newType, MODULE_TYPE_NONE, MODULE_TYPE_MAX, 0, isExternalModuleAvailable);
break;

case 1:
Expand Down Expand Up @@ -1294,6 +1295,7 @@ void menuModelSetup(event_t event)
lcdDrawText(lcdNextPos + FW, y, STR_MODULE_RANGE, l_posHorz == 2 ? attr : 0);
}
uint8_t newFlag = 0;
uint8_t oldFlag = moduleState[moduleIdx].mode;
#if defined(MULTIMODULE)
if (isModuleMultimodule(moduleIdx) &&
getMultiBindStatus(moduleIdx) == MULTI_BIND_FINISHED) {
Expand All @@ -1315,7 +1317,7 @@ void menuModelSetup(event_t event)
startBindMenu(moduleIdx);
continue;
}
if (moduleState[moduleIdx].mode == MODULE_MODE_BIND) {
if (oldFlag == MODULE_MODE_BIND) {
newFlag = MODULE_MODE_BIND;
}
else {
Expand All @@ -1327,6 +1329,12 @@ void menuModelSetup(event_t event)
else {
newFlag = MODULE_MODE_BIND;
}

if (!event && (oldFlag != newFlag) &&
(oldFlag == MODULE_MODE_NORMAL)) {
// Bind mode switched off from somewhere else
s_editMode = 0;
}
}
else if (l_posHorz == 2) {
newFlag = MODULE_MODE_RANGECHECK;
Expand All @@ -1340,6 +1348,12 @@ void menuModelSetup(event_t event)
setMultiBindStatus(moduleIdx, MULTI_BIND_INITIATED);
}
#endif
if (isModuleDSMP(moduleIdx) &&
(oldFlag != newFlag) &&
(oldFlag == MODULE_MODE_BIND)) {
// Restart DSMP module when exiting bind mode
restartModule(moduleIdx);
}
}
}
break;
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/gui_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ inline uint8_t MODULE_BIND_ROWS(int moduleIdx)
else
return 2;
}
else if (isModuleXJTD8(moduleIdx) || isModuleSBUS(moduleIdx) || isModuleAFHDS3(moduleIdx)) {
else if (isModuleXJTD8(moduleIdx) || isModuleSBUS(moduleIdx) || isModuleAFHDS3(moduleIdx) || isModuleDSMP(moduleIdx)) {
return 1;
}
else if (isModulePPM(moduleIdx) || isModulePXX1(moduleIdx) || isModulePXX2(moduleIdx) || isModuleDSM2(moduleIdx)) {
Expand Down

0 comments on commit ae29df9

Please sign in to comment.