12#include <soc/gpio_num.h>
20 static constexpr const char* TAG =
"Device::Encoders";
23 static constexpr uint8_t NUM_ENCODERS = 2;
24 static constexpr gpio_num_t LEFT_ENCODER_PIN = GPIO_NUM_27;
25 static constexpr gpio_num_t RIGHT_ENCODER_PIN = GPIO_NUM_14;
27 struct isr_context_t {
29 uint8_t encoder_index;
33 std::atomic<int32_t> pulse_count[NUM_ENCODERS];
34 isr_context_t isr_contexts[NUM_ENCODERS];
61 return pulse_count[
static_cast<uint8_t
>(encoder_id)];
70 pulse_count[
static_cast<uint8_t
>(encoder_id)] = 0;
encoder_id_t
Definition encoders.h:39
@ RIGHT
Definition encoders.h:41
@ LEFT
Definition encoders.h:40
int32_t get_pulse_count(encoder_id_t encoder_id) const
Gets the pulse count of the given encoder.
Definition encoders.h:60
Encoders(Robot &robot)
Definition encoders.cpp:15
void reset_pulse_count(encoder_id_t encoder_id)
Resets the pulse count of the given encoder back to zero.
Definition encoders.h:69
~Encoders()
Definition encoders.cpp:22
static void IRAM_ATTR encoder_isr_handler(void *arg)
Definition encoders.cpp:26
void initialize()
Sets up the necessary GPIO pins.
Definition encoders.cpp:33
Class containing all the components of the robot.
Definition robot.h:32
log_source
Definition log_sources.h:12
@ LOG_SOURCE_DEVICE_ENCODERS
Definition log_sources.h:26
Definition battery.cpp:14