Receiver RESET added
This commit is contained in:
@@ -303,8 +303,8 @@ enum TelemetryProtocol
|
||||
};
|
||||
|
||||
struct TelemetryData {
|
||||
TelemetryValueWithMin swr; // TODO Min not needed
|
||||
TelemetryValueWithMin rssi; // TODO Min not needed
|
||||
TelemetryValue swr;
|
||||
FilteredTelemetryValue rssi;
|
||||
uint16_t xjtVersion;
|
||||
bool varioHighPrecision;
|
||||
};
|
||||
|
||||
@@ -122,7 +122,8 @@ void processRegisterFrame(uint8_t module, uint8_t * frame)
|
||||
reusableBuffer.moduleSetup.pxx2.registerStep = REGISTER_OK;
|
||||
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
||||
POPUP_INFORMATION(STR_REG_OK);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
TRACE("KO %s %s", &frame[4], reusableBuffer.moduleSetup.pxx2.registerRxName);
|
||||
}
|
||||
}
|
||||
@@ -165,6 +166,19 @@ void processBindFrame(uint8_t module, uint8_t * frame)
|
||||
}
|
||||
}
|
||||
|
||||
void processResetFrame(uint8_t module, uint8_t * frame)
|
||||
{
|
||||
if (moduleSettings[module].mode != MODULE_MODE_RESET) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (reusableBuffer.moduleSetup.pxx2.resetReceiverIndex == frame[3]) {
|
||||
memclear(g_model.moduleData[module].pxx2.receiverName[reusableBuffer.moduleSetup.pxx2.resetReceiverIndex], PXX2_LEN_RX_NAME);
|
||||
}
|
||||
|
||||
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
||||
}
|
||||
|
||||
void processTelemetryFrame(uint8_t module, uint8_t * frame)
|
||||
{
|
||||
uint8_t origin = (module << 2) + (frame[3] & 0x03);
|
||||
@@ -232,6 +246,10 @@ void processModuleFrame(uint8_t module, uint8_t *frame)
|
||||
case PXX2_TYPE_ID_TELEMETRY:
|
||||
processTelemetryFrame(module, frame);
|
||||
break;
|
||||
|
||||
case PXX2_TYPE_ID_RESET:
|
||||
processResetFrame(module, frame);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,13 +162,15 @@ void sportProcessTelemetryPacketWithoutCrc(uint8_t origin, const uint8_t * packe
|
||||
if (dataId == RSSI_ID) {
|
||||
telemetryStreaming = TELEMETRY_TIMEOUT10ms; // reset counter only if valid packets are being detected
|
||||
data = SPORT_DATA_U8(packet);
|
||||
if(g_model.frsky.rssiSource) {
|
||||
if (g_model.frsky.rssiSource) {
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[g_model.frsky.rssiSource];
|
||||
if(sensor->instance == instance)
|
||||
if (sensor->instance == instance) {
|
||||
telemetryData.rssi.set(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
telemetryData.rssi.set(data);
|
||||
}
|
||||
}
|
||||
else if (dataId == R9_PWR_ID) {
|
||||
uint32_t r9pwr[] = {100, 200, 500, 1000};
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
void TelemetryValueWithMin::reset()
|
||||
void FilteredTelemetryValue::reset()
|
||||
{
|
||||
memclear(this, sizeof(*this));
|
||||
}
|
||||
|
||||
void TelemetryValueWithMin::set(uint8_t value)
|
||||
void FilteredTelemetryValue::set(uint8_t value)
|
||||
{
|
||||
if (this->value == 0) {
|
||||
memset(values, value, TELEMETRY_AVERAGE_COUNT);
|
||||
@@ -44,19 +44,17 @@ void TelemetryValueWithMin::set(uint8_t value)
|
||||
sum += value;
|
||||
this->value = sum/(TELEMETRY_AVERAGE_COUNT+1);
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryValueWithMin::reset()
|
||||
{
|
||||
memclear(this, sizeof(*this));
|
||||
}
|
||||
|
||||
void TelemetryValueWithMin::set(uint8_t value)
|
||||
{
|
||||
FilteredTelemetryValue::set(value);
|
||||
if (!min || value < min) {
|
||||
min = value;
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryValueWithMinMax::set(uint8_t value, uint8_t unit)
|
||||
{
|
||||
TelemetryValueWithMin::set(value);
|
||||
if (unit != UNIT_VOLTS) {
|
||||
this->value = value;
|
||||
}
|
||||
if (!max || value > max) {
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,19 +25,34 @@
|
||||
|
||||
#define TELEMETRY_AVERAGE_COUNT 3 // we actually average one more reading!
|
||||
#define RAW_FRSKY_MINMAX(v) v.values[TELEMETRY_AVERAGE_COUNT-1]
|
||||
class TelemetryValueWithMin {
|
||||
|
||||
class TelemetryValue {
|
||||
public:
|
||||
uint8_t value; // fitered value (average of last TELEMETRY_AVERAGE_COUNT+1 values)
|
||||
uint8_t min;
|
||||
uint8_t value;
|
||||
void set(uint8_t value)
|
||||
{
|
||||
this->value = value;
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
this->value = 0;
|
||||
};
|
||||
};
|
||||
|
||||
class FilteredTelemetryValue: public TelemetryValue {
|
||||
public:
|
||||
uint8_t value; // filtered value (average of last TELEMETRY_AVERAGE_COUNT+1 values)
|
||||
uint8_t values[TELEMETRY_AVERAGE_COUNT];
|
||||
void set(uint8_t value);
|
||||
void reset();
|
||||
};
|
||||
|
||||
class TelemetryValueWithMinMax: public TelemetryValueWithMin {
|
||||
class TelemetryValueWithMin: public FilteredTelemetryValue {
|
||||
public:
|
||||
uint8_t max;
|
||||
void set(uint8_t value, uint8_t unit);
|
||||
uint8_t min;
|
||||
void set(uint8_t value);
|
||||
void reset();
|
||||
};
|
||||
|
||||
#endif // _TELEMETRY_HOLDERS_H_
|
||||
|
||||
Reference in New Issue
Block a user