forked from EmbeddedTeam/app_photomagnetic
change led color and add flashing of led
This commit is contained in:
parent
0c6cfe4571
commit
7c49416c68
@ -3,16 +3,19 @@
|
|||||||
compatible = "led-strip-indicator";
|
compatible = "led-strip-indicator";
|
||||||
en-gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>;
|
en-gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>;
|
||||||
standby {
|
standby {
|
||||||
rgb = <0 0 180>; // Blue
|
// rgb = <0 0 180>; // Blue
|
||||||
|
rgb = <0 0 255>; // Blue
|
||||||
};
|
};
|
||||||
running {
|
running {
|
||||||
rgb = <0 172 0>; // Green
|
// rgb = <0 172 0>; // Green
|
||||||
|
rgb = <0 255 0>; // Green
|
||||||
};
|
};
|
||||||
// pause {
|
// pause {
|
||||||
// rgb = <254 254 0>;
|
// rgb = <254 254 0>;
|
||||||
// interval-ms = <500>;
|
// interval-ms = <500>;
|
||||||
// };
|
// };
|
||||||
error {
|
error {
|
||||||
rgb = <160 0 0>; //Red
|
// rgb = <160 0 0>; //Red
|
||||||
|
rgb = <255 0 0>; //Red
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
14
src/main.cpp
14
src/main.cpp
@ -1,3 +1,4 @@
|
|||||||
|
#include <ctime>
|
||||||
#include <etl/vector.h>
|
#include <etl/vector.h>
|
||||||
#include <zephyr/drivers/hwinfo.h>
|
#include <zephyr/drivers/hwinfo.h>
|
||||||
#include <zephyr/drivers/sensor.h>
|
#include <zephyr/drivers/sensor.h>
|
||||||
@ -7,7 +8,10 @@
|
|||||||
#include <zpp/device.hpp>
|
#include <zpp/device.hpp>
|
||||||
|
|
||||||
#include "watchdog.hpp"
|
#include "watchdog.hpp"
|
||||||
|
#include "zephyr/drivers/gpio.h"
|
||||||
|
#include "zephyr/kernel.h"
|
||||||
#include "zpp/fmt.hpp"
|
#include "zpp/fmt.hpp"
|
||||||
|
#include "zpp/timer.hpp"
|
||||||
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));
|
||||||
@ -15,11 +19,19 @@ auto &led_strip = ZPP_DRV_GET(ledstrip::Indicator, DT_NODELABEL(indicator));
|
|||||||
enum Command { kTemp = 0x00, kGetId, kRunningState };
|
enum Command { kTemp = 0x00, kGetId, kRunningState };
|
||||||
enum RunningState {};
|
enum RunningState {};
|
||||||
constexpr auto kDeviceIdSize = 20;
|
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};
|
volatile bool flag{false};
|
||||||
|
gpio_dt_spec led_g = GPIO_DT_SPEC_GET(DT_NODELABEL(led_g), gpios);
|
||||||
|
k_timer led_timer;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
auto main(void) -> int {
|
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 {
|
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));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user