From 141c3b8aeef86c2de7c33acc7015f053029a3a8f Mon Sep 17 00:00:00 2001 From: zhangjing Date: Fri, 27 Mar 2026 22:39:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(app=5Fphotomagnetic):1.main.?= =?UTF-8?q?cpp=20=E6=B7=BB=E5=8A=A0=E5=88=9D=E5=A7=8B=E5=8C=96rgb(?= =?UTF-8?q?=E7=BA=A2=E7=BB=BF=E8=93=9D=E9=97=AA=E5=AE=8C=EF=BC=8C=E8=93=9D?= =?UTF-8?q?=E7=81=AF=E5=B8=B8=E4=BA=AE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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));