Merge branch 'MoonModules:mdev' into downsample4x

This commit is contained in:
Troy
2023-09-18 09:17:34 -04:00
committed by GitHub
12 changed files with 1052 additions and 934 deletions

View File

@@ -133,12 +133,14 @@ platform_packages = platformio/framework-arduinoespressif8266
# ------------------------------------------------------------------------------
# FLAGS: DEBUG
#
# esp8266 : see https://docs.platformio.org/en/latest/platforms/espressif8266.html#debug-level
# esp32 : see https://docs.platformio.org/en/latest/platforms/espressif32.html#debug-level
# ------------------------------------------------------------------------------
debug_flags = -D DEBUG=1 -D WLED_DEBUG -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM
debug_flags = -D DEBUG=1 -D WLED_DEBUG
-DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM ;; for esp8266
-DARDUINOJSON_DEBUG=1 ;; enables some debug asserts in arduinoJSON
#if needed (for memleaks etc) also add; -DDEBUG_ESP_OOM -include "umm_malloc/umm_malloc_cfg.h"
#-DDEBUG_ESP_CORE is not working right now
# if needed (for memleaks etc) also add; -DDEBUG_ESP_OOM -include "umm_malloc/umm_malloc_cfg.h"
# -DDEBUG_ESP_CORE is not working right now
# ------------------------------------------------------------------------------
# FLAGS: ldscript (available ldscripts at https://github.com/esp8266/Arduino/tree/master/tools/sdk/ld)
@@ -269,6 +271,9 @@ build_flags =
-DVTABLES_IN_FLASH
; restrict to minimal mime-types
-DMIMETYPE_MINIMAL
; other special-purpose framework flags (see https://docs.platformio.org/en/latest/platforms/espressif8266.html)
; -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
lib_deps =

View File

@@ -2310,7 +2310,7 @@ uint16_t mode_meteor() {
{
byte meteorTrailDecay = 128 + random8(127);
trail[i] = scale8(trail[i], meteorTrailDecay);
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, false, 0, trail[i]));
SEGMENT.setPixelColor(i, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(i, true, false, 0), trail[i]));
}
}
@@ -2321,12 +2321,12 @@ uint16_t mode_meteor() {
index -= SEGLEN;
}
trail[index] = 240;
SEGMENT.setPixelColor(index, SEGMENT.color_from_palette(index, true, false, 0, 255));
SEGMENT.setPixelColor(index, SEGMENT.color_from_palette(index, true, false, 0));
}
return FRAMETIME;
}
static const char _data_FX_MODE_METEOR[] PROGMEM = "Meteor@!,Trail length;!;!";
static const char _data_FX_MODE_METEOR[] PROGMEM = "Meteor@!,Trail length;!,!;!;1";
// smooth meteor effect
@@ -2349,7 +2349,7 @@ uint16_t mode_meteor_smooth() {
trail[i] += change;
if (trail[i] > 245) trail[i] = 0;
if (trail[i] > 240) trail[i] = 240;
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, false, 0, trail[i]));
SEGMENT.setPixelColor(i, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(i, true, false, 0), trail[i]));
}
}
@@ -2360,13 +2360,13 @@ uint16_t mode_meteor_smooth() {
index -= SEGLEN;
}
trail[index] = 240;
SEGMENT.setPixelColor(index, SEGMENT.color_from_palette(index, true, false, 0, 255));
SEGMENT.setPixelColor(index, SEGMENT.color_from_palette(index, true, false, 0));
}
SEGENV.step += SEGMENT.speed +1;
return FRAMETIME;
}
static const char _data_FX_MODE_METEOR_SMOOTH[] PROGMEM = "Meteor Smooth@!,Trail length;!;!";
static const char _data_FX_MODE_METEOR_SMOOTH[] PROGMEM = "Meteor Smooth@!,Trail length;!,!;!;1";
//Railway Crossing / Christmas Fairy lights
@@ -2441,9 +2441,10 @@ uint16_t ripple_base()
#ifndef WLED_DISABLE_2D
if (SEGMENT.is2D()) {
propI /= 2;
uint16_t cx = rippleorigin >> 8;
uint16_t cy = rippleorigin & 0xFF;
uint8_t mag = scale8(cubicwave8((propF>>2)), amp);
uint8_t mag = scale8(sin8((propF>>2)), amp);
if (propI > 0) SEGMENT.draw_circle(cx, cy, propI, color_blend(SEGMENT.getPixelColorXY(cx + propI, cy), col, mag));
} else
#endif
@@ -2461,7 +2462,7 @@ uint16_t ripple_base()
ripplestate += rippledecay;
ripples[i].state = (ripplestate > 254) ? 0 : ripplestate;
} else {//randomly create new wave
if (random16(IBN + 10000) <= SEGMENT.intensity) {
if (random16(IBN + 10000) <= (SEGMENT.intensity >> (SEGMENT.is2D()*3))) {
ripples[i].state = 1;
ripples[i].pos = SEGMENT.is2D() ? ((random8(SEGENV.virtualWidth())<<8) | (random8(SEGENV.virtualHeight()))) : random16(SEGLEN);
ripples[i].color = random8(); //color
@@ -2477,6 +2478,7 @@ uint16_t ripple_base()
uint16_t mode_ripple(void) {
if (SEGLEN == 1) return mode_static();
if (!SEGMENT.check2) SEGMENT.fill(SEGCOLOR(1));
else SEGMENT.fade_out(250);
return ripple_base();
}
static const char _data_FX_MODE_RIPPLE[] PROGMEM = "Ripple@!,Wave #,,,,,Overlay;,!;!;12";
@@ -2883,6 +2885,103 @@ uint16_t mode_bouncing_balls(void) {
static const char _data_FX_MODE_BOUNCINGBALLS[] PROGMEM = "Bouncing Balls@Gravity,# of balls,,,,,Overlay;!,!,!;!;1.5d;m12=1"; //bar WLEDMM 1.5d
/*
* bouncing balls on a track track Effect modified from Aircoookie's bouncing balls
* Courtesy of pjhatch (https://github.com/pjhatch)
* https://github.com/Aircoookie/WLED/pull/1039
*/
// modified for balltrack mode
typedef struct RollingBall {
unsigned long lastBounceUpdate;
float mass; // could fix this to be = 1. if memory is an issue
float velocity;
float height;
} rball_t;
static uint16_t rolling_balls(void) {
//allocate segment data
const uint16_t maxNumBalls = 16; // 255/16 + 1
uint16_t dataSize = sizeof(rball_t) * maxNumBalls;
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
rball_t *balls = reinterpret_cast<rball_t *>(SEGENV.data);
// number of balls based on intensity setting to max of 16 (cycles colors)
// non-chosen color is a random color
uint8_t numBalls = SEGMENT.intensity/16 + 1;
if (SEGENV.call == 0) {
for (int i = 0; i < maxNumBalls; i++) {
balls[i].lastBounceUpdate = strip.now;
balls[i].velocity = 20.0f * float(random16(1000, 10000))/10000.0f; // number from 1 to 10
if (random8()<128) balls[i].velocity = -balls[i].velocity; // 50% chance of reverse direction
balls[i].height = (float(random16(0, 10000)) / 10000.0f); // from 0. to 1.
balls[i].mass = (float(random16(1000, 10000)) / 10000.0f); // from .1 to 1.
}
}
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));
for (int i = 0; i < numBalls; i++) {
float timeSinceLastUpdate = float((strip.now - balls[i].lastBounceUpdate))/cfac;
float thisHeight = balls[i].height + balls[i].velocity * timeSinceLastUpdate; // this method keeps higher resolution
// test if intensity level was increased and some balls are way off the track then put them back
if (thisHeight < -0.5f || thisHeight > 1.5f){
thisHeight = balls[i].height = (float(random16(0, 10000)) / 10000.0f); // from 0. to 1.
balls[i].lastBounceUpdate = strip.now;
}
// check if reached ends of the strip
if ((thisHeight <= 0.0f && balls[i].velocity < 0.0f) || (thisHeight >= 1.0f && balls[i].velocity > 0.0f)) {
balls[i].velocity = -balls[i].velocity; // reverse velocity
balls[i].lastBounceUpdate = strip.now;
balls[i].height = thisHeight;
}
// check for collisions
if (SEGMENT.check1) {
for (int j = i+1; j < numBalls; j++) {
if (balls[j].velocity != balls[i].velocity) {
// tcollided + balls[j].lastBounceUpdate is acutal time of collision (this keeps precision with long to float conversions)
float tcollided = (cfac*(balls[i].height - balls[j].height) +
balls[i].velocity*float(balls[j].lastBounceUpdate - balls[i].lastBounceUpdate))/(balls[j].velocity - balls[i].velocity);
if ((tcollided > 2.0f) && (tcollided < float(strip.now - balls[j].lastBounceUpdate))) { // 2ms minimum to avoid duplicate bounces
balls[i].height = balls[i].height + balls[i].velocity*(tcollided + float(balls[j].lastBounceUpdate - balls[i].lastBounceUpdate))/cfac;
balls[j].height = balls[i].height;
balls[i].lastBounceUpdate = (unsigned long)(tcollided + 0.5f) + balls[j].lastBounceUpdate;
balls[j].lastBounceUpdate = balls[i].lastBounceUpdate;
float vtmp = balls[i].velocity;
balls[i].velocity = ((balls[i].mass - balls[j].mass)*vtmp + 2.0f*balls[j].mass*balls[j].velocity)/(balls[i].mass + balls[j].mass);
balls[j].velocity = ((balls[j].mass - balls[i].mass)*balls[j].velocity + 2.0f*balls[i].mass*vtmp) /(balls[i].mass + balls[j].mass);
thisHeight = balls[i].height + balls[i].velocity*(strip.now - balls[i].lastBounceUpdate)/cfac;
}
}
}
}
uint32_t color = SEGCOLOR(0);
if (SEGMENT.palette) {
//color = SEGMENT.color_wheel(i*(256/MAX(numBalls, 8)));
color = SEGMENT.color_from_palette(i*255/numBalls, false, PALETTE_SOLID_WRAP, 0);
} else if (hasCol2) {
color = SEGCOLOR(i % NUM_COLORS);
}
if (thisHeight < 0.0f) thisHeight = 0.0f;
if (thisHeight > 1.0f) thisHeight = 1.0f;
uint16_t pos = round(thisHeight * (SEGLEN - 1));
SEGMENT.setPixelColor(pos, color);
balls[i].lastBounceUpdate = strip.now;
balls[i].height = thisHeight;
}
return FRAMETIME;
}
static const char _data_FX_MODE_ROLLINGBALLS[] PROGMEM = "Rolling Balls@!,# of balls,,,,Collisions,Overlay;!,!,!;!;1;m12=1"; //bar
/*
* Sinelon stolen from FASTLED examples
*/
@@ -5165,7 +5264,7 @@ static const char _data_FX_MODE_2DLISSAJOUS[] PROGMEM = "Lissajous ☾@X frequen
///////////////////////
// 2D Matrix //
///////////////////////
uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams. Adapted by Andrew Tuline & improved by merkisoft and ewowi.
uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams. Adapted by Andrew Tuline & improved by merkisoft and ewowi, and softhack007.
if (!strip.isMatrix) return mode_static(); // not a 2D set-up
const uint16_t cols = SEGMENT.virtualWidth();
@@ -5174,6 +5273,8 @@ uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams.
if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
SEGENV.aux0 = SEGENV.aux1 = UINT16_MAX;
SEGENV.step = 0;
}
uint8_t fade = map(SEGMENT.custom1, 0, 255, 50, 250); // equals trail size
@@ -5191,10 +5292,23 @@ uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams.
if (strip.now - SEGENV.step >= speed) {
SEGENV.step = strip.now;
// find out what color value is returned by gPC for a "falling code" example pixel
// the color values returned may differ from the previously set values, due to
// - auto brightness limiter (dimming)
// - lossy color buffer (when not using global buffer)
// - color balance correction
// - segment opacity
CRGB oldSpawnColor = spawnColor;
if ((SEGENV.aux0 < cols) && (SEGENV.aux1 < rows)) { // we have a hint from last run
oldSpawnColor = SEGMENT.getPixelColorXY(SEGENV.aux0, SEGENV.aux1); // find color of previous spawns
SEGENV.aux1 ++; // our sample pixel will be one row down the next time
}
// move pixels one row down. Falling codes keep color and add trail pixels; all others pixels are faded
for (int row=rows-1; row>=0; row--) {
for (int col=0; col<cols; col++) {
CRGB pix = SEGMENT.getPixelColorXY(col, row);
if (pix == spawnColor) {
if (pix == oldSpawnColor) { // this comparison may still fail due to overlays changing pixels, or due to gaps (2d-gaps.json)
SEGMENT.setPixelColorXY(col, row, trailColor); // create trail
if (row < rows-1) SEGMENT.setPixelColorXY(col, row+1, spawnColor);
} else {
@@ -5205,18 +5319,15 @@ uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams.
}
// check for empty screen to ensure code spawn
bool emptyScreen = true;
for (int x=0; x<cols; x++) for (int y=0; y<rows; y++) {
if (SEGMENT.getPixelColorXY(x,y)) {
emptyScreen = false;
break;
}
}
bool emptyScreen = (SEGENV.aux1 >= rows); // empty screen means that the last falling code has moved out of screen area
// spawn new falling code
if (random8() < SEGMENT.intensity || emptyScreen) {
if (random8() <= SEGMENT.intensity || emptyScreen) {
uint8_t spawnX = random8(cols);
SEGMENT.setPixelColorXY(spawnX, 0, spawnColor);
// update hint for next run
SEGENV.aux0 = spawnX;
SEGENV.aux1 = 0;
}
} // if millis
@@ -7986,6 +8097,7 @@ void WS2812FX::setupEffectData() {
addEffect(FX_MODE_FIRE_FLICKER, &mode_fire_flicker, _data_FX_MODE_FIRE_FLICKER);
addEffect(FX_MODE_GRADIENT, &mode_gradient, _data_FX_MODE_GRADIENT);
addEffect(FX_MODE_LOADING, &mode_loading, _data_FX_MODE_LOADING);
addEffect(FX_MODE_ROLLINGBALLS, &rolling_balls, _data_FX_MODE_ROLLINGBALLS);
addEffect(FX_MODE_FAIRY, &mode_fairy, _data_FX_MODE_FAIRY);
addEffect(FX_MODE_TWO_DOTS, &mode_two_dots, _data_FX_MODE_TWO_DOTS);

View File

@@ -190,7 +190,7 @@ void strip_wait_until_idle(String whoCalledMe); // WLEDMM implemented in FX_fcn.
#define FX_MODE_FIRE_FLICKER 45
#define FX_MODE_GRADIENT 46
#define FX_MODE_LOADING 47
// #define FX_MODE_POLICE 48 // removed in 0.14!
#define FX_MODE_ROLLINGBALLS 48 //was Police before 0.14
#define FX_MODE_FAIRY 49 //was Police All prior to 0.13.0-b6 (use "Two Dots" with Red/Blue and full intensity)
#define FX_MODE_TWO_DOTS 50
#define FX_MODE_FAIRYTWINKLE 51 //was Two Areas prior to 0.13.0-b6 (use "Two Dots" with full intensity)

View File

@@ -156,6 +156,7 @@ void handleAnalog(uint8_t b)
#ifdef ESP8266
rawReading = analogRead(A0) << 2; // convert 10bit read to 12bit
#else
if ((btnPin[b] < 0) || (digitalPinToAnalogChannel(btnPin[b]) < 0)) return; // pin must support analog ADC - newer esp32 frameworks throw lots of warnings otherwise
rawReading = analogRead(btnPin[b]); // collect at full 12bit resolution
#endif
yield(); // keep WiFi task running - analog read may take several millis on ESP8266
@@ -188,7 +189,7 @@ void handleAnalog(uint8_t b)
if (aRead == 0) {
briLast = bri;
bri = 0;
} else{
} else {
bri = aRead;
}
} else if (macroDoublePress[b] == 249) {

View File

@@ -1595,7 +1595,7 @@ function updateSelectedPalette(s)
if (s > 1 && s < 6) {
cd[0].classList.remove('hide'); // * Color 1
if (s > 2) cd[1].classList.remove('hide'); // * Color 1 & 2
if (s == 5) cd[2].classList.remove('hide'); // all colors
if (s > 3) cd[2].classList.remove('hide'); // all colors
} else {
for (let i of cd) if (i.dataset.hide == '1') i.classList.add('hide');
}

File diff suppressed because it is too large Load Diff

View File

@@ -187,7 +187,7 @@ void handleTransitions()
if (transitionActive && transitionDelayTemp > 0)
{
float tper = (millis() - transitionStartTime)/(float)transitionDelayTemp;
if (tper >= 1.0)
if (tper >= 1.0f)
{
strip.setTransitionMode(false);
transitionActive = false;

View File

@@ -25,7 +25,7 @@ bool parseLx(int lxValue, byte rgbw[4])
float tmpBri = floor((lxValue - 200000000) / 10000); ;
uint16_t ct = (lxValue - 200000000) - (((uint8_t)tmpBri) * 10000);
tmpBri *= 2.55;
tmpBri *= 2.55f;
tmpBri = constrain(tmpBri, 0, 255);
colorKtoRGB(ct, rgbw);

View File

@@ -505,7 +505,7 @@ um_data_t* simulateSound(uint8_t simulationId)
maxVol = 31; // this gets feedback fro UI
binNum = 8; // this gets feedback fro UI
volumeRaw = volumeSmth;
my_magnitude = 10000.0 / 8.0f; //no idea if 10000 is a good value for FFT_Magnitude ???
my_magnitude = 10000.0f / 8.0f; //no idea if 10000 is a good value for FFT_Magnitude ???
if (volumeSmth < 1 ) my_magnitude = 0.001f; // noise gate closed - mute
return um_data;

View File

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

View File

@@ -41,7 +41,7 @@ float sin_t(float x) {
float tan_t(float x) {
float c = cos_t(x);
if (c==0.0) return 0;
if (c==0.0f) return 0;
float res = sin_t(x) / c;
#ifdef WLED_DEBUG_MATH
Serial.printf("tan: %f,%f,%f,(%f)\n",x,res,tan(x),res-tan(x));
@@ -54,14 +54,14 @@ float tan_t(float x) {
float acos_t(float x) {
float negate = float(x < 0);
float xabs = std::abs(x);
float ret = -0.0187293;
float ret = -0.0187293f;
ret = ret * xabs;
ret = ret + 0.0742610;
ret = ret + 0.0742610f;
ret = ret * xabs;
ret = ret - 0.2121144;
ret = ret - 0.2121144f;
ret = ret * xabs;
ret = ret + HALF_PI;
ret = ret * sqrt(1.0-xabs);
ret = ret * sqrt(1.0f-xabs);
ret = ret - 2 * negate * ret;
float res = negate * PI + ret;
#ifdef WLED_DEBUG_MATH

View File

@@ -682,7 +682,7 @@ void getSettingsJS(AsyncWebServerRequest* request, byte subPage, char* dest) //W
sappends('s',SET_F("LT"),tm);
getTimeString(tm);
sappends('m',SET_F("(\"times\")[0]"),tm);
if ((int)(longitude*10.) || (int)(latitude*10.)) {
if ((int)(longitude*10.0f) || (int)(latitude*10.0f)) {
snprintf_P(tm, sizeof(tm), PSTR("Sunrise: %02d:%02d Sunset: %02d:%02d"), hour(sunrise), minute(sunrise), hour(sunset), minute(sunset));
sappends('m',SET_F("(\"times\")[1]"),tm);
}