7#include <AH/STL/limits>
8#include <AH/STL/type_traits>
50template <
class RegisterType, uint8_t NumEnc,
51 class EncoderPositionType = int32_t,
bool InterruptSafe =
false>
54 static_assert(std::is_unsigned<RegisterType>::value,
55 "RegisterType should be an unsigned integer type");
72 state = std::numeric_limits<RegisterType>::max();
143 return positions[
idx];
246#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
262 return &positions[index];
#define BEGIN_AH_NAMESPACE
Proxy to access a single encoder of the encoders managed by RegisterEncoders.
EncoderPositionStorageType * position
A pointer to the position value inside of the RegisterEncoders class.
void write(EncoderPositionType pos)
Set the position of the encoder.
EncoderPositionType read() const
Read the position of the encoder.
EncoderPositionType readAndReset()
Read the position of the encoder and reset it to zero.
Encoder(EncoderPositionStorageType *position)
Class for keeping track of the position of multiple rotary encoders.
Encoder operator[](uint8_t index)
Get a proxy to one of the encoders managed by this object.
void reset(RegisterType resetstate)
Reset the positions to zero and the state to the given value.
EncoderPositionType read(uint8_t idx) const
Read the position of the given encoder.
typename std::conditional< InterruptSafe, volatile EncoderPositionType, EncoderPositionType >::type EncoderPositionStorageType
bool update(RegisterType newstate)
Update the encoder positions based on the new state.
EncoderPositionType readAndReset(uint8_t idx)
Read the position of the given encoder and reset it to zero.
typename std::conditional< InterruptSafe, volatile RegisterType, RegisterType >::type StateStorageType
void reset()
Reset the positions to zero and the state to 0xFF...FF.
void write(uint8_t idx, EncoderPositionType pos)
Set the position of the given encoder.
A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...
static constexpr int8_t RegisterEncodersLUT[16]
Lookup table that maps rotary encoder (2-bit gray code) state changes to position deltas.