remove most of the defines
This commit is contained in:
@@ -19,19 +19,6 @@
|
||||
#include "counter.h"
|
||||
#include "component.h"
|
||||
|
||||
/**
|
||||
* @brief The default size of numbers to be taken in account for the average.
|
||||
*
|
||||
*/
|
||||
#define BUFSIZE 5
|
||||
#define CONVERSION_FACTOR 100
|
||||
|
||||
/**
|
||||
* @brief Default value for min Millisseconds between each loop
|
||||
* @see setDelay(uint8_t val)
|
||||
*/
|
||||
#define DELAY_SPEEDOMETER 30
|
||||
|
||||
/**
|
||||
* @brief A class which use a encoder to calc the speed
|
||||
*
|
||||
@@ -60,9 +47,7 @@ class Speedometer : public Component {
|
||||
* @param pin Pin on the Esp from the encoder.
|
||||
* @param diameter Diameter of the wheel in meters.
|
||||
* @param steps Encodersteps for a complete wheel rotation.
|
||||
* @param numOfValForAvg Number of last values to be taken into account for the average.
|
||||
*/
|
||||
Speedometer(uint8_t pin, double diameter, uint16_t steps, uint8_t numOfValForAvg);
|
||||
Speedometer(uint8_t pin, double diameter, uint16_t steps);
|
||||
|
||||
~Speedometer();
|
||||
@@ -127,12 +112,14 @@ class Speedometer : public Component {
|
||||
private:
|
||||
void run() override;
|
||||
void init(uint8_t pin, double diameter, uint16_t steps);
|
||||
void initAvgBuf();
|
||||
void clearAvgBuf();
|
||||
void addValToBuf(int16_t val);
|
||||
void updateAvgBufSize();
|
||||
int16_t calcAverage() const;
|
||||
|
||||
static constexpr uint8_t loopDelay = 30;
|
||||
static constexpr uint8_t bufSize = 5;
|
||||
static constexpr uint8_t conversionFactor = 100;
|
||||
|
||||
Counter* pulseCounter;
|
||||
Direction currentDirection = Direction::None;
|
||||
|
||||
@@ -142,11 +129,10 @@ class Speedometer : public Component {
|
||||
double diameter;
|
||||
|
||||
uint8_t printCounter = 0;
|
||||
uint8_t bufSize = BUFSIZE;
|
||||
uint8_t bufPos = 0;
|
||||
uint16_t steps;
|
||||
|
||||
int16_t *buf = nullptr;
|
||||
int16_t buf[Speedometer::bufSize];
|
||||
|
||||
uint32_t lastMillisCalc = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user