feat(nodes): adding window status reading

This commit is contained in:
adrien balleyguier
2026-05-05 14:03:46 +02:00
committed by Klagarge
parent 158767deec
commit 35fbe7c488
4 changed files with 23 additions and 25 deletions

11
nodes/app.overlay Normal file
View File

@@ -0,0 +1,11 @@
/* SPDX-License-Identifier: Apache-2.0 */
/ {
buttons{
compatible = "gpio-keys";
window_switch: window_switch {
gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
label = "Window Switch";
};
};
};

View File

@@ -1,23 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0 */
/ {
aliases {
led0 = &led0;
};
leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio9 0 GPIO_ACTIVE_HIGH>;
label = "Green LED 0";
};
};
};
&gpiote130 {
status = "okay";
};
&gpio9 {
status = "okay";
};

View File

@@ -1,9 +1,17 @@
#include "window_status.h"
static const struct gpio_dt_spec window_switch = GPIO_DT_SPEC_GET(DT_NODELABEL(window_switch), gpios);
enum error_code window_init(){
return success;
enum error_code ret = init_failed;
if(gpio_is_ready_dt(&window_switch) && gpio_pin_configure_dt(&window_switch, GPIO_INPUT)){
ret = success;
}else{}
return ret;
}
enum error_code window_get_value(enum window_status* holder){
return 0;
// active high
*holder = (gpio_pin_get_dt(&window_switch) ? open : closed);
return success;
}

View File

@@ -1,6 +1,8 @@
#ifndef WINDOW_STATUS_H
#define WINDOW_STATUS_H
#include <zephyr/drivers/gpio.h>
#include "error_code.h"
enum window_status{