diff --git a/boards/dr2501a_g070rb.overlay b/boards/dr2501a_g070rb.overlay index c0f9575..93a4bf1 100644 --- a/boards/dr2501a_g070rb.overlay +++ b/boards/dr2501a_g070rb.overlay @@ -3,16 +3,19 @@ compatible = "led-strip-indicator"; en-gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>; standby { - rgb = <0 0 180>; // Blue + // rgb = <0 0 180>; // Blue + rgb = <0 0 255>; // Blue }; running { - rgb = <0 172 0>; // Green + // rgb = <0 172 0>; // Green + rgb = <0 255 0>; // Green }; // pause { // rgb = <254 254 0>; // interval-ms = <500>; // }; error { - rgb = <160 0 0>; //Red + // rgb = <160 0 0>; //Red + rgb = <255 0 0>; //Red }; }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index df47ad3..5f42d0c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -7,7 +8,10 @@ #include #include "watchdog.hpp" +#include "zephyr/drivers/gpio.h" +#include "zephyr/kernel.h" #include "zpp/fmt.hpp" +#include "zpp/timer.hpp" namespace { auto sensor = DEVICE_DT_GET(DT_NODELABEL(godtek)); auto &pmc = ZPP_DRV_GET(uart_com::Protocal, DT_NODELABEL(pm_protocal)); @@ -15,11 +19,19 @@ auto &led_strip = ZPP_DRV_GET(ledstrip::Indicator, DT_NODELABEL(indicator)); enum Command { kTemp = 0x00, kGetId, kRunningState }; enum RunningState {}; constexpr auto kDeviceIdSize = 20; -enum StatusId : uint8_t { kStandby, kRunning, kPause, kError }; +// enum StatusId : uint8_t { kStandby, kRunning, kPause, kError }; +enum StatusId : uint8_t { kStandby, kRunning, kError }; volatile bool flag{false}; +gpio_dt_spec led_g = GPIO_DT_SPEC_GET(DT_NODELABEL(led_g), gpios); +k_timer led_timer; } // namespace auto main(void) -> int { + gpio_pin_configure_dt(&led_g, GPIO_OUTPUT_ACTIVE); + k_timer_init(&led_timer, [](k_timer* tim) { + gpio_pin_toggle_dt(&led_g); + }, [](k_timer* tim) {}); + k_timer_start(&led_timer, K_NO_WAIT, K_SECONDS(1)); pmc.SetRxCallback(kGetId, [](uart_com::DataType data) -> void { uint8_t buffer[kDeviceIdSize]; auto size = hwinfo_get_device_id(buffer, sizeof(buffer));