10#if defined(ESP8266) || defined(ESP32)
11#define CS_ENCODER_ISR_ATTR IRAM_ATTR
13#define CS_ENCODER_ISR_ATTR
17#define CS_ENCODER_ARGLIST_SIZE CORE_NUM_INTERRUPT
67 void write(int32_t p);
72 template <
unsigned NumISR = CS_ENCODER_ARGLIST_SIZE>
#define CS_ENCODER_ISR_ATTR
#define CS_ENCODER_ARGLIST_SIZE
AH::function_traits< decltype(::digitalWrite)>::argument_t< 0 > ArduinoPin_t
#define BEGIN_CS_NAMESPACE
Class for reading quadrature encoders, heavily influenced by http://www.pjrc.com/teensy/td_libs_Encod...
AtomicPosition< int32_t > position
void(*)() isr_func_t
The type of a handler function.
static isr_func_t get_isr(unsigned interrupt)
Get a pointer to the interrupt handler function for the given interrupt.
static AHEncoder * instance_table[NUM_DIGITAL_PINS]
Array of pointers to all instances with active interrupts.
void attachInterruptCtx(int interrupt)
Register the interrupt handler for this instance.
void write(int32_t p)
Set the absolute position to the given value.
void detachInterruptCtx(int interrupt)
Un-register the interrupt handler for this instance.
AHEncoder(const AHEncoder &)=delete
Copy constructor: copying an Encoder object is semantically meaningless, so it has been deleted.
~AHEncoder()
Destructor, detaches the interrupts.
AHEncoder(ArduinoPin_t pinA, ArduinoPin_t pinB)
Constructor.
uint8_t interrupts_in_use
int32_t read()
Read the current absolute position of the encoder.
void end()
Disable the interrupts used by this encoder.
int32_t readAndReset(int32_t newpos=0)
Read the current absolute position of the encoder and reset it to zero afterwards.
void begin()
Initialize this encoder by enabling the pull-up resistors and attaching the interrupts handlers (if i...
AHEncoder & operator=(const AHEncoder &)=delete
Copy assignment: copying an Encoder object is semantically meaningless, so it has been deleted.
DirectPinRead direct_pins[2]
friend void swap(AHEncoder &a, AHEncoder &b)
Swap two Encoder objects.
void update()
Private handler function that is called from the ISR.