Fixed registering/binding
This commit is contained in:
@@ -88,7 +88,7 @@ void BindWaitDialog::checkEvents()
|
|||||||
removePXX2ReceiverIfEmpty(moduleIdx, receiverIdx);
|
removePXX2ReceiverIfEmpty(moduleIdx, receiverIdx);
|
||||||
deleteLater();
|
deleteLater();
|
||||||
if (bindInfo.step == BIND_OK) {
|
if (bindInfo.step == BIND_OK) {
|
||||||
new MessageDialog(parent, STR_BIND, STR_BIND_OK);
|
POPUP_INFORMATION(STR_REG_OK);
|
||||||
} else {
|
} else {
|
||||||
// TODO: display error???
|
// TODO: display error???
|
||||||
}
|
}
|
||||||
@@ -278,17 +278,17 @@ void RegisterDialog::start()
|
|||||||
|
|
||||||
void RegisterDialog::checkEvents()
|
void RegisterDialog::checkEvents()
|
||||||
{
|
{
|
||||||
if (!rxName && reusableBuffer.moduleSetup.pxx2.registerStep >=
|
auto& modSetup = getPXX2ModuleSetupBuffer();
|
||||||
REGISTER_RX_NAME_RECEIVED) {
|
if (!rxName && modSetup.registerStep >= REGISTER_RX_NAME_RECEIVED) {
|
||||||
rect_t rect = waiting->getRect();
|
rect_t rect = waiting->getRect();
|
||||||
waiting->deleteLater();
|
waiting->deleteLater();
|
||||||
|
|
||||||
rxName = new ModelTextEdit(&content->form, rect,
|
rxName = new ModelTextEdit(&content->form, rect, modSetup.registerRxName,
|
||||||
reusableBuffer.moduleSetup.pxx2.registerRxName,
|
|
||||||
PXX2_LEN_RX_NAME);
|
PXX2_LEN_RX_NAME);
|
||||||
rect = exitButton->getRect();
|
rect = exitButton->getRect();
|
||||||
auto okButton = new TextButton(&content->form, rect, "OK", [=]() -> int8_t {
|
auto okButton = new TextButton(&content->form, rect, "OK", [=]() -> int8_t {
|
||||||
reusableBuffer.moduleSetup.pxx2.registerStep = REGISTER_RX_NAME_SELECTED;
|
auto& modSetup = getPXX2ModuleSetupBuffer();
|
||||||
|
modSetup.registerStep = REGISTER_RX_NAME_SELECTED;
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
exitButton->setLeft(left() + rect.w + 10);
|
exitButton->setLeft(left() + rect.w + 10);
|
||||||
@@ -296,10 +296,22 @@ void RegisterDialog::checkEvents()
|
|||||||
FormField::link(rxName, okButton);
|
FormField::link(rxName, okButton);
|
||||||
FormField::link(okButton, exitButton);
|
FormField::link(okButton, exitButton);
|
||||||
okButton->setFocus(SET_FOCUS_DEFAULT);
|
okButton->setFocus(SET_FOCUS_DEFAULT);
|
||||||
} else if (reusableBuffer.moduleSetup.pxx2.registerStep == REGISTER_OK) {
|
} else if (modSetup.registerStep == REGISTER_OK) {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
POPUP_INFORMATION(STR_REG_OK);
|
POPUP_INFORMATION(STR_REG_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog::checkEvents();
|
Dialog::checkEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HARDWARE_KEYS)
|
||||||
|
void RegisterDialog::onEvent(event_t event)
|
||||||
|
{
|
||||||
|
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(),
|
||||||
|
event);
|
||||||
|
|
||||||
|
if (event == EVT_KEY_BREAK(KEY_EXIT)) {
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ class RegisterDialog : public Dialog
|
|||||||
|
|
||||||
void start();
|
void start();
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
|
#if defined(HARDWARE_KEYS)
|
||||||
|
void onEvent(event_t event) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t moduleIdx;
|
uint8_t moduleIdx;
|
||||||
|
|||||||
@@ -1163,7 +1163,6 @@ extern ReusableBuffer reusableBuffer;
|
|||||||
|
|
||||||
uint8_t zlen(const char *str, uint8_t size);
|
uint8_t zlen(const char *str, uint8_t size);
|
||||||
bool zexist(const char *str, uint8_t size);
|
bool zexist(const char *str, uint8_t size);
|
||||||
unsigned int effectiveLen(const char * str, unsigned int size);
|
|
||||||
char * strcat_zchar(char *dest, const char *name, uint8_t size, const char spaceSym = 0, const char *defaultName=nullptr, uint8_t defaultNameSize=0, uint8_t defaultIdx=0);
|
char * strcat_zchar(char *dest, const char *name, uint8_t size, const char spaceSym = 0, const char *defaultName=nullptr, uint8_t defaultNameSize=0, uint8_t defaultIdx=0);
|
||||||
#define strcatFlightmodeName(dest, idx) strcat_zchar(dest, g_model.flightModeData[idx].name, LEN_FLIGHT_MODE_NAME, 0, STR_FM, PSIZE(TR_FM), idx+1)
|
#define strcatFlightmodeName(dest, idx) strcat_zchar(dest, g_model.flightModeData[idx].name, LEN_FLIGHT_MODE_NAME, 0, STR_FM, PSIZE(TR_FM), idx+1)
|
||||||
#if defined(EEPROM)
|
#if defined(EEPROM)
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ int8_t char2zchar(char c);
|
|||||||
void str2zchar(char *dest, const char *src, int size);
|
void str2zchar(char *dest, const char *src, int size);
|
||||||
int zchar2str(char *dest, const char *src, int size);
|
int zchar2str(char *dest, const char *src, int size);
|
||||||
int strnlen(const char *src, int max_size);
|
int strnlen(const char *src, int max_size);
|
||||||
|
unsigned int effectiveLen(const char * str, unsigned int size);
|
||||||
|
|
||||||
char *strAppend(char *dest, const char *source, int len = 0);
|
char *strAppend(char *dest, const char *source, int len = 0);
|
||||||
char *strAppendUnsigned(char *dest, uint32_t value, uint8_t digits = 0,
|
char *strAppendUnsigned(char *dest, uint32_t value, uint8_t digits = 0,
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ void processRegisterFrame(uint8_t module, const uint8_t * frame)
|
|||||||
case 0x00:
|
case 0x00:
|
||||||
if (mod.registerStep == REGISTER_INIT) {
|
if (mod.registerStep == REGISTER_INIT) {
|
||||||
// RX_NAME follows, we store it for the next step
|
// RX_NAME follows, we store it for the next step
|
||||||
str2zchar(mod.registerRxName, (const char *)&frame[4], PXX2_LEN_RX_NAME);
|
memcpy(mod.registerRxName, (const char *)&frame[4], PXX2_LEN_RX_NAME);
|
||||||
mod.registerLoopIndex = frame[12];
|
mod.registerLoopIndex = frame[12];
|
||||||
mod.registerStep = REGISTER_RX_NAME_RECEIVED;
|
mod.registerStep = REGISTER_RX_NAME_RECEIVED;
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
|
|||||||
Reference in New Issue
Block a user