mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
More unit tests and unified target for all tests (#6661)
* added general settings tests * fixed pre-219 switchUnlockState (CPN) * X7 radio settings tests * updated X10 model * patched TESTS_PATH to point directly at the complete tests path * fixed horus general settings switch conversion * cpn x10 general settings tests * fixed horus cpn import * use x10 model from otx file to ease editing with companion * added make targets "gtests" and "tests" gtests builds all the tests (radio & companion) tests builds and executes all the tests (radio & companion) * fixed companion tests cmake * fixed gtests-radio target * fixed commit tests * fixed converting LS & RS on X10 * fixed converting global functions on X10 * fixed source conversion on X10 * fixed throttle source on X10 * fixed throttle source on radio and companion * more checks and re-enabled Horus screenData copy * more tests (X10) * [X10] restore correct direction for RS & LS * [horus] convert "Value" widget source * fixed conversion of ModelHeader::bitmap length * added missing X10 radio tests to companion tests * fixed conversion of telemetry sources in logical switches * [horus] fixed potential crash * fixed "AND switch" conversion in logical switches
This commit is contained in:
parent
274528ee1d
commit
5db30ea7bc
19 changed files with 340 additions and 105 deletions
|
@ -58,6 +58,11 @@ int convertSource_218_to_219(int source)
|
|||
source += 2;
|
||||
#endif
|
||||
|
||||
#if defined(PCBX10)
|
||||
if ((source == MIXSRC_EXT1) || (source == MIXSRC_EXT2))
|
||||
source += 2;
|
||||
#endif
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
|
@ -111,6 +116,12 @@ void convertModelData_218_to_219(ModelData &model)
|
|||
memcpy(&oldModel, &model, sizeof(ModelData_v218));
|
||||
ModelData_v219 & newModel = (ModelData_v219 &) model;
|
||||
|
||||
#if defined(PCBHORUS)
|
||||
// 4 bytes more for the ModelHeader::bitmap
|
||||
memclear(&newModel.header.bitmap[10], 4);
|
||||
memcpy(newModel.timers, oldModel.timers, offsetof(ModelData_v218, mixData) - offsetof(ModelData_v218, timers));
|
||||
#endif
|
||||
|
||||
memclear(newModel.mixData, sizeof(ModelData_v219) - offsetof(ModelData_v219, mixData));
|
||||
|
||||
char name[LEN_MODEL_NAME+1];
|
||||
|
@ -147,9 +158,9 @@ void convertModelData_218_to_219(ModelData &model)
|
|||
uint8_t cstate = lswFamily(sw.func);
|
||||
if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_COMP || cstate == LS_FAMILY_DIFF) {
|
||||
LogicalSwitchData & sw = newModel.logicalSw[i];
|
||||
sw.v1 = convertSource_218_to_219((uint8_t)sw.v1);
|
||||
sw.v1 = convertSource_218_to_219(sw.v1);
|
||||
if (cstate == LS_FAMILY_COMP) {
|
||||
sw.v2 = convertSource_218_to_219((uint8_t)sw.v2);
|
||||
sw.v2 = convertSource_218_to_219(sw.v2);
|
||||
}
|
||||
}
|
||||
else if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
|
||||
|
@ -159,6 +170,7 @@ void convertModelData_218_to_219(ModelData &model)
|
|||
else if (cstate == LS_FAMILY_EDGE) {
|
||||
sw.v1 = convertSwitch_218_to_219(sw.v1);
|
||||
}
|
||||
sw.andsw = convertSwitch_218_to_219(sw.andsw);
|
||||
}
|
||||
|
||||
for (uint8_t i=0; i<MAX_SPECIAL_FUNCTIONS_218; i++) {
|
||||
|
@ -179,6 +191,10 @@ void convertModelData_218_to_219(ModelData &model)
|
|||
}
|
||||
|
||||
newModel.thrTraceSrc = oldModel.thrTraceSrc;
|
||||
#if defined(PCBX10)
|
||||
if (newModel.thrTraceSrc > 3) // 0=Thr, 1/2/3=Old 3 Pots, then Sliders
|
||||
newModel.thrTraceSrc += 2;
|
||||
#endif
|
||||
newModel.switchWarningState = oldModel.switchWarningState;
|
||||
#if !defined(COLORLCD)
|
||||
newModel.switchWarningEnable = oldModel.switchWarningEnable;
|
||||
|
@ -279,9 +295,33 @@ void convertModelData_218_to_219(ModelData &model)
|
|||
#endif
|
||||
|
||||
#if defined(PCBHORUS)
|
||||
// memcpy(newModel.screenData, oldModel.screenData,
|
||||
// sizeof(newModel.screenData) +
|
||||
// sizeof(newModel.topbarData))
|
||||
memcpy(newModel.screenData, oldModel.screenData,
|
||||
sizeof(newModel.screenData) +
|
||||
sizeof(newModel.topbarData));
|
||||
|
||||
for (int screen=0; screen<MAX_CUSTOM_SCREENS; screen++) {
|
||||
CustomScreenData& screenData = g_model.screenData[screen];
|
||||
if (screenData.layoutName[0] == '\0')
|
||||
continue;
|
||||
for (int zone=0; zone<MAX_LAYOUT_ZONES; zone++) {
|
||||
Layout::ZonePersistentData& zoneData = screenData.layoutData.zones[zone];
|
||||
if (strcmp("Value",zoneData.widgetName))
|
||||
continue;
|
||||
|
||||
ZoneOptionValue& option = zoneData.widgetData.options[0];
|
||||
option.unsignedValue = convertSource_218_to_219(option.unsignedValue);
|
||||
}
|
||||
}
|
||||
|
||||
for (int zone=0; zone<MAX_LAYOUT_ZONES; zone++) {
|
||||
Topbar::ZonePersistentData& zoneData = g_model.topbarData.zones[zone];
|
||||
if (strcmp("Value",zoneData.widgetName))
|
||||
continue;
|
||||
|
||||
ZoneOptionValue& option = zoneData.widgetData.options[0];
|
||||
option.unsignedValue = convertSource_218_to_219(option.unsignedValue);
|
||||
}
|
||||
|
||||
#else
|
||||
newModel.screensType = oldModel.frsky.screensType;
|
||||
memmove(&newModel.screens, &oldModel.frsky.screens, sizeof(newModel.screens));
|
||||
|
@ -320,13 +360,6 @@ void convertRadioData_218_to_219(RadioData & settings)
|
|||
memcpy(&oldSettings, &settings, sizeof(RadioData_v218));
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX7) || defined(PCBXLITE)
|
||||
for (uint8_t i=0; i<MAX_SPECIAL_FUNCTIONS_218; i++) {
|
||||
CustomFunctionData & cf = settings.customFn[i];
|
||||
cf.swtch = convertSwitch_218_to_219(cf.swtch);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9D) || defined(PCBX9DP)
|
||||
// no bluetooth before PCBREV 2019
|
||||
settings.auxSerialMode = oldSettings.auxSerialMode;
|
||||
|
@ -376,6 +409,16 @@ void convertRadioData_218_to_219(RadioData & settings)
|
|||
g_eeGeneral.potsConfig = bfSet<uint32_t>(g_eeGeneral.potsConfig, POT_WITHOUT_DETENT, 2, 2); // T12 comes with wrongly defined pot2
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX7) || defined(PCBXLITE) || defined(PCBHORUS)
|
||||
for (uint8_t i=0; i<MAX_SPECIAL_FUNCTIONS_218; i++) {
|
||||
CustomFunctionData & cf = settings.customFn[i];
|
||||
cf.swtch = convertSwitch_218_to_219(cf.swtch);
|
||||
if (cf.func == FUNC_PLAY_VALUE || cf.func == FUNC_VOLUME || (IS_ADJUST_GV_FUNC(cf.func) && cf.all.mode == FUNC_ADJUST_GVAR_SOURCE)) {
|
||||
cf.all.val = convertSource_218_to_219(cf.all.val);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9DP) && PCBREV >= 2019
|
||||
// force re-calibration
|
||||
settings.chkSum = 0xFFFF;
|
||||
|
|
|
@ -80,11 +80,6 @@ void ModelCell::loadBitmap()
|
|||
}) partialmodel;
|
||||
const char * error = NULL;
|
||||
|
||||
buffer = new BitmapBuffer(BMP_RGB565, MODELCELL_WIDTH, MODELCELL_HEIGHT);
|
||||
if (buffer == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp(modelFilename, g_eeGeneral.currModelFilename, LEN_MODEL_FILENAME) == 0) {
|
||||
memcpy(&partialmodel.header, &g_model.header, sizeof(partialmodel));
|
||||
}
|
||||
|
@ -92,6 +87,13 @@ void ModelCell::loadBitmap()
|
|||
error = readModel(modelFilename, (uint8_t *)&partialmodel.header, sizeof(partialmodel), &version);
|
||||
}
|
||||
|
||||
if ((modelName[0] == 0) && ! error)
|
||||
setModelName(partialmodel.header.name); // resets buffer!!!
|
||||
|
||||
buffer = new BitmapBuffer(BMP_RGB565, MODELCELL_WIDTH, MODELCELL_HEIGHT);
|
||||
if (buffer == NULL) {
|
||||
return;
|
||||
}
|
||||
buffer->clear(TEXT_BGCOLOR);
|
||||
|
||||
if (error) {
|
||||
|
@ -99,9 +101,6 @@ void ModelCell::loadBitmap()
|
|||
buffer->drawBitmapPattern(5, 23, LBM_LIBRARY_SLOT, TEXT_COLOR);
|
||||
}
|
||||
else {
|
||||
if (modelName[0] == 0)
|
||||
setModelName(partialmodel.header.name);
|
||||
|
||||
char timer[LEN_TIMER_STRING];
|
||||
buffer->drawSizedText(5, 2, modelName, LEN_MODEL_NAME, SMLSIZE|TEXT_COLOR);
|
||||
getTimerString(timer, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue