change name to inputs
This commit is contained in:
parent
c82c9adf32
commit
8bc5a982d1
@ -1,7 +1,7 @@
|
|||||||
#include "blk_box.h"
|
#include "blk_box.h"
|
||||||
|
|
||||||
#include "blk_box_drivers/i2c.h"
|
#include "blk_box_drivers/i2c.h"
|
||||||
#include "blk_box_drivers/expander.hpp"
|
#include "blk_box_drivers/inputs.hpp"
|
||||||
|
|
||||||
void init_blk_box(BlkBoxInitConfig cfg) {
|
void init_blk_box(BlkBoxInitConfig cfg) {
|
||||||
init_main_i2c();
|
init_main_i2c();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
set(SOURCES
|
set(SOURCES
|
||||||
"expander.cpp"
|
"inputs.cpp"
|
||||||
"i2c.cpp"
|
"i2c.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "blk_box_drivers/expander.hpp"
|
#include "blk_box_drivers/inputs.hpp"
|
||||||
|
|
||||||
#include "pins.h"
|
#include "pins.h"
|
||||||
#include "blk_box_drivers/i2c.h"
|
#include "blk_box_drivers/i2c.h"
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
|
|
||||||
static const char *TAG = "EXPANDER";
|
static const char *TAG = "INPUTS";
|
||||||
|
|
||||||
static TaskHandle_t expander_task_handle = NULL;
|
static TaskHandle_t expander_task_handle = NULL;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class ExpanderPeripheral {
|
|||||||
// or even make this class hidden
|
// or even make this class hidden
|
||||||
public:
|
public:
|
||||||
SemaphoreHandle_t state_mutex;
|
SemaphoreHandle_t state_mutex;
|
||||||
ExpanderState state;
|
InputsState state;
|
||||||
|
|
||||||
// channels
|
// channels
|
||||||
QueueHandle_t button_press_events;
|
QueueHandle_t button_press_events;
|
||||||
@ -323,9 +323,9 @@ void InputsController::clear_all_events() {
|
|||||||
xQueueReset(expander_peripheral_singleton.keypad_release_events);
|
xQueueReset(expander_peripheral_singleton.keypad_release_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpanderState InputsController::get_input_state() {
|
InputsState InputsController::get_input_state() {
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
||||||
ExpanderState state_copy = expander_peripheral_singleton.state;
|
InputsState state_copy = expander_peripheral_singleton.state;
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
||||||
return state_copy;
|
return state_copy;
|
||||||
}
|
}
|
||||||
@ -14,3 +14,5 @@ dependencies:
|
|||||||
# # `public` flag doesn't have an effect dependencies of the `main` component.
|
# # `public` flag doesn't have an effect dependencies of the `main` component.
|
||||||
# # All dependencies of `main` are public by default.
|
# # All dependencies of `main` are public by default.
|
||||||
# public: true
|
# public: true
|
||||||
|
espressif/led_strip: ^3.0.3
|
||||||
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef EXPANDER_H
|
#ifndef INPUTS_H
|
||||||
#define EXPANDER_H
|
#define INPUTS_H
|
||||||
|
|
||||||
#include "blk_box_drivers/i2c.h"
|
#include "blk_box_drivers/i2c.h"
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
@ -207,7 +207,7 @@ static_assert(sizeof(ButtonOrSwitch) == 1);
|
|||||||
|
|
||||||
|
|
||||||
/// @brief The state of the bottom half of the box.
|
/// @brief The state of the bottom half of the box.
|
||||||
struct ExpanderState {
|
struct InputsState {
|
||||||
/// The touch state of the switches in the lower 4 bits.
|
/// The touch state of the switches in the lower 4 bits.
|
||||||
/// The touch pad state in bit 4.
|
/// The touch pad state in bit 4.
|
||||||
uint8_t touch_state;
|
uint8_t touch_state;
|
||||||
@ -233,14 +233,14 @@ struct ExpanderState {
|
|||||||
/// The RFID card that was presented last.
|
/// The RFID card that was presented last.
|
||||||
uint32_t rfid_state;
|
uint32_t rfid_state;
|
||||||
|
|
||||||
ExpanderState() : touch_state(0), button_state(0), switch_state(0), keypad_state(0), hal_sense(0), close_hal_sense(0), hal(0), close_hal(0), rfid_state(0) {}
|
InputsState() : touch_state(0), button_state(0), switch_state(0), keypad_state(0), hal_sense(0), close_hal_sense(0), hal(0), close_hal(0), rfid_state(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputsController {
|
class InputsController {
|
||||||
public:
|
public:
|
||||||
static void clear_all_events();
|
static void clear_all_events();
|
||||||
|
|
||||||
static ExpanderState get_input_state();
|
static InputsState get_input_state();
|
||||||
|
|
||||||
static bool has_button_press();
|
static bool has_button_press();
|
||||||
static std::optional<Button> get_button_press();
|
static std::optional<Button> get_button_press();
|
||||||
@ -273,4 +273,4 @@ public:
|
|||||||
// TODO: impl and add the hal and RFID stuff
|
// TODO: impl and add the hal and RFID stuff
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXPANDER_H
|
#endif // INPUTS_H
|
||||||
Loading…
Reference in New Issue
Block a user