Compare commits

...

1 Commits

View File

@ -12,6 +12,9 @@
#include "zephyr/kernel.h" #include "zephyr/kernel.h"
#include "zpp/fmt.hpp" #include "zpp/fmt.hpp"
#include "zpp/timer.hpp" #include "zpp/timer.hpp"
#include <zephyr/drivers/led_strip.h>
#include <zephyr/sys/printk.h>
namespace { namespace {
auto sensor = DEVICE_DT_GET(DT_NODELABEL(godtek)); auto sensor = DEVICE_DT_GET(DT_NODELABEL(godtek));
auto &pmc = ZPP_DRV_GET(uart_com::Protocal, DT_NODELABEL(pm_protocal)); 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; k_timer led_timer;
} // namespace } // 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 { auto main(void) -> int {
gpio_pin_configure_dt(&led_g, GPIO_OUTPUT_ACTIVE); gpio_pin_configure_dt(&led_g, GPIO_OUTPUT_ACTIVE);
k_timer_init(&led_timer, [](k_timer* tim) { k_timer_init(&led_timer, [](k_timer* tim) {
gpio_pin_toggle_dt(&led_g); gpio_pin_toggle_dt(&led_g);
}, [](k_timer* tim) {}); }, [](k_timer* tim) {});
k_timer_start(&led_timer, K_NO_WAIT, K_SECONDS(1)); k_timer_start(&led_timer, K_NO_WAIT, K_SECONDS(1));
rgb_init();
pmc.SetRxCallback(kGetId, [](uart_com::DataType data) -> void { pmc.SetRxCallback(kGetId, [](uart_com::DataType data) -> void {
uint8_t buffer[kDeviceIdSize]; uint8_t buffer[kDeviceIdSize];
auto size = hwinfo_get_device_id(buffer, sizeof(buffer)); auto size = hwinfo_get_device_id(buffer, sizeof(buffer));