[ACCESS] Automatic detection of the module for accessPushTelemetry if module < 0
This commit is contained in:
@@ -79,7 +79,7 @@ void onSdFormatConfirm(const char * result)
|
||||
#endif
|
||||
audioQueue.stopSD();
|
||||
if (sdCardFormat()) {
|
||||
f_chdir("/");
|
||||
f_chdir(ROOT_PATH);
|
||||
REFRESH_FILES();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ bool addRadioTool(uint8_t index, const char * label)
|
||||
lcdDrawText(3*FW, y, label, (sub == index ? INVERS : 0));
|
||||
if (attr && s_editMode > 0) {
|
||||
s_editMode = 0;
|
||||
killAllEvents();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -101,6 +102,7 @@ void addRadioScriptTool(uint8_t index, const char * filename)
|
||||
}
|
||||
|
||||
if (addRadioTool(index, label)) {
|
||||
f_chdir("/SCRIPTS/TOOLS/");
|
||||
luaExec(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,6 @@ void logsWrite()
|
||||
#endif
|
||||
|
||||
#if defined(TELEMETRY_FRSKY)
|
||||
|
||||
for (int i=0; i<MAX_TELEMETRY_SENSORS; i++) {
|
||||
if (isTelemetryFieldAvailable(i)) {
|
||||
TelemetrySensor & sensor = g_model.telemetrySensors[i];
|
||||
|
||||
@@ -513,6 +513,21 @@ When called without parameters, it will only return the status of the output buf
|
||||
|
||||
*/
|
||||
|
||||
bool getDefaultAccessDestination(uint8_t & destination)
|
||||
{
|
||||
for (uint8_t i=0; i<MAX_TELEMETRY_SENSORS; i++) {
|
||||
TelemetrySensor & sensor = g_model.telemetrySensors[i];
|
||||
if (sensor.type == TELEM_TYPE_CUSTOM) {
|
||||
TelemetryItem sensorItem = telemetryItems[i];
|
||||
if (sensorItem.isFresh()) {
|
||||
destination = sensor.frskyInstance.rxIndex;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int luaAccessTelemetryPush(lua_State * L)
|
||||
{
|
||||
if (lua_gettop(L) == 0) {
|
||||
@@ -521,13 +536,25 @@ static int luaAccessTelemetryPush(lua_State * L)
|
||||
}
|
||||
|
||||
if (outputTelemetryBuffer.isAvailable()) {
|
||||
uint8_t module = luaL_checkunsigned(L, 1);
|
||||
int8_t module = luaL_checkinteger(L, 1);
|
||||
uint8_t rxUid = luaL_checkunsigned(L, 2);
|
||||
uint8_t destination;
|
||||
|
||||
if (module < 0) {
|
||||
if (!getDefaultAccessDestination(destination)) {
|
||||
lua_pushboolean(L, false);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
destination = (module << 2) + rxUid;
|
||||
}
|
||||
|
||||
outputTelemetryBuffer.sport.physicalId = getDataId(luaL_checkunsigned(L, 3));
|
||||
outputTelemetryBuffer.sport.primId = luaL_checkunsigned(L, 4);
|
||||
outputTelemetryBuffer.sport.dataId = luaL_checkunsigned(L, 5);
|
||||
outputTelemetryBuffer.sport.value = luaL_checkunsigned(L, 6);
|
||||
outputTelemetryBuffer.setDestination((module << 2) + rxUid);
|
||||
outputTelemetryBuffer.setDestination(destination);
|
||||
lua_pushboolean(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user