1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-14 03:49:52 +03:00

If modelRegistrationID is default it will be kept the same than ownerRegistrationID

This commit is contained in:
Bertrand Songis 2019-04-18 16:15:22 +02:00
parent 7f05872bd4
commit b1ea16c3d8
7 changed files with 25 additions and 12 deletions

View file

@ -377,6 +377,10 @@ void runPopupRegister(event_t event)
}
else if (reusableBuffer.moduleSetup.pxx2.registerStep >= REGISTER_RX_NAME_RECEIVED && menuHorizontalPosition == 0) {
// [Enter] pressed
if (memcmp(reusableBuffer.moduleSetup.pxx2.registrationId, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID) == 0)
memclear(g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID);
else
memcpy(g_model.modelRegistrationID, reusableBuffer.moduleSetup.pxx2.registrationId, PXX2_LEN_REGISTRATION_ID);
reusableBuffer.moduleSetup.pxx2.registerStep = REGISTER_RX_NAME_SELECTED;
backupEditMode = EDIT_MODIFY_FIELD; // so that the [Register] button blinks and the REGISTER process can continue
}
@ -401,7 +405,7 @@ void runPopupRegister(event_t event)
// registration password
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y - 4, STR_REG_ID);
editName(WARNING_LINE_X + 8*FW, WARNING_LINE_Y - 4, g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID, event, menuVerticalPosition == ITEM_REGISTER_PASSWORD);
editName(WARNING_LINE_X + 8*FW, WARNING_LINE_Y - 4, reusableBuffer.moduleSetup.pxx2.registrationId, PXX2_LEN_REGISTRATION_ID, event, menuVerticalPosition == ITEM_REGISTER_PASSWORD);
// loop index (will be removed in future)
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y - 4 + FH, "UID");
@ -436,15 +440,13 @@ void runPopupRegister(event_t event)
void startRegisterDialog(uint8_t module)
{
memclear(&reusableBuffer.moduleSetup.pxx2, sizeof(reusableBuffer.moduleSetup.pxx2));
memcpy(reusableBuffer.moduleSetup.pxx2.registrationId, currentRegistrationID(), PXX2_LEN_REGISTRATION_ID);
moduleSettings[module].mode = MODULE_MODE_REGISTER;
s_editMode = 0;
POPUP_INPUT("", runPopupRegister);
}
inline bool isDefaultModelRegistrationID()
{
return memcmp(g_model.modelRegistrationID, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID) == 0;
}
void menuModelSetup(event_t event)
{
@ -1250,7 +1252,7 @@ void menuModelSetup(event_t event)
if (isDefaultModelRegistrationID())
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, "<default>");
else
lcdDrawSizedText(MODEL_SETUP_2ND_COLUMN, y, g_model.modelRegistrationID, sizeof(g_model.modelRegistrationID), ZCHAR);
lcdDrawSizedText(MODEL_SETUP_2ND_COLUMN, y, g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID, ZCHAR);
break;
case ITEM_MODEL_INTERNAL_MODULE_PXX2_MODEL_NUM:

View file

@ -461,8 +461,6 @@ void modelDefault(uint8_t id)
applyDefaultTemplate();
memcpy(g_model.modelRegistrationID, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID);
#if defined(LUA) && defined(PCBTARANIS) //Horus uses menuModelWizard() for wizard
if (isFileAvailable(WIZARD_PATH "/" WIZARD_NAME)) {
f_chdir(WIZARD_PATH);

View file

@ -1132,6 +1132,7 @@ union ReusableBuffer
uint8_t bindStep;
uint8_t resetStep;
};
char registrationId[PXX2_LEN_REGISTRATION_ID];
uint32_t bindWaitTimeout;
uint8_t registerPopupVerticalPosition;
uint8_t registerPopupHorizontalPosition;

View file

@ -268,4 +268,14 @@ inline bool isModuleOptionAvailable(uint8_t modelId, uint8_t option)
return moduleOptions[modelId] & (1 << option);
}
inline bool isDefaultModelRegistrationID()
{
return is_memclear(g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID);
}
inline const char * currentRegistrationID()
{
return isDefaultModelRegistrationID() ? g_eeGeneral.ownerRegistrationID : g_model.modelRegistrationID;
}
#endif // _MODULES_H_

View file

@ -157,8 +157,9 @@ void Pxx2Pulses::setupRegisterFrame(uint8_t module)
for (uint8_t i=0; i<PXX2_LEN_RX_NAME; i++) {
Pxx2Transport::addByte(zchar2char(reusableBuffer.moduleSetup.pxx2.registerRxName[i]));
}
const char * registrationID = currentRegistrationID();
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
Pxx2Transport::addByte(zchar2char(g_model.modelRegistrationID[i]));
Pxx2Transport::addByte(zchar2char(registrationID[i]));
}
Pxx2Transport::addByte(reusableBuffer.moduleSetup.pxx2.registerLoopIndex);
}
@ -239,8 +240,9 @@ void Pxx2Pulses::setupBindFrame(uint8_t module)
}
else {
Pxx2Transport::addByte(0x00);
const char * registrationID = currentRegistrationID();
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
Pxx2Transport::addByte(zchar2char(g_model.modelRegistrationID[i]));
Pxx2Transport::addByte(zchar2char(registrationID[i]));
}
}
}

View file

@ -118,7 +118,7 @@ void processRegisterFrame(uint8_t module, uint8_t * frame)
if (reusableBuffer.moduleSetup.pxx2.registerStep == REGISTER_RX_NAME_SELECTED) {
// RX_NAME + PASSWORD follow, we check they are good
if (cmpStrWithZchar((char *)&frame[4], reusableBuffer.moduleSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME) &&
cmpStrWithZchar((char *)&frame[12], g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID)) {
cmpStrWithZchar((char *)&frame[12], currentRegistrationID(), PXX2_LEN_REGISTRATION_ID)) {
reusableBuffer.moduleSetup.pxx2.registerStep = REGISTER_OK;
moduleSettings[module].mode = MODULE_MODE_NORMAL;
POPUP_INFORMATION(STR_REG_OK);

View file

@ -21,7 +21,7 @@ options = {
}
def timestamp():
return datetime.datetime.now().strftime("%Y-%m-%d-%H%M")
return datetime.datetime.now().strftime("%y%m%d")
def build(board, srcdir):