2022-02-18 18:15:30 +01:00
|
|
|
/**
|
|
|
|
* \file cimditrotary.h
|
|
|
|
* \brief declaration of the CimditRotary class
|
|
|
|
* \author GrumpyDeveloper (Sascha Nitsch)
|
|
|
|
* \copyright 2022 Sascha Nitsch
|
|
|
|
* Licensed under MIT license
|
|
|
|
*
|
|
|
|
*/
|
2022-03-12 21:36:54 +01:00
|
|
|
|
2022-02-18 18:15:30 +01:00
|
|
|
#ifndef CIMDITROTARY_H_
|
|
|
|
#define CIMDITROTARY_H_
|
|
|
|
|
|
|
|
// system includes
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \class CimditRotary
|
|
|
|
* \brief rotary encocer class
|
|
|
|
*/
|
|
|
|
class CimditRotary {
|
|
|
|
public:
|
|
|
|
/// constructor
|
|
|
|
CimditRotary();
|
|
|
|
|
|
|
|
/// update internal state with new inputs
|
|
|
|
/// \param a first pin
|
|
|
|
/// \param b second pin
|
|
|
|
/// \return true on position change
|
|
|
|
bool update(bool a, bool b);
|
|
|
|
|
|
|
|
/// get delta value since last read
|
|
|
|
/// \returns number of ticks in positive - negative direction
|
|
|
|
/// \note resets internal counters
|
|
|
|
int8_t getDelta();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// delta position since last read
|
|
|
|
int8_t m_delta;
|
|
|
|
|
|
|
|
/// old a value
|
|
|
|
bool m_a;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CIMDITROTARY_H_
|