organize pin_control
This commit is contained in:
parent
25df6dae36
commit
3564d79100
|
@ -5,10 +5,6 @@ int init_gpio();
|
||||||
|
|
||||||
void cleanup_gpio();
|
void cleanup_gpio();
|
||||||
|
|
||||||
int set_pin_state(int pin, int state);
|
|
||||||
|
|
||||||
int read_button(int pin);
|
|
||||||
|
|
||||||
int turn_on_pin(int pin);
|
int turn_on_pin(int pin);
|
||||||
|
|
||||||
int turn_off_pin(int pin);
|
int turn_off_pin(int pin);
|
||||||
|
|
|
@ -22,7 +22,7 @@ void cleanup_gpio() {
|
||||||
gpiod_chip_close(chip);
|
gpiod_chip_close(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_pin_state(int pin, int state) {
|
static int set_pin_state(int pin, int state) {
|
||||||
// https://libgpiod-dlang.dpldocs.info/gpiod.gpiod_chip_get_line.html
|
// https://libgpiod-dlang.dpldocs.info/gpiod.gpiod_chip_get_line.html
|
||||||
struct gpiod_line *line = gpiod_chip_get_line(chip, pin); // this may need an offset
|
struct gpiod_line *line = gpiod_chip_get_line(chip, pin); // this may need an offset
|
||||||
if (!line) {
|
if (!line) {
|
||||||
|
@ -73,7 +73,7 @@ int turn_off_all_pins() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int button_presssed(int event, unsigned int pin, const struct timespec * timestamp, void *data) {
|
static int button_presssed(int event, unsigned int pin, const struct timespec * timestamp, void *data) {
|
||||||
(void) event;
|
(void) event;
|
||||||
(void) timestamp;
|
(void) timestamp;
|
||||||
* (int *) data = (int) pin;
|
* (int *) data = (int) pin;
|
||||||
|
|
Loading…
Reference in a new issue