6 #include <driver/gpio.h>
7 #include <driver/pcnt.h>
33 void driveToValue(int32_t positionAbsolute, uint8_t power, std::function<
void(
Encoder&)> callback =
nullptr);
43 void drive(int32_t positionRelative, uint8_t power, std::function<
void(
Encoder&)> callback =
nullptr);
62 static void IRAM_ATTR isrGpio(
void* cookie);
66 void onEdgeIsr(int64_t timestamp, uint8_t pinLevel);
67 void onPcntIsr(uint32_t status);
69 void pcnt_init(pcnt_unit_t pcntUnit, gpio_num_t GPIO_A, gpio_num_t GPIO_B);
74 std::atomic<int32_t> m_counter;
76 std::mutex m_time_mutex;
77 int64_t m_counter_time_us_last;
78 int64_t m_counter_time_us_diff;
80 int8_t m_target_direction;
81 std::function<void(
Encoder&)> m_target_callback;
85 class PcntInterruptHandler {
87 static PcntInterruptHandler& get(
Manager* manager);
89 void enable(
int index);
92 PcntInterruptHandler(
Manager* manager);
93 ~PcntInterruptHandler();
94 static void IRAM_ATTR isrHandler(
void* cookie);
Definition: RBControl_encoder.hpp:17
~Encoder()
Definition: RBControl_encoder.cpp:110
float speed()
Get number of edges per one second.
Definition: RBControl_encoder.cpp:248
int32_t value()
Get number of edges from encoder.
Definition: RBControl_encoder.cpp:242
void drive(int32_t positionRelative, uint8_t power, std::function< void(Encoder &)> callback=nullptr)
Drive motor to set position (according relative value).
Definition: RBControl_encoder.cpp:284
void driveToValue(int32_t positionAbsolute, uint8_t power, std::function< void(Encoder &)> callback=nullptr)
Drive motor to set position (according absolute value).
Definition: RBControl_encoder.cpp:263
The main library class for working with the RBControl board. Call the install() method at the start o...
Definition: RBControl_manager.hpp:49
Definition: RBControl_motor.hpp:17
The base namespace. Contains some logging functions, too.
Definition: half_duplex_uart.cpp:53
MotorId
Definition: RBControl_pinout.hpp:8