This commit is contained in:
2025-08-28 14:58:55 +02:00
parent 80d48eac8a
commit 7cdf5d4682
5 changed files with 113 additions and 13 deletions

View File

@@ -1,10 +1,13 @@
#include <Arduino.h>
#include "appcontext.hpp"
#include "config.h"
#include "light.h"
#include "mqtt.h"
#include "network.h"
#include "ota.h"
#include "pin.h"
#include "statemachine.hpp"
#include "states.hpp"
#include "TaskScheduler.h"
#include "wifimanager.h"
@@ -13,29 +16,38 @@ OTAHandler* otaHandler = nullptr;
Mqtt* mqttClient = nullptr;
Light *light = nullptr;
Task *updateTask = nullptr;
Task *mqttTickTask = nullptr;
Task *mqttCheckConnectionTask = nullptr;
Pin *pinR = new Pin(16, true, true, 5000, 0); // Example pin numbers, adjust as needed
Pin *pinG = new Pin(17, true, true, 5000, 1);
Pin *pinB = new Pin(18, true, true, 5000, 2);
Pin *pinCW = new Pin(19, true, true, 5000, 3);
Pin *pinWW = new Pin(21, true, true, 5000, 4);
Pin *pinR = new Pin(ledPinR, true, true, 5000, 0);
Pin *pinG = new Pin(ledPinG, true, true, 5000, 1);
Pin *pinB = new Pin(ledPinB, true, true, 5000, 2);
Pin *pinCW = new Pin(ledPinCW, true, true, 5000, 3);
Pin *pinWW = new Pin(ledPinWW, true, true, 5000, 4);
Scheduler *scheduler;
AppContext *appContext = new AppContext();
StartState *startState = new StartState(appContext);
StateMachine<maxNumberOfStates> *stateMachine = nullptr;
Scheduler *scheduler = nullptr;
void initializeScheduler();
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Starting Smart RGB ESP32...");
pinR->setLedLevel(0);
pinG->setLedLevel(0);
pinB->setLedLevel(0);
pinCW->setLedLevel(0);
pinWW->setLedLevel(0);
// Serial.begin(115200);
// Serial.println("Starting Smart RGB ESP32...");
stateMachine = new StateMachine<maxNumberOfStates>();
appContext->pinR = pinR;
appContext->pinG = pinG;
appContext->pinB = pinB;
appContext->pinCW = pinCW;
appContext->pinWW = pinWW;
stateMachine->addStateRaw(startState);
stateMachine->setInitialState(StateId::StartState);
network = new Network("smart-rgb");
otaHandler = new OTAHandler("smart-rgb-ota");
network->registerMDNS();