Skip to content

Commit

Permalink
first boot wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
acvigue committed Jul 22, 2023
1 parent 78ae054 commit b8671a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/RdLedStrip/LedStrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ LedStrip::LedStrip(ConfigBase& ledNvValues) : _ledNvValues(ledNvValues) {
CRGBW LedStrip::getRGBWFromRGB(CRGB rgb) {
// Reference, currently set to warm light (2700-3000 (2850k)):
// https://andi-siess.de/rgb-to-color-temperature/
const uint8_t kWhiteRedChannel = 255;
const uint8_t kWhiteRedChannel = 176;
const uint8_t kWhiteGreenChannel = 176;
const uint8_t kWhiteBlueChannel = 97;

Expand Down
30 changes: 25 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
const char* systemType = "Tranquil";

// System version
const char* systemVersion = "4.2.3";
const char* systemVersion = "4.2.5";

// Build date
const char* buildDate = __DATE__;
Expand All @@ -63,6 +63,7 @@ const char* buildTime = __TIME__;
// Config
#include "ConfigFile.h"
#include "ConfigNVS.h"
#include "RobotConfigurations.h"

// WiFi Manager
#include "WiFiManager.h"
Expand Down Expand Up @@ -134,7 +135,8 @@ WebServer webServer(securityConfig);

// REST API System
#include "RestAPISystem.h"
RestAPISystem restAPISystem(wifiManager, wireGuardManager, otaUpdate, fileManager, ntpClient, commandScheduler, hwConfig, tranquilConfig, securityConfig, systemType, systemVersion);
RestAPISystem restAPISystem(wifiManager, wireGuardManager, otaUpdate, fileManager, ntpClient, commandScheduler, hwConfig, tranquilConfig,
securityConfig, systemType, systemVersion);

// Config for LED Strip
ConfigNVS ledStripConfig("ledStrip", 200);
Expand Down Expand Up @@ -182,6 +184,24 @@ void setup() {
// Robot config
robotConfig.setup();

if (robotConfig.getConfigString().equals("{}")) {
String defaultConfigType = RdJson::getString("defaultRobotType", "TranquilSmall", hwConfigJSON);
Log.infoln("Robot config empty, initializing to %s", defaultConfigType.c_str());

RobotConfigurations configs;
const char* newRobotConfig = configs.getConfig(defaultConfigType.c_str());
if(strcmp(newRobotConfig, "{}") != 0) {
robotConfig.setConfigData(newRobotConfig);
robotConfig.writeConfig();
Log.infoln("New config: %s", robotConfig.getConfigCStrPtr());
Log.infoln("Set default robot config, restarting...");
esp_restart();
} else {
Log.errorln("Couldn't get default robot config!!");
while(1) {}
}
}

// WiFi Config
wifiConfig.setup();

Expand All @@ -203,7 +223,7 @@ void setup() {
// Security config
securityConfig.setup();

//Scheduler config
// Scheduler config
schedulerConfig.setup();

// WiFi Manager
Expand Down Expand Up @@ -272,10 +292,10 @@ void loop() {
String newStatus;
_workManager.queueIsEmpty();
_workManager.queryStatus(newStatus);
webServer.webSocketSend((uint8_t *) newStatus.c_str(), newStatus.length());
webServer.webSocketSend((uint8_t*)newStatus.c_str(), newStatus.length());
webServer.sendAsyncEvent(newStatus.c_str(), "status");
}

commandScheduler.service();
_workManager.service();
_robotController.service();
Expand Down

0 comments on commit b8671a6

Please sign in to comment.