Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
/**
* @file main.cpp
* @brief Main Entry Point
* @author Jeevan Sanchez
* @date 2026-07-18
*
* HOMECTRL
*/
#include <Arduino.h>
#include "config.hpp"
#include "test.hpp"
#include "Dashboard.hpp"
extern CRGB rgb_leds[NUM_LEDS];
bool menuShown = false;
Controller state;
HTTPServer http(state);
bool dashboardRunning = false;
void displayMenu()
{
Serial.println("\n--- homectrl ---");
Serial.println("[SPACE] launch dashboard");
Serial.println(" [t] : launch test bench");
Serial.println(" [s] : scan I2C bus");
Serial.println("------------------------");
}
void runTaskSpace()
{
Serial.println("\n>> ---launching dashboard");
run_dashboard();
}
void runTaskT()
{
Serial.println("\n>> ---launching test bench");
run_test_bench();
}
void runTaskS()
{
Serial.println("\n>> ---scanning I2C bus");
scanI2C();
delay(1000);
}
void setup()
{
Serial.begin(115200);
while (!Serial && millis() < 4000)
{
delay(10);
}
Serial.println("\n==============================");
Serial.println("homectrl ---initializing");
pinMode(Pins::Indicators::DBG_LED, OUTPUT);
pinMode(Pins::Indicators::WIFI_LED, OUTPUT);
ledcAttach(Pins::Indicators::BUZZ_EN, PWM_FREQ, PWM_RES);
ledcWrite(Pins::Indicators::BUZZ_EN, 0);
FastLED.addLeds<WS2812B, Pins::Indicators::RGB_LED, GRB>(rgb_leds, NUM_LEDS);
FastLED.setBrightness(64);
rgb_leds[0] = CRGB::Green;
FastLED.show();
led_startup();
displayMenu();
}
void loop()
{
if (blinksRemaining > 0)
{
blinkP(activeBlinkPin, blinkCount);
}
scheduler.update(state);
if (dashboardRunning)
{
http.update(state);
}
if (!menuShown && millis() > 5000)
{
displayMenu();
menuShown = true;
}
if (Serial.available() > 0)
{
char choice = Serial.read();
menuShown = true;
switch (choice)
{
case 't':
case 'T':
runTaskT();
displayMenu();
break;
case 's':
case 'S':
runTaskS();
displayMenu();
break;
case 'm':
case 'M':
displayMenu();
break;
case ' ':
runTaskSpace();
break;
case '\n':
case '\r':
break;
default:
break;
}
}
}
04fc3be0cThis file is pinned to the selected release. Download the original to open it in your design tool.