add callback support
This commit is contained in:
1 parent
337b683e9f
commit
23dca4bc75
6 files changed
+155
-10
No files matched your search
@@ -38,6 +38,11 @@
|
||||
|
||||
class HwRotaryEncoder RotaryEncoder;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void QDEC_IRQHandler(void);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Hardware Encoder
|
||||
*/
|
||||
@@ -187,17 +192,21 @@ void HwRotaryEncoder::clearAbs(void)
|
||||
_abs = 0;
|
||||
}
|
||||
|
||||
|
||||
void QDEC_IRQHandler(void)
|
||||
void HwRotaryEncoder::_irq_handler(void)
|
||||
{
|
||||
if ( (NRF_QDEC->INTENSET & QDEC_INTENSET_SAMPLERDY_Msk) && NRF_QDEC->EVENTS_SAMPLERDY )
|
||||
{
|
||||
NRF_QDEC->EVENTS_SAMPLERDY = 0;
|
||||
|
||||
// if ( _cb )
|
||||
// {
|
||||
// int32_t step = read();
|
||||
// if ( step ) _cb(step);
|
||||
// }
|
||||
if ( _cb )
|
||||
{
|
||||
int32_t step = read();
|
||||
if ( step ) _cb(step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QDEC_IRQHandler(void)
|
||||
{
|
||||
RotaryEncoder._irq_handler();
|
||||
}
|
||||
Reference in new issue
Block a user