Effect: modified KITT (Scanner)

- add delay
- add dual checkmark
- rename Fade rate to Trail (inverse)
- makes Scanner Dual obsolete
pull/3763/head
Blaz Kristan 2024-02-17 12:58:04 +01:00
rodzic 989bdfb0d5
commit f2c30ba3f7
2 zmienionych plików z 45 dodań i 40 usunięć

Wyświetl plik

@ -1125,57 +1125,62 @@ uint16_t mode_running_random(void) {
static const char _data_FX_MODE_RUNNING_RANDOM[] PROGMEM = "Stream@!,Zone size;;!";
uint16_t larson_scanner(bool dual) {
if (SEGLEN == 1) return mode_static();
uint16_t counter = strip.now * ((SEGMENT.speed >> 2) +8);
uint16_t index = (counter * SEGLEN) >> 16;
SEGMENT.fade_out(SEGMENT.intensity);
if (SEGENV.step > index && SEGENV.step - index > SEGLEN/2) {
SEGENV.aux0 = !SEGENV.aux0;
}
for (int i = SEGENV.step; i < index; i++) {
uint16_t j = (SEGENV.aux0)?i:SEGLEN-1-i;
SEGMENT.setPixelColor( j, SEGMENT.color_from_palette(j, true, PALETTE_SOLID_WRAP, 0));
}
if (dual) {
uint32_t c;
if (SEGCOLOR(2) != 0) {
c = SEGCOLOR(2);
} else {
c = SEGMENT.color_from_palette(index, true, PALETTE_SOLID_WRAP, 0);
}
for (int i = SEGENV.step; i < index; i++) {
uint16_t j = (SEGENV.aux0)?SEGLEN-1-i:i;
SEGMENT.setPixelColor(j, c);
}
}
SEGENV.step = index;
return FRAMETIME;
}
/*
* K.I.T.T.
*/
uint16_t mode_larson_scanner(void){
return larson_scanner(false);
}
static const char _data_FX_MODE_LARSON_SCANNER[] PROGMEM = "Scanner@!,Fade rate;!,!;!;;m12=0";
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
SEGMENT.fade_out(255-SEGMENT.intensity);
if (SEGENV.step > strip.now) return FRAMETIME; // we have a pause
unsigned index = SEGENV.aux1 + pixels;
// are we slow enough to use frames per pixel?
if (pixels == 0) {
const unsigned frames = speed / SEGLEN; // how many frames per 1 pixel
if (SEGENV.step++ < frames) return FRAMETIME;
SEGENV.step = 0;
index++;
}
if (index > SEGLEN) {
SEGENV.aux0 = !SEGENV.aux0; // change direction
SEGENV.aux1 = 0; // reset position
// set delay
if (SEGENV.aux0 || SEGMENT.check2) SEGENV.step = strip.now + SEGMENT.custom1 * 25; // multiply by 25ms
else SEGENV.step = 0;
} else {
// paint as many pixels as needed
for (unsigned i = SEGENV.aux1; i < index; i++) {
unsigned j = (SEGENV.aux0) ? i : SEGLEN - 1 - i;
uint32_t c = SEGMENT.color_from_palette(j, true, PALETTE_SOLID_WRAP, 0);
SEGMENT.setPixelColor(j, c);
if (SEGMENT.check1) {
SEGMENT.setPixelColor(SEGLEN - 1 - j, SEGCOLOR(2) ? SEGCOLOR(2) : c);
}
}
SEGENV.aux1 = index;
}
return FRAMETIME;
}
static const char _data_FX_MODE_LARSON_SCANNER[] PROGMEM = "Scanner@!,Trail,Delay,,,Dual,Bi-delay;!,!,!;!;;m12=0,c1=0";
/*
* Creates two Larson scanners moving in opposite directions
* Custom mode by Keith Lord: https://github.com/kitesurfer1404/WS2812FX/blob/master/src/custom/DualLarson.h
*/
uint16_t mode_dual_larson_scanner(void){
return larson_scanner(true);
SEGMENT.check1 = true;
return mode_larson_scanner();
}
static const char _data_FX_MODE_DUAL_LARSON_SCANNER[] PROGMEM = "Scanner Dual@!,Fade rate;!,!,!;!;;m12=0";
static const char _data_FX_MODE_DUAL_LARSON_SCANNER[] PROGMEM = "Scanner Dual@!,Trail,Delay,,,Dual,Bi-delay;!,!,!;!;;m12=0,c1=0";
/*

Wyświetl plik

@ -187,7 +187,7 @@
#define FX_MODE_LIGHTNING 57
#define FX_MODE_ICU 58
#define FX_MODE_MULTI_COMET 59
#define FX_MODE_DUAL_LARSON_SCANNER 60
#define FX_MODE_DUAL_LARSON_SCANNER 60 // candidate for removal (use Scanner with with check 1)
#define FX_MODE_RANDOM_CHASE 61
#define FX_MODE_OSCILLATE 62
#define FX_MODE_PRIDE_2015 63