32 lines
526 B
C++
32 lines
526 B
C++
#ifndef ROTARY_ENCODER_DRIVER_H
|
|
#define ROTARY_ENCODER_DRIVER_H
|
|
|
|
#include "digital_in.h"
|
|
#include "digital_out.h"
|
|
#include "timer_usec.h"
|
|
|
|
class RotaryEncoderDriver {
|
|
volatile uint8_t cycle;
|
|
volatile int16_t count;
|
|
volatile int16_t prev_count;
|
|
|
|
Digital_out led;
|
|
|
|
Digital_in eA;
|
|
Digital_in eB;
|
|
|
|
Timer_usec timer;
|
|
|
|
public:
|
|
volatile int16_t delta;
|
|
|
|
RotaryEncoderDriver();
|
|
void begin();
|
|
void update();
|
|
int position();
|
|
void update_delta();
|
|
float count_per_sec();
|
|
|
|
};
|
|
#endif
|