4LD refresh task.
Scrolling text improvement. LED settings bugfix. Audioreactive disabled by default.
This commit is contained in:
parent
d8b7cfb36b
commit
e0a954caa2
@ -415,7 +415,7 @@ class AudioReactive : public Usermod {
|
|||||||
WiFiUDP fftUdp;
|
WiFiUDP fftUdp;
|
||||||
|
|
||||||
// set your config variables to their boot default value (this can also be done in readFromConfig() or a constructor if you prefer)
|
// set your config variables to their boot default value (this can also be done in readFromConfig() or a constructor if you prefer)
|
||||||
bool enabled = true;
|
bool enabled = false;
|
||||||
bool initDone = false;
|
bool initDone = false;
|
||||||
|
|
||||||
const uint16_t delayMs = 10; // I don't want to sample too often and overload WLED
|
const uint16_t delayMs = 10; // I don't want to sample too often and overload WLED
|
||||||
|
@ -105,6 +105,7 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
|
|
||||||
static FourLineDisplayUsermod *instance;
|
static FourLineDisplayUsermod *instance;
|
||||||
bool initDone = false;
|
bool initDone = false;
|
||||||
|
volatile bool drawing = false;
|
||||||
|
|
||||||
// HW interface & configuration
|
// HW interface & configuration
|
||||||
U8X8 *u8x8 = nullptr; // pointer to U8X8 display object
|
U8X8 *u8x8 = nullptr; // pointer to U8X8 display object
|
||||||
@ -397,6 +398,8 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (drawing && millis()-now < 250) delay(1); // wait if someone else is drawing
|
||||||
|
|
||||||
if (apActive && WLED_WIFI_CONFIGURED && now<15000) {
|
if (apActive && WLED_WIFI_CONFIGURED && now<15000) {
|
||||||
knownSsid = apSSID;
|
knownSsid = apSSID;
|
||||||
networkOverlay(PSTR("NETWORK INFO"),30000);
|
networkOverlay(PSTR("NETWORK INFO"),30000);
|
||||||
@ -632,10 +635,14 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
bool wakeDisplay() {
|
bool wakeDisplay() {
|
||||||
if (type == NONE || !enabled) return false;
|
if (type == NONE || !enabled) return false;
|
||||||
if (displayTurnedOff) {
|
if (displayTurnedOff) {
|
||||||
|
unsigned long now = millis();
|
||||||
|
while (drawing && millis()-now < 250) delay(1); // wait if someone else is drawing
|
||||||
|
drawing = true;
|
||||||
clear();
|
clear();
|
||||||
// Turn the display back on
|
// Turn the display back on
|
||||||
sleepOrClock(false);
|
sleepOrClock(false);
|
||||||
//lastRedraw = millis();
|
//lastRedraw = millis();
|
||||||
|
drawing = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -647,6 +654,9 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
* Used in Rotary Encoder usermod.
|
* Used in Rotary Encoder usermod.
|
||||||
*/
|
*/
|
||||||
void overlay(const char* line1, long showHowLong, byte glyphType) {
|
void overlay(const char* line1, long showHowLong, byte glyphType) {
|
||||||
|
unsigned long now = millis();
|
||||||
|
while (drawing && millis()-now < 250) delay(1); // wait if someone else is drawing
|
||||||
|
drawing = true;
|
||||||
// Turn the display back on
|
// Turn the display back on
|
||||||
if (!wakeDisplay()) clear();
|
if (!wakeDisplay()) clear();
|
||||||
// Print the overlay
|
// Print the overlay
|
||||||
@ -660,6 +670,7 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
drawString(0, (glyphType<255?3:0)*lineHeight, buf.c_str());
|
drawString(0, (glyphType<255?3:0)*lineHeight, buf.c_str());
|
||||||
}
|
}
|
||||||
overlayUntil = millis() + showHowLong;
|
overlayUntil = millis() + showHowLong;
|
||||||
|
drawing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -667,6 +678,9 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
* Clears the screen and prints.
|
* Clears the screen and prints.
|
||||||
*/
|
*/
|
||||||
void overlayLogo(long showHowLong) {
|
void overlayLogo(long showHowLong) {
|
||||||
|
unsigned long now = millis();
|
||||||
|
while (drawing && millis()-now < 250) delay(1); // wait if someone else is drawing
|
||||||
|
drawing = true;
|
||||||
// Turn the display back on
|
// Turn the display back on
|
||||||
if (!wakeDisplay()) clear();
|
if (!wakeDisplay()) clear();
|
||||||
// Print the overlay
|
// Print the overlay
|
||||||
@ -716,6 +730,7 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
overlayUntil = millis() + showHowLong;
|
overlayUntil = millis() + showHowLong;
|
||||||
|
drawing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -724,6 +739,9 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
* Used in Auto Save usermod
|
* Used in Auto Save usermod
|
||||||
*/
|
*/
|
||||||
void overlay(const char* line1, const char* line2, long showHowLong) {
|
void overlay(const char* line1, const char* line2, long showHowLong) {
|
||||||
|
unsigned long now = millis();
|
||||||
|
while (drawing && millis()-now < 250) delay(1); // wait if someone else is drawing
|
||||||
|
drawing = true;
|
||||||
// Turn the display back on
|
// Turn the display back on
|
||||||
if (!wakeDisplay()) clear();
|
if (!wakeDisplay()) clear();
|
||||||
// Print the overlay
|
// Print the overlay
|
||||||
@ -738,9 +756,14 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
drawString(0, 2*lineHeight, buf.c_str());
|
drawString(0, 2*lineHeight, buf.c_str());
|
||||||
}
|
}
|
||||||
overlayUntil = millis() + showHowLong;
|
overlayUntil = millis() + showHowLong;
|
||||||
|
drawing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void networkOverlay(const char* line1, long showHowLong) {
|
void networkOverlay(const char* line1, long showHowLong) {
|
||||||
|
unsigned long now = millis();
|
||||||
|
while (drawing && millis()-now < 250) delay(1); // wait if someone else is drawing
|
||||||
|
drawing = true;
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
// Turn the display back on
|
// Turn the display back on
|
||||||
if (!wakeDisplay()) clear();
|
if (!wakeDisplay()) clear();
|
||||||
@ -771,6 +794,7 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
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;
|
||||||
|
drawing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -799,6 +823,10 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
void showTime() {
|
void showTime() {
|
||||||
if (type == NONE || !enabled || !displayTurnedOff) return;
|
if (type == NONE || !enabled || !displayTurnedOff) return;
|
||||||
|
|
||||||
|
unsigned long now = millis();
|
||||||
|
while (drawing && millis()-now < 250) delay(1); // wait if someone else is drawing
|
||||||
|
drawing = true;
|
||||||
|
|
||||||
char lineBuffer[LINE_BUFFER_SIZE];
|
char lineBuffer[LINE_BUFFER_SIZE];
|
||||||
static byte lastSecond;
|
static byte lastSecond;
|
||||||
byte secondCurrent = second(localTime);
|
byte secondCurrent = second(localTime);
|
||||||
@ -826,15 +854,14 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
|
|
||||||
knownMinute = minuteCurrent;
|
knownMinute = minuteCurrent;
|
||||||
knownHour = hourCurrent;
|
knownHour = hourCurrent;
|
||||||
} else {
|
|
||||||
if (secondCurrent == lastSecond) return;
|
|
||||||
}
|
}
|
||||||
if (showSeconds) {
|
if (showSeconds && secondCurrent != lastSecond) {
|
||||||
lastSecond = secondCurrent;
|
lastSecond = secondCurrent;
|
||||||
draw2x2String(6, lineHeight*2, secondCurrent%2 ? " " : ":");
|
draw2x2String(6, lineHeight*2, secondCurrent%2 ? " " : ":");
|
||||||
sprintf_P(lineBuffer, PSTR("%02d"), secondCurrent);
|
sprintf_P(lineBuffer, PSTR("%02d"), secondCurrent);
|
||||||
drawString(12, lineHeight*2+1, lineBuffer, true); // even with double sized rows print seconds in 1 line
|
drawString(12, lineHeight*2+1, lineBuffer, true); // even with double sized rows print seconds in 1 line
|
||||||
}
|
}
|
||||||
|
drawing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -910,7 +937,12 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
}
|
}
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_FREERTOS_UNICORE
|
||||||
|
#define ARDUINO_RUNNING_CORE 0
|
||||||
|
#else
|
||||||
|
#define ARDUINO_RUNNING_CORE 1
|
||||||
|
#endif
|
||||||
void onUpdateBegin(bool init) {
|
void onUpdateBegin(bool init) {
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
if (init && Display_Task) {
|
if (init && Display_Task) {
|
||||||
@ -920,23 +952,24 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
if (Display_Task)
|
if (Display_Task)
|
||||||
vTaskResume(Display_Task);
|
vTaskResume(Display_Task);
|
||||||
else
|
else
|
||||||
xTaskCreate(
|
xTaskCreatePinnedToCore(
|
||||||
[](void * par) { // Function to implement the task
|
[](void * par) { // Function to implement the task
|
||||||
// see https://www.freertos.org/vtaskdelayuntil.html
|
// see https://www.freertos.org/vtaskdelayuntil.html
|
||||||
const TickType_t xFrequency = REFRESH_RATE_MS * portTICK_PERIOD_MS;
|
const TickType_t xFrequency = REFRESH_RATE_MS * portTICK_PERIOD_MS / 2;
|
||||||
|
TickType_t xLastWakeTime = xTaskGetTickCount();
|
||||||
for(;;) {
|
for(;;) {
|
||||||
TickType_t xLastWakeTime = xTaskGetTickCount();
|
delay(1); // DO NOT DELETE THIS LINE! It is needed to give the IDLE(0) task enough time and to keep the watchdog happy.
|
||||||
delay(1); // DO NOT DELETE THIS LINE! It is needed to give the IDLE(0) task enough time and to keep the watchdog happy.
|
// taskYIELD(), yield(), vTaskDelay() and esp_task_wdt_feed() didn't seem to work.
|
||||||
// taskYIELD(), yield(), vTaskDelay() and esp_task_wdt_feed() didn't seem to work.
|
vTaskDelayUntil(&xLastWakeTime, xFrequency); // release CPU, by doing nothing for REFRESH_RATE_MS millis
|
||||||
vTaskDelayUntil(&xLastWakeTime, xFrequency); // release CPU, by doing nothing for REFRESH_RATE_MS millis
|
|
||||||
FourLineDisplayUsermod::getInstance()->redraw(false);
|
FourLineDisplayUsermod::getInstance()->redraw(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"4LD", // Name of the task
|
"4LD", // Name of the task
|
||||||
2048, // Stack size in words
|
3072, // Stack size in words
|
||||||
NULL, // Task input parameter
|
NULL, // Task input parameter
|
||||||
0, // Priority of the task (idle)
|
1, // Priority of the task (not idle)
|
||||||
&Display_Task // Task handle
|
&Display_Task, // Task handle
|
||||||
|
ARDUINO_RUNNING_CORE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -5840,7 +5840,7 @@ uint16_t mode_2Dscrollingtext(void) {
|
|||||||
const uint16_t cols = SEGMENT.virtualWidth();
|
const uint16_t cols = SEGMENT.virtualWidth();
|
||||||
const uint16_t rows = SEGMENT.virtualHeight();
|
const uint16_t rows = SEGMENT.virtualHeight();
|
||||||
|
|
||||||
const int letterWidth = SEGMENT.custom2 > 128 ? 6 : 5;
|
const int letterWidth = SEGMENT.custom2 > 127 ? 6 : 5;
|
||||||
const int letterHeight = 8;
|
const int letterHeight = 8;
|
||||||
const int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-letterHeight)/2;
|
const int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-letterHeight)/2;
|
||||||
char text[33] = {'\0'};
|
char text[33] = {'\0'};
|
||||||
@ -5867,14 +5867,15 @@ uint16_t mode_2Dscrollingtext(void) {
|
|||||||
else SEGENV.aux0 = (cols + (numberOfLetters * letterWidth))/2;
|
else SEGENV.aux0 = (cols + (numberOfLetters * letterWidth))/2;
|
||||||
++SEGENV.aux1 &= 0xFF; // color shift
|
++SEGENV.aux1 &= 0xFF; // color shift
|
||||||
SEGENV.step = millis() + map(SEGMENT.speed, 0, 255, 10*FRAMETIME_FIXED, 2*FRAMETIME_FIXED);
|
SEGENV.step = millis() + map(SEGMENT.speed, 0, 255, 10*FRAMETIME_FIXED, 2*FRAMETIME_FIXED);
|
||||||
}
|
|
||||||
|
|
||||||
SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color
|
// we need it 3 times
|
||||||
|
SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color
|
||||||
for (int i = 0; i < numberOfLetters; i++) {
|
SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color
|
||||||
if (int(cols) - int(SEGENV.aux0) + letterWidth*(i+1) < 0) continue; // don't draw characters off-screen
|
SEGMENT.fade_out(255 - (SEGMENT.custom1>>5)); // fade to background color
|
||||||
if (text[i]<32 || text[i]>126) continue; // skip non-ANSII characters (may add UTF translation at some point)
|
for (int i = 0; i < numberOfLetters; i++) {
|
||||||
SEGMENT.drawCharacter(text[i], int(cols) - int(SEGENV.aux0) + letterWidth*i, yoffset, letterWidth, letterHeight, SEGMENT.color_from_palette(SEGENV.aux1, false, PALETTE_SOLID_WRAP, 0));
|
if (int(cols) - int(SEGENV.aux0) + letterWidth*(i+1) < 0) continue; // don't draw characters off-screen
|
||||||
|
SEGMENT.drawCharacter(text[i], int(cols) - int(SEGENV.aux0) + letterWidth*i, yoffset, letterWidth, letterHeight, SEGMENT.color_from_palette(SEGENV.aux1, false, PALETTE_SOLID_WRAP, 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
|
@ -320,7 +320,7 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
oappend(SET_F("bLimits("));
|
oappend(SET_F("bLimits("));
|
||||||
#if defined(ESP32) && defined(USERMOD_AUDIOREACTIVE)
|
#if defined(ESP32) && defined(USERMOD_AUDIOREACTIVE)
|
||||||
// requested by @softhack007 https://github.com/blazoncek/WLED/issues/33
|
// requested by @softhack007 https://github.com/blazoncek/WLED/issues/33
|
||||||
oappend(itoa(WLED_MAX_BUSSES-2,nS,10)); // prevent use of I2S buses if audio installed
|
oappend(itoa(WLED_MAX_BUSSES-2,nS,10)); oappend(","); // prevent use of I2S buses if audio installed
|
||||||
#else
|
#else
|
||||||
oappend(itoa(WLED_MAX_BUSSES,nS,10)); oappend(",");
|
oappend(itoa(WLED_MAX_BUSSES,nS,10)); oappend(",");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user