This commit is contained in:
cxh 2025-06-05 10:57:18 +08:00
parent 3f498e2a9e
commit 2a3bcd312b
2 changed files with 9 additions and 4 deletions

View File

@ -7,3 +7,5 @@ username = "zxwl"
password = "zxwl1234@"
topic = "/zxwl/vehicle/V060001/info"
qos = 1
[led]
num = 5

View File

@ -9,6 +9,8 @@
using namespace toml;
int led_num = 0;
class BreathingLight
{
public:
@ -18,7 +20,7 @@ public:
{
LedCommand cmd;
cmd.setColor(brightness, brightness, 0); // 黄色
cmd.setExtCount(1);
cmd.setExtCount(led_num);
auto packet = cmd.serialize();
if (!serial.writeData(packet.data(), packet.size()))
{
@ -56,7 +58,7 @@ void alwaysRed(SerialPort &serial)
{
LedCommand cmd;
cmd.setColor(255, 0, 0); // 红色
cmd.setExtCount(1);
cmd.setExtCount(led_num);
auto packet = cmd.serialize();
std::cout << "发送常红数据包:";
@ -73,7 +75,7 @@ void alwaysGreen(SerialPort &serial)
{
LedCommand cmd;
cmd.setColor(0, 255, 0); // 红色
cmd.setExtCount(1);
cmd.setExtCount(led_num);
auto packet = cmd.serialize();
std::cout << "发送常红数据包:";
@ -103,6 +105,7 @@ int main()
}
port = toml::find<std::string>(data, "serial", "port");
baudrate = toml::find<int>(data, "serial", "baudrate");
led_num = toml::find<int>(data, "led", "num");
}
catch (const std::exception &e)
{