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; this->value = value;
} }
else { 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]; unsigned int sum = values[0];
for (int i=0; i<TELEMETRY_AVERAGE_COUNT-1; i++) { for (int i=0; i<TELEMETRY_AVERAGE_COUNT-1; i++) {
uint8_t tmp = values[i+1]; uint8_t tmp = values[i+1];
values[i] = tmp; values[i] = tmp;
sum += tmp; sum += tmp;
} }
values[TELEMETRY_AVERAGE_COUNT-1] = raw; values[TELEMETRY_AVERAGE_COUNT-1] = value;
sum += raw + value; sum += value;
this->value = sum/(TELEMETRY_AVERAGE_COUNT+2); this->value = sum/(TELEMETRY_AVERAGE_COUNT+1);
} }
raw = value;
#else #else
if (this->value == 0) { if (this->value == 0) {
this->value = value; this->value = value;
+4 -5
View File
@@ -70,18 +70,17 @@ extern uint8_t telemetryState;
#endif #endif
#if defined(CPUARM) #if defined(CPUARM)
#define RAW_FRSKY_MINMAX(v) v.raw #define TELEMETRY_AVERAGE_COUNT 3 //we actually average one more reading!
#define TELEMETRY_AVERAGE_COUNT 2 //we actually average two more readings! #define RAW_FRSKY_MINMAX(v) v.values[TELEMETRY_AVERAGE_COUNT-1]
class FrskyValueWithMin { class FrskyValueWithMin {
public: 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 min;
uint8_t values[TELEMETRY_AVERAGE_COUNT]; uint8_t values[TELEMETRY_AVERAGE_COUNT];
uint8_t raw; //raw value (unfiltered)
void set(uint8_t value); void set(uint8_t value);
}; };
#else #else
#define RAW_FRSKY_MINMAX(v) v.value #define RAW_FRSKY_MINMAX(v) v.value
class FrskyValueWithMin { class FrskyValueWithMin {
public: public:
uint8_t value; uint8_t value;