@@ -46,34 +46,31 @@ void fx_init(int count, LightColor& currentColor) {
4646 }
4747}
4848
49- void fx_reset (Adafruit_NeoPixel* pixels, LightColor& color) {
49+ void fx_reset (LightColor& color) {
5050// hueOffset = 0;
5151 hueZoom = 1 ;
5252}
5353
54- void fx_solid (Adafruit_NeoPixel* pixels, LightColor& color, int transitionMs = 200 ) {
55- if (pixels == nullptr ) return ;
56-
57- for (int i = 0 ; i < pixels->numPixels (); i++) {
54+ void fx_solid (uint16_t ledsCount, LightColor& color, int transitionMs = 200 ) {
55+ for (int i = 0 ; i < ledsCount; i++) {
5856 animatedColors[i]->setColor (color.getHue (), color.getSaturation (), color.getValue (), transitionMs);
5957 }
6058}
6159
6260float currentSaturation;
6361float cursorDirection = 1 ;
6462unsigned long rainbow_refresh_ts = 0 ;
65- void fx_rainbow (Adafruit_NeoPixel* pixels , LightColor& color, float iterations = 1 ) {
66- if (pixels == nullptr || millis () - rainbow_refresh_ts <= 100 ) return ;
63+ void fx_rainbow (uint16_t ledsCount , LightColor& color, float iterations = 1 ) {
64+ if (millis () - rainbow_refresh_ts <= 100 ) return ;
6765
68- uint numPixels = pixels->numPixels ();
6966 currentSaturation = color.getSaturation ();
70- float length = numPixels * hueZoom;
67+ float length = ledsCount * hueZoom;
7168
7269 float hueStep = 1 .0f / (float ) length * iterations;
7370
7471 float v = color.getValue ();
75- for (int i = 0 ; i < numPixels ; i++) {
76- float inc = (i < numPixels / iterations ? (float )i : (float )(numPixels - i)) * hueStep;
72+ for (int i = 0 ; i < ledsCount ; i++) {
73+ float inc = (i < ledsCount / iterations ? (float )i : (float )(ledsCount - i)) * hueStep;
7774 float h = FX_DEG_NORM ((color.getHue () + hueOffset) + inc);
7875 animatedColors[i]->setColor (h, currentSaturation, v, currentSaturation * 100 );
7976 }
@@ -99,11 +96,10 @@ int stripe_step = 3;
9996float stripe_cycle = 0 ;
10097float stripe_previous_hue;
10198
102- void fx_white_stripes (Adafruit_NeoPixel* pixels , LightColor& color, bool brightWhite = false ) {
103- if (pixels == nullptr || millis () - stripe_refresh_ts <= stripe_delay) return ;
99+ void fx_white_stripes (uint16_t ledsCount , LightColor& color, bool brightWhite = false ) {
100+ if (millis () - stripe_refresh_ts <= stripe_delay) return ;
104101
105- uint numPixels = pixels->numPixels ();
106- int stripe_length = (int )round ((float )numPixels / 5 .0f );
102+ int stripe_length = (int )round ((float )ledsCount / 5 .0f );
107103 float shift;
108104
109105 if (stripe_length <= stripe_step) stripe_length = stripe_step * 2 ;
@@ -116,13 +112,13 @@ void fx_white_stripes(Adafruit_NeoPixel* pixels, LightColor& color, bool brightW
116112 cursorDirection = (color.getHue () - stripe_previous_hue > 0 ) ? 1 : -1 ;
117113 stripe_previous_hue = color.getHue ();
118114
119- for (int i = 0 ; i < numPixels ; i++) {
115+ for (int i = 0 ; i < ledsCount ; i++) {
120116 float v = color.getValue ();
121117 float s = color.getSaturation ();
122118 if ((int )round (i + shift) % stripe_length < stripe_step) {
123119 // draw stripe
124120 animatedColors[i]->setColor (0 , 0 , brightWhite && v > 0 ? 1 : v,
125- (float )stripe_transition / numPixels );
121+ (float )stripe_transition / ledsCount );
126122 } else {
127123 // draw solid color
128124 animatedColors[i]->setColor (color.getHue (), s, v,
@@ -137,10 +133,10 @@ void fx_white_stripes(Adafruit_NeoPixel* pixels, LightColor& color, bool brightW
137133unsigned long kaleidoscope_refresh_ts = 0 ;
138134int kaleidoscope_delay = 500 ;
139135
140- void fx_kaleidoscope (Adafruit_NeoPixel* pixels , LightColor& color) {
141- if (pixels == nullptr || millis () - kaleidoscope_refresh_ts <= kaleidoscope_delay) return ;
136+ void fx_kaleidoscope (uint16_t ledsCount , LightColor& color) {
137+ if (millis () - kaleidoscope_refresh_ts <= kaleidoscope_delay) return ;
142138
143- for (int i = 0 ; i < pixels-> numPixels () ; i++) {
139+ for (int i = 0 ; i < ledsCount ; i++) {
144140 float rnd1 = random (1000 );
145141 float rnd2 = random (1000 );
146142 if ((int )rnd1 % 2 == 0 ) {
0 commit comments