Class Encoder

Class Documentation

class Encoder

This class allows to use a quadrature encoder by configuring it and then getting its ticks count value.

Note

The current implementation only supports two instances of this class to be constructed.

Public Functions

inline Encoder(const InterruptIn *channel_a_interrupt_in, const InterruptIn *channel_b_interrupt_in)

Constructs a new Encoder object.

Parameters:
  • channel_a_interrupt_in – Digital interrupt input connected to encoder channel A pin.

  • channel_b_interrupt_in – Digital interrupt input connected to encoder channel B pin.

void begin()

Initializes the encoder.

long read()

Gets the ticks count value.

Returns:

Ticks count value.

void reset()

Sets the ticks count value to zero.