SpeedSensor.h 743 Bytes
Newer Older
Manuel Pitz's avatar
Manuel Pitz committed
1
2
3
4
/////////////////////////////////////////////////////////
///// This file does not need any modification, /////////
///// if needed it can be extended //////////////////////
///////////////////////////////////////////////////////// 
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

extern void speedInterrupt();

class SpeedSensor {
  public:
    SpeedSensor(int);
    ~SpeedSensor();

    void interrupt(unsigned long microseconds);
    bool getState();
    double getSpeed();
    void setup();
    
  private:
    int speedSendPin;
    
  
    bool state = false;    
    long rawValArray[8] = {0};
    int arraySize = 8;
    unsigned long lastTurn = 0;
    unsigned long avgPos = 0;
    unsigned long avgVal = 0;
    unsigned int initOk = 0;
    double currentSpeed = 0;
};