Added Separate Timings for each Relay

The setting is saved on a file in:
/settings/relayTimings.json

Then during bootup, it's read and restored. 
Settings can be set via MQTT command on Topic: 
vesoer/*dev-id*/control/settings/relayTimers
using a json format. 
{ "b1":50, b2...}
where b1 is Bell 1, b2 Bell 2, etc..
This commit is contained in:
2025-01-21 11:42:23 +02:00
parent a33f626dde
commit 84534025f4
5 changed files with 150 additions and 65 deletions

View File

@@ -15,8 +15,8 @@ AsyncMqttClient mqttClient;
class melody_attributes {
public:
uint16_t id; // The (internal) ID of the selected melody. Not specificly used anywhere atm. Might be used later.
std::string name; // Name of the Melody saved. Will be used to read the file: /name.bin
uint16_t speed; // Time to wait per beat. (In Miliseconds)
std::string name = "melody1"; // Name of the Melody saved. Will be used to read the file: /name.bin
uint16_t speed = 500; // Time to wait per beat. (In Miliseconds)
uint32_t duration = 15000; // Total Duration that program will run (In Miliseconds)
uint32_t loop_duration = 0; // Duration of the playback per segment
uint32_t interval = 0; // Indicates the Duration of the Interval between finished segments, IF "inf" is true
@@ -63,9 +63,6 @@ public:
melody_attributes melody;
std::vector<uint16_t> melody_steps;
uint16_t relayMask = 0; // Bitmask indicating which relays to activate
uint8_t relayDurations[16] = {5,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100}; // Deactivation timers for each relay in milliseconds
#include "config.h"
#include "functions.hpp"
#include "MQTT_Message_Handling.hpp"
@@ -109,25 +106,11 @@ void setup()
ConnectWiFi_STA();
delay(1000);
xTaskCreatePinnedToCore(
bellEngine, // Task function
"bellEngine", // Task name
8192, // Stack size
NULL, // Task input parameters
1, // Task priority, be carefull when changing this
&bellEngineHandle, // Task handle, add one if you want control over the task (resume or suspend the task)
1 // Core to run the task on
);
xTaskCreatePinnedToCore(bellEngine,"bellEngine", 8192, NULL, 1, &bellEngineHandle, 1);
xTaskCreatePinnedToCore(durationTimer, "durationTimer", 8192, NULL, 2, NULL, 1);
xTaskCreatePinnedToCore(relayControlTask, "Relay Control Task", 2048, NULL, 2, NULL, 1);
xTaskCreatePinnedToCore(
durationTimer, // Task function
"durationTimer", // Task name
8192, // Stack size
NULL, // Task input parameters
2, // Task priority, be carefull when changing this
NULL, // Task handle, add one if you want control over the task (resume or suspend the task)
1 // Core to run the task on
);
loadRelayTimings();
}