Implement speedometer and encoder

This commit is contained in:
2021-04-01 14:37:47 +02:00
parent e798f0904c
commit fd44f84738
10 changed files with 196 additions and 63 deletions
+19
View File
@@ -0,0 +1,19 @@
#include "wheelEncoder.h"
WheelEncoder::WheelEncoder() {
}
void WheelEncoder::initEncoder(uint8_t pinA, uint8_t pinB) {
this->pinA = pinA;
this->pinB = pinB;
pinMode(this->pinA, INPUT_PULLDOWN);
pinMode(this->pinB, INPUT_PULLDOWN);
}
int64_t WheelEncoder::getCount() {
return this->count;
}
+24
View File
@@ -0,0 +1,24 @@
#ifndef WHEEL_ENCODER_H
#define WHEEL_ENCODER_H
#include <cstdint>
#include <Arduino.h>
#include <driver/gpio.h>
#include <driver/pcnt.h>
class WheelEncoder {
public:
WheelEncoder();
void initEncoder(uint8_t pinA, uint8_t pinB);
int64_t getCount();
private:
uint8_t pinA;
uint8_t pinB;
bool init = false;
volatile int64_t count = 0;
};
#endif // WHEEL_ENCODER_H