/**
 * \file cimditrotary.h
 * \brief declaration of the CimditRotary class
 * \author GrumpyDeveloper (Sascha Nitsch)
 * \copyright 2022 Sascha Nitsch
 * Licensed under MIT license
 *
 */

#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_
