🐞 fix(app_photomagnetic):1.main.cpp 添加初始化rgb(红绿蓝闪完,蓝灯常亮)

This commit is contained in:
zhangjing 2026-03-27 22:39:59 +08:00
parent 1f2a92ad04
commit 141c3b8aee

View File

@ -12,6 +12,9 @@
#include "zephyr/kernel.h"
#include "zpp/fmt.hpp"
#include "zpp/timer.hpp"
#include <zephyr/drivers/led_strip.h>
#include <zephyr/sys/printk.h>
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));