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:
Frank
2023-12-10 16:49:13 +01:00
parent 281d9b5eb1
commit e4cb0929c3
2 changed files with 12 additions and 26 deletions

View File

@@ -1921,21 +1921,20 @@ uint16_t mode_pride_2015(void) {
}
static const char _data_FX_MODE_PRIDE_2015[] PROGMEM = "Pride 2015@!;;";
//////////////////////
// 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() {
if (SEGENV.call == 0) {
SEGMENT.fill(BLACK); // clear LEDs
SEGENV.aux0 = 0;
SEGENV.aux1 = 0;
SEGENV.step = 0;
}
/*
* use of persistent variables:
* aux0: hueDelay
@@ -1948,24 +1947,18 @@ uint16_t mode_partyjerk() {
// add support for no audio
um_data = simulateSound(SEGMENT.soundSim);
}
uint8_t samplePeak = *(uint8_t*)um_data->u_data[3];
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];
float volumeSmth = *(float*) um_data->u_data[0];
SEGENV.aux0++;
if (SEGENV.aux1 > 254) {
SEGENV.aux1 = 0;
}
if (SEGENV.aux0 > map(SEGMENT.custom1, 0, 255, 0, 14)) {
SEGENV.aux0 = 0;
SEGENV.aux1++;
}
uint_fast32_t speed = 0;
uint16_t counter = 0;
if (volumeSmth * 2 > (255 - SEGMENT.intensity)) {
@@ -1975,30 +1968,24 @@ uint16_t mode_partyjerk() {
};
SEGENV.step += speed;
counter = SEGENV.step >> 8;
for (uint16_t i = 0; i < SEGLEN; i++) {
uint8_t colorIndex = (i * 255 / SEGLEN) - counter;
uint32_t paletteColor = SEGMENT.color_from_palette(colorIndex, false, true, 255);
for (unsigned i = 0; i < SEGLEN; i++) {
uint8_t colorIndex = ((i * 255) / SEGLEN) - counter;
uint32_t paletteColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_MOVING_WRAP, 255);
uint8_t r = R(paletteColor);
uint8_t g = G(paletteColor);
uint8_t b = B(paletteColor);
uint8_t activeColor = max(r, max(g, b));
CRGB rgb(CHSV(SEGENV.aux1, 255, activeColor));
SEGMENT.setPixelColor(i, rgb.r, rgb.g, rgb.b);
SEGMENT.setPixelColor((uint16_t)i, rgb.r, rgb.g, rgb.b);
};
return FRAMETIME;
} // 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
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 counter = 0;
uint16_t counter = 0;
if (SEGMENT.speed != 0)
{
counter = (strip.now * ((SEGMENT.speed >> 3) +1)) & 0xFFFF;

View File

@@ -334,8 +334,7 @@ void strip_wait_until_idle(String whoCalledMe); // WLEDMM implemented in FX_fcn.
#define FX_MODE_ROCKTAVES 185
#define FX_MODE_2DAKEMI 186
#define FX_MODE_ARTIFX 187 //WLEDMM ARTIFX
#define FX_MODE_PARTYJERK 188
#define FX_MODE_PARTYJERK 188
#define MODE_COUNT 189