@@ -232,12 +232,13 @@ bool FastLEDController::renderTemperature(ChannelData& channelData, LEDGroup& gr
232
232
}
233
233
234
234
bool FastLEDController::renderVisor (ChannelData& channelData, LEDGroup& group, int groupLedCount) {
235
- int duration = applySpeed (150 * groupLedCount, group.speed );
236
- int steps = groupLedCount * 2 ;
235
+ int duration = applySpeed (120 * groupLedCount, group.speed );
236
+ const int resolution = 64 ;
237
+ int steps = groupLedCount * 2 * resolution;
237
238
int count = animation_step_count (duration, steps);
238
239
if (count > 0 ) {
239
240
int step = animation_step (duration, steps);
240
- if (step >= groupLedCount ? count > step - groupLedCount : count > step) {
241
+ if (step >= steps / 2 ? count > step - steps / 2 : count > step) {
241
242
if (group.extra == GroupExtra::Random) {
242
243
group.color1 = randomColor ();
243
244
group.color2 = randomColor ();
@@ -247,13 +248,25 @@ bool FastLEDController::renderVisor(ChannelData& channelData, LEDGroup& group, i
247
248
group.color2 = temp;
248
249
}
249
250
}
250
- fill_solid (&channelData.leds [group.ledIndex ], groupLedCount, CRGB::Black);
251
- int gradientLength = 4 ;
252
- int gradientMiddlePosition = (step >= groupLedCount) ? steps - step - 1 : step;
253
- int gradientStartPosition = gradientMiddlePosition - ((gradientLength - 1 ) / 2 );
254
- fill_gradient_RGB (&channelData.leds [group.ledIndex ], constrain (gradientStartPosition, 0 , groupLedCount - 1 ),
255
- group.color1 , constrain (gradientStartPosition + (gradientLength - 1 ), 0 , groupLedCount - 1 ),
256
- group.color2 );
251
+ const float gradientLength = 3 .0f ;
252
+ float pos = step / (float )resolution;
253
+ float gradientMiddlePosition = (pos >= groupLedCount) ? (groupLedCount * 2 ) - pos : pos;
254
+ gradientMiddlePosition -= 0 .5f ;
255
+ const float gradientStartPosition = gradientMiddlePosition - (gradientLength / 2 );
256
+ const float gradientEndPosition = gradientMiddlePosition + (gradientLength / 2 );
257
+ for (int i = 0 ; i < groupLedCount; i++) {
258
+ CRGB color = CRGB::Black;
259
+ if (i >= gradientStartPosition - 1 && i < gradientStartPosition) {
260
+ color = group.color1 ;
261
+ color.nscale8 ((i - (gradientStartPosition - 1 )) * 256.0 );
262
+ } else if (i >= gradientStartPosition && i < gradientEndPosition) {
263
+ color = blend (group.color1 , group.color2 , ((i - gradientStartPosition) / gradientLength) * 256 );
264
+ } else if (i >= gradientEndPosition && i < gradientEndPosition + 1 ) {
265
+ color = group.color2 ;
266
+ color.nscale8 ((1 - (i - gradientEndPosition)) * 256.0 );
267
+ }
268
+ channelData.leds [group.ledIndex + i] = color;
269
+ }
257
270
return true ;
258
271
}
259
272
return false ;
0 commit comments