more clean up

This commit is contained in:
hathach committed 2017-09-14 01:23:39 +07:00
1 parent 23dca4bc75
commit 09e3dc3712
2 files changed
+10 -18

No files matched your search

+8 -12
View File
@@ -46,26 +46,22 @@ extern "C"
/**
* Initialize Hardware Encoder
*/
void HwRotaryEncoder::begin(int8_t pina, int8_t pinb, int8_t pinled)
void HwRotaryEncoder::begin(uint8_t pina, uint8_t pinb, int8_t pinled)
{
_pina = pina;
_pinb = pinb;
_pinled = pinled;
// default sample period
NRF_QDEC->SAMPLEPER = QDEC_SAMPLEPER_SAMPLEPER_128us;
pinMode(_pina, INPUT);
pinMode(_pinb, INPUT);
pinMode(pina, INPUT);
pinMode(pinb, INPUT);
NRF_QDEC->PSEL.A = _pina;
NRF_QDEC->PSEL.B = _pinb;
NRF_QDEC->PSEL.A = pina;
NRF_QDEC->PSEL.B = pinb;
if ( _pinled >= 0 )
if ( pinled >= 0 )
{
pinMode(_pinled, INPUT);
pinMode(pinled, INPUT);
NRF_QDEC->PSEL.LED = _pinled;
NRF_QDEC->PSEL.LED = pinled;
}
// Disable debounce by default
+2 -6
View File
@@ -37,6 +37,7 @@
#define ROTARYENCODER_H_
#include "Arduino.h"
#include "SwRotaryEncoder.h"
class HwRotaryEncoder
{
@@ -45,14 +46,12 @@ class HwRotaryEncoder
HwRotaryEncoder(void)
{
_pina = _pinb = _pinled = -1;
_abs = 0;
_step = 0;
_cb = NULL;
}
void begin(int8_t pina, int8_t pinb, int8_t pinled = -1);
void begin(uint8_t pina, uint8_t pinb, int8_t pinled = -1);
void setSampler(uint8_t period);
void setDebounce(bool enable);
@@ -72,9 +71,6 @@ class HwRotaryEncoder
void _irq_handler(void);
private:
int8_t _pina, _pinb;
int8_t _pinled;
// Note For each turn, encoder generate 2 transitions
int32_t _abs; // Absolute position
int32_t _step; // Moving step that take intermediate transition in account