@@ -6734,6 +6734,7 @@ uint16_t mode_DJLight(void) { // Written by ??? Adapted by Wil
67346734 um_data = simulateSound (SEGMENT.soundSim );
67356735 }
67366736 uint8_t *fftResult = (uint8_t *)um_data->u_data [2 ];
6737+ float volumeSmth = *(float *)um_data->u_data [0 ];
67376738
67386739 if (SEGENV.call == 0 ) {
67396740 SEGMENT.setUpLeds ();
@@ -6744,31 +6745,49 @@ uint16_t mode_DJLight(void) { // Written by ??? Adapted by Wil
67446745 if (SEGENV.aux0 != secondHand) { // Triggered millis timing.
67456746 SEGENV.aux0 = secondHand;
67466747
6747- // CRGB color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100
6748- // CRGB color = CRGB(fftResult[12]/2, fftResult[3]/2, fftResult[1]/2); // formula for 0.14.x (22Khz): R = 3015-3704, G=216-301, B=86-129
6749- // an attempt to get colors more balanced
6750- CRGB color = CRGB (fftResult[11 ]/2 + fftResult[12 ]/4 + fftResult[14 ]/4 , // red : 2412-3704 + 4479-7106
6751- fftResult[4 ]/2 + fftResult[3 ]/4 , // green: 216-430
6752- fftResult[1 ]/4 + fftResult[2 ]/4 ); // blue: 86-216
6748+ CRGB color = CRGB (0 ,0 ,0 );
6749+ // color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100
6750+ if (!SEGENV.check1 ) {
6751+ color = CRGB (fftResult[12 ]/2 , fftResult[3 ]/2 , fftResult[1 ]/2 ); // formula for 0.14.x (22Khz): R = 3015-3704, G=216-301, B=86-129
6752+ } else {
6753+ // candy factory: an attempt to get more colors
6754+ color = CRGB (fftResult[11 ]/2 + fftResult[12 ]/4 + fftResult[14 ]/4 , // red : 2412-3704 + 4479-7106
6755+ fftResult[4 ]/2 + fftResult[3 ]/4 , // green: 216-430
6756+ fftResult[0 ]/4 + fftResult[1 ]/4 + fftResult[2 ]/4 ); // blue: 46-216
6757+ if ((color.getLuma () < 96 ) && (volumeSmth >= 1 .5f )) { // enhance "almost dark" pixels with yellow, based on not-yet-used channels
6758+ unsigned yello_g = (fftResult[5 ] + fftResult[6 ] + fftResult[7 ]) / 3 ;
6759+ unsigned yello_r = (fftResult[7 ] + fftResult[8 ] + fftResult[9 ] + fftResult[10 ]) / 4 ;
6760+ color.green += (uint8_t ) yello_g / 2 ;
6761+ color.red += (uint8_t ) yello_r / 2 ;
6762+ }
6763+ }
6764+
6765+ if (volumeSmth < 1 .0f ) color = CRGB (0 ,0 ,0 ); // silence = black
6766+
67536767 // make colors less "pastel", by turning up color saturation in HSV space
67546768 if (color.getLuma () > 32 ) { // don't change "dark" pixels
67556769 CHSV hsvColor = rgb2hsv_approximate (color);
6756- hsvColor.v = min (max (hsvColor.v , (uint8_t )48 ), (uint8_t )212 ); // 48 < brightness < 212
6757- hsvColor.s = max (hsvColor.s , (uint8_t )192 ); // turn up color saturation (> 192)
6770+ hsvColor.v = min (max (hsvColor.v , (uint8_t )48 ), (uint8_t )204 ); // 48 < brightness < 204
6771+ if (SEGENV.check1 )
6772+ hsvColor.s = max (hsvColor.s , (uint8_t )204 ); // candy factory mode: strongly turn up color saturation (> 192)
6773+ else
6774+ hsvColor.s = max (hsvColor.s , (uint8_t )108 ); // normal mode: turn up color saturation to avoid pastels
67586775 color = hsvColor;
67596776 }
67606777 // if (color.getLuma() > 12) color.maximizeBrightness(); // for testing
67616778
67626779 // SEGMENT.setPixelColor(mid, color.fadeToBlackBy(map(fftResult[4], 0, 255, 255, 4))); // 0.13.x fade -> 180hz-260hz
6763- SEGMENT.setPixelColor (mid, color.fadeToBlackBy (map (fftResult[3 ], 0 , 255 , 255 , 4 ))); // 0.14.x fade -> 216hz-301hz
6780+ uint8_t fadeVal = map (fftResult[3 ], 0 , 255 , 255 , 4 ); // 0.14.x fade -> 216hz-301hz
6781+ if (SEGENV.check1 ) fadeVal = constrain (fadeVal, 0 , 176 ); // "candy factory" mode - avoid complete fade-out
6782+ SEGMENT.setPixelColor (mid, color.fadeToBlackBy (fadeVal));
67646783
67656784 for (int i = SEGLEN - 1 ; i > mid; i--) SEGMENT.setPixelColor (i, SEGMENT.getPixelColor (i-1 )); // move to the left
67666785 for (int i = 0 ; i < mid; i++) SEGMENT.setPixelColor (i, SEGMENT.getPixelColor (i+1 )); // move to the right
67676786 }
67686787
67696788 return FRAMETIME;
67706789} // mode_DJLight()
6771- static const char _data_FX_MODE_DJLIGHT[] PROGMEM = " DJ Light@Speed;;;1f;m12=2,si=0" ; // Arc, Beatsin
6790+ static const char _data_FX_MODE_DJLIGHT[] PROGMEM = " DJ Light@Speed,,,,,Candy Factory ;;;1f;m12=2,si=0" ; // Arc, Beatsin
67726791
67736792
67746793// //////////////////
0 commit comments