From eb6ba88f5ab51d63214b6812e5a4c82f7d9c86a7 Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 5 May 2015 20:02:02 +0200 Subject: [PATCH] Fixes #2186 Also provides a lua function to retrieve module settings --- companion/src/eeprominterface.cpp | 2 +- companion/src/eeprominterface.h | 2 +- .../firmwares/opentx/open9xGruvin9xeeprom.cpp | 10 ++-- .../firmwares/opentx/open9xSky9xeeprom.cpp | 10 ++-- .../firmwares/opentx/open9xStockeeprom.cpp | 16 +++--- .../src/firmwares/opentx/opentxeeprom.cpp | 10 ++-- companion/src/modeledit/customfunctions.cpp | 2 - companion/src/modeledit/setup.cpp | 4 +- companion/src/wizarddata.cpp | 2 +- radio/src/gui/9X/menu_model_setup.cpp | 13 +++-- radio/src/gui/Taranis/menu_model_setup.cpp | 8 +-- radio/src/lua_api.cpp | 52 +++++++++++++++++-- radio/src/myeeprom.h | 2 +- radio/src/opentx.cpp | 23 +++++--- radio/src/opentx.h | 2 +- radio/src/pulses/dsm2_arm.cpp | 2 +- radio/src/pulses/pulses_avr.cpp | 4 +- radio/src/pulses/pxx_arm.cpp | 2 +- 18 files changed, 109 insertions(+), 57 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 3fd6e5ee2..2bd8ff4ca 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -1366,7 +1366,7 @@ void ModelData::setDefaultValues(unsigned int id, const GeneralSettings & settin clear(); used = true; sprintf(name, "MODEL%02d", id+1); - modelId = id+1; + moduleData[0].modelId = id+1; setDefaultMixes(settings); } diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index abd9d9cf4..cceb67c2a 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -814,6 +814,7 @@ enum Protocol { class ModuleData { public: ModuleData() { clear(); } + unsigned int modelId; int protocol; unsigned int channelsStart; int channelsCount; // 0=8 channels @@ -973,7 +974,6 @@ class ModelData { CustomFunctionData customFn[C9X_MAX_CUSTOM_FUNCTIONS]; SwashRingData swashRingData; unsigned int thrTraceSrc; - unsigned int modelId; uint64_t switchWarningStates; unsigned int switchWarningEnable; unsigned int potsWarningMode; diff --git a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp index 44de1ce22..63df8e9d1 100644 --- a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp @@ -501,7 +501,7 @@ t_Open9xGruvin9xModelData_v207::operator ModelData () c9x.frsky = frsky; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { c9x.frsky.screens[1].body.lines[line].source[col] = (col==0 ? (frskyLines[line] & 0x0f) : ((frskyLines[line] & 0xf0) / 16)); @@ -587,7 +587,7 @@ t_Open9xGruvin9xModelData_v208::operator ModelData () c9x.frsky.varioCenterMin = varioSpeedDownMin; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { c9x.frsky.screens[1].body.lines[line].source[col] = (col==0 ? (frskyLines[line] & 0x0f) : ((frskyLines[line] & 0xf0) / 16)); @@ -677,7 +677,7 @@ t_Open9xGruvin9xModelData_v209::operator ModelData () c9x.switchWarningStates = switchWarningStates; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { c9x.frsky.screens[1].body.lines[line].source[col] = (col==0 ? (frskyLines[line] & 0x0f) : ((frskyLines[line] & 0xf0) / 16)); @@ -767,7 +767,7 @@ t_Open9xGruvin9xModelData_v210::operator ModelData () c9x.switchWarningStates = switchWarningStates; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; for (int i=0; i<16; i++) { c9x.limitData[i].ppmCenter = servoCenter[i]; } @@ -854,6 +854,6 @@ t_Open9xGruvin9xModelData_v211::operator ModelData () c9x.switchWarningStates = switchWarningStates; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; return c9x; } diff --git a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp index 938b205c3..9f0ab590c 100644 --- a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp @@ -808,7 +808,7 @@ t_Open9xArmModelData_v208::operator ModelData () c9x.frsky.varioCenterMin = varioSpeedDownMin; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { c9x.frsky.screens[1].body.lines[line].source[col] = (col==0 ? (frskyLines[line] & 0x0f) : ((frskyLines[line] & 0xf0) / 16)); @@ -898,7 +898,7 @@ t_Open9xArmModelData_v209::operator ModelData () c9x.switchWarningStates = switchWarningStates; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { c9x.frsky.screens[1].body.lines[line].source[col] = (col==0 ? (frskyLines[line] & 0x0f) : ((frskyLines[line] & 0xf0) / 16)); @@ -988,7 +988,7 @@ t_Open9xArmModelData_v210::operator ModelData () c9x.switchWarningStates = switchWarningStates; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; for (int i=0; i<16; i++) { c9x.limitData[i].ppmCenter = servoCenter[i]; } @@ -1072,7 +1072,7 @@ t_Open9xArmModelData_v211::operator ModelData () c9x.switchWarningStates = switchWarningStates; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; for (int i=0; i<16; i++) { c9x.limitData[i].ppmCenter = servoCenter[i]; } @@ -1159,6 +1159,6 @@ t_Open9xArmModelData_v212::operator ModelData () c9x.switchWarningStates = switchWarningStates; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; return c9x; } diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.cpp b/companion/src/firmwares/opentx/open9xStockeeprom.cpp index 880ce420f..040d6ab07 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xStockeeprom.cpp @@ -1060,7 +1060,7 @@ t_Open9xModelData_v202::operator ModelData () c9x.frsky = frsky; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId=modelId; + c9x.moduleData[0].modelId = modelId; return c9x; } @@ -1134,7 +1134,7 @@ t_Open9xModelData_v203::operator ModelData () c9x.frsky = frsky; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; return c9x; } @@ -1210,7 +1210,7 @@ t_Open9xModelData_v204::operator ModelData () c9x.frsky.rssiAlarms[1] = frskyRssiAlarms[1].get(1); c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; return c9x; } @@ -1287,7 +1287,7 @@ t_Open9xModelData_v205::operator ModelData () c9x.frsky = frsky; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0]. modelId = modelId; c9x.frsky.screens[1].type = 0; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { @@ -1377,7 +1377,7 @@ t_Open9xModelData_v208::operator ModelData () c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; c9x.frsky.screens[1].type = 0; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { @@ -1471,7 +1471,7 @@ t_Open9xModelData_v209::operator ModelData () c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; c9x.frsky.screens[1].type = 0; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { @@ -1565,7 +1565,7 @@ t_Open9xModelData_v210::operator ModelData () c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; for (int i=0; i<16; i++) { c9x.limitData[i].ppmCenter=servoCenter[i]; @@ -1653,7 +1653,7 @@ t_Open9xModelData_v211::operator ModelData () c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; - c9x.modelId = modelId; + c9x.moduleData[0].modelId = modelId; return c9x; } diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 915acc187..211826185 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2781,8 +2781,12 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne bool afterrelease21March2013 = IS_AFTER_RELEASE_21_MARCH_2013(board, version); - if (afterrelease21March2013) - internalField.Append(new UnsignedField<8>(modelData.modelId)); + if (afterrelease21March2013) { + internalField.Append(new UnsignedField<8>(modelData.moduleData[0].modelId)); + } + if (IS_ARM(board) && version >= 217) { + internalField.Append(new UnsignedField<8>(modelData.moduleData[1].modelId)); + } if (IS_TARANIS(board) && version >= 215) { internalField.Append(new CharField<10>(modelData.bitmap)); @@ -2902,7 +2906,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne internalField.Append(new ConversionField< UnsignedField<8> >(modelData.thrTraceSrc, &throttleSourceConversionTable, "Throttle Source")); if (!afterrelease21March2013) { - internalField.Append(new UnsignedField<8>(modelData.modelId)); + internalField.Append(new UnsignedField<8>(modelData.moduleData[0].modelId)); } if (IS_TARANIS_X9E(board) && version >= 217) diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 8171034fd..11c27e4d6 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -73,7 +73,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, } } } - qDebug() << tracksSet; } if (IS_TARANIS(firmware->getBoard())) { @@ -86,7 +85,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, } } } - qDebug() << scriptsSet; } CompanionIcon playIcon("play.png"); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 9d37b1af8..35452781c 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -249,7 +249,7 @@ void ModulePanel::update() ui->label_rxNumber->setVisible(mask & MASK_RX_NUMBER); ui->rxNumber->setVisible(mask & MASK_RX_NUMBER); ui->rxNumber->setMaximum(max_rx_num); - ui->rxNumber->setValue(model->modelId); + ui->rxNumber->setValue(module.modelId); ui->label_channelsStart->setVisible(mask & MASK_CHANNELS_RANGE); ui->channelsStart->setVisible(mask & MASK_CHANNELS_RANGE); ui->channelsStart->setValue(module.channelsStart+1); @@ -348,7 +348,7 @@ void ModulePanel::on_ppmDelay_editingFinished() void ModulePanel::on_rxNumber_editingFinished() { - model->modelId = ui->rxNumber->value(); + module.modelId = ui->rxNumber->value(); emit modified(); } diff --git a/companion/src/wizarddata.cpp b/companion/src/wizarddata.cpp index 3b619121a..76005cf52 100644 --- a/companion/src/wizarddata.cpp +++ b/companion/src/wizarddata.cpp @@ -86,7 +86,7 @@ WizMix::operator ModelData() ModelData model; model.used = true; - model.modelId = modelId; + model.moduleData[0].modelId = modelId; model.setDefaultInputs(settings); int mixIndex = 0; diff --git a/radio/src/gui/9X/menu_model_setup.cpp b/radio/src/gui/9X/menu_model_setup.cpp index 2b700edad..523dd1e7b 100644 --- a/radio/src/gui/9X/menu_model_setup.cpp +++ b/radio/src/gui/9X/menu_model_setup.cpp @@ -601,16 +601,16 @@ void menuModelSetup(uint8_t event) lcd_putsLeft(y, STR_RXNUM); } if (IS_MODULE_XJT(moduleIdx) || IS_MODULE_DSM2(moduleIdx)) { - if (xOffsetBind) lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId, (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2); + if (xOffsetBind) lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2); if (attr && l_posHorz==0) { if (editMode>0 || p1valdiff) { - CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId, IS_MODULE_DSM2(moduleIdx) ? 20 : 63); + CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], IS_MODULE_DSM2(moduleIdx) ? 20 : 63); if (checkIncDec_Ret) { - modelHeaders[g_eeGeneral.currModel].modelId = g_model.header.modelId; + modelHeaders[g_eeGeneral.currModel].modelId[moduleIdx] = g_model.header.modelId[moduleIdx]; } } if (editMode==0 && event==EVT_KEY_BREAK(KEY_ENTER)) { - checkModelIdUnique(g_eeGeneral.currModel); + checkModelIdUnique(g_eeGeneral.currModel, moduleIdx); } } lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); @@ -771,11 +771,10 @@ void menuModelSetup(uint8_t event) if (attr && m_posHorz > 1) { REPEAT_LAST_CURSOR_MOVE(); // limit 3 column row to 2 colums (Rx_Num and RANGE fields) } - lcd_putsLeft(y, STR_RXNUM); - lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId, (m_posHorz<=0 ? attr : 0) | LEADING0|LEFT, 2); + lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[0], (m_posHorz<=0 ? attr : 0) | LEADING0|LEFT, 2); if (attr && (m_posHorz==0 && (editMode>0 || p1valdiff))) { - CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId, 99); + CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[0], 99); } #if defined(PXX) if (protocol == PROTO_PXX) { diff --git a/radio/src/gui/Taranis/menu_model_setup.cpp b/radio/src/gui/Taranis/menu_model_setup.cpp index 296f3f165..8849488df 100644 --- a/radio/src/gui/Taranis/menu_model_setup.cpp +++ b/radio/src/gui/Taranis/menu_model_setup.cpp @@ -700,16 +700,16 @@ void menuModelSetup(uint8_t event) lcd_putsLeft(y, STR_RXNUM); } if (IS_MODULE_XJT(moduleIdx) || IS_MODULE_DSM2(moduleIdx)) { - if (xOffsetBind) lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId, (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2); + if (xOffsetBind) lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2); if (attr && l_posHorz==0) { if (s_editMode>0) { - CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId, IS_MODULE_DSM2(moduleIdx) ? 20 : 63); + CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], IS_MODULE_DSM2(moduleIdx) ? 20 : 63); if (checkIncDec_Ret) { - modelHeaders[g_eeGeneral.currModel].modelId = g_model.header.modelId; + modelHeaders[g_eeGeneral.currModel].modelId[moduleIdx] = g_model.header.modelId[moduleIdx]; } } if (s_editMode==0 && event==EVT_KEY_BREAK(KEY_ENTER)) { - checkModelIdUnique(g_eeGeneral.currModel); + checkModelIdUnique(g_eeGeneral.currModel, moduleIdx); } } lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); diff --git a/radio/src/lua_api.cpp b/radio/src/lua_api.cpp index 9c2ea06ad..4a41a73a1 100644 --- a/radio/src/lua_api.cpp +++ b/radio/src/lua_api.cpp @@ -584,7 +584,6 @@ static int luaModelGetInfo(lua_State *L) lua_newtable(L); lua_pushtablezstring(L, "name", g_model.header.name); lua_pushtablenzstring(L, "bitmap", g_model.header.bitmap); - lua_pushtableinteger(L, "id", g_model.header.modelId); return 1; } @@ -603,15 +602,56 @@ static int luaModelSetInfo(lua_State *L) const char * name = luaL_checkstring(L, -1); strncpy(g_model.header.bitmap, name, sizeof(g_model.header.bitmap)); } - else if (!strcmp(key, "id")) { - g_model.header.modelId = luaL_checkinteger(L, -1); - modelHeaders[g_eeGeneral.currModel].modelId = g_model.header.modelId; - } } eeDirty(EE_MODEL); return 0; } +static int luaModelGetModule(lua_State *L) +{ + unsigned int idx = luaL_checkunsigned(L, 1); + if (idx < NUM_MODULES) { + ModuleData & module = g_model.moduleData[idx]; + lua_newtable(L); + lua_pushtableinteger(L, "rfProtocol", module.rfProtocol); + lua_pushtableinteger(L, "modelId", g_model.header.modelId[idx]); + lua_pushtableinteger(L, "firstChannel", module.channelsStart); + lua_pushtableinteger(L, "channelsCount", module.channelsCount + 8); + } + else { + lua_pushnil(L); + } + return 1; +} + +static int luaModelSetModule(lua_State *L) +{ + unsigned int idx = luaL_checkunsigned(L, 1); + + if (idx < NUM_MODULES) { + ModuleData & module = g_model.moduleData[idx]; + luaL_checktype(L, -1, LUA_TTABLE); + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { + luaL_checktype(L, -2, LUA_TSTRING); // key is string + const char * key = luaL_checkstring(L, -2); + if (!strcmp(key, "rfProtocol")) { + module.rfProtocol = luaL_checkinteger(L, -1); + } + else if (!strcmp(key, "modelId")) { + g_model.header.modelId[idx] = luaL_checkinteger(L, -1); + } + else if (!strcmp(key, "firstChannel")) { + module.channelsStart = luaL_checkinteger(L, -1); + } + else if (!strcmp(key, "channelsCount")) { + module.channelsCount = luaL_checkinteger(L, -1) - 8; + } + } + eeDirty(EE_MODEL); + } + return 0; +} + static int luaModelGetTimer(lua_State *L) { unsigned int idx = luaL_checkunsigned(L, 1); @@ -1401,6 +1441,8 @@ const luaR_value_entry opentxConstants[] = { const luaL_Reg modelLib[] = { { "getInfo", luaModelGetInfo }, { "setInfo", luaModelSetInfo }, + { "getModule", luaModelGetModule }, + { "setModule", luaModelSetModule }, { "getTimer", luaModelGetTimer }, { "setTimer", luaModelSetTimer }, { "resetTimer", luaModelResetTimer }, diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index b75b1af4a..a3d96f8e4 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -2067,7 +2067,7 @@ enum FailsafeModes { PACK(typedef struct { char name[LEN_MODEL_NAME]; // must be first for eeLoadModelName - uint8_t modelId; + uint8_t modelId[NUM_MODULES]; MODELDATA_BITMAP }) ModelHeader; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 025509c9b..aa219c2dc 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -374,12 +374,20 @@ void applyDefaultTemplate() #endif #if defined(CPUARM) -void checkModelIdUnique(uint8_t id) +void checkModelIdUnique(uint8_t index, uint8_t module) { - for (uint8_t i=0; i>5)+512, 1023); diff --git a/radio/src/pulses/pulses_avr.cpp b/radio/src/pulses/pulses_avr.cpp index 6d40af9c9..f86f6054a 100644 --- a/radio/src/pulses/pulses_avr.cpp +++ b/radio/src/pulses/pulses_avr.cpp @@ -338,7 +338,7 @@ void setupPulsesPXX() PcmBitCount = PcmByte = 0 ; PcmOnesCount = 0 ; putPcmHead() ; - putPcmByte( g_model.header.modelId ) ; // putPcmByte( g_model.rxnum ) ; // + putPcmByte(g_model.header.modelId[0]); uint8_t flag1 = 0; if (moduleFlag[0] == MODULE_BIND) flag1 |= (g_eeGeneral.countryCode << 1) | PXX_SEND_BIND; @@ -554,7 +554,7 @@ void setupPulsesDSM2() moduleFlag[0] = 0; } - dsmDat[1] = g_model.header.modelId; // DSM2 Header second byte for model match + dsmDat[1] = g_model.header.modelId[0]; for (uint8_t i=0; i>5)+512, 1023); diff --git a/radio/src/pulses/pxx_arm.cpp b/radio/src/pulses/pxx_arm.cpp index 371d781a2..df4e562fd 100644 --- a/radio/src/pulses/pxx_arm.cpp +++ b/radio/src/pulses/pxx_arm.cpp @@ -190,7 +190,7 @@ void setupPulsesPXX(unsigned int port) putPcmHead(port); /* Rx Number */ - putPcmByte(g_model.header.modelId, port); + putPcmByte(g_model.header.modelId[port], port); /* FLAG1 */ uint8_t flag1 = (g_model.moduleData[port].rfProtocol << 6);