You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
577 B
C
38 lines
577 B
C
3 years ago
|
/*
|
||
|
* Rotary encoder library for Arduino.
|
||
|
*/
|
||
|
|
||
|
#ifndef rotary_h
|
||
|
#define rotary_h
|
||
|
|
||
|
#include "Arduino.h"
|
||
|
|
||
|
// Enable this to emit codes twice per step.
|
||
|
//#define HALF_STEP
|
||
|
|
||
|
// Enable weak pullups
|
||
|
#define ENABLE_PULLUPS
|
||
|
|
||
|
// Values returned by 'process'
|
||
|
// No complete step yet.
|
||
|
#define DIR_NONE 0x0
|
||
|
// Clockwise step.
|
||
|
#define DIR_CW 0x10
|
||
|
// Anti-clockwise step.
|
||
|
#define DIR_CCW 0x20
|
||
|
|
||
|
class Rotary
|
||
|
{
|
||
|
public:
|
||
|
Rotary(char, char);
|
||
|
// Process pin(s)
|
||
|
unsigned char process();
|
||
|
private:
|
||
|
unsigned char state;
|
||
|
unsigned char pin1;
|
||
|
unsigned char pin2;
|
||
|
};
|
||
|
|
||
|
#endif
|
||
|
|