2022-02-18 18:15:30 +01:00
|
|
|
/**
|
|
|
|
* \file cimditrotary.cpp
|
|
|
|
* \brief implementiton of the CimditRotary class
|
|
|
|
* \author GrumpyDeveloper (Sascha Nitsch)
|
|
|
|
* \copyright 2022 Sascha Nitsch
|
|
|
|
* Licensed under MIT license
|
|
|
|
*
|
|
|
|
*/
|
2022-03-12 21:36:54 +01:00
|
|
|
#include "Arduino.h"
|
2022-02-18 18:15:30 +01:00
|
|
|
// own includes
|
|
|
|
#include "cimditrotary.h"
|
|
|
|
|
|
|
|
CimditRotary::CimditRotary() {
|
|
|
|
m_a = false;
|
|
|
|
m_delta = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CimditRotary::update(bool a, bool b) {
|
|
|
|
if (a == m_a) return false; // no change
|
|
|
|
if (a && !m_a) { // rising bit a
|
|
|
|
if (b) {
|
|
|
|
++m_delta;
|
|
|
|
} else {
|
|
|
|
--m_delta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_a = a;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
int8_t CimditRotary::getDelta() {
|
|
|
|
int8_t ret = m_delta;
|
|
|
|
m_delta = 0;
|
|
|
|
return ret;
|
|
|
|
}
|