Boboter
Loading...
Searching...
No Matches
robot.h
Go to the documentation of this file.
1
7
8#pragma once
9
11#include "include/hal/gpio.h"
12#include "include/hal/ledc.h"
13#include "include/hal/adc.h"
14#include "include/hal/i2c.h"
16#include "devices/leds/leds.h"
20
24class Robot {
25private:
26 static constexpr const char* TAG = "Robot";
27
28 static constexpr gpio_num_t STATUS_LED_PIN = GPIO_NUM_5;
29 static constexpr gpio_num_t BOTTOM_LED_PIN = GPIO_NUM_13;
30
31private:
32 explicit Robot();
33 ~Robot();
34
35public:
37 TaskFunction_t task_function;
38 const char* task_name;
39 const uint32_t stack_depth;
40 void* const params_for_task;
41 UBaseType_t priority;
42 TaskHandle_t* const created_task_handle;
43 const BaseType_t core_id;
44 };
45
46 enum class rgb_leds_mode_t : uint8_t {
47 OFF = 0,
51 };
52
53public:
58
64
73
74public:
75 Robot(const Robot&) = delete;
76 Robot& operator=(const Robot&) = delete;
77
84 static Robot& get_instance() {
85 static Robot _instance;
86 return _instance;
87 }
88
94 void create_task(const task_config_t& config);
95
99 void permanent_sleep();
100
106 void set_status_led(bool state) const;
107
113 void set_bottom_led(bool state) const;
114};
Definition battery.h:15
Definition buttons.h:16
Definition buzzer.h:17
Definition display.h:15
Definition leds.h:17
The ADC hardware abstraction layer's control class.
Definition adc.h:30
The GPIO hardware abstraction layer's control class.
Definition gpio.h:36
The I2C hardware abstraction layer's control class.
Definition i2c.h:34
The LEDC hardware abstraction layer's control class.
Definition ledc.h:35
Device::Display display
Definition robot.h:61
Robot & operator=(const Robot &)=delete
Device::Leds leds
Definition robot.h:60
Robot(const Robot &)=delete
protected_struct< data_struct > data
Definition robot.h:72
void create_task(const task_config_t &config)
Creates a FreeRTOS task.
Definition robot.cpp:43
void set_bottom_led(bool state) const
Sets the bottom LED state.
Definition robot.cpp:91
HAL::GPIO::Controller & gpio
Definition robot.h:54
Device::Buttons buttons
Definition robot.h:62
void permanent_sleep()
Shuts down all HALs, pulls down a few pins and puts the ESP32 into deep sleep mode.
Definition robot.cpp:55
HAL::I2C::Controller & i2c
Definition robot.h:57
void set_status_led(bool state) const
Sets the status LED.
Definition robot.cpp:81
Device::Buzzer buzzer
Definition robot.h:63
Device::Battery battery
Definition robot.h:59
rgb_leds_mode_t
Definition robot.h:46
@ HEADLIGHTS
Definition robot.h:48
@ RANDOM_COLORS
Definition robot.h:49
@ OFF
Definition robot.h:47
@ POLICE
Definition robot.h:50
HAL::ADC::Controller & adc
Definition robot.h:56
static Robot & get_instance()
Gets the robot instance.
Definition robot.h:84
HAL::LEDC::Controller & ledc
Definition robot.h:55
A RAII type used to make structs thread-safe for FreeRTOS via mutexes.
Definition protected_struct.h:65
Definition robot.h:66
rgb_leds_mode_t rgb_leds_mode
Definition robot.h:69
bool bottom_led_active
Definition robot.h:68
bool status_led_active
Definition robot.h:67
Definition robot.h:65
Definition robot.h:36
const uint32_t stack_depth
Definition robot.h:39
TaskFunction_t task_function
Definition robot.h:37
UBaseType_t priority
Definition robot.h:41
void *const params_for_task
Definition robot.h:40
TaskHandle_t *const created_task_handle
Definition robot.h:42
const char * task_name
Definition robot.h:38
const BaseType_t core_id
Definition robot.h:43