PicoLowLevel
Loading...
Searching...
No Matches
TractionEncoder.h
Go to the documentation of this file.
1#ifndef TRACTION_ENCODER_H
2#define TRACTION_ENCODER_H
3
4#include <Arduino.h>
5#include <functional>
6#include "Filter.h"
7#include "definitions.h"
9
14 public:
15 TractionEncoder(byte pin_a, byte pin_b, Filter<int> *filter = NULL, bool invert = false, PIO pio = pio0);
16 void begin();
17 int getSpeed();
18 int getSteps();
19
20 private:
21 byte pin_a, pin_b;
22 bool invert;
23 Filter<int> *filter;
24
25 unsigned long last_time;
26 int last_steps;
27
28 PIO pio;
29 uint sm;
30
31 static uint last_sm;
32 static uint offset;
33 static bool initialized;
34};
35
36#endif
Interface for a generic filter, with parameterized type.
Definition Filter.h:9
Class used to read data from traction rotary encoders.
Definition TractionEncoder.h:13
int getSpeed()
Returns the last detected speed.
Definition TractionEncoder.cpp:39
void begin()
Sets the encoder's pins and attach the interrupt.
Definition TractionEncoder.cpp:23
int getSteps()
Returns the number of steps since the class was initialized.
Definition TractionEncoder.cpp:59