Skip to content

Commit fd658fc

Browse files
authored
DJ Light: update to adjust to frequency channels of 0.14.x
related to #12 - fftResult channels contain different frequencies in 0.14 - fftResult content is more balanced in 0.14, while in 0.13 it was always strong in low, an always weak in high frequncies - an new idea to avoid pastel colors: increase color saturation (HSV)
1 parent 6316c5e commit fd658fc

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

wled00/FX.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6740,8 +6740,23 @@ uint16_t mode_DJLight(void) { // Written by ??? Adapted by Wil
67406740
if (SEGENV.aux0 != secondHand) { // Triggered millis timing.
67416741
SEGENV.aux0 = secondHand;
67426742

6743-
CRGB color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // 16-> 15 as 16 is out of bounds
6744-
SEGMENT.setPixelColor(mid, color.fadeToBlackBy(map(fftResult[4], 0, 255, 255, 4))); // TODO - Update
6743+
//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
6744+
//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
6745+
// an attempt to get colors more balanced
6746+
CRGB color = CRGB(fftResult[11]/2 + fftResult[12]/4 + fftResult[14]/4, // red : 2412-3704 + 4479-7106
6747+
fftResult[4]/2 + fftResult[3]/4, // green: 216-430
6748+
fftResult[1]/4 + fftResult[2]/4); // blue: 86-216
6749+
// make colors less "pastel", by turning up color saturation in HSV space
6750+
if (color.getLuma() > 32) { // don't change "dark" pixels
6751+
CHSV hsvColor = rgb2hsv_approximate(color);
6752+
hsvColor.v = min(max(hsvColor.v, (uint8_t)48), (uint8_t)212); // 48 < brightness < 212
6753+
hsvColor.s = max(hsvColor.s, (uint8_t)192); // turn up color saturation (> 192)
6754+
color = hsvColor;
6755+
}
6756+
//if (color.getLuma() > 12) color.maximizeBrightness(); // for testing
6757+
6758+
//SEGMENT.setPixelColor(mid, color.fadeToBlackBy(map(fftResult[4], 0, 255, 255, 4))); // 0.13.x fade -> 180hz-260hz
6759+
SEGMENT.setPixelColor(mid, color.fadeToBlackBy(map(fftResult[3], 0, 255, 255, 4))); // 0.14.x fade -> 216hz-301hz
67456760

67466761
for (int i = SEGLEN - 1; i > mid; i--) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i-1)); // move to the left
67476762
for (int i = 0; i < mid; i++) SEGMENT.setPixelColor(i, SEGMENT.getPixelColor(i+1)); // move to the right

0 commit comments

Comments
 (0)