Merge branch 'main' into gif-fix
This commit is contained in:
275
wled00/FX.cpp
275
wled00/FX.cpp
@@ -197,7 +197,7 @@ static const char _data_FX_MODE_STROBE_RAINBOW[] PROGMEM = "Strobe Rainbow@!;,!;
|
||||
* if (bool rev == true) then LEDs are turned off in reverse order
|
||||
*/
|
||||
uint16_t color_wipe(bool rev, bool useRandomColors) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
uint32_t cycleTime = 750 + (255 - SEGMENT.speed)*150;
|
||||
uint32_t perc = strip.now % cycleTime;
|
||||
unsigned prog = (perc * 65535) / cycleTime;
|
||||
@@ -410,7 +410,7 @@ static const char _data_FX_MODE_FADE[] PROGMEM = "Fade@!;!,!;!;01";
|
||||
* Scan mode parent function
|
||||
*/
|
||||
uint16_t scan(bool dual) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
uint32_t cycleTime = 750 + (255 - SEGMENT.speed)*150;
|
||||
uint32_t perc = strip.now % cycleTime;
|
||||
int prog = (perc * 65535) / cycleTime;
|
||||
@@ -642,11 +642,12 @@ static const char _data_FX_MODE_TWINKLE[] PROGMEM = "Twinkle@!,!;!,!;!;;m12=0";
|
||||
* Dissolve function
|
||||
*/
|
||||
uint16_t dissolve(uint32_t color) {
|
||||
unsigned dataSize = (SEGLEN+7) >> 3; //1 bit per LED
|
||||
unsigned dataSize = sizeof(uint32_t) * SEGLEN;
|
||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||
uint32_t* pixels = reinterpret_cast<uint32_t*>(SEGENV.data);
|
||||
|
||||
if (SEGENV.call == 0) {
|
||||
memset(SEGMENT.data, 0xFF, dataSize); // start by fading pixels up
|
||||
for (unsigned i = 0; i < SEGLEN; i++) pixels[i] = SEGCOLOR(1);
|
||||
SEGENV.aux0 = 1;
|
||||
}
|
||||
|
||||
@@ -654,33 +655,26 @@ uint16_t dissolve(uint32_t color) {
|
||||
if (hw_random8() <= SEGMENT.intensity) {
|
||||
for (size_t times = 0; times < 10; times++) { //attempt to spawn a new pixel 10 times
|
||||
unsigned i = hw_random16(SEGLEN);
|
||||
unsigned index = i >> 3;
|
||||
unsigned bitNum = i & 0x07;
|
||||
bool fadeUp = bitRead(SEGENV.data[index], bitNum);
|
||||
if (SEGENV.aux0) { //dissolve to primary/palette
|
||||
if (fadeUp) {
|
||||
if (color == SEGCOLOR(0)) {
|
||||
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
||||
} else {
|
||||
SEGMENT.setPixelColor(i, color);
|
||||
}
|
||||
bitWrite(SEGENV.data[index], bitNum, false);
|
||||
if (pixels[i] == SEGCOLOR(1)) {
|
||||
pixels[i] = color == SEGCOLOR(0) ? SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0) : color;
|
||||
break; //only spawn 1 new pixel per frame per 50 LEDs
|
||||
}
|
||||
} else { //dissolve to secondary
|
||||
if (!fadeUp) {
|
||||
SEGMENT.setPixelColor(i, SEGCOLOR(1)); break;
|
||||
bitWrite(SEGENV.data[index], bitNum, true);
|
||||
if (pixels[i] != SEGCOLOR(1)) {
|
||||
pixels[i] = SEGCOLOR(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// fix for #4401
|
||||
for (unsigned i = 0; i < SEGLEN; i++) SEGMENT.setPixelColor(i, pixels[i]);
|
||||
|
||||
if (SEGENV.step > (255 - SEGMENT.speed) + 15U) {
|
||||
SEGENV.aux0 = !SEGENV.aux0;
|
||||
SEGENV.step = 0;
|
||||
memset(SEGMENT.data, (SEGENV.aux0 ? 0xFF : 0), dataSize); // switch fading
|
||||
} else {
|
||||
SEGENV.step++;
|
||||
}
|
||||
@@ -1023,7 +1017,7 @@ static const char _data_FX_MODE_COLORFUL[] PROGMEM = "Colorful@!,Saturation;1,2,
|
||||
* Emulates a traffic light.
|
||||
*/
|
||||
uint16_t mode_traffic_light(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
for (unsigned i=0; i < SEGLEN; i++)
|
||||
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
|
||||
uint32_t mdelay = 500;
|
||||
@@ -1056,7 +1050,7 @@ static const char _data_FX_MODE_TRAFFIC_LIGHT[] PROGMEM = "Traffic Light@!,US st
|
||||
*/
|
||||
#define FLASH_COUNT 4
|
||||
uint16_t mode_chase_flash(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned flash_step = SEGENV.call % ((FLASH_COUNT * 2) + 1);
|
||||
|
||||
for (unsigned i = 0; i < SEGLEN; i++) {
|
||||
@@ -1086,7 +1080,7 @@ static const char _data_FX_MODE_CHASE_FLASH[] PROGMEM = "Chase Flash@!;Bg,Fx;!";
|
||||
* Prim flashes running, followed by random color.
|
||||
*/
|
||||
uint16_t mode_chase_flash_random(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned flash_step = SEGENV.call % ((FLASH_COUNT * 2) + 1);
|
||||
|
||||
for (int i = 0; i < SEGENV.aux1; i++) {
|
||||
@@ -1168,7 +1162,7 @@ static const char _data_FX_MODE_RUNNING_RANDOM[] PROGMEM = "Stream@!,Zone size;;
|
||||
* K.I.T.T.
|
||||
*/
|
||||
uint16_t mode_larson_scanner(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
|
||||
const unsigned speed = FRAMETIME * map(SEGMENT.speed, 0, 255, 96, 2); // map into useful range
|
||||
const unsigned pixels = SEGLEN / speed; // how many pixels to advance per frame
|
||||
@@ -1226,7 +1220,7 @@ static const char _data_FX_MODE_DUAL_LARSON_SCANNER[] PROGMEM = "Scanner Dual@!,
|
||||
* Firing comets from one end. "Lighthouse"
|
||||
*/
|
||||
uint16_t mode_comet(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned counter = (strip.now * ((SEGMENT.speed >>2) +1)) & 0xFFFF;
|
||||
unsigned index = (counter * SEGLEN) >> 16;
|
||||
if (SEGENV.call == 0) SEGENV.aux0 = index;
|
||||
@@ -1254,7 +1248,7 @@ static const char _data_FX_MODE_COMET[] PROGMEM = "Lighthouse@!,Fade rate;!,!;!"
|
||||
* Fireworks function.
|
||||
*/
|
||||
uint16_t mode_fireworks() {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
const uint16_t width = SEGMENT.is2D() ? SEG_W : SEGLEN;
|
||||
const uint16_t height = SEG_H;
|
||||
|
||||
@@ -1296,7 +1290,7 @@ static const char _data_FX_MODE_FIREWORKS[] PROGMEM = "Fireworks@,Frequency;!,!;
|
||||
|
||||
//Twinkling LEDs running. Inspired by https://github.com/kitesurfer1404/WS2812FX/blob/master/src/custom/Rain.h
|
||||
uint16_t mode_rain() {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
const unsigned width = SEG_W;
|
||||
const unsigned height = SEG_H;
|
||||
SEGENV.step += FRAMETIME;
|
||||
@@ -1362,7 +1356,7 @@ static const char _data_FX_MODE_FIRE_FLICKER[] PROGMEM = "Fire Flicker@!,!;!;!;0
|
||||
* Gradient run base function
|
||||
*/
|
||||
uint16_t gradient_base(bool loading) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
uint16_t counter = strip.now * ((SEGMENT.speed >> 2) + 1);
|
||||
uint16_t pp = (counter * SEGLEN) >> 16;
|
||||
if (SEGENV.call == 0) pp = 0;
|
||||
@@ -1407,7 +1401,7 @@ static const char _data_FX_MODE_LOADING[] PROGMEM = "Loading@!,Fade;!,!;!;;ix=16
|
||||
* Two dots running
|
||||
*/
|
||||
uint16_t mode_two_dots() {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned delay = 1 + (FRAMETIME<<3) / SEGLEN; // longer segments should change faster
|
||||
uint32_t it = strip.now / map(SEGMENT.speed, 0, 255, delay<<4, delay);
|
||||
unsigned offset = it % SEGLEN;
|
||||
@@ -1827,7 +1821,7 @@ uint16_t mode_oscillate(void) {
|
||||
// if the counter has increased, move the oscillator by the random step
|
||||
if (it != SEGENV.step) oscillators[i].pos += oscillators[i].dir * oscillators[i].speed;
|
||||
oscillators[i].size = SEGLEN/(3+SEGMENT.intensity/8);
|
||||
if((oscillators[i].dir == -1) && (oscillators[i].pos <= 0)) {
|
||||
if((oscillators[i].dir == -1) && (oscillators[i].pos > SEGLEN << 1)) { // use integer overflow
|
||||
oscillators[i].pos = 0;
|
||||
oscillators[i].dir = 1;
|
||||
// make bigger steps for faster speeds
|
||||
@@ -1843,7 +1837,7 @@ uint16_t mode_oscillate(void) {
|
||||
for (unsigned i = 0; i < SEGLEN; i++) {
|
||||
uint32_t color = BLACK;
|
||||
for (unsigned j = 0; j < numOscillators; j++) {
|
||||
if(i >= (unsigned)oscillators[j].pos - oscillators[j].size && i <= oscillators[j].pos + oscillators[j].size) {
|
||||
if((int)i >= (int)oscillators[j].pos - oscillators[j].size && i <= oscillators[j].pos + oscillators[j].size) {
|
||||
color = (color == BLACK) ? SEGCOLOR(j) : color_blend(color, SEGCOLOR(j), uint8_t(128));
|
||||
}
|
||||
}
|
||||
@@ -1858,7 +1852,7 @@ static const char _data_FX_MODE_OSCILLATE[] PROGMEM = "Oscillate";
|
||||
|
||||
//TODO
|
||||
uint16_t mode_lightning(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned ledstart = hw_random16(SEGLEN); // Determine starting location of flash
|
||||
unsigned ledlen = 1 + hw_random16(SEGLEN -ledstart); // Determine length of flash (not to go beyond NUM_LEDS-1)
|
||||
uint8_t bri = 255/hw_random8(1, 3);
|
||||
@@ -1899,52 +1893,76 @@ uint16_t mode_lightning(void) {
|
||||
}
|
||||
static const char _data_FX_MODE_LIGHTNING[] PROGMEM = "Lightning@!,!,,,,,Overlay;!,!;!";
|
||||
|
||||
|
||||
// Pride2015
|
||||
// Animated, ever-changing rainbows.
|
||||
// by Mark Kriegsman: https://gist.github.com/kriegsman/964de772d64c502760e5
|
||||
uint16_t mode_pride_2015(void) {
|
||||
// combined function from original pride and colorwaves
|
||||
uint16_t mode_colorwaves_pride_base(bool isPride2015) {
|
||||
unsigned duration = 10 + SEGMENT.speed;
|
||||
unsigned sPseudotime = SEGENV.step;
|
||||
unsigned sHue16 = SEGENV.aux0;
|
||||
|
||||
uint8_t sat8 = beatsin88_t( 87, 220, 250);
|
||||
uint8_t brightdepth = beatsin88_t( 341, 96, 224);
|
||||
unsigned brightnessthetainc16 = beatsin88_t( 203, (25 * 256), (40 * 256));
|
||||
uint8_t sat8 = isPride2015 ? beatsin88_t(87, 220, 250) : 255;
|
||||
unsigned brightdepth = beatsin88_t(341, 96, 224);
|
||||
unsigned brightnessthetainc16 = beatsin88_t(203, (25 * 256), (40 * 256));
|
||||
unsigned msmultiplier = beatsin88_t(147, 23, 60);
|
||||
|
||||
unsigned hue16 = sHue16;//gHue * 256;
|
||||
unsigned hueinc16 = beatsin88_t(113, 1, 3000);
|
||||
unsigned hue16 = sHue16;
|
||||
unsigned hueinc16 = isPride2015 ? beatsin88_t(113, 1, 3000) :
|
||||
beatsin88_t(113, 60, 300) * SEGMENT.intensity * 10 / 255;
|
||||
|
||||
sPseudotime += duration * msmultiplier;
|
||||
sHue16 += duration * beatsin88_t( 400, 5,9);
|
||||
sHue16 += duration * beatsin88_t(400, 5, 9);
|
||||
unsigned brightnesstheta16 = sPseudotime;
|
||||
|
||||
for (unsigned i = 0 ; i < SEGLEN; i++) {
|
||||
for (unsigned i = 0; i < SEGLEN; i++) {
|
||||
hue16 += hueinc16;
|
||||
uint8_t hue8 = hue16 >> 8;
|
||||
uint8_t hue8;
|
||||
|
||||
brightnesstheta16 += brightnessthetainc16;
|
||||
unsigned b16 = sin16_t( brightnesstheta16 ) + 32768;
|
||||
if (isPride2015) {
|
||||
hue8 = hue16 >> 8;
|
||||
} else {
|
||||
unsigned h16_128 = hue16 >> 7;
|
||||
hue8 = (h16_128 & 0x100) ? (255 - (h16_128 >> 1)) : (h16_128 >> 1);
|
||||
}
|
||||
|
||||
brightnesstheta16 += brightnessthetainc16;
|
||||
unsigned b16 = sin16_t(brightnesstheta16) + 32768;
|
||||
unsigned bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
||||
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
||||
bri8 += (255 - brightdepth);
|
||||
|
||||
CRGB newcolor = CHSV(hue8, sat8, bri8);
|
||||
SEGMENT.blendPixelColor(i, newcolor, 64);
|
||||
if (isPride2015) {
|
||||
CRGB newcolor = CHSV(hue8, sat8, bri8);
|
||||
SEGMENT.blendPixelColor(i, newcolor, 64);
|
||||
} else {
|
||||
SEGMENT.blendPixelColor(i, SEGMENT.color_from_palette(hue8, false, PALETTE_SOLID_WRAP, 0, bri8), 128);
|
||||
}
|
||||
}
|
||||
|
||||
SEGENV.step = sPseudotime;
|
||||
SEGENV.aux0 = sHue16;
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
||||
// Pride2015
|
||||
// Animated, ever-changing rainbows.
|
||||
// by Mark Kriegsman: https://gist.github.com/kriegsman/964de772d64c502760e5
|
||||
uint16_t mode_pride_2015(void) {
|
||||
return mode_colorwaves_pride_base(true);
|
||||
}
|
||||
static const char _data_FX_MODE_PRIDE_2015[] PROGMEM = "Pride 2015@!;;";
|
||||
|
||||
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
|
||||
// This function draws color waves with an ever-changing,
|
||||
// widely-varying set of parameters, using a color palette.
|
||||
uint16_t mode_colorwaves() {
|
||||
return mode_colorwaves_pride_base(false);
|
||||
}
|
||||
static const char _data_FX_MODE_COLORWAVES[] PROGMEM = "Colorwaves@!,Hue;!;!;;pal=26";
|
||||
|
||||
|
||||
//eight colored dots, weaving in and out of sync with each other
|
||||
uint16_t mode_juggle(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
|
||||
SEGMENT.fadeToBlackBy(192 - (3*SEGMENT.intensity/4));
|
||||
CRGB fastled_col;
|
||||
@@ -2089,7 +2107,7 @@ static const char _data_FX_MODE_PALETTE[] PROGMEM = "Palette@Shift,Size,Rotation
|
||||
// feel of your fire: COOLING (used in step 1 above) (Speed = COOLING), and SPARKING (used
|
||||
// in step 3 above) (Effect Intensity = Sparking).
|
||||
uint16_t mode_fire_2012() {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
const unsigned strips = SEGMENT.nrOfVStrips();
|
||||
if (!SEGENV.allocateData(strips * SEGLEN)) return mode_static(); //allocation failed
|
||||
byte* heat = SEGENV.data;
|
||||
@@ -2147,53 +2165,6 @@ uint16_t mode_fire_2012() {
|
||||
}
|
||||
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate,,2D Blur,Boost;;!;1;pal=35,sx=64,ix=160,m12=1,c2=128"; // bars
|
||||
|
||||
|
||||
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
|
||||
// This function draws color waves with an ever-changing,
|
||||
// widely-varying set of parameters, using a color palette.
|
||||
uint16_t mode_colorwaves() {
|
||||
unsigned duration = 10 + SEGMENT.speed;
|
||||
unsigned sPseudotime = SEGENV.step;
|
||||
unsigned sHue16 = SEGENV.aux0;
|
||||
|
||||
unsigned brightdepth = beatsin88_t(341, 96, 224);
|
||||
unsigned brightnessthetainc16 = beatsin88_t( 203, (25 * 256), (40 * 256));
|
||||
unsigned msmultiplier = beatsin88_t(147, 23, 60);
|
||||
|
||||
unsigned hue16 = sHue16;//gHue * 256;
|
||||
unsigned hueinc16 = beatsin88_t(113, 60, 300)*SEGMENT.intensity*10/255; // Use the Intensity Slider for the hues
|
||||
|
||||
sPseudotime += duration * msmultiplier;
|
||||
sHue16 += duration * beatsin88_t(400, 5, 9);
|
||||
unsigned brightnesstheta16 = sPseudotime;
|
||||
|
||||
for (unsigned i = 0 ; i < SEGLEN; i++) {
|
||||
hue16 += hueinc16;
|
||||
uint8_t hue8 = hue16 >> 8;
|
||||
unsigned h16_128 = hue16 >> 7;
|
||||
if ( h16_128 & 0x100) {
|
||||
hue8 = 255 - (h16_128 >> 1);
|
||||
} else {
|
||||
hue8 = h16_128 >> 1;
|
||||
}
|
||||
|
||||
brightnesstheta16 += brightnessthetainc16;
|
||||
unsigned b16 = sin16_t(brightnesstheta16) + 32768;
|
||||
|
||||
unsigned bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
||||
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
||||
bri8 += (255 - brightdepth);
|
||||
|
||||
SEGMENT.blendPixelColor(i, SEGMENT.color_from_palette(hue8, false, PALETTE_SOLID_WRAP, 0, bri8), 128); // 50/50 mix
|
||||
}
|
||||
SEGENV.step = sPseudotime;
|
||||
SEGENV.aux0 = sHue16;
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_COLORWAVES[] PROGMEM = "Colorwaves@!,Hue;!;!;;pal=26";
|
||||
|
||||
|
||||
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
|
||||
uint16_t mode_bpm() {
|
||||
uint32_t stp = (strip.now / 20) & 0xFF;
|
||||
@@ -2369,7 +2340,7 @@ static const char _data_FX_MODE_LAKE[] PROGMEM = "Lake@!;Fx;!";
|
||||
// send a meteor from begining to to the end of the strip with a trail that randomly decays.
|
||||
// adapted from https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#LEDStripEffectMeteorRain
|
||||
uint16_t mode_meteor() {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
if (!SEGENV.allocateData(SEGLEN)) return mode_static(); //allocation failed
|
||||
const bool meteorSmooth = SEGMENT.check3;
|
||||
byte* trail = SEGENV.data;
|
||||
@@ -2436,7 +2407,7 @@ static const char _data_FX_MODE_METEOR[] PROGMEM = "Meteor@!,Trail,,,,Gradient,,
|
||||
|
||||
//Railway Crossing / Christmas Fairy lights
|
||||
uint16_t mode_railway() {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned dur = (256 - SEGMENT.speed) * 40;
|
||||
uint16_t rampdur = (dur * SEGMENT.intensity) >> 8;
|
||||
if (SEGENV.step > dur)
|
||||
@@ -2537,7 +2508,7 @@ static uint16_t ripple_base(uint8_t blurAmount = 0) {
|
||||
|
||||
|
||||
uint16_t mode_ripple(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
if(SEGMENT.custom1 || SEGMENT.check2) // blur or overlay
|
||||
SEGMENT.fade_out(250);
|
||||
else
|
||||
@@ -2549,7 +2520,7 @@ static const char _data_FX_MODE_RIPPLE[] PROGMEM = "Ripple@!,Wave #,Blur,,,,Over
|
||||
|
||||
|
||||
uint16_t mode_ripple_rainbow(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
if (SEGENV.call ==0) {
|
||||
SEGENV.aux0 = hw_random8();
|
||||
SEGENV.aux1 = hw_random8();
|
||||
@@ -2727,7 +2698,7 @@ uint16_t mode_halloween_eyes()
|
||||
uint32_t blinkEndTime;
|
||||
};
|
||||
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
const unsigned maxWidth = strip.isMatrix ? SEG_W : SEGLEN;
|
||||
const unsigned HALLOWEEN_EYE_SPACE = MAX(2, strip.isMatrix ? SEG_W>>4: SEGLEN>>5);
|
||||
const unsigned HALLOWEEN_EYE_WIDTH = HALLOWEEN_EYE_SPACE/2;
|
||||
@@ -2912,7 +2883,7 @@ static const char _data_FX_MODE_TRI_STATIC_PATTERN[] PROGMEM = "Solid Pattern Tr
|
||||
|
||||
static uint16_t spots_base(uint16_t threshold)
|
||||
{
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
if (!SEGMENT.check2) SEGMENT.fill(SEGCOLOR(1));
|
||||
|
||||
unsigned maxZones = SEGLEN >> 2;
|
||||
@@ -2968,7 +2939,7 @@ typedef struct Ball {
|
||||
* Bouncing Balls Effect
|
||||
*/
|
||||
uint16_t mode_bouncing_balls(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
//allocate segment data
|
||||
const unsigned strips = SEGMENT.nrOfVStrips(); // adapt for 2D
|
||||
const size_t maxNumBalls = 16;
|
||||
@@ -3146,7 +3117,7 @@ static const char _data_FX_MODE_ROLLINGBALLS[] PROGMEM = "Rolling Balls@!,# of b
|
||||
* Sinelon stolen from FASTLED examples
|
||||
*/
|
||||
static uint16_t sinelon_base(bool dual, bool rainbow=false) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
SEGMENT.fade_out(SEGMENT.intensity);
|
||||
unsigned pos = beatsin16_t(SEGMENT.speed/10,0,SEGLEN-1);
|
||||
if (SEGENV.call == 0) SEGENV.aux0 = pos;
|
||||
@@ -3251,7 +3222,7 @@ typedef struct Spark {
|
||||
* modified from https://github.com/kitesurfer1404/WS2812FX/blob/master/src/custom/Popcorn.h
|
||||
*/
|
||||
uint16_t mode_popcorn(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
//allocate segment data
|
||||
unsigned strips = SEGMENT.nrOfVStrips();
|
||||
unsigned usablePopcorns = maxNumPopcorn;
|
||||
@@ -3426,7 +3397,7 @@ typedef struct particle {
|
||||
} star;
|
||||
|
||||
uint16_t mode_starburst(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned maxData = FAIR_DATA_PER_SEG; //ESP8266: 256 ESP32: 640
|
||||
unsigned segs = strip.getActiveSegmentsNum();
|
||||
if (segs <= (strip.getMaxSegments() /2)) maxData *= 2; //ESP8266: 512 if <= 8 segs ESP32: 1280 if <= 16 segs
|
||||
@@ -3545,7 +3516,7 @@ static const char _data_FX_MODE_STARBURST[] PROGMEM = "Fireworks Starburst@Chanc
|
||||
*/
|
||||
uint16_t mode_exploding_fireworks(void)
|
||||
{
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
const int cols = SEGMENT.is2D() ? SEG_W : 1;
|
||||
const int rows = SEGMENT.is2D() ? SEG_H : SEGLEN;
|
||||
|
||||
@@ -3683,7 +3654,7 @@ static const char _data_FX_MODE_EXPLODING_FIREWORKS[] PROGMEM = "Fireworks 1D@Gr
|
||||
*/
|
||||
uint16_t mode_drip(void)
|
||||
{
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
//allocate segment data
|
||||
unsigned strips = SEGMENT.nrOfVStrips();
|
||||
const int maxNumDrops = 4;
|
||||
@@ -3779,7 +3750,7 @@ typedef struct Tetris {
|
||||
} tetris;
|
||||
|
||||
uint16_t mode_tetrix(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned strips = SEGMENT.nrOfVStrips(); // allow running on virtual strips (columns in 2D segment)
|
||||
unsigned dataSize = sizeof(tetris);
|
||||
if (!SEGENV.allocateData(dataSize * strips)) return mode_static(); //allocation failed
|
||||
@@ -3990,7 +3961,7 @@ static const char _data_FX_MODE_HEARTBEAT[] PROGMEM = "Heartbeat@!,!;!,!;!;01;m1
|
||||
// Modified for WLED, based on https://github.com/FastLED/FastLED/blob/master/examples/Pacifica/Pacifica.ino
|
||||
//
|
||||
// Add one layer of waves into the led array
|
||||
static CRGB pacifica_one_layer(uint16_t i, CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
|
||||
static CRGB pacifica_one_layer(uint16_t i, const CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
|
||||
{
|
||||
unsigned ci = cistart;
|
||||
unsigned waveangle = ioff;
|
||||
@@ -4086,7 +4057,7 @@ static const char _data_FX_MODE_PACIFICA[] PROGMEM = "Pacifica@!,Angle;;!;;pal=5
|
||||
* Mode simulates a gradual sunrise
|
||||
*/
|
||||
uint16_t mode_sunrise() {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
//speed 0 - static sun
|
||||
//speed 1 - 60: sunrise time in minutes
|
||||
//speed 60 - 120 : sunset time in minutes - 60;
|
||||
@@ -4293,7 +4264,7 @@ static const char _data_FX_MODE_FLOW[] PROGMEM = "Flow@!,Zones;;!;;m12=1"; //ver
|
||||
*/
|
||||
uint16_t mode_chunchun(void)
|
||||
{
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
SEGMENT.fade_out(254); // add a bit of trail
|
||||
unsigned counter = strip.now * (6 + (SEGMENT.speed >> 4));
|
||||
unsigned numBirds = 2 + (SEGLEN >> 3); // 2 + 1/8 of a segment
|
||||
@@ -4344,7 +4315,7 @@ typedef struct Spotlight {
|
||||
*/
|
||||
uint16_t mode_dancing_shadows(void)
|
||||
{
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned numSpotlights = map(SEGMENT.intensity, 0, 255, 2, SPOT_MAX_COUNT); // 49 on 32 segment ESP32, 17 on 16 segment ESP8266
|
||||
bool initialize = SEGENV.aux0 != numSpotlights;
|
||||
SEGENV.aux0 = numSpotlights;
|
||||
@@ -4824,7 +4795,7 @@ static const char _data_FX_MODE_AURORA[] PROGMEM = "Aurora@!,!;1,2,3;!;;sx=24,pa
|
||||
// 16 bit perlinmove. Use Perlin Noise instead of sinewaves for movement. By Andrew Tuline.
|
||||
// Controls are speed, # of pixels, faderate.
|
||||
uint16_t mode_perlinmove(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
SEGMENT.fade_out(255-SEGMENT.custom1);
|
||||
for (int i = 0; i < SEGMENT.intensity/16 + 1; i++) {
|
||||
unsigned locn = inoise16(strip.now*128/(260-SEGMENT.speed)+i*15000, strip.now*128/(260-SEGMENT.speed)); // Get a new pixel location from moving noise.
|
||||
@@ -4860,7 +4831,7 @@ static const char _data_FX_MODE_WAVESINS[] PROGMEM = "Wavesins@!,Brightness vari
|
||||
//////////////////////////////
|
||||
// By: ldirko https://editor.soulmatelights.com/gallery/392-flow-led-stripe , modifed by: Andrew Tuline
|
||||
uint16_t mode_FlowStripe(void) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
const int hl = SEGLEN * 10 / 13;
|
||||
uint8_t hue = strip.now / (SEGMENT.speed+1);
|
||||
uint32_t t = strip.now / (SEGMENT.intensity/8+1);
|
||||
@@ -5184,7 +5155,7 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
|
||||
neighbors++;
|
||||
bool colorFound = false;
|
||||
int k;
|
||||
for (k=0; k<9 && colorsCount[i].count != 0; k++)
|
||||
for (k=0; k<9 && colorsCount[k].count != 0; k++)
|
||||
if (colorsCount[k].color == prevLeds[xy]) {
|
||||
colorsCount[k].count++;
|
||||
colorFound = true;
|
||||
@@ -5493,15 +5464,15 @@ uint16_t mode_2Dmetaballs(void) { // Metaballs by Stefan Petrick. Cannot have
|
||||
// and add them together with weightening
|
||||
unsigned dx = abs(x - x1);
|
||||
unsigned dy = abs(y - y1);
|
||||
unsigned dist = 2 * sqrt16((dx * dx) + (dy * dy));
|
||||
unsigned dist = 2 * sqrt32_bw((dx * dx) + (dy * dy));
|
||||
|
||||
dx = abs(x - x2);
|
||||
dy = abs(y - y2);
|
||||
dist += sqrt16((dx * dx) + (dy * dy));
|
||||
dist += sqrt32_bw((dx * dx) + (dy * dy));
|
||||
|
||||
dx = abs(x - x3);
|
||||
dy = abs(y - y3);
|
||||
dist += sqrt16((dx * dx) + (dy * dy));
|
||||
dist += sqrt32_bw((dx * dx) + (dy * dy));
|
||||
|
||||
// inverse result
|
||||
int color = dist ? 1000 / dist : 255;
|
||||
@@ -6141,13 +6112,23 @@ uint16_t mode_2Dscrollingtext(void) {
|
||||
if (!strlen(text)) { // fallback if empty segment name: display date and time
|
||||
sprintf_P(text, PSTR("%s %d, %d %d:%02d%s"), monthShortStr(month(localTime)), day(localTime), year(localTime), AmPmHour, minute(localTime), sec);
|
||||
} else {
|
||||
if (text[0] == '#') for (auto &c : text) c = std::toupper(c);
|
||||
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));
|
||||
else if (!strncmp_P(text,PSTR("#DDMM"),5)) sprintf_P(text, zero?PSTR("%02d.%02d") :PSTR("%d.%d"), day(localTime), month(localTime));
|
||||
else if (!strncmp_P(text,PSTR("#MMDD"),5)) sprintf_P(text, zero?PSTR("%02d/%02d") :PSTR("%d/%d"), month(localTime), day(localTime));
|
||||
else if (!strncmp_P(text,PSTR("#TIME"),5)) sprintf_P(text, zero?PSTR("%02d:%02d%s") :PSTR("%2d:%02d%s"), AmPmHour, minute(localTime), sec);
|
||||
else if (!strncmp_P(text,PSTR("#HHMM"),5)) sprintf_P(text, zero?PSTR("%02d:%02d") :PSTR("%d:%02d"), AmPmHour, minute(localTime));
|
||||
else if (!strncmp_P(text,PSTR("#HH"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), AmPmHour);
|
||||
else if (!strncmp_P(text,PSTR("#MM"),3)) sprintf_P(text, zero?PSTR("%02d") :PSTR("%d"), minute(localTime));
|
||||
else if (!strncmp_P(text,PSTR("#HH"),3)) sprintf (text, zero? ("%02d") : ("%d"), AmPmHour);
|
||||
else if (!strncmp_P(text,PSTR("#MM"),3)) sprintf (text, zero? ("%02d") : ("%d"), minute(localTime));
|
||||
else if (!strncmp_P(text,PSTR("#SS"),3)) sprintf (text, ("%02d") , second(localTime));
|
||||
else if (!strncmp_P(text,PSTR("#DD"),3)) sprintf (text, zero? ("%02d") : ("%d"), day(localTime));
|
||||
else if (!strncmp_P(text,PSTR("#DAY"),4)) sprintf (text, ("%s") , dayShortStr(day(localTime)));
|
||||
else if (!strncmp_P(text,PSTR("#DDDD"),5)) sprintf (text, ("%s") , dayStr(day(localTime)));
|
||||
else if (!strncmp_P(text,PSTR("#MO"),3)) sprintf (text, zero? ("%02d") : ("%d"), month(localTime));
|
||||
else if (!strncmp_P(text,PSTR("#MON"),4)) sprintf (text, ("%s") , monthShortStr(month(localTime)));
|
||||
else if (!strncmp_P(text,PSTR("#MMMM"),5)) sprintf (text, ("%s") , monthStr(month(localTime)));
|
||||
else if (!strncmp_P(text,PSTR("#YY"),3)) sprintf (text, ("%02d") , year(localTime)%100);
|
||||
else if (!strncmp_P(text,PSTR("#YYYY"),5)) sprintf_P(text, zero?PSTR("%04d") : ("%d"), year(localTime));
|
||||
}
|
||||
|
||||
const int numberOfLetters = strlen(text);
|
||||
@@ -6586,23 +6567,31 @@ static const char _data_FX_MODE_JUGGLES[] PROGMEM = "Juggles@!,# of balls;!,!;!;
|
||||
// * MATRIPIX //
|
||||
//////////////////////
|
||||
uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline.
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
// even with 1D effect we have to take logic for 2D segments for allocation as fill_solid() fills whole segment
|
||||
// effect can work on single pixels, we just lose the shifting effect
|
||||
unsigned dataSize = sizeof(uint32_t) * SEGLEN;
|
||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||
uint32_t* pixels = reinterpret_cast<uint32_t*>(SEGENV.data);
|
||||
|
||||
um_data_t *um_data = getAudioData();
|
||||
int volumeRaw = *(int16_t*)um_data->u_data[1];
|
||||
|
||||
if (SEGENV.call == 0) {
|
||||
SEGMENT.fill(BLACK);
|
||||
for (unsigned i = 0; i < SEGLEN; i++) pixels[i] = BLACK; // may not be needed as resetIfRequired() clears buffer
|
||||
}
|
||||
|
||||
uint8_t secondHand = micros()/(256-SEGMENT.speed)/500 % 16;
|
||||
if(SEGENV.aux0 != secondHand) {
|
||||
SEGENV.aux0 = secondHand;
|
||||
|
||||
uint8_t pixBri = volumeRaw * SEGMENT.intensity / 64;
|
||||
for (unsigned i = 0; i < SEGLEN-1; i++) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i+1)); // shift left
|
||||
SEGMENT.setPixelColor(SEGLEN-1, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(strip.now, false, PALETTE_SOLID_WRAP, 0), pixBri));
|
||||
int pixBri = volumeRaw * SEGMENT.intensity / 64;
|
||||
unsigned k = SEGLEN-1;
|
||||
// loop will not execute if SEGLEN equals 1
|
||||
for (unsigned i = 0; i < k; i++) {
|
||||
pixels[i] = pixels[i+1]; // shift left
|
||||
SEGMENT.setPixelColor(i, pixels[i]);
|
||||
}
|
||||
pixels[k] = color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(strip.now, false, PALETTE_SOLID_WRAP, 0), pixBri);
|
||||
SEGMENT.setPixelColor(k, pixels[k]);
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
@@ -6614,7 +6603,7 @@ static const char _data_FX_MODE_MATRIPIX[] PROGMEM = "Matripix@!,Brightness;!,!;
|
||||
// * MIDNOISE //
|
||||
//////////////////////
|
||||
uint16_t mode_midnoise(void) { // Midnoise. By Andrew Tuline.
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
// Changing xdist to SEGENV.aux0 and ydist to SEGENV.aux1.
|
||||
|
||||
um_data_t *um_data = getAudioData();
|
||||
@@ -6705,7 +6694,7 @@ static const char _data_FX_MODE_NOISEMETER[] PROGMEM = "Noisemeter@Fade rate,Wid
|
||||
// * PIXELWAVE //
|
||||
//////////////////////
|
||||
uint16_t mode_pixelwave(void) { // Pixelwave. By Andrew Tuline.
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
// even with 1D effect we have to take logic for 2D segments for allocation as fill_solid() fills whole segment
|
||||
|
||||
if (SEGENV.call == 0) {
|
||||
@@ -6773,7 +6762,7 @@ static const char _data_FX_MODE_PLASMOID[] PROGMEM = "Plasmoid@Phase,# of pixels
|
||||
//////////////////////
|
||||
// Puddles/Puddlepeak By Andrew Tuline. Merged by @dedehai
|
||||
uint16_t mode_puddles_base(bool peakdetect) {
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
unsigned size = 0;
|
||||
uint8_t fadeVal = map(SEGMENT.speed, 0, 255, 224, 254);
|
||||
unsigned pos = hw_random16(SEGLEN); // Set a random starting position.
|
||||
@@ -6823,7 +6812,7 @@ static const char _data_FX_MODE_PUDDLES[] PROGMEM = "Puddles@Fade rate,Puddle si
|
||||
// * PIXELS //
|
||||
//////////////////////
|
||||
uint16_t mode_pixels(void) { // Pixels. By Andrew Tuline.
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
|
||||
if (!SEGENV.allocateData(32*sizeof(uint8_t))) return mode_static(); //allocation failed
|
||||
uint8_t *myVals = reinterpret_cast<uint8_t*>(SEGENV.data); // Used to store a pile of samples because WLED frame rate and WLED sample rate are not synchronized. Frame rate is too low.
|
||||
@@ -6851,7 +6840,7 @@ static const char _data_FX_MODE_PIXELS[] PROGMEM = "Pixels@Fade rate,# of pixels
|
||||
// ** Blurz //
|
||||
//////////////////////
|
||||
uint16_t mode_blurz(void) { // Blurz. By Andrew Tuline.
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
// even with 1D effect we have to take logic for 2D segments for allocation as fill_solid() fills whole segment
|
||||
|
||||
um_data_t *um_data = getAudioData();
|
||||
@@ -6915,7 +6904,7 @@ static const char _data_FX_MODE_DJLIGHT[] PROGMEM = "DJ Light@Speed;;;01f;m12=2,
|
||||
// ** Freqmap //
|
||||
////////////////////
|
||||
uint16_t mode_freqmap(void) { // Map FFT_MajorPeak to SEGLEN. Would be better if a higher framerate.
|
||||
if (SEGLEN == 1) return mode_static();
|
||||
if (SEGLEN <= 1) return mode_static();
|
||||
// Start frequency = 60 Hz and log10(60) = 1.78
|
||||
// End frequency = MAX_FREQUENCY in Hz and lo10(MAX_FREQUENCY) = MAX_FREQ_LOG10
|
||||
|
||||
@@ -7157,8 +7146,11 @@ static const char _data_FX_MODE_ROCKTAVES[] PROGMEM = "Rocktaves@;!,!;!;01f;m12=
|
||||
// Combines peak detection with FFT_MajorPeak and FFT_Magnitude.
|
||||
uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tuline
|
||||
// effect can work on single pixels, we just lose the shifting effect
|
||||
|
||||
um_data_t *um_data = getAudioData();
|
||||
unsigned dataSize = sizeof(uint32_t) * SEGLEN;
|
||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||
uint32_t* pixels = reinterpret_cast<uint32_t*>(SEGENV.data);
|
||||
|
||||
um_data_t *um_data = getAudioData();
|
||||
uint8_t samplePeak = *(uint8_t*)um_data->u_data[3];
|
||||
float FFT_MajorPeak = *(float*) um_data->u_data[4];
|
||||
uint8_t *maxVol = (uint8_t*)um_data->u_data[6];
|
||||
@@ -7168,7 +7160,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
|
||||
if (FFT_MajorPeak < 1) FFT_MajorPeak = 1; // log10(0) is "forbidden" (throws exception)
|
||||
|
||||
if (SEGENV.call == 0) {
|
||||
SEGMENT.fill(BLACK);
|
||||
for (unsigned i = 0; i < SEGLEN; i++) pixels[i] = BLACK; // may not be needed as resetIfRequired() clears buffer
|
||||
SEGENV.aux0 = 255;
|
||||
SEGMENT.custom1 = *binNum;
|
||||
SEGMENT.custom2 = *maxVol * 2;
|
||||
@@ -7185,13 +7177,18 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
|
||||
uint8_t pixCol = (log10f(FFT_MajorPeak) - 2.26f) * 150; // 22Khz sampling - log10 frequency range is from 2.26 (182hz) to 3.967 (9260hz). Let's scale accordingly.
|
||||
if (FFT_MajorPeak < 182.0f) pixCol = 0; // handle underflow
|
||||
|
||||
unsigned k = SEGLEN-1;
|
||||
if (samplePeak) {
|
||||
SEGMENT.setPixelColor(SEGLEN-1, CHSV(92,92,92));
|
||||
pixels[k] = (uint32_t)CRGB(CHSV(92,92,92));
|
||||
} else {
|
||||
SEGMENT.setPixelColor(SEGLEN-1, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(pixCol+SEGMENT.intensity, false, PALETTE_SOLID_WRAP, 0), (uint8_t)my_magnitude));
|
||||
pixels[k] = color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(pixCol+SEGMENT.intensity, false, PALETTE_SOLID_WRAP, 0), (uint8_t)my_magnitude);
|
||||
}
|
||||
SEGMENT.setPixelColor(k, pixels[k]);
|
||||
// loop will not execute if SEGLEN equals 1
|
||||
for (unsigned i = 0; i < SEGLEN-1; i++) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i+1)); // shift left
|
||||
for (unsigned i = 0; i < k; i++) {
|
||||
pixels[i] = pixels[i+1]; // shift left
|
||||
SEGMENT.setPixelColor(i, pixels[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
|
||||
Reference in New Issue
Block a user