PartyJerk: minor code style improvements
* fix some too-long tabs *author info added * shrunk number of blank lines * removed unused audio variables * colorIndex : better accuracy by first doing multiply, then divide
This commit is contained in:
@@ -1921,21 +1921,20 @@ uint16_t mode_pride_2015(void) {
|
|||||||
}
|
}
|
||||||
static const char _data_FX_MODE_PRIDE_2015[] PROGMEM = "Pride 2015@!;;";
|
static const char _data_FX_MODE_PRIDE_2015[] PROGMEM = "Pride 2015@!;;";
|
||||||
|
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// PARTYJERK //
|
// PARTYJERK //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
// by @tonyxforce
|
||||||
|
// NB: This effects expects a palette that starts with black and then ramps up brightness.
|
||||||
|
// Currently works best with the "color gradient" and the "colors 1&2" palettes
|
||||||
uint16_t mode_partyjerk() {
|
uint16_t mode_partyjerk() {
|
||||||
|
|
||||||
if (SEGENV.call == 0) {
|
if (SEGENV.call == 0) {
|
||||||
SEGMENT.fill(BLACK); // clear LEDs
|
SEGMENT.fill(BLACK); // clear LEDs
|
||||||
SEGENV.aux0 = 0;
|
SEGENV.aux0 = 0;
|
||||||
SEGENV.aux1 = 0;
|
SEGENV.aux1 = 0;
|
||||||
SEGENV.step = 0;
|
SEGENV.step = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* use of persistent variables:
|
* use of persistent variables:
|
||||||
* aux0: hueDelay
|
* aux0: hueDelay
|
||||||
@@ -1948,24 +1947,18 @@ uint16_t mode_partyjerk() {
|
|||||||
// add support for no audio
|
// add support for no audio
|
||||||
um_data = simulateSound(SEGMENT.soundSim);
|
um_data = simulateSound(SEGMENT.soundSim);
|
||||||
}
|
}
|
||||||
uint8_t samplePeak = *(uint8_t*)um_data->u_data[3];
|
float volumeSmth = *(float*) um_data->u_data[0];
|
||||||
uint8_t *maxVol = (uint8_t*)um_data->u_data[6];
|
|
||||||
uint8_t *binNum = (uint8_t*)um_data->u_data[7];
|
|
||||||
float volumeSmth = *(float*) um_data->u_data[0];
|
|
||||||
|
|
||||||
SEGENV.aux0++;
|
SEGENV.aux0++;
|
||||||
|
|
||||||
if (SEGENV.aux1 > 254) {
|
if (SEGENV.aux1 > 254) {
|
||||||
SEGENV.aux1 = 0;
|
SEGENV.aux1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SEGENV.aux0 > map(SEGMENT.custom1, 0, 255, 0, 14)) {
|
if (SEGENV.aux0 > map(SEGMENT.custom1, 0, 255, 0, 14)) {
|
||||||
SEGENV.aux0 = 0;
|
SEGENV.aux0 = 0;
|
||||||
SEGENV.aux1++;
|
SEGENV.aux1++;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint_fast32_t speed = 0;
|
uint_fast32_t speed = 0;
|
||||||
|
|
||||||
uint16_t counter = 0;
|
uint16_t counter = 0;
|
||||||
|
|
||||||
if (volumeSmth * 2 > (255 - SEGMENT.intensity)) {
|
if (volumeSmth * 2 > (255 - SEGMENT.intensity)) {
|
||||||
@@ -1975,30 +1968,24 @@ uint16_t mode_partyjerk() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SEGENV.step += speed;
|
SEGENV.step += speed;
|
||||||
|
|
||||||
counter = SEGENV.step >> 8;
|
counter = SEGENV.step >> 8;
|
||||||
|
|
||||||
for (uint16_t i = 0; i < SEGLEN; i++) {
|
for (unsigned i = 0; i < SEGLEN; i++) {
|
||||||
|
uint8_t colorIndex = ((i * 255) / SEGLEN) - counter;
|
||||||
uint8_t colorIndex = (i * 255 / SEGLEN) - counter;
|
uint32_t paletteColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_MOVING_WRAP, 255);
|
||||||
|
|
||||||
uint32_t paletteColor = SEGMENT.color_from_palette(colorIndex, false, true, 255);
|
|
||||||
|
|
||||||
uint8_t r = R(paletteColor);
|
uint8_t r = R(paletteColor);
|
||||||
uint8_t g = G(paletteColor);
|
uint8_t g = G(paletteColor);
|
||||||
uint8_t b = B(paletteColor);
|
uint8_t b = B(paletteColor);
|
||||||
|
|
||||||
uint8_t activeColor = max(r, max(g, b));
|
uint8_t activeColor = max(r, max(g, b));
|
||||||
|
|
||||||
CRGB rgb(CHSV(SEGENV.aux1, 255, activeColor));
|
CRGB rgb(CHSV(SEGENV.aux1, 255, activeColor));
|
||||||
|
SEGMENT.setPixelColor((uint16_t)i, rgb.r, rgb.g, rgb.b);
|
||||||
SEGMENT.setPixelColor(i, rgb.r, rgb.g, rgb.b);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
} // mode_partyjerk()
|
} // mode_partyjerk()
|
||||||
|
static const char _data_FX_MODE_PARTYJERK[] PROGMEM = "Party jerk@Effect speed,Sensitivity,Color change speed,Effect speed active multiplier;!,!;!;1v;c1=8,c2=48,m12=0,si=0";
|
||||||
|
|
||||||
static const char _data_FX_MODE_PARTYJERK[] PROGMEM = "Party jerk@Effect speed,Sensivity,Color change speed,Effect speed active multiplier;!,!;!;1v;c1=8,c2=48,m12=0,si=0";
|
|
||||||
|
|
||||||
//eight colored dots, weaving in and out of sync with each other
|
//eight colored dots, weaving in and out of sync with each other
|
||||||
uint16_t mode_juggle(void) {
|
uint16_t mode_juggle(void) {
|
||||||
@@ -2025,7 +2012,7 @@ static const char _data_FX_MODE_JUGGLE[] PROGMEM = "Juggle@!,Trail;;!;;sx=64,ix=
|
|||||||
|
|
||||||
|
|
||||||
uint16_t mode_palette() {
|
uint16_t mode_palette() {
|
||||||
uint16_t counter = 0;
|
uint16_t counter = 0;
|
||||||
if (SEGMENT.speed != 0)
|
if (SEGMENT.speed != 0)
|
||||||
{
|
{
|
||||||
counter = (strip.now * ((SEGMENT.speed >> 3) +1)) & 0xFFFF;
|
counter = (strip.now * ((SEGMENT.speed >> 3) +1)) & 0xFFFF;
|
||||||
|
|||||||
@@ -334,8 +334,7 @@ void strip_wait_until_idle(String whoCalledMe); // WLEDMM implemented in FX_fcn.
|
|||||||
#define FX_MODE_ROCKTAVES 185
|
#define FX_MODE_ROCKTAVES 185
|
||||||
#define FX_MODE_2DAKEMI 186
|
#define FX_MODE_2DAKEMI 186
|
||||||
#define FX_MODE_ARTIFX 187 //WLEDMM ARTIFX
|
#define FX_MODE_ARTIFX 187 //WLEDMM ARTIFX
|
||||||
|
#define FX_MODE_PARTYJERK 188
|
||||||
#define FX_MODE_PARTYJERK 188
|
|
||||||
|
|
||||||
#define MODE_COUNT 189
|
#define MODE_COUNT 189
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user