Removed raw member that was introduced in commit 3f39352d95. Its role now plays last member of values[] array. Same RAM usage, reduced FLASH usage.

This commit is contained in:
Damjan Adamic
2014-07-13 14:44:42 +02:00
parent 2d22c18758
commit b41ba50b53
2 changed files with 9 additions and 10 deletions
+5 -5
View File
@@ -84,18 +84,18 @@ void FrskyValueWithMin::set(uint8_t value)
this->value = value;
}
else {
//calculate the average from values[], raw, value
//calculate the average from values[] and value
//also shift readings in values [] array
unsigned int sum = values[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] = raw;
sum += raw + value;
this->value = sum/(TELEMETRY_AVERAGE_COUNT+2);
values[TELEMETRY_AVERAGE_COUNT-1] = value;
sum += value;
this->value = sum/(TELEMETRY_AVERAGE_COUNT+1);
}
raw = value;
#else
if (this->value == 0) {
this->value = value;
+4 -5
View File
@@ -70,18 +70,17 @@ extern uint8_t telemetryState;
#endif
#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 3 //we actually average one more reading!
#define RAW_FRSKY_MINMAX(v) v.values[TELEMETRY_AVERAGE_COUNT-1]
class FrskyValueWithMin {
public:
uint8_t value; //fitered value (average of last TELEMETRY_AVERAGE_COUNT+2 values)
uint8_t value; //fitered value (average of last TELEMETRY_AVERAGE_COUNT+1 values)
uint8_t min;
uint8_t values[TELEMETRY_AVERAGE_COUNT];
uint8_t raw; //raw value (unfiltered)
void set(uint8_t value);
};
#else
#define RAW_FRSKY_MINMAX(v) v.value
#define RAW_FRSKY_MINMAX(v) v.value
class FrskyValueWithMin {
public:
uint8_t value;