1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 08:15:17 +03:00
This commit is contained in:
bsongis 2014-05-31 20:44:43 +02:00
parent 148483819d
commit 0a0d6a18b6
2 changed files with 29 additions and 0 deletions

View file

@ -99,6 +99,23 @@ TelemetryProtocol getTelemetryProtocol()
void FrskyValueWithMin::set(uint8_t value)
{
#if defined(CPUARM)
if (this->value == 0) {
memset(values, value, TELEMETRY_AVERAGE_COUNT);
this->value = value;
}
else {
unsigned int sum = 0;
for (int i=0; i<TELEMETRY_AVERAGE_COUNT-1; i++) {
uint8_t tmp = values[i+1];
values[i] = tmp;
sum += tmp;
}
values[TELEMETRY_AVERAGE_COUNT-1] = value;
sum += value;
this->value = sum/TELEMETRY_AVERAGE_COUNT;
}
#else
if (this->value == 0) {
this->value = value;
}
@ -109,6 +126,7 @@ void FrskyValueWithMin::set(uint8_t value)
sum = 0;
}
}
#endif
if (!min || value < min) {
min = value;

View file

@ -69,6 +69,16 @@ enum TelemetryStates {
extern uint8_t telemetryState;
#endif
#if defined(CPUARM)
#define TELEMETRY_AVERAGE_COUNT 4
class FrskyValueWithMin {
public:
uint8_t value;
uint8_t min;
uint8_t values[TELEMETRY_AVERAGE_COUNT];
void set(uint8_t value);
};
#else
class FrskyValueWithMin {
public:
uint8_t value;
@ -76,6 +86,7 @@ class FrskyValueWithMin {
uint16_t sum;
void set(uint8_t value);
};
#endif
class FrskyValueWithMinMax: public FrskyValueWithMin {
public: