mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 23:27:49 +01:00
41 lines
742 B
C++
41 lines
742 B
C++
//
|
|
// Created by Stepan Usatiuk on 02.03.2025.
|
|
//
|
|
|
|
#ifndef BUTTONS_HPP
|
|
#define BUTTONS_HPP
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
|
|
typedef enum {
|
|
BTN_START = 1 << 1,
|
|
BTN_DOWN = 1 << 6,
|
|
BTN_SELECT = 1 << 0,
|
|
BTN_LEFT = 1 << 7,
|
|
BTN_UP = 1 << 5,
|
|
BTN_B = 1 << 2,
|
|
BTN_RIGHT = 1 << 4,
|
|
BTN_A = 1 << 3,
|
|
} btn_num;
|
|
|
|
class Buttons {
|
|
public:
|
|
static Buttons& get();
|
|
void pooler(); // FIXME:
|
|
uint8_t get_pressed();
|
|
void install_isr();
|
|
void register_listener(TaskHandle_t task);
|
|
|
|
TaskHandle_t _pooler_task;
|
|
|
|
private:
|
|
Buttons();
|
|
|
|
volatile uint8_t _current;
|
|
volatile TaskHandle_t _listener = nullptr;
|
|
};
|
|
|
|
|
|
#endif // BUTTONS_HPP
|