add SW encoder callback support and example

This commit is contained in:
hathach committed 2017-09-14 23:54:08 +07:00
1 parent 5d03ea59d0
commit 3db9b9150a
3 files changed
+24 -9

No files matched your search

@@ -43,15 +43,20 @@
class SwRotaryEncoder
{
public:
typedef void (*callback_t) (int step);
SwRotaryEncoder(void)
{
_pina = _pinb = 0;
_a_last = 0;
_last_read = _abs = 0;
_cb = NULL;
}
bool begin(uint8_t pina, uint8_t pinb);
void setCallback(callback_t fp);
void stop(void);
int32_t read(void);
@@ -69,6 +74,8 @@ class SwRotaryEncoder
int32_t _abs;
int32_t _last_read;
callback_t _cb;
};