Skip to content

Commit

Permalink
Merge branch 'mdev' into W5500_Support
Browse files Browse the repository at this point in the history
  • Loading branch information
troyhacks authored Dec 20, 2024
2 parents 4eccf99 + fd2bce5 commit 1d02d5b
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 30 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wled",
"version": "14.5.0-beta",
"version": "14.5.1-dev",
"description": "Tools for WLED project",
"main": "tools/cdata.js",
"directories": {
Expand Down
38 changes: 23 additions & 15 deletions wled00/bus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,7 @@ int BusManager::add(BusConfig &bc) {
lastBus = nullptr;
laststart = 0;
lastend = 0;
slowMode = false;
return numBusses++;
}

Expand All @@ -1277,6 +1278,7 @@ void BusManager::removeAll() {
lastBus = nullptr;
laststart = 0;
lastend = 0;
slowMode = false;
}

void __attribute__((hot)) BusManager::show() {
Expand All @@ -1296,7 +1298,7 @@ void BusManager::setStatusPixel(uint32_t c) {
}

void IRAM_ATTR __attribute__((hot)) BusManager::setPixelColor(uint16_t pix, uint32_t c, int16_t cct) {
if ((pix >= laststart) && (pix < lastend ) && (lastBus != nullptr)) {
if ( !slowMode && (pix >= laststart) && (pix < lastend ) && (lastBus != nullptr)) {
// WLEDMM same bus as last time - no need to search again
lastBus->setPixelColor(pix - laststart, c);
return;
Expand All @@ -1307,10 +1309,12 @@ void IRAM_ATTR __attribute__((hot)) BusManager::setPixelColor(uint16_t pix, uint
uint_fast16_t bstart = b->getStart();
if (pix < bstart || pix >= bstart + b->getLength()) continue;
else {
// WLEDMM remember last Bus we took
lastBus = b;
laststart = bstart;
lastend = bstart + b->getLength();
if (!slowMode) {
// WLEDMM remember last Bus we took
lastBus = b;
laststart = bstart;
lastend = bstart + b->getLength();
}
b->setPixelColor(pix - bstart, c);
break; // WLEDMM found the right Bus -> so we can stop searching
}
Expand All @@ -1333,7 +1337,7 @@ void __attribute__((cold)) BusManager::setSegmentCCT(int16_t cct, bool allowWBCo
}

uint32_t IRAM_ATTR __attribute__((hot)) BusManager::getPixelColor(uint_fast16_t pix) { // WLEDMM use fast native types, IRAM_ATTR
if ((pix >= laststart) && (pix < lastend ) && (lastBus != nullptr)) {
if ( !slowMode && (pix >= laststart) && (pix < lastend ) && (lastBus != nullptr)) {
// WLEDMM same bus as last time - no need to search again
return lastBus->getPixelColor(pix - laststart);
}
Expand All @@ -1343,18 +1347,20 @@ uint32_t IRAM_ATTR __attribute__((hot)) BusManager::getPixelColor(uint_fast16_t
uint_fast16_t bstart = b->getStart();
if (pix < bstart || pix >= bstart + b->getLength()) continue;
else {
// WLEDMM remember last Bus we took
lastBus = b;
laststart = bstart;
lastend = bstart + b->getLength();
if (!slowMode) {
// WLEDMM remember last Bus we took
lastBus = b;
laststart = bstart;
lastend = bstart + b->getLength();
}
return b->getPixelColor(pix - bstart);
}
}
return 0;
}

uint32_t IRAM_ATTR __attribute__((hot)) BusManager::getPixelColorRestored(uint_fast16_t pix) { // WLEDMM uses bus::getPixelColorRestored()
if ((pix >= laststart) && (pix < lastend ) && (lastBus != nullptr)) {
if ( !slowMode && (pix >= laststart) && (pix < lastend ) && (lastBus != nullptr)) {
// WLEDMM same bus as last time - no need to search again
return lastBus->getPixelColorRestored(pix - laststart);
}
Expand All @@ -1364,10 +1370,12 @@ uint32_t IRAM_ATTR __attribute__((hot)) BusManager::getPixelColorRestored(uint_
uint_fast16_t bstart = b->getStart();
if (pix < bstart || pix >= bstart + b->getLength()) continue;
else {
// WLEDMM remember last Bus we took
lastBus = b;
laststart = bstart;
lastend = bstart + b->getLength();
if (!slowMode) {
// WLEDMM remember last Bus we took
lastBus = b;
laststart = bstart;
lastend = bstart + b->getLength();
}
return b->getPixelColorRestored(pix - bstart);
}
}
Expand Down
9 changes: 9 additions & 0 deletions wled00/bus_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,14 @@ class BusManager {

void show();

void invalidateCache(bool isRTMode) {
// WLEDMM clear cached Bus info
lastBus = nullptr;
laststart = 0;
lastend = 0;
slowMode = isRTMode;
}

void setStatusPixel(uint32_t c);

void setPixelColor(uint16_t pix, uint32_t c, int16_t cct=-1);
Expand Down Expand Up @@ -497,6 +505,7 @@ class BusManager {
Bus *lastBus = nullptr;
unsigned laststart = 0;
unsigned lastend = 0;
bool slowMode = false; // WLEDMM not sure why we need this. But its necessary.

inline uint8_t getNumVirtualBusses() const {
int j = 0;
Expand Down
2 changes: 1 addition & 1 deletion wled00/improv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void sendImprovInfoResponse() {
bool useMdnsName = (strcmp(serverDescription, "WLED") == 0 && strlen(cmDNS) > 0);
char vString[32] = { '\0' };
//snprintf_P(vString, sizeof(vString)-1, PSTR("0.14.1-b34.42/%i"),VERSION); // upstream baseline
snprintf_P(vString, sizeof(vString)-1, PSTR("14.5.0-beta/%i"),VERSION); // WLEDMM version
snprintf_P(vString, sizeof(vString)-1, PSTR("14.5.1-dev/%i"),VERSION); // WLEDMM version
const char *str[4] = {"WLED", vString, bString, useMdnsName ? cmDNS : serverDescription};

sendImprovRPCResult(ImprovRPCType::Request_Info, 4, str);
Expand Down
12 changes: 12 additions & 0 deletions wled00/udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,22 @@ void notify(byte callMode, bool followUp)
void realtimeLock(uint32_t timeoutMs, byte md)
{
if (!realtimeMode && !realtimeOverride) {
// this code runs once when we enter realtime mode
// WLEDMM begin - we need to init segment caches before putting any pixels
if (strip.isServicing()) {
USER_PRINTLN(F("realtimeLock() enter RTM: strip is still drawing effects."));
strip.waitUntilIdle();
}
strip.service(); // WLEDMM make sure that all segments are properly initialized
busses.invalidateCache(true);
// WLEDMM end

uint16_t stop, start;
if (useMainSegmentOnly) {
Segment& mainseg = strip.getMainSegment();
start = mainseg.start;
stop = mainseg.stop;
mainseg.map1D2D = M12_Pixels; // WLEDMM no mapping
mainseg.freeze = true;
} else {
start = 0;
Expand Down Expand Up @@ -199,6 +210,7 @@ void exitRealtime() {
} else {
strip.show(); // possible fix for #3589
}
busses.invalidateCache(false); // WLEDMM
updateInterfaces(CALL_MODE_WS_SEND);
}

Expand Down
2 changes: 1 addition & 1 deletion wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

// version code in format yymmddb (b = daily build)
#define VERSION 2412180
#define VERSION 2412200

// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
#define _MoonModules_WLED_
Expand Down
19 changes: 9 additions & 10 deletions wled00/wled00.ino
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ unsigned long lastMillis = 0; //WLEDMM
unsigned long loopCounter = 0; //WLEDMM

unsigned long lps = 0; // loops per second
unsigned long lps2 = 0; // lps without "show"

unsigned long long showtime = 0; // time spent in "show" (micros)
//unsigned long lps2 = 0; // lps without "show"
//unsigned long long showtime = 0; // time spent in "show" (micros)

void setup() __attribute__((used)); // needed for -flto
void setup() {
Expand All @@ -77,24 +76,24 @@ void setup() {
void loop() __attribute__((used)); // needed for -flto
void loop() {
//WLEDMM show loops per second
#ifdef WLED_DEBUG
loopCounter++;
//if (millis() - lastMillis >= 10000) {
if (millis() - lastMillis >= 8000) {
long delta = millis() - lastMillis;
if (delta > 0) {
lps = (loopCounter*1000U) / delta;
//USER_PRINTF("%lu lps\n",(loopCounter*1000U) / delta);
if (delta > (showtime / 1000)) lps2 = (loopCounter*1000U) / (delta - (showtime / 1000));
//if (delta > (showtime / 1000)) lps2 = (loopCounter*1000U) / (delta - (showtime / 1000));
USER_PRINTF("%lu lps\t", lps);
USER_PRINTF("%u fps\t", strip.getFps());
USER_PRINTF("%lu lps without show\t\t", lps2);
USER_PRINTF("frametime %d\t", int(strip.getFrameTime()));
USER_PRINTF("targetFPS %d\n", int(strip.getTargetFps()));
//USER_PRINTF("%lu lps without show\t\t", lps2);
USER_PRINTF("target frametime %dms\t", int(strip.getFrameTime()));
USER_PRINTF("target FPS %d\n", int(strip.getTargetFps()));
}
lastMillis = millis();
loopCounter = 0;
showtime = 0;
//showtime = 0;
}

#endif
WLED::instance().loop();
}
1 change: 1 addition & 0 deletions wled00/ws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ static bool sendLiveLedsWs(uint32_t wsClient) // WLEDMM added "static"
uint32_t c = restoreColorLossy(strip.getPixelColor(i), stripBrightness); // WLEDMM full bright preview - does _not_ recover ABL reductions
#endif
//uint32_t c = strip.getPixelColorRestored(i);

// WLEDMM begin: preview with color gamma correction
if (gammaCorrectPreview) {
uint8_t w = W(c); // not sure why, but it looks better if using "white" without corrections
Expand Down

0 comments on commit 1d02d5b

Please sign in to comment.