update encoder

This commit is contained in:
hathach committed 2017-09-13 19:05:25 +07:00
1 parent f13e3f6113
commit 97ecc06347
3 files changed
+24 -6

No files matched your search

+19 -1
View File
@@ -44,7 +44,7 @@
void RotaryEncoder::begin(void)
{
// default sample period
NRF_QDEC->SAMPLEPER = QDEC_SAMPLEPER_SAMPLEPER_16384us;
NRF_QDEC->SAMPLEPER = QDEC_SAMPLEPER_SAMPLEPER_128us;
pinMode(_pina, INPUT);
pinMode(_pinb, INPUT);
@@ -130,6 +130,24 @@ int32_t RotaryEncoder::read(void)
return NRF_QDEC->ACCREAD;
}
int32_t RotaryEncoder::readAbs(void)
{
// first update the abs
read();
return _abs;
}
void RotaryEncoder::writeAbs(int32_t value)
{
_abs = value;
}
void RotaryEncoder::clearAbs(void)
{
_abs = 0;
}
void QDEC_IRQHandler(void)
{