3 #include <freertos/FreeRTOS.h>
4 #include <freertos/queue.h>
23 class MotorChangeBuilder;
105 void schedule(uint32_t period_ms, std::function<
bool()> callback) {
120 EVENT_MOTORS_STOP_ALL,
125 struct EventMotorsData {
126 bool (Motor::*setter_func)(int8_t);
134 std::vector<EventMotorsData>* motors;
149 void queue(
const Event* event,
bool toFront =
false);
150 bool queueFromIsr(
const Event* event,
bool toFront =
false);
151 static void consumerRoutineTrampoline(
void* cookie);
152 void consumerRoutine();
153 void processEvent(
struct Event* ev);
155 bool motorsFailSafe();
157 void setupExpander();
159 #ifdef RB_DEBUG_MONITOR_TASKS
160 bool printTasksDebugInfo();
162 std::vector<TaskHandle_t> m_tasks;
163 std::mutex m_tasks_mutex;
166 QueueHandle_t m_queue;
168 TickType_t m_motors_last_set;
169 std::vector<std::unique_ptr<Motor>> m_motors;
170 SerialPWM m_motors_pwm;
214 void set(
bool toFront =
false);
218 std::unique_ptr<std::vector<Manager::EventMotorsData>> m_values;
Controls the expander pins.
Definition: Adafruit_MCP23017.h:24
Contains the battery state and can control the robot's power.
Definition: RBControl_battery.hpp:17
Definition: RBControl_encoder.hpp:17
Helper class for controlling the LEDs connected to the expander.
Definition: RBControl_leds.hpp:10
The main library class for working with the RBControl board. Call the install() method at the start o...
Definition: RBControl_manager.hpp:49
static Manager & get()
Get manager instance.
Definition: RBControl_manager.hpp:64
SmartServoBus & servoBus()
Get the SmartServoBus for working with intelligent servos LX-16..
Definition: RBControl_manager.hpp:85
Nvs & config()
Definition: RBControl_manager.hpp:95
Timers & timers()
Definition: RBControl_manager.hpp:109
SmartServoBus & initSmartServoBus(uint8_t servo_count, gpio_num_t pin=GPIO_NUM_32, uart_port_t uart=UART_NUM_1)
Initialize the UART servo bus for intelligent servos LX-16.
Definition: RBControl_manager.cpp:183
friend class PcntInterruptHandler
Definition: RBControl_manager.hpp:52
Motor & motor(MotorId id)
Definition: RBControl_manager.hpp:92
void monitorTask(TaskHandle_t task)
Definition: RBControl_manager.cpp:192
Adafruit_MCP23017 & expander()
Get the expander Adafruit_MCP23017. LEDs and buttons are connected to it.
Definition: RBControl_manager.hpp:87
void schedule(uint32_t period_ms, std::function< bool()> callback)
Schedule callback to fire after period (in millisecond).
Definition: RBControl_manager.hpp:105
Piezo & piezo()
Get the Piezo controller.
Definition: RBControl_manager.hpp:88
MotorChangeBuilder setMotors()
Get a motor instance.
Definition: RBControl_manager.cpp:188
Manager(Manager const &)=delete
Leds & leds()
Get the Leds helper.
Definition: RBControl_manager.hpp:90
void install(ManagerInstallFlags flags=MAN_NONE)
Initialize the manager - must be called once at the start of the program.
Definition: RBControl_manager.cpp:38
Battery & battery()
Get the Battery interface.
Definition: RBControl_manager.hpp:89
void operator=(Manager const &)=delete
Helper class for building the motor change event.
Definition: RBControl_manager.hpp:183
MotorChangeBuilder & power(MotorId id, int8_t value)
Set single motor power.
Definition: RBControl_manager.cpp:228
MotorChangeBuilder & stop(MotorId id)
Stop motor.
Definition: RBControl_manager.cpp:244
MotorChangeBuilder(const MotorChangeBuilder &o)=delete
void set(bool toFront=false)
Finish the changes and submit the events.
Definition: RBControl_manager.cpp:252
MotorChangeBuilder(Manager &manager)
Definition: RBControl_manager.cpp:215
MotorChangeBuilder & pwmMaxPercent(MotorId id, int8_t percent)
Limit motor index's power to percent.
Definition: RBControl_manager.cpp:236
~MotorChangeBuilder()
Definition: RBControl_manager.cpp:225
Definition: RBControl_motor.hpp:17
Definition: RBControl_nvs.hpp:11
Helper class for controlling the piezo.
Definition: RBControl_piezo.hpp:10
Definition: RBControl_servo.hpp:18
Definition: RBControl_timers.hpp:14
uint16_t schedule(uint32_t period_ms, std::function< bool()> callback)
Schedule callback to fire after period (in millisecond).
Definition: RBControl_timers.cpp:45
static Timers & get()
Definition: RBControl_timers.cpp:18
The base namespace. Contains some logging functions, too.
Definition: half_duplex_uart.cpp:53
ManagerInstallFlags operator|(ManagerInstallFlags a, ManagerInstallFlags b)
Definition: RBControl_manager.hpp:38
MotorId
Definition: RBControl_pinout.hpp:8
ManagerInstallFlags
This enum contains flags for the Manager's install() method.
Definition: RBControl_manager.hpp:26
@ MAN_DISABLE_BATTERY_MANAGEMENT
auto-shutdown on low battery voltage.
Definition: RBControl_manager.hpp:30
@ MAN_DISABLE_PIEZO
Definition: RBControl_manager.hpp:32
@ MAN_DISABLE_MOTOR_FAILSAFE
after 300ms of no set motor power calls.
Definition: RBControl_manager.hpp:28
@ MAN_NONE
Definition: RBControl_manager.hpp:27