diff --git a/src/main.cpp b/src/main.cpp index ccc0a35..c4b6130 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,9 @@ #include "zephyr/kernel.h" #include "zpp/fmt.hpp" #include "zpp/timer.hpp" +#include +#include + namespace { auto sensor = DEVICE_DT_GET(DT_NODELABEL(godtek)); auto &pmc = ZPP_DRV_GET(uart_com::Protocal, DT_NODELABEL(pm_protocal)); @@ -25,12 +28,34 @@ gpio_dt_spec led_g = GPIO_DT_SPEC_GET(DT_NODELABEL(led_g), gpios); k_timer led_timer; } // namespace +const led_rgb red{255, 0, 0}; +const led_rgb green{0, 255, 0}; +const led_rgb blue{0, 0, 255}; + +auto rgb_init(void)->int{ + led_strip.TurnOn(red); + k_msleep(10); + led_strip.TurnOff(); + + led_strip.TurnOn(green); + k_msleep(10); + led_strip.TurnOff(); + + led_strip.TurnOn(blue); // 常亮 + // k_msleep(10); + // led_strip.TurnOff(); + return 0; +} + 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)); + + rgb_init(); + pmc.SetRxCallback(kGetId, [](uart_com::DataType data) -> void { uint8_t buffer[kDeviceIdSize]; auto size = hwinfo_get_device_id(buffer, sizeof(buffer));