Bootloop fix for ALT 4LD.

This commit is contained in:
Blaz Kristan 2022-01-11 21:58:05 +01:00
parent 06ded0098c
commit 6990986d9f
3 changed files with 30 additions and 24 deletions

View File

@ -37,7 +37,7 @@ class UsermodTemperature : public Usermod {
// used to determine when we can read the sensors temperature // used to determine when we can read the sensors temperature
// we have to wait at least 93.75 ms after requestTemperatures() is called // we have to wait at least 93.75 ms after requestTemperatures() is called
unsigned long lastTemperaturesRequest; unsigned long lastTemperaturesRequest;
float temperature = -127.0f; // default to -127, DS18B20 only goes down to -50C float temperature;
// indicates requestTemperatures has been called but the sensor measurement is not complete // indicates requestTemperatures has been called but the sensor measurement is not complete
bool waitingForConversion = false; bool waitingForConversion = false;
// flag set at startup if DS18B20 sensor not found, avoids trying to keep getting // flag set at startup if DS18B20 sensor not found, avoids trying to keep getting
@ -136,6 +136,7 @@ class UsermodTemperature : public Usermod {
void setup() { void setup() {
int retries = 10; int retries = 10;
sensorFound = 0; sensorFound = 0;
temperature = -127.0f; // default to -127, DS18B20 only goes down to -50C
if (enabled) { if (enabled) {
// config says we are enabled // config says we are enabled
DEBUG_PRINTLN(F("Allocating temperature pin...")); DEBUG_PRINTLN(F("Allocating temperature pin..."));
@ -159,7 +160,7 @@ class UsermodTemperature : public Usermod {
} }
void loop() { void loop() {
if (!enabled || strip.isUpdating()) return; if (!enabled || !sensorFound || strip.isUpdating()) return;
unsigned long now = millis(); unsigned long now = millis();

View File

@ -139,8 +139,8 @@ class FourLineDisplayUsermod : public Usermod {
// Next variables hold the previous known values to determine if redraw is // Next variables hold the previous known values to determine if redraw is
// required. // required.
String knownSsid = ""; String knownSsid = apSSID;
IPAddress knownIp; IPAddress knownIp = IPAddress(4, 3, 2, 1);
uint8_t knownBrightness = 0; uint8_t knownBrightness = 0;
uint8_t knownEffectSpeed = 0; uint8_t knownEffectSpeed = 0;
uint8_t knownEffectIntensity = 0; uint8_t knownEffectIntensity = 0;
@ -161,8 +161,8 @@ class FourLineDisplayUsermod : public Usermod {
unsigned long overlayUntil = 0; unsigned long overlayUntil = 0;
// Set to 2 or 3 to mark lines 2 or 3. Other values ignored. // Set to 2 or 3 to mark lines 2 or 3. Other values ignored.
byte markLineNum = 0; byte markLineNum = 255;
byte markColNum = 0; byte markColNum = 255;
// strings to reduce flash memory usage (used more than twice) // strings to reduce flash memory usage (used more than twice)
static const char _name[]; static const char _name[];
@ -264,8 +264,8 @@ class FourLineDisplayUsermod : public Usermod {
// gets called every time WiFi is (re-)connected. Initialize own network // gets called every time WiFi is (re-)connected. Initialize own network
// interfaces here // interfaces here
void connected() { void connected() {
knownSsid = apActive ? apSSID : WiFi.SSID(); //apActive ? WiFi.softAPSSID() : knownSsid = WiFi.SSID(); //apActive ? apSSID : WiFi.SSID(); //apActive ? WiFi.softAPSSID() :
knownIp = apActive ? IPAddress(4, 3, 2, 1) : Network.localIP(); knownIp = Network.localIP(); //apActive ? IPAddress(4, 3, 2, 1) : Network.localIP();
networkOverlay(PSTR("NETWORK INFO"),7000); networkOverlay(PSTR("NETWORK INFO"),7000);
} }
@ -358,6 +358,12 @@ class FourLineDisplayUsermod : public Usermod {
} }
} }
if (apActive && WLED_WIFI_CONFIGURED && now<15000) {
knownSsid = apSSID;
networkOverlay(PSTR("NETWORK INFO"),30000);
return;
}
// Check if values which are shown on display changed from the last time. // Check if values which are shown on display changed from the last time.
if (forceRedraw) { if (forceRedraw) {
needRedraw = true; needRedraw = true;
@ -407,7 +413,7 @@ class FourLineDisplayUsermod : public Usermod {
// and turn it back on if it changed. // and turn it back on if it changed.
clear(); clear();
sleepOrClock(true); sleepOrClock(true);
} else if (displayTurnedOff && clockMode) { } else if (displayTurnedOff && ntpEnabled) {
showTime(); showTime();
} }
return; return;
@ -489,8 +495,8 @@ class FourLineDisplayUsermod : public Usermod {
drawGlyph( 2, 0, 1, u8x8_4LineDisplay_WLED_icons_1x1); //brightness icon drawGlyph( 2, 0, 1, u8x8_4LineDisplay_WLED_icons_1x1); //brightness icon
drawGlyph( 6, 0, 2, u8x8_4LineDisplay_WLED_icons_1x1); //speed icon drawGlyph( 6, 0, 2, u8x8_4LineDisplay_WLED_icons_1x1); //speed icon
drawGlyph(10, 0, 3, u8x8_4LineDisplay_WLED_icons_1x1); //intensity icon drawGlyph(10, 0, 3, u8x8_4LineDisplay_WLED_icons_1x1); //intensity icon
if (markLineNum!=2) drawGlyph(0, 2, 4, u8x8_4LineDisplay_WLED_icons_1x1); //palette icon drawGlyph(15, 2, 4, u8x8_4LineDisplay_WLED_icons_1x1); //palette icon
if (markLineNum!=3) drawGlyph(0, 3, 5, u8x8_4LineDisplay_WLED_icons_1x1); //effect icon drawGlyph(15, 3, 5, u8x8_4LineDisplay_WLED_icons_1x1); //effect icon
} }
} }
@ -500,7 +506,7 @@ class FourLineDisplayUsermod : public Usermod {
drawGlyph(col, row, (wificonnected ? 20 : 0), u8x8_4LineDisplay_WLED_icons_1x1, true); // wifi icon drawGlyph(col, row, (wificonnected ? 20 : 0), u8x8_4LineDisplay_WLED_icons_1x1, true); // wifi icon
if (lineHeight==2) { col--; } else { row++; } if (lineHeight==2) { col--; } else { row++; }
drawGlyph(col, row, (bri > 0 ? 9 : 0), u8x8_4LineDisplay_WLED_icons_1x1, true); // power icon drawGlyph(col, row, (bri > 0 ? 9 : 0), u8x8_4LineDisplay_WLED_icons_1x1, true); // power icon
if (lineHeight==2) { col--; } else { row++; } if (lineHeight==2) { col--; } else { row++; col = row = 0; }
drawGlyph(col, row, (nightlightActive ? 6 : 0), u8x8_4LineDisplay_WLED_icons_1x1, true); // moon icon for nighlight mode drawGlyph(col, row, (nightlightActive ? 6 : 0), u8x8_4LineDisplay_WLED_icons_1x1, true); // moon icon for nighlight mode
} }
@ -693,17 +699,17 @@ class FourLineDisplayUsermod : public Usermod {
} }
void networkOverlay(const char* line1, long showHowLong) { void networkOverlay(const char* line1, long showHowLong) {
String line;
// Turn the display back on // Turn the display back on
if (!wakeDisplay()) clear(); if (!wakeDisplay()) clear();
// Print the overlay // Print the overlay
if (line1) { if (line1) {
String l1 = line1; line = line1;
l1.trim(); center(line, getCols());
center(l1, getCols()); drawString(0, 0, line.c_str());
drawString(0, 0, l1.c_str());
} }
// Second row with Wifi name // Second row with Wifi name
String line = knownSsid.substring(0, getCols() > 1 ? getCols() - 2 : 0); line = knownSsid.substring(0, getCols() > 1 ? getCols() - 2 : 0);
if (line.length() < getCols()) center(line, getCols()); if (line.length() < getCols()) center(line, getCols());
drawString(0, lineHeight, line.c_str()); drawString(0, lineHeight, line.c_str());
// Print `~` char to indicate that SSID is longer, than our display // Print `~` char to indicate that SSID is longer, than our display
@ -714,15 +720,14 @@ class FourLineDisplayUsermod : public Usermod {
line = knownIp.toString(); line = knownIp.toString();
center(line, getCols()); center(line, getCols());
drawString(0, lineHeight*2, line.c_str()); drawString(0, lineHeight*2, line.c_str());
line = "";
if (apActive) { if (apActive) {
line = apPass; line = apPass;
center(line, getCols()); } else if (strcmp(serverDescription, "WLED") != 0) {
drawString(0, lineHeight*3, line.c_str());
} else if (strcmp(serverDescription, PSTR("WLED")) != 0) {
line = serverDescription; line = serverDescription;
}
center(line, getCols()); center(line, getCols());
drawString(0, lineHeight*3, line.c_str()); drawString(0, lineHeight*3, line.c_str());
}
overlayUntil = millis() + showHowLong; overlayUntil = millis() + showHowLong;
} }
@ -733,7 +738,7 @@ class FourLineDisplayUsermod : public Usermod {
void sleepOrClock(bool enabled) { void sleepOrClock(bool enabled) {
if (enabled) { if (enabled) {
displayTurnedOff = true; displayTurnedOff = true;
if (clockMode) { if (clockMode && ntpEnabled) {
knownMinute = knownHour = 99; knownMinute = knownHour = 99;
showTime(); showTime();
} else } else

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2201101 #define VERSION 2201111
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG