cleaning
refactore all components now have a base class compnent for loop functions
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
Speedometer::Speedometer(uint8_t pin, double diameter, uint16_t steps, uint8_t numOfValForAvg) {
|
||||
this->init(pin, diameter, steps);
|
||||
this->bufSize = numOfValForAvg;
|
||||
this->loopDelay = DELAY_SPEEDOMETER;
|
||||
}
|
||||
|
||||
Speedometer::Speedometer(uint8_t pin, double diameter, uint16_t steps) {
|
||||
@@ -25,24 +26,11 @@ Speedometer::~Speedometer() {
|
||||
delete this->pulseCounter;
|
||||
}
|
||||
|
||||
uint16_t Speedometer::loop() {
|
||||
void Speedometer::run() {
|
||||
if (this->calibrationRunning)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
uint32_t time = millis();
|
||||
uint16_t elapsedTime = time - this->lastMillisLoop;
|
||||
|
||||
//Cancel if delayLoop is not reached
|
||||
if (elapsedTime < this->delayLoop)
|
||||
return elapsedTime;
|
||||
|
||||
runSpeedometer();
|
||||
this->lastMillisLoop = time;
|
||||
return elapsedTime;
|
||||
}
|
||||
|
||||
void Speedometer::runSpeedometer() {
|
||||
uint32_t time = millis();
|
||||
|
||||
uint16_t elapsedTime = time - this->lastMillisCalc;
|
||||
this->lastMillisCalc = time;
|
||||
|
||||
Reference in New Issue
Block a user