Boboter
Loading...
Searching...
No Matches
buttons.h
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <cstdint>
11#include <soc/gpio_num.h>
12#include "include/log_sources.h"
13
14class Robot;
15
16namespace Device {
17 class Buttons {
18 private:
19 static constexpr const char* TAG = "Device::Buttons";
20 static constexpr log_source LOG_SOURCE = LOG_SOURCE_DEVICE_BUTTONS;
21
22 static constexpr gpio_num_t BUTTON_PRIMARY_PIN = GPIO_NUM_16;
23 static constexpr gpio_num_t BUTTON_SECONDARY_PIN = GPIO_NUM_17;
24 static constexpr uint32_t DEBOUNCE_US = 250'000;
25
26 Robot& robot;
27 bool primary_button_state;
28 bool secondary_button_state;
29
30 public:
31 explicit Buttons(Robot& robot);
32 ~Buttons();
33
37 void initialize();
38
43
47 [[nodiscard]] bool get_button_state_primary() const { return primary_button_state; }
48
52 [[nodiscard]] bool get_button_state_secondary() const { return secondary_button_state; }
53 };
54}
bool get_button_state_secondary() const
Gets the state of the secondary button.
Definition buttons.h:52
void initialize()
Sets up the necessary GPIO pins.
Definition buttons.cpp:26
Buttons(Robot &robot)
Definition buttons.cpp:14
void update_button_states()
Updates the button states with the current hardware states.
Definition buttons.cpp:48
~Buttons()
Definition buttons.cpp:22
bool get_button_state_primary() const
Gets the state of the primary button.
Definition buttons.h:47
Class containing all the components of the robot.
Definition robot.h:32
log_source
Definition log_sources.h:12
@ LOG_SOURCE_DEVICE_BUTTONS
Definition log_sources.h:22
Definition battery.cpp:14