From 2a3bcd312bdcd1ee9c2a38ed448b35239d9fbd16 Mon Sep 17 00:00:00 2001 From: cxh Date: Thu, 5 Jun 2025 10:57:18 +0800 Subject: [PATCH] temp --- config/config.toml | 4 +++- src/main.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config/config.toml b/config/config.toml index ea0c870..102a2cb 100644 --- a/config/config.toml +++ b/config/config.toml @@ -6,4 +6,6 @@ host = "192.168.4.196:11883" username = "zxwl" password = "zxwl1234@" topic = "/zxwl/vehicle/V060001/info" -qos = 1 \ No newline at end of file +qos = 1 +[led] +num = 5 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 1374a2a..8355502 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(data, "serial", "port"); baudrate = toml::find(data, "serial", "baudrate"); + led_num = toml::find(data, "led", "num"); } catch (const std::exception &e) {