Skip to content

Commit

Permalink
Merge branch 'MoonModules:mdev' into W5500_Support
Browse files Browse the repository at this point in the history
  • Loading branch information
troyhacks authored Nov 28, 2024
2 parents 79a99d5 + f21b294 commit e1b7bbb
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 31 deletions.
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ build_flags =
; -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48 ;; in case of linker errors like "section `.text1' will not fit in region `iram1_0_seg'"
; -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED ;; (experimental) adds some extra heap, but may cause slowdown
-D USERMOD_AUDIOREACTIVE
-D NON32XFER_HANDLER ;; ask forgiveness for PROGMEM misuse

lib_deps =
#https://github.com/lorol/LITTLEFS.git
Expand Down
77 changes: 51 additions & 26 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ uint16_t mode_tricolor_fade(void) {

return FRAMETIME;
}
static const char _data_FX_MODE_TRICOLOR_FADE[] PROGMEM = "Tri Fade@!;1,2,3;!";
static const char _data_FX_MODE_TRICOLOR_FADE[] PROGMEM = "Tri Fade@!;1,2,3;!;01";


/*
Expand Down Expand Up @@ -3048,7 +3048,8 @@ static uint16_t rolling_balls(void) {
float cfac = float(scale8(8, 255-SEGMENT.speed) +1)*20000.0f; // this uses the Aircoookie conversion factor for scaling time using speed slider

bool hasCol2 = SEGCOLOR(2);
if (!SEGMENT.check2) SEGMENT.fill(hasCol2 ? BLACK : SEGCOLOR(1));
//if (!SEGMENT.check2) SEGMENT.fill(hasCol2 ? BLACK : SEGCOLOR(1));
if (!SEGMENT.check2) SEGMENT.fade_out(253); // WLEDMM adding a bit of trail

for (int i = 0; i < numBalls; i++) {
float timeSinceLastUpdate = float((strip.now - balls[i].lastBounceUpdate))/cfac;
Expand Down Expand Up @@ -6214,9 +6215,9 @@ uint16_t mode_2Dsquaredswirl(void) { // By: Mark Kriegsman. https://g

uint16_t ms = strip.now;

SEGMENT.addPixelColorXY(i, m, ColorFromPalette(SEGPALETTE, ms/29, 255, LINEARBLEND));
SEGMENT.addPixelColorXY(j, n, ColorFromPalette(SEGPALETTE, ms/41, 255, LINEARBLEND));
SEGMENT.addPixelColorXY(k, p, ColorFromPalette(SEGPALETTE, ms/73, 255, LINEARBLEND));
if (i<cols && m<rows) SEGMENT.addPixelColorXY(i, m, ColorFromPalette(SEGPALETTE, ms/29, 255, LINEARBLEND));
if (j<cols && n<rows) SEGMENT.addPixelColorXY(j, n, ColorFromPalette(SEGPALETTE, ms/41, 255, LINEARBLEND));
if (k<cols && p<rows) SEGMENT.addPixelColorXY(k, p, ColorFromPalette(SEGPALETTE, ms/73, 255, LINEARBLEND));

return FRAMETIME;
} // mode_2Dsquaredswirl()
Expand Down Expand Up @@ -6943,10 +6944,10 @@ uint16_t mode_2DSwirl(void) {

SEGMENT.blur(SEGMENT.custom1);

uint8_t i = beatsin8( 27*SEGMENT.speed/255, borderWidth, cols - borderWidth);
uint8_t j = beatsin8( 41*SEGMENT.speed/255, borderWidth, rows - borderWidth);
uint8_t ni = (cols - 1) - i;
uint8_t nj = (cols - 1) - j;
unsigned i = beatsin8( 27*SEGMENT.speed/255, borderWidth, cols - borderWidth);
unsigned j = beatsin8( 41*SEGMENT.speed/255, borderWidth, rows - borderWidth);
unsigned ni = (cols - 1) - i;
unsigned nj = (cols - 1) - j;
uint16_t ms = strip.now;

um_data_t *um_data = getAudioData();
Expand All @@ -6955,12 +6956,12 @@ uint16_t mode_2DSwirl(void) {

// printUmData();

SEGMENT.addPixelColorXY( i, j, ColorFromPalette(SEGPALETTE, (ms / 11 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 11, 200, 255);
SEGMENT.addPixelColorXY( j, i, ColorFromPalette(SEGPALETTE, (ms / 13 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 13, 200, 255);
SEGMENT.addPixelColorXY(ni,nj, ColorFromPalette(SEGPALETTE, (ms / 17 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 17, 200, 255);
SEGMENT.addPixelColorXY(nj,ni, ColorFromPalette(SEGPALETTE, (ms / 29 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 29, 200, 255);
SEGMENT.addPixelColorXY( i,nj, ColorFromPalette(SEGPALETTE, (ms / 37 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 37, 200, 255);
SEGMENT.addPixelColorXY(ni, j, ColorFromPalette(SEGPALETTE, (ms / 41 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 41, 200, 255);
if (i<cols && j<rows) SEGMENT.addPixelColorXY( i, j, ColorFromPalette(SEGPALETTE, (ms / 11 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 11, 200, 255);
if (j<cols && i<rows) SEGMENT.addPixelColorXY( j, i, ColorFromPalette(SEGPALETTE, (ms / 13 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 13, 200, 255);
if (ni<cols && nj<rows) SEGMENT.addPixelColorXY(ni,nj, ColorFromPalette(SEGPALETTE, (ms / 17 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 17, 200, 255);
if (nj<cols && ni<rows) SEGMENT.addPixelColorXY(nj,ni, ColorFromPalette(SEGPALETTE, (ms / 29 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 29, 200, 255);
if (i<cols && nj<rows) SEGMENT.addPixelColorXY( i,nj, ColorFromPalette(SEGPALETTE, (ms / 37 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 37, 200, 255);
if (ni<cols && j<rows) SEGMENT.addPixelColorXY(ni, j, ColorFromPalette(SEGPALETTE, (ms / 41 + volumeSmth*4), volumeRaw * SEGMENT.intensity / 64, LINEARBLEND)); //CHSV( ms / 41, 200, 255);

return FRAMETIME;
} // mode_2DSwirl()
Expand Down Expand Up @@ -8100,15 +8101,37 @@ static const char _data_FX_MODE_WATERFALL[] PROGMEM = "Waterfall@!,Adjust color,

#ifndef WLED_DISABLE_2D
/////////////////////////
// ** 2D GEQ //
// 1D / 2D GEQ //
/////////////////////////
uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
if (!strip.isMatrix) return mode_static(); // not a 2D set-up

// GEQ helper: either draws 2D, or flattens pixels to 1D
static void setFlatPixelXY(bool flatMode, int x, int y, uint32_t color, unsigned cols, unsigned rows, unsigned offset) {
if ((unsigned(x) >= cols) || (unsigned(y) >= rows)) return; // skip invisible

if (!flatMode) SEGMENT.setPixelColorXY(x, y, color); // normal 2D
else {
y = rows - y - 1; // reverse y
if (rows > 4) { // center y if we have more than 4 pixels per bar
if (y & 0x01) y = (rows + y) / 2; // center bars: odd pixels to the right
else y = (rows - 1 - y) / 2; // even pixels to the left
}
int pix = x*rows + y + offset; // flatten -> transpose x y so that bars stay bars
if (unsigned(pix) >= SEGLEN) return; // skip invisible
SEGMENT.setPixelColor(pix, color);
}
}

uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma. Flat Mode added by softhack007
//if (!strip.isMatrix) return mode_static(); // not a 2D set-up, not a problem
bool flatMode = !SEGMENT.is2D() || (SEGMENT.width() < 3) || (SEGMENT.height() < 3); // also use flat mode when less than 3 colums or rows

const int NUM_BANDS = map2(SEGMENT.custom1, 0, 255, 1, 16);
const uint16_t cols = SEGMENT.virtualWidth();
const uint16_t rows = SEGMENT.virtualHeight();
if ((cols <=1) || (rows <=1)) return mode_static(); // not really a 2D set-up
const int vLength = SEGLEN; // for flat mode
const uint16_t cols = flatMode ? min(max(2, NUM_BANDS), (vLength+1)/2) : SEGMENT.virtualWidth();
const uint16_t rows = flatMode ? vLength / cols : SEGMENT.virtualHeight();
const unsigned offset = flatMode ? max(0, (vLength - rows*cols +1) / 2) : 0; // flatmode: always center effect

if ((cols <=1) || (rows <=1)) return mode_static(); // too small

if (!SEGENV.allocateData(cols*sizeof(uint16_t))) return mode_static(); //allocation failed
uint16_t *previousBarHeight = reinterpret_cast<uint16_t*>(SEGENV.data); //array of previous bar heights per frequency band
Expand Down Expand Up @@ -8174,7 +8197,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
if (barHeight > previousBarHeight[x]) previousBarHeight[x] = barHeight; //drive the peak up

uint32_t ledColor = BLACK;
if ((! SEGMENT.check1) && (barHeight > 0)) { // use faster drawLine when single-color bars are needed
if ((! SEGMENT.check1) && !flatMode && (barHeight > 0)) { // use faster drawLine when single-color bars are needed
ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);
SEGMENT.drawLine(int(x), max(0,int(rows)-barHeight), int(x), int(rows-1), ledColor, false); // max(0, ...) to prevent negative Y
} else {
Expand All @@ -8183,23 +8206,25 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
colorIndex = map(y, 0, rows-1, 0, 255);

ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);
SEGMENT.setPixelColorXY(x, rows-1 - y, ledColor);
setFlatPixelXY(flatMode, x, rows-1 - y, ledColor, cols, rows, offset);
} }
if ((SEGMENT.intensity < 255) && (previousBarHeight[x] > 0) && (previousBarHeight[x] < rows)) // WLEDMM avoid "overshooting" into other segments
SEGMENT.setPixelColorXY(x, rows - previousBarHeight[x], (SEGCOLOR(2) != BLACK) ? SEGCOLOR(2) : ledColor);
if (!flatMode && (SEGMENT.intensity < 255) && (previousBarHeight[x] > 0) && (previousBarHeight[x] < rows)) // WLEDMM avoid "overshooting" into other segments - disable ripple pixels in 1D mode
setFlatPixelXY(flatMode, x, rows - previousBarHeight[x], (SEGCOLOR(2) != BLACK) ? SEGCOLOR(2) : ledColor, cols, rows, offset);

if (rippleTime && previousBarHeight[x]>0) previousBarHeight[x]--; //delay/ripple effect
}

#ifdef SR_DEBUG
if (!flatMode) {
// WLEDMM: abuse top left/right pixels for peak detection debugging
SEGMENT.setPixelColorXY(cols-1, 0, (samplePeak > 0) ? GREEN : BLACK);
if (samplePeak > 0) SEGMENT.setPixelColorXY(0, 0, GREEN);
// WLEDMM end
}
#endif
return FRAMETIME;
} // mode_2DGEQ()
static const char _data_FX_MODE_2DGEQ[] PROGMEM = "GEQ ☾@Fade speed,Ripple decay,# of bands,,,Color bars,Smooth bars ☾;!,,Peaks;!;2f;c1=255,c2=64,pal=11,si=0"; // Beatsin
static const char _data_FX_MODE_2DGEQ[] PROGMEM = "GEQ ☾@Fade speed,Ripple decay,# of bands,,,Color bars,Smooth bars ☾;!,,Peaks;!;12f;c1=255,c2=64,pal=11,si=0"; // Beatsin


/////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,12 @@ void Segment::setCurrentPalette() {
}

void Segment::handleTransition() {
if (!transitional) return;
if (!transitional || !_t) return; // Early exit if no transition active
unsigned long maxWait = millis() + 20;
if (mode == FX_MODE_STATIC && next_time > maxWait) next_time = maxWait;
if (progress() == 0xFFFFU) {
if (_t) {
if (_t->_modeP != mode) markForReset();
//if (_t->_modeP != mode) markForReset(); // WLEDMM effect transition disabled as it does not work (flashes due to double effect restart)
delete _t;
_t = nullptr;
}
Expand Down Expand Up @@ -630,7 +630,7 @@ void Segment::setMode(uint8_t fx, bool loadDefaults, bool sliderDefaultsOnly) {
sOpt = extractModeDefaults(fx, "pal"); if (sOpt >= 0) {if (oldPalette==-1) oldPalette = palette; setPalette(sOpt);} else {if (oldPalette!=-1) setPalette(oldPalette); oldPalette = -1;}
}
}
if (!fadeTransition) markForReset(); // WLEDMM quickfix for effect "double startup" bug. -> only works when "Crossfade" is disabled (led settings)
/*if (!fadeTransition)*/ markForReset(); // WLEDMM quickfix for effect "double startup" bug.
stateChanged = true; // send UDP/WS broadcast
}
}
Expand Down
1 change: 1 addition & 0 deletions wled00/data/settings_time.htm
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ <h2>Time setup</h2>
<option value="20">AKST/AKDT (Anchorage)</option>
<option value="21">MX-CST</option>
<option value="22">PKT (Pakistan)</option>
<option value="23">BRT (Brasília)</option>
</select><br>
UTC offset: <input name="UO" type="number" min="-65500" max="65500" required> seconds (max. 18 hours)<br>
Current local time is <span class="times">unknown</span>.<br>
Expand Down
6 changes: 6 additions & 0 deletions wled00/ntp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Timezone* tz = nullptr;
#define TZ_ANCHORAGE 20
#define TZ_MX_CENTRAL 21
#define TZ_PAKISTAN 22
#define TZ_BRASILIA 23
#define TZ_INIT 255

byte tzCurrent = TZ_INIT; //uninitialized
Expand Down Expand Up @@ -168,6 +169,11 @@ void updateTimezone() {
tcrStandard = tcrDaylight;
break;
}
case TZ_BRASILIA : {
tcrDaylight = {Last, Sun, Mar, 1, -180}; //Brasília Standard Time = UTC - 3 hours
tcrStandard = tcrDaylight;
break;
}
}

tzCurrent = currentTimezone;
Expand Down
4 changes: 2 additions & 2 deletions wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

// version code in format yymmddb (b = daily build)
#define VERSION 2411150
#define VERSION 2411271

// 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 Expand Up @@ -388,7 +388,7 @@ WLED_GLOBAL byte briS _INIT(128); // default brightness
WLED_GLOBAL byte nightlightTargetBri _INIT(0); // brightness after nightlight is over
WLED_GLOBAL byte nightlightDelayMins _INIT(60);
WLED_GLOBAL byte nightlightMode _INIT(NL_MODE_FADE); // See const.h for available modes. Was nightlightFade
WLED_GLOBAL bool fadeTransition _INIT(false); // enable crossfading color transition // WLEDMM disabled - has bugs that will be solved in upstream beta4
WLED_GLOBAL bool fadeTransition _INIT(true); // enable crossfading color transition // WLEDMM only do color x-fade -- effect x-fade has bugs that will be solved in upstream beta4
WLED_GLOBAL uint16_t transitionDelay _INIT(750); // default crossfade duration in ms

WLED_GLOBAL uint_fast16_t briMultiplier _INIT(100); // % of brightness to set (to limit power, if you set it to 50 and set bri to 255, actual brightness will be 127)
Expand Down

0 comments on commit e1b7bbb

Please sign in to comment.