Commit 59a60cb2 authored by 学习的菜鸟's avatar 学习的菜鸟

射击加入了延迟

parent 7866fe0d
......@@ -194,7 +194,9 @@ void DeviceControl::update() {
// 简单的实现:每隔一定时间或阈值触发时发布
// static unsigned long lastSensorPublishTime = 0;
// const unsigned long sensorPublishInterval = 50; // 每 1 秒发布一次传感器数据
if(_shot_count < 6){
return ;
}
// if (millis() - lastSensorPublishTime >= sensorPublishInterval) {
double sensorVoltage = readSensor();
......@@ -203,13 +205,14 @@ void DeviceControl::update() {
if (_mqttManager) {
// 发布 "shoted" 消息
_mqttManager->publishJson("shoted", 1);
Serial.printf("Voltage\n",sensorVoltage);
Serial.print(sensorVoltage);
} else {
Serial.println("MQTTManager not set, cannot publish sensor data.");
}
}
// lastSensorPublishTime = millis();
// }
_shot_count=0;
}
......
......@@ -19,6 +19,8 @@ private:
bool _smoke_index =false;
int _beat_count=0;
int _shot_count=0;
MQTTManager* _mqttManager = nullptr; // MQTT 管理器指针,用于发布传感器数据
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment