1
0

feat(MP/daemon): new header for led and button functionalities

This commit is contained in:
2026-06-05 17:28:53 +02:00
parent 6e19040c50
commit 9f305c4626
2 changed files with 34 additions and 13 deletions

View File

@@ -1,10 +1,24 @@
#ifndef BUTTON_H
#define BUTTON_H
#define GPIO_EXPORT "/sys/class/gpio/export"
#define GPIO_UNEXPORT "/sys/class/gpio/unexport"
#define GPIO_BTN_INCREASE "0"
#define GPIO_BTN_DECREASE "2"
#define GPIO_BTN_MODE "3"
int btn_open(const char* gpio_path, const char* pin);
typedef enum {
BTN_INCREASE,
BTN_DECREASE,
BTN_MODE,
} btn_type_t;
typedef void (*btn_callback_t)();
typedef struct {
int gpio;
btn_callback_t callback;
} btn_t;
btn_t* btn_init(btn_type_t type);
void btn_set_callback(btn_t* btn, btn_callback_t callback);
#endif

View File

@@ -1,14 +1,21 @@
#ifndef CSEL_WORKSPACE_LED_H
#define CSEL_WORKSPACE_LED_H
#ifndef LED_H
#define LED_H
#define GPIO_EXPORT "/sys/class/gpio/export"
#define GPIO_UNEXPORT "/sys/class/gpio/unexport"
#define GPIO_LED_STATUS "10"
#define GPIO_LED_POWER "362"
#define GPIO_LED "/sys/class/gpio/gpio10"
#define LED "10"
typedef enum {
LED_STATUS, // gpioa.10 --> gpio10
LED_POWER, // gpiol.10 --> gpio362
} led_type_t;
int led_open(const char* gpio_path, const char* pin);
void led_on(int led);
void led_off(int led);
typedef struct {
int gpio;
} led_t;
#endif //CSEL_WORKSPACE_LED_H
led_t* led_init(led_type_t type);
void led_on(led_t* led);
void led_off(led_t* led);
void led_toggle(led_t* led);
#endif //LED_H