Added RAW_FRSKY_MINMAX() macro for access to the raw telemetry value and gtests for it
This commit is contained in:
+3
-7
@@ -196,17 +196,13 @@ void writeLogs()
|
|||||||
|
|
||||||
#if defined(FRSKY)
|
#if defined(FRSKY)
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
f_printf(&g_oLogFile, "%d,%d,", frskyData.swr.raw, frskyData.rssi[0].raw);
|
f_printf(&g_oLogFile, "%d,%d,", RAW_FRSKY_MINMAX(frskyData.swr), RAW_FRSKY_MINMAX(frskyData.rssi[0]));
|
||||||
#else
|
#else
|
||||||
f_printf(&g_oLogFile, "%d,%d,%d,", frskyStreaming, frskyData.rssi[0].value, frskyData.rssi[1].value);
|
f_printf(&g_oLogFile, "%d,%d,%d,", frskyStreaming, RAW_FRSKY_MINMAX(frskyData.rssi[0]), RAW_FRSKY_MINMAX(frskyData.rssi[1]));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint8_t i=0; i<MAX_FRSKY_A_CHANNELS; i++) {
|
for (uint8_t i=0; i<MAX_FRSKY_A_CHANNELS; i++) {
|
||||||
#if defined(CPUARM)
|
int16_t converted_value = applyChannelRatio(i, RAW_FRSKY_MINMAX(frskyData.analog[i]));
|
||||||
int16_t converted_value = applyChannelRatio(i, frskyData.analog[i].raw);
|
|
||||||
#else
|
|
||||||
int16_t converted_value = applyChannelRatio(i, frskyData.analog[i].value);
|
|
||||||
#endif
|
|
||||||
f_printf(&g_oLogFile, "%d.%02d,", converted_value/100, converted_value%100);
|
f_printf(&g_oLogFile, "%d.%02d,", converted_value/100, converted_value%100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ extern uint8_t telemetryState;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
|
#define RAW_FRSKY_MINMAX(v) v.raw
|
||||||
#define TELEMETRY_AVERAGE_COUNT 2 //we actually average two more readings!
|
#define TELEMETRY_AVERAGE_COUNT 2 //we actually average two more readings!
|
||||||
class FrskyValueWithMin {
|
class FrskyValueWithMin {
|
||||||
public:
|
public:
|
||||||
@@ -80,6 +81,7 @@ class FrskyValueWithMin {
|
|||||||
void set(uint8_t value);
|
void set(uint8_t value);
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
#define RAW_FRSKY_MINMAX(v) v.value
|
||||||
class FrskyValueWithMin {
|
class FrskyValueWithMin {
|
||||||
public:
|
public:
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
|
|||||||
@@ -110,13 +110,16 @@ TEST(FrSky, FrskyValueWithMinAveraging)
|
|||||||
FrskyValueWithMin testVal;
|
FrskyValueWithMin testVal;
|
||||||
testVal.value = 0;
|
testVal.value = 0;
|
||||||
testVal.set(10);
|
testVal.set(10);
|
||||||
|
EXPECT_EQ(RAW_FRSKY_MINMAX(testVal), 10);
|
||||||
EXPECT_EQ(testVal.value, expected[testPos++]);
|
EXPECT_EQ(testVal.value, expected[testPos++]);
|
||||||
for(int n=2; n<10; ++n) {
|
for(int n=2; n<10; ++n) {
|
||||||
testVal.set(n*10);
|
testVal.set(n*10);
|
||||||
|
EXPECT_EQ(RAW_FRSKY_MINMAX(testVal), n*10);
|
||||||
EXPECT_EQ(testVal.value, expected[testPos++]);
|
EXPECT_EQ(testVal.value, expected[testPos++]);
|
||||||
}
|
}
|
||||||
for(int n=2; n<10; ++n) {
|
for(int n=2; n<10; ++n) {
|
||||||
testVal.set(100);
|
testVal.set(100);
|
||||||
|
EXPECT_EQ(RAW_FRSKY_MINMAX(testVal), 100);
|
||||||
EXPECT_EQ(testVal.value, expected[testPos++]);
|
EXPECT_EQ(testVal.value, expected[testPos++]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user