1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-15 20:35:17 +03:00

Model Setup refactoring

This commit is contained in:
Bertrand Songis 2019-04-03 11:27:43 +02:00
parent 46dc85aa7e
commit 1d5b780c2f
12 changed files with 134 additions and 271 deletions

View file

@ -420,25 +420,6 @@ When called without parameters, it will only return the status of the output buf
@status current Introduced in 2.2.0
*/
TelemetryEndpoint getTelemetryEndpoint(uint8_t receiverIndex)
{
TelemetryEndpoint result;
for (uint8_t module=0; module<NUM_MODULES; module++) {
for (uint8_t receiver=0; receiver<PXX2_MAX_RECEIVERS_PER_MODULE; receiver++) {
uint8_t candidateIndex = g_model.moduleData[module].pxx2.getReceiverSlot(receiver) - 1;
if (candidateIndex == receiverIndex) {
result.module = module;
result.rxUid = candidateIndex;
return result;
}
}
}
result.value = TELEMETRY_ENDPOINT_NONE;
return result;
}
static int luaSportTelemetryPush(lua_State * L)
{
if (lua_gettop(L) == 0) {
@ -459,16 +440,14 @@ static int luaSportTelemetryPush(lua_State * L)
packet.dataId = dataId;
packet.value = luaL_checkunsigned(L, 4);
outputTelemetryBuffer.pushSportPacketWithBytestuffing(packet);
outputTelemetryBuffer.setDestination(TELEMETRY_ENDPOINT_SPORT);
}
else {
outputTelemetryBuffer.sport.physicalId = getDataId(luaL_checkunsigned(L, 1));
outputTelemetryBuffer.sport.primId = luaL_checkunsigned(L, 2);
outputTelemetryBuffer.sport.dataId = dataId;
outputTelemetryBuffer.sport.value = luaL_checkunsigned(L, 4);
TelemetryEndpoint destination = getTelemetryEndpoint(sensor.frskyInstance.rxIndex);
outputTelemetryBuffer.setDestination(destination.value);
}
outputTelemetryBuffer.setDestination(sensor.frskyInstance.rxIndex);
lua_pushboolean(L, true);
return 1;
}