Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arduino_bootstrapper
4 changes: 3 additions & 1 deletion include/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#if defined(ARDUINO_ARCH_ESP32)
#define LDR_DIVIDER 4096
#endif
#define SERIAL_SIZE_RX 1500
#define SERIAL_SIZE_RX 2048
#define CONFIG_NUM_PARAMS 20
#define CONFIG_PREFIX_LENGTH 6
// This value must meet the one in Firefly Luciferin
Expand Down Expand Up @@ -105,6 +105,8 @@ extern unsigned long previousMillisLDR;
extern unsigned long lastUdpMsgReceived;
extern unsigned long disconnectionTime;
extern bool disconnectionResetEnable;
extern bool builtInLedStatus;
extern bool resetLedStatus;
extern unsigned long secondsBeforeReset;

extern unsigned long currentMillisCheckConn;
Expand Down
4 changes: 4 additions & 0 deletions include/LedManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class LedManager {

static void setColor(uint8_t inR, uint8_t inG, uint8_t inB);

static void setColorNoSolid(uint8_t inR, uint8_t inG, uint8_t inB);

static void setColorLoop(uint8_t inR, uint8_t inG, uint8_t inB);

static void setNumLed(int numLedFromLuciferin);
Expand All @@ -127,6 +129,8 @@ class LedManager {

void flushSerial();

static void manageBuiltInLed(uint8_t r, uint8_t g, uint8_t b);

};

#endif //GLOW_WORM_LUCIFERIN_LEDMANAGER_H
4 changes: 2 additions & 2 deletions include/Version.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

// AUTO GENERATED FILE, DO NOT EDIT
#ifndef VERSION
#define VERSION "5.15.4"
#define VERSION "5.16.33"
#endif
#ifndef BUILD_TIMESTAMP
#define BUILD_TIMESTAMP "2024-08-02 13:34:16.324757"
#define BUILD_TIMESTAMP "2024-09-19 13:54:35.159175"
#endif

8 changes: 4 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ extra_scripts =
pre:platformio_version_increment/version_increment_pre.py
post:platformio_version_increment/version_increment_post.py
lib_deps =
makuna/NeoPixelBus@2.8.0
bblanchon/ArduinoJson@7.1.0
makuna/NeoPixelBus@2.8.2
bblanchon/ArduinoJson@7.2.0
knolleary/PubSubClient@2.8.0
;https://github.com/Makuna/NeoPixelBus.git#master
lib_extra_dirs = arduino_bootstrapper
Expand Down Expand Up @@ -91,8 +91,8 @@ board_build.filesystem = ${common_env_data.filesystem}
monitor_filters = ${common_env_data.monitor_filters_esp8266}
board_build.f_cpu = ${common_env_data.f_cpu_esp8266}
;build_type = debug
monitor_port = COM4
upload_port = COM4
monitor_port = COM3
upload_port = COM3
;upload_protocol = espota
;upload_port = 192.168.1.52
;upload_flags =
Expand Down
2 changes: 2 additions & 0 deletions src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ unsigned long previousMillisLDR = 0;
unsigned long lastUdpMsgReceived;
unsigned long disconnectionTime;
bool disconnectionResetEnable;
bool builtInLedStatus;
bool resetLedStatus;
// after three minutes, start device reset
unsigned long secondsBeforeReset = 180000;
bool apFileRead;
Expand Down
25 changes: 19 additions & 6 deletions src/GlowWormLuciferin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
#include <FS.h> //this needs to be first, or it all crashes and burns...
#include "GlowWormLuciferin.h"


/**
* Setup function
*/
void setup() {
LedManager::manageBuiltInLed(0, 0, 255);
firmwareVersion = VERSION;
// if fastDisconnectionManagement we need to execute the disconnection callback immediately
fastDisconnectionManagement = true;
Expand All @@ -38,10 +40,7 @@ void setup() {
// Increase the RX Buffer size allows to send bigger messages via Serial in one chunk, increase performance.
Serial.setRxBufferSize(SERIAL_SIZE_RX);
#endif
Serial.begin(baudRateToUse);
//#if defined(ESP8266)
// Serial.setTimeout(10);
//#endif
Serial.begin(baudRateToUse);
Serial.setTimeout(10);
Serial.setDebugOutput(false); // switch off kernel messages when using USBCDC

Expand Down Expand Up @@ -82,14 +81,17 @@ void setup() {
if (!ap.isEmpty() && ap != ERROR && ap.toInt() == 10) {
setApState(11);
LedManager::setColorLoop(0, 255, 0);
LedManager::manageBuiltInLed(0, 255, 0);
} else if (!ap.isEmpty() && ap != ERROR && ap.toInt() == 11) {
setApState(12);
LedManager::setColorLoop(0, 0, 255);
LedManager::manageBuiltInLed(0, 0, 255);
} else if (!ap.isEmpty() && ap != ERROR && ap.toInt() == 12) {
bootstrapManager.littleFsInit();
BootstrapManager::isWifiConfigured();
setApState(13);
LedManager::setColorLoop(255, 75, 0);
LedManager::manageBuiltInLed(255, 75, 0);
bootstrapManager.launchWebServerCustom(false, manageApRoot);
} else if (!ap.isEmpty() && ap != ERROR && ap.toInt() == 13) {
setApState(0);
Expand Down Expand Up @@ -168,7 +170,6 @@ void setup() {
if (!as.isEmpty() && r != ERROR && as.toInt() != -1) {
autoSave = bootstrapManager.readValueFromFile(AUTO_SAVE_FILENAME, F("autosave")).toInt();
}

pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW);

Expand Down Expand Up @@ -198,6 +199,7 @@ void setup() {
}
}
#endif
LedManager::manageBuiltInLed(0, 0, 0);
}

/**
Expand Down Expand Up @@ -280,6 +282,7 @@ void mainLoop() {
#endif
if (!ledManager.led_state) ledManager.led_state = true;
int i = 0;
yield();
int prefixLength = Serial.readBytes((byte *) pre, CONFIG_PREFIX_LENGTH);
bool prefixOk = false;
if (prefixLength == CONFIG_PREFIX_LENGTH) {
Expand All @@ -289,6 +292,7 @@ void mainLoop() {
}
}
if (prefixOk) {
yield();
int configLen = Serial.readBytes((byte *) config, CONFIG_NUM_PARAMS);
if (configLen == CONFIG_NUM_PARAMS) {
hi = config[i++];
Expand Down Expand Up @@ -438,6 +442,7 @@ void mainLoop() {
rlenChunk = LED_BUFF;
}
// Serial buffer is read with a single block using Serial.readBytes()
yield();
int rlen = Serial.readBytes((byte *) ledBuffer, rlenChunk);
if (rlenChunk == rlen) {
i = 0;
Expand Down Expand Up @@ -631,7 +636,15 @@ void loop() {
}
}
}

if ((builtInLedStatus || resetLedStatus) && wifiReconnectAttemp == 0 && mqttReconnectAttemp == 0) {
builtInLedStatus = false;
resetLedStatus = false;
LedManager::setColorNoSolid(0, 0, 0);
disconnectionTime = currentMillisMainLoop;
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
LedManager::manageBuiltInLed(0, 0, 0);
#endif
}
}


22 changes: 22 additions & 0 deletions src/LedManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,16 @@ void LedManager::setColor(uint8_t inR, uint8_t inG, uint8_t inB) {
if (inR == 0 && inG == 0 && inB == 0) {
effect = Effect::solid;
}
setColorNoSolid(inR, inG, inB);
}

/**
* Set led strip color
* @param inR red color
* @param inG green color
* @param inB blu color
*/
void LedManager::setColorNoSolid(uint8_t inR, uint8_t inG, uint8_t inB) {
if (effect != Effect::GlowWorm && effect != Effect::GlowWormWifi) {
for (int i = 0; i < ledManager.dynamicLedNum; i++) {
ledManager.setPixelColor(i, inR, inG, inB);
Expand Down Expand Up @@ -814,3 +824,15 @@ void LedManager::setWhiteTemp(int wt) {
BootstrapManager::writeToLittleFS(whiteTempDoc, WHITE_TEMP_FILENAME);
delay(20);
}

/**
* Manage built in LED in GRB color order
* @param r red
* @param g green
* @param b blu
*/
void LedManager::manageBuiltInLed(uint8_t r, uint8_t g, uint8_t b) {
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
neopixelWrite(LED_BUILTIN, r, g, b);
#endif
}
Loading