Skip to content

Commit 24082d1

Browse files
authored
Merge branch 'main' into parallel-I2S
2 parents a98685d + 2448266 commit 24082d1

File tree

23 files changed

+442
-246
lines changed

23 files changed

+442
-246
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
- v0.15.0-b2
174174
- WS2805 support (RGB + WW + CW, 600kbps)
175175
- Unified PSRAM use
176-
- NeoPixelBus v2.7.9
176+
- NeoPixelBus v2.7.9 (for future WS2805 support)
177177
- Ubiquitous PSRAM mode for all variants of ESP32
178178
- SSD1309_64 I2C Support for FLD Usermod (#3836 by @THATDONFC)
179179
- Palette cycling fix (add support for `{"seg":[{"pal":"X~Y~"}]}` or `{"seg":[{"pal":"X~Yr"}]}`)

usermods/seven_segment_display_reloaded/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Very loosely based on the existing usermod "seven segment display".
99

1010
Add the compile-time option `-D USERMOD_SSDR` to your `platformio.ini` (or `platformio_override.ini`) or use `#define USERMOD_SSDR` in `my_config.h`.
1111

12-
For the auto brightness option, the usermod SN_Photoresistor has to be installed as well. See SN_Photoresistor/readme.md for instructions.
12+
For the auto brightness option, the usermod SN_Photoresistor or BH1750_V2 has to be installed as well. See SN_Photoresistor/readme.md or BH1750_V2/readme.md for instructions.
1313

1414
## Settings
1515
All settings can be controlled via the usermod settings page.
@@ -28,10 +28,10 @@ Enables the blinking colon(s) if they are defined
2828
Shows the leading zero of the hour if it exists (i.e. shows `07` instead of `7`)
2929

3030
### enable-auto-brightness
31-
Enables the auto brightness feature. Can be used only when the usermod SN_Photoresistor is installed.
31+
Enables the auto brightness feature. Can be used only when the usermods SN_Photoresistor or BH1750_V2 are installed.
3232

3333
### auto-brightness-min / auto-brightness-max
34-
The lux value calculated from usermod SN_Photoresistor will be mapped to the values defined here.
34+
The lux value calculated from usermod SN_Photoresistor or BH1750_V2 will be mapped to the values defined here.
3535
The mapping, 0 - 1000 lux, will be mapped to auto-brightness-min and auto-brightness-max
3636

3737
WLED current protection will override the calculated value if it is too high.

usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ class UsermodSSDR : public Usermod {
9797
#else
9898
void* ptr = nullptr;
9999
#endif
100+
#ifdef USERMOD_BH1750
101+
Usermod_BH1750* bh1750 = nullptr;
102+
#else
103+
void* bh1750 = nullptr;
104+
#endif
100105

101106
void _overlaySevenSegmentDraw() {
102107
int displayMaskLen = static_cast<int>(umSSDRDisplayMask.length());
@@ -387,6 +392,9 @@ class UsermodSSDR : public Usermod {
387392
#ifdef USERMOD_SN_PHOTORESISTOR
388393
ptr = (Usermod_SN_Photoresistor*) UsermodManager::lookup(USERMOD_ID_SN_PHOTORESISTOR);
389394
#endif
395+
#ifdef USERMOD_BH1750
396+
bh1750 = (Usermod_BH1750*) UsermodManager::lookup(USERMOD_ID_BH1750);
397+
#endif
390398
DEBUG_PRINTLN(F("Setup done"));
391399
}
392400

@@ -410,6 +418,20 @@ class UsermodSSDR : public Usermod {
410418
umSSDRLastRefresh = millis();
411419
}
412420
#endif
421+
#ifdef USERMOD_BH1750
422+
if(bri != 0 && umSSDREnableLDR && (millis() - umSSDRLastRefresh > umSSDRResfreshTime)) {
423+
if (bh1750 != nullptr) {
424+
float lux = bh1750->getIlluminance();
425+
uint16_t brightness = map(lux, 0, 1000, umSSDRBrightnessMin, umSSDRBrightnessMax);
426+
if (bri != brightness) {
427+
DEBUG_PRINTF("Adjusting brightness based on lux value: %.2f lx, new brightness: %d\n", lux, brightness);
428+
bri = brightness;
429+
stateUpdated(1);
430+
}
431+
}
432+
umSSDRLastRefresh = millis();
433+
}
434+
#endif
413435
}
414436

415437
void handleOverlayDraw() {

usermods/stairway_wipe_basic/wled06_usermod.ino

Lines changed: 0 additions & 111 deletions
This file was deleted.

wled00/FX.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5446,15 +5446,15 @@ uint16_t mode_2Dmetaballs(void) { // Metaballs by Stefan Petrick. Cannot have
54465446
// and add them together with weightening
54475447
unsigned dx = abs(x - x1);
54485448
unsigned dy = abs(y - y1);
5449-
unsigned dist = 2 * sqrt16((dx * dx) + (dy * dy));
5449+
unsigned dist = 2 * sqrt32_bw((dx * dx) + (dy * dy));
54505450

54515451
dx = abs(x - x2);
54525452
dy = abs(y - y2);
5453-
dist += sqrt16((dx * dx) + (dy * dy));
5453+
dist += sqrt32_bw((dx * dx) + (dy * dy));
54545454

54555455
dx = abs(x - x3);
54565456
dy = abs(y - y3);
5457-
dist += sqrt16((dx * dx) + (dy * dy));
5457+
dist += sqrt32_bw((dx * dx) + (dy * dy));
54585458

54595459
// inverse result
54605460
int color = dist ? 1000 / dist : 255;
@@ -6094,13 +6094,23 @@ uint16_t mode_2Dscrollingtext(void) {
60946094
if (!strlen(text)) { // fallback if empty segment name: display date and time
60956095
sprintf_P(text, PSTR("%s %d, %d %d:%02d%s"), monthShortStr(month(localTime)), day(localTime), year(localTime), AmPmHour, minute(localTime), sec);
60966096
} else {
6097+
if (text[0] == '#') for (auto &c : text) c = std::toupper(c);
60976098
if (!strncmp_P(text,PSTR("#DATE"),5)) sprintf_P(text, zero?PSTR("%02d.%02d.%04d"):PSTR("%d.%d.%d"), day(localTime), month(localTime), year(localTime));
60986099
else if (!strncmp_P(text,PSTR("#DDMM"),5)) sprintf_P(text, zero?PSTR("%02d.%02d") :PSTR("%d.%d"), day(localTime), month(localTime));
60996100
else if (!strncmp_P(text,PSTR("#MMDD"),5)) sprintf_P(text, zero?PSTR("%02d/%02d") :PSTR("%d/%d"), month(localTime), day(localTime));
61006101
else if (!strncmp_P(text,PSTR("#TIME"),5)) sprintf_P(text, zero?PSTR("%02d:%02d%s") :PSTR("%2d:%02d%s"), AmPmHour, minute(localTime), sec);
61016102
else if (!strncmp_P(text,PSTR("#HHMM"),5)) sprintf_P(text, zero?PSTR("%02d:%02d") :PSTR("%d:%02d"), AmPmHour, minute(localTime));
6102-
else if (!strncmp_P(text,PSTR("#HH"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), AmPmHour);
6103-
else if (!strncmp_P(text,PSTR("#MM"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), minute(localTime));
6103+
else if (!strncmp_P(text,PSTR("#HH"),3)) sprintf (text, zero? ("%02d") : ("%d"), AmPmHour);
6104+
else if (!strncmp_P(text,PSTR("#MM"),3)) sprintf (text, zero? ("%02d") : ("%d"), minute(localTime));
6105+
else if (!strncmp_P(text,PSTR("#SS"),3)) sprintf (text, ("%02d") , second(localTime));
6106+
else if (!strncmp_P(text,PSTR("#DD"),3)) sprintf (text, zero? ("%02d") : ("%d"), day(localTime));
6107+
else if (!strncmp_P(text,PSTR("#DAY"),4)) sprintf (text, ("%s") , dayShortStr(day(localTime)));
6108+
else if (!strncmp_P(text,PSTR("#DDDD"),5)) sprintf (text, ("%s") , dayStr(day(localTime)));
6109+
else if (!strncmp_P(text,PSTR("#MO"),3)) sprintf (text, zero? ("%02d") : ("%d"), month(localTime));
6110+
else if (!strncmp_P(text,PSTR("#MON"),4)) sprintf (text, ("%s") , monthShortStr(month(localTime)));
6111+
else if (!strncmp_P(text,PSTR("#MMMM"),5)) sprintf (text, ("%s") , monthStr(month(localTime)));
6112+
else if (!strncmp_P(text,PSTR("#YY"),3)) sprintf (text, ("%02d") , year(localTime)%100);
6113+
else if (!strncmp_P(text,PSTR("#YYYY"),5)) sprintf_P(text, zero?PSTR("%04d") : ("%d"), year(localTime));
61046114
}
61056115

61066116
const int numberOfLetters = strlen(text);

wled00/FX.h

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,30 @@ extern byte realtimeMode; // used in getMappedPixelIndex()
326326

327327
#define MODE_COUNT 187
328328

329+
330+
#define BLEND_STYLE_FADE 0x00 // universal
331+
#define BLEND_STYLE_FAIRY_DUST 0x01 // universal
332+
#define BLEND_STYLE_SWIPE_RIGHT 0x02 // 1D or 2D
333+
#define BLEND_STYLE_SWIPE_LEFT 0x03 // 1D or 2D
334+
#define BLEND_STYLE_PINCH_OUT 0x04 // 1D or 2D
335+
#define BLEND_STYLE_INSIDE_OUT 0x05 // 1D or 2D
336+
#define BLEND_STYLE_SWIPE_UP 0x06 // 2D
337+
#define BLEND_STYLE_SWIPE_DOWN 0x07 // 2D
338+
#define BLEND_STYLE_OPEN_H 0x08 // 2D
339+
#define BLEND_STYLE_OPEN_V 0x09 // 2D
340+
// as there are many push variants to optimise if statements they are groupped together
341+
#define BLEND_STYLE_PUSH_RIGHT 0x10 // 1D or 2D (& 0b00010000)
342+
#define BLEND_STYLE_PUSH_LEFT 0x11 // 1D or 2D (& 0b00010000)
343+
#define BLEND_STYLE_PUSH_UP 0x12 // 2D (& 0b00010000)
344+
#define BLEND_STYLE_PUSH_DOWN 0x13 // 2D (& 0b00010000)
345+
#define BLEND_STYLE_PUSH_TL 0x14 // 2D (& 0b00010000)
346+
#define BLEND_STYLE_PUSH_TR 0x15 // 2D (& 0b00010000)
347+
#define BLEND_STYLE_PUSH_BR 0x16 // 2D (& 0b00010000)
348+
#define BLEND_STYLE_PUSH_BL 0x17 // 2D (& 0b00010000)
349+
#define BLEND_STYLE_PUSH_MASK 0x10
350+
#define BLEND_STYLE_COUNT 18
351+
352+
329353
typedef enum mapping1D2D {
330354
M12_Pixels = 0,
331355
M12_pBar = 1,
@@ -334,7 +358,7 @@ typedef enum mapping1D2D {
334358
M12_sPinwheel = 4
335359
} mapping1D2D_t;
336360

337-
// segment, 80 bytes
361+
// segment, 68 bytes
338362
typedef struct Segment {
339363
public:
340364
uint16_t start; // start index / start X coordinate 2D (left)
@@ -437,6 +461,9 @@ typedef struct Segment {
437461
static uint16_t _transitionprogress; // current transition progress 0 - 0xFFFF
438462
#ifndef WLED_DISABLE_MODE_BLEND
439463
static bool _modeBlend; // mode/effect blending semaphore
464+
// clipping
465+
static uint16_t _clipStart, _clipStop;
466+
static uint8_t _clipStartY, _clipStopY;
440467
#endif
441468

442469
// transition data, valid only if transitional==true, holds values during transition (72 bytes)
@@ -447,6 +474,7 @@ typedef struct Segment {
447474
#else
448475
uint32_t _colorT[NUM_COLORS];
449476
#endif
477+
uint8_t _palTid; // previous palette
450478
uint8_t _briT; // temporary brightness
451479
uint8_t _cctT; // temporary CCT
452480
CRGBPalette16 _palT; // temporary palette
@@ -611,6 +639,10 @@ typedef struct Segment {
611639
inline void setPixelColor(float i, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0, bool aa = true) const { setPixelColor(i, RGBW32(r,g,b,w), aa); }
612640
inline void setPixelColor(float i, CRGB c, bool aa = true) const { setPixelColor(i, RGBW32(c.r,c.g,c.b,0), aa); }
613641
#endif
642+
#ifndef WLED_DISABLE_MODE_BLEND
643+
static inline void setClippingRect(int startX, int stopX, int startY = 0, int stopY = 1) { _clipStart = startX; _clipStop = stopX; _clipStartY = startY; _clipStopY = stopY; };
644+
#endif
645+
bool isPixelClipped(int i) const;
614646
[[gnu::hot]] uint32_t getPixelColor(int i) const;
615647
// 1D support functions (some implement 2D as well)
616648
void blur(uint8_t, bool smear = false);
@@ -657,6 +689,7 @@ typedef struct Segment {
657689
inline void setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = true) const { setPixelColorXY(x, y, RGBW32(r,g,b,w), aa); }
658690
inline void setPixelColorXY(float x, float y, CRGB c, bool aa = true) const { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0), aa); }
659691
#endif
692+
[[gnu::hot]] bool isPixelXYClipped(int x, int y) const;
660693
[[gnu::hot]] uint32_t getPixelColorXY(int x, int y) const;
661694
// 2D support functions
662695
inline void blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend) { setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, blend)); }
@@ -694,6 +727,7 @@ typedef struct Segment {
694727
inline void setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = true) { setPixelColor(x, RGBW32(r,g,b,w), aa); }
695728
inline void setPixelColorXY(float x, float y, CRGB c, bool aa = true) { setPixelColor(x, RGBW32(c.r,c.g,c.b,0), aa); }
696729
#endif
730+
inline bool isPixelXYClipped(int x, int y) { return isPixelClipped(x); }
697731
inline uint32_t getPixelColorXY(int x, int y) { return getPixelColor(x); }
698732
inline void blendPixelColorXY(uint16_t x, uint16_t y, uint32_t c, uint8_t blend) { blendPixelColor(x, c, blend); }
699733
inline void blendPixelColorXY(uint16_t x, uint16_t y, CRGB c, uint8_t blend) { blendPixelColor(x, RGBW32(c.r,c.g,c.b,0), blend); }
@@ -738,7 +772,6 @@ class WS2812FX { // 96 bytes
738772
public:
739773

740774
WS2812FX() :
741-
paletteFade(0),
742775
paletteBlend(0),
743776
now(millis()),
744777
timebase(0),
@@ -827,7 +860,6 @@ class WS2812FX { // 96 bytes
827860
inline void resume() { _suspend = false; } // will resume strip.service() execution
828861

829862
bool
830-
paletteFade,
831863
checkSegmentAlignment() const,
832864
hasRGBWBus() const,
833865
hasCCTBus() const,

0 commit comments

Comments
 (0)