fix(color): simulator may crash or freeze when RF module is set to MPM (#6954)
This commit is contained in:
@@ -31,10 +31,12 @@
|
|||||||
typedef const char* STR_TYP;
|
typedef const char* STR_TYP;
|
||||||
#define STR_DEF(x) x
|
#define STR_DEF(x) x
|
||||||
#define STR_VAL(x) x
|
#define STR_VAL(x) x
|
||||||
|
#define STR_SAFE_VAL(x) x
|
||||||
#else
|
#else
|
||||||
typedef const char* (*STR_TYP)();
|
typedef const char* (*STR_TYP)();
|
||||||
#define STR_DEF(x) x##_FN
|
#define STR_DEF(x) x##_FN
|
||||||
#define STR_VAL(x) x()
|
#define STR_VAL(x) x()
|
||||||
|
#define STR_SAFE_VAL(x) (x ? x() : nullptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(M_PI)
|
#if !defined(M_PI)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "ppm_settings.h"
|
#include "ppm_settings.h"
|
||||||
#include "storage/modelslist.h"
|
#include "storage/modelslist.h"
|
||||||
#include "etx_lv_theme.h"
|
#include "etx_lv_theme.h"
|
||||||
|
#include "os/sleep.h"
|
||||||
|
|
||||||
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
|
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
|
||||||
#include "pxx1_settings.h"
|
#include "pxx1_settings.h"
|
||||||
@@ -611,9 +612,10 @@ class ModuleSubTypeChoice : public Choice
|
|||||||
MultiModuleStatus& status = getMultiModuleStatus(moduleIdx);
|
MultiModuleStatus& status = getMultiModuleStatus(moduleIdx);
|
||||||
status.invalidate();
|
status.invalidate();
|
||||||
|
|
||||||
uint32_t startUpdate = lv_tick_get();
|
uint32_t startUpdate = time_get_ms();
|
||||||
while (!status.isValid() && (lv_tick_elaps(startUpdate) < 250))
|
while (!status.isValid() && (time_get_ms() - startUpdate < 250))
|
||||||
;
|
sleep_ms(1);
|
||||||
|
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1261,7 +1261,7 @@ const char * getMultiOptionTitleStatic(uint8_t moduleIdx)
|
|||||||
{
|
{
|
||||||
const uint8_t multi_proto = g_model.moduleData[moduleIdx].multi.rfProtocol;
|
const uint8_t multi_proto = g_model.moduleData[moduleIdx].multi.rfProtocol;
|
||||||
const mm_protocol_definition * pdef = getMultiProtocolDefinition(multi_proto);
|
const mm_protocol_definition * pdef = getMultiProtocolDefinition(multi_proto);
|
||||||
return STR_VAL(pdef->optionsstr);
|
return STR_SAFE_VAL(pdef->optionsstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * getMultiOptionTitle(uint8_t moduleIdx)
|
const char * getMultiOptionTitle(uint8_t moduleIdx)
|
||||||
@@ -1272,7 +1272,7 @@ const char * getMultiOptionTitle(uint8_t moduleIdx)
|
|||||||
if (status.optionDisp >= getMaxMultiOptions()) {
|
if (status.optionDisp >= getMaxMultiOptions()) {
|
||||||
status.optionDisp = 1; // Unknown options are defaulted to type 1 (basic option)
|
status.optionDisp = 1; // Unknown options are defaulted to type 1 (basic option)
|
||||||
}
|
}
|
||||||
return STR_VAL(mm_options_strings::options[status.optionDisp]);
|
return STR_SAFE_VAL(mm_options_strings::options[status.optionDisp]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getMultiOptionTitleStatic(moduleIdx);
|
return getMultiOptionTitleStatic(moduleIdx);
|
||||||
|
|||||||
Reference in New Issue
Block a user