File management and Completed Part 1
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#ifndef SPEED_ESTIMATOR_H
|
||||
#define SPEED_ESTIMATOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class Speed_estimator
|
||||
{
|
||||
public:
|
||||
Speed_estimator(
|
||||
double countsPerRevolution,
|
||||
double sampleTimeSeconds
|
||||
);
|
||||
|
||||
void reset(int32_t initialPosition);
|
||||
|
||||
double update(int32_t currentPosition);
|
||||
|
||||
double rpm() const;
|
||||
|
||||
private:
|
||||
static const uint8_t WINDOW_SIZE = 10;
|
||||
|
||||
double countsPerRevolution;
|
||||
double sampleTime;
|
||||
|
||||
int32_t previousPosition;
|
||||
|
||||
int32_t countHistory[WINDOW_SIZE];
|
||||
int32_t rollingCounts;
|
||||
|
||||
uint8_t historyIndex;
|
||||
uint8_t samplesFilled;
|
||||
|
||||
double currentRPM;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user