Skip to content

Commit dd482b5

Browse files
committed
int16_t sliders
1 parent 7ac79ae commit dd482b5

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ FastLEDManager allows you to display a static color in the web interface. It wil
151151
152152
### Pre-defined and custom sliders
153153
154-
You can add custom numeric sliders of type `int16_t` to adjust variables of animations dynamically. FastLEDManager automatically adds two sliders for brightness (0-255, default: 255) and animation speed (0-255, default: 127). Both of these fixed sliders have been integrated tightly into FastLEDManager and don't require any further attention. Changing the brightness will apply gamma correction automatically. Adjusting the speed will affect the effective delay of `FastLEDManager.delay()` to speed up or slow down animations. To prevent this explicitly use `FastLED.delay()` or Arduino's standard `delay()`.
154+
You can add custom numeric sliders of type `int16_t` to adjust variables of animations dynamically. FastLEDManager automatically adds two sliders for brightness (0-1023, default: 1023) and animation speed (0-255, default: 127). Both of these fixed sliders have been integrated tightly into FastLEDManager and don't require any further attention. Changing the brightness will apply gamma correction automatically. Adjusting the speed will affect the effective delay of `FastLEDManager.delay()` to speed up or slow down animations. To prevent this explicitly use `FastLED.delay()` or Arduino's standard `delay()`.
155155
156156
To add more custom sliders simply register them in the main sketch via
157157

data/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function handleJsonData(data) {
6464
});
6565
sliderDiv.querySelector(".noUi-handle").innerHTML = slider.name;
6666
sliderDiv.noUiSlider.on('update', (values, handle) => {
67-
ws_pending_msg = [20, idx, values[handle]];
67+
ws_pending_msg = [20, idx, (values[handle] >> 8) & 0xff, values[handle] & 0xff];
6868
});
6969
document.getElementById('slidersWrapper').appendChild(sliderDiv);
7070
});

src/FastLEDManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void FastLEDManagerClass::initialize(String projectName, uint16_t numberOfLeds)
4343

4444
registerAnimation(new Color("Color"));
4545

46-
registerSlider(new Slider("Brightness", 0, 255, 255, 1));
46+
registerSlider(new Slider("Brightness", 0, 1023, 1023, 1));
4747
registerSlider(new Slider("Speed", 0, 255, 127, 1));
4848
}
4949

src/WebSocket.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,20 @@ void handleBinary(uint8_t *binary, uint8_t id)
8585
FastLEDManager.leds[i] = CRGB(binary[1 + i * 3], binary[2 + i * 3], binary[3 + i * 3]);
8686
break;
8787
case 20: // Slider data
88-
switch (binary[1])
8988
{
90-
case 0:
91-
FastLEDManager.brightness10 = binary[2] * 4 + 3;
92-
break;
93-
case 1:
94-
FastLEDManager.speed = binary[2];
95-
break;
96-
default:
97-
FastLEDManager.getSlider(binary[1])->value = binary[2];
98-
break;
89+
int16_t value = (binary[2] << 8) | binary[3];
90+
switch (binary[1])
91+
{
92+
case 0:
93+
FastLEDManager.brightness10 = value;
94+
break;
95+
case 1:
96+
FastLEDManager.speed = value;
97+
break;
98+
default:
99+
FastLEDManager.getSlider(binary[1])->value = value;
100+
break;
101+
}
99102
}
100103
break;
101104
case 30: // Request configuration

0 commit comments

Comments
 (0)