diff --git a/radio/src/bluetooth.cpp b/radio/src/bluetooth.cpp index 1d3cc92bb..5c48704fd 100644 --- a/radio/src/bluetooth.cpp +++ b/radio/src/bluetooth.cpp @@ -255,7 +255,6 @@ void bluetoothSendTrainer() void bluetoothForwardTelemetry(const uint8_t * packet) { - bluetoothBufferIndex = 0; bluetoothCrc = 0x00; bluetoothBuffer[bluetoothBufferIndex++] = START_STOP; // start byte @@ -264,8 +263,11 @@ void bluetoothForwardTelemetry(const uint8_t * packet) } bluetoothBuffer[bluetoothBufferIndex++] = bluetoothCrc; bluetoothBuffer[bluetoothBufferIndex++] = START_STOP; // end byte - bluetoothWrite(bluetoothBuffer, bluetoothBufferIndex); - bluetoothBufferIndex = 0; + + if (bluetoothBufferIndex >= 2*FRSKY_SPORT_PACKET_SIZE) { + bluetoothWrite(bluetoothBuffer, bluetoothBufferIndex); + bluetoothBufferIndex = 0; + } } void bluetoothReceiveTrainer() diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index 03edb89a4..2c4c44069 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -333,8 +333,8 @@ PACK(struct TelemetrySensor { }; union { PACK(struct { - uint8_t physID:5; // instance ID to allow handling multiple instances of same value type, for FrSky can be the physical ID of the sensor - uint8_t rxIndex:3; + uint8_t physID:5; + uint8_t rxIndex:3; // 1 bit for module index, 2 bits for receiver index }) frskyInstance; uint8_t instance; NOBACKUP(uint8_t formula); diff --git a/radio/src/gui/128x64/model_telemetry_sensor.cpp b/radio/src/gui/128x64/model_telemetry_sensor.cpp index 5582dfeb5..c468a9845 100644 --- a/radio/src/gui/128x64/model_telemetry_sensor.cpp +++ b/radio/src/gui/128x64/model_telemetry_sensor.cpp @@ -51,7 +51,7 @@ void menuModelSensor(event_t event) 0, // Name 0, // Type sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, // ID / Formula - sensor->type == TELEM_TYPE_CALCULATED ? HIDDEN_ROW : LABEL(Receiver), // Receiver name + (sensor->type == TELEM_TYPE_CALCULATED || sensor->frskyInstance.rxIndex == TELEMETRY_ENDPOINT_SPORT) ? HIDDEN_ROW : LABEL(Receiver), // Receiver name ((sensor->type == TELEM_TYPE_CALCULATED && (sensor->formula == TELEM_FORMULA_DIST)) || sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW), // Unit (sensor->isPrecConfigurable() && sensor->unit != UNIT_FAHRENHEIT ? (uint8_t)0 : HIDDEN_ROW), // Precision (sensor->unit >= UNIT_FIRST_VIRTUAL ? HIDDEN_ROW : (uint8_t)0), // Param1 @@ -144,10 +144,9 @@ void menuModelSensor(event_t event) case SENSOR_FILED_RECEIVER_NAME: lcdDrawTextAlignedLeft(y, STR_RECEIVER); - drawReceiverName(SENSOR_2ND_COLUMN, y, (sensor->instance >> 7) & 0x01, (sensor->instance >> 5) & 0x03, 0); + drawReceiverName(SENSOR_2ND_COLUMN, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, 0); break; - case SENSOR_FIELD_UNIT: lcdDrawTextAlignedLeft(y, "Unit"); // TODO flash saving with editChoice where I copied those 2 lines? diff --git a/radio/src/pulses/pxx2.cpp b/radio/src/pulses/pxx2.cpp index 0386a2e8d..1bf0bc58e 100644 --- a/radio/src/pulses/pxx2.cpp +++ b/radio/src/pulses/pxx2.cpp @@ -323,7 +323,7 @@ void Pxx2Pulses::setupFrame(uint8_t module) setupShareMode(module); break; default: - if (outputTelemetryBuffer.destination == module) { + if (outputTelemetryBuffer.isModuleDestination(module)) { setupTelemetryFrame(module); outputTelemetryBuffer.reset(); } diff --git a/radio/src/telemetry/telemetry.h b/radio/src/telemetry/telemetry.h index b742489e0..f43787dba 100644 --- a/radio/src/telemetry/telemetry.h +++ b/radio/src/telemetry/telemetry.h @@ -171,6 +171,11 @@ class OutputTelemetryBuffer { timeout = 200; /* 2s */ } + bool isModuleDestination(uint8_t module) + { + return destination != TELEMETRY_ENDPOINT_NONE && destination != TELEMETRY_ENDPOINT_SPORT && (destination >> 2) == module; + } + void per10ms() { if (timeout > 0) {