Skip to content

Commit

Permalink
Added:
Browse files Browse the repository at this point in the history
- analogue FX speed
- analogue FX intensity
- analogue palette selection
- UI legend
  • Loading branch information
blazoncek committed May 28, 2021
1 parent 13bc378 commit 7e0d9cb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 10 deletions.
37 changes: 32 additions & 5 deletions wled00/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,51 @@ void handleAnalog(uint8_t b)
{
static uint8_t oldRead[WLED_MAX_BUTTONS];
#ifdef ESP8266
uint16_t aRead = analogRead(A0) >> 5; // convert 10bit read to 5bit (remove noise)
uint16_t aRead = analogRead(A0) >> 4; // convert 10bit read to 6bit (remove noise/reduce range & frequency of UI updates)
#else
uint16_t aRead = analogRead(btnPin[b]) >> 7; // convert 12bit read to 5bit (remove noise)
uint16_t aRead = analogRead(btnPin[b]) >> 6; // convert 12bit read to 6bit (remove noise/reduce range & frequency of UI updates)
#endif

if (oldRead[b] == aRead) return; // no change in reading
oldRead[b] = aRead;

// if no macro for "short press" and "long press" is defined use brightness control
if (!macroButton[b] && !macroLongPress[b]) {
// if "double press" macro is 250 or greater use global brightness
// if "double press" macro defines which option to change
if (macroDoublePress[b] >= 250) {
// if change in analog read was detected change global brightness
// global brightness
if (aRead == 0) {
briLast = bri;
bri = 0;
} else{
bri = aRead << 3;
bri = aRead << 2;
}
} else if (macroDoublePress[b] == 249) {
// effect speed
effectSpeed = aRead << 2;
effectChanged = true;
for (uint8_t i = 0; i < strip.getMaxSegments(); i++) {
WS2812FX::Segment& seg = strip.getSegment(i);
if (!seg.isSelected()) continue;
seg.speed = effectSpeed;
}
} else if (macroDoublePress[b] == 248) {
// effect intensity
effectIntensity = aRead << 2;
effectChanged = true;
for (uint8_t i = 0; i < strip.getMaxSegments(); i++) {
WS2812FX::Segment& seg = strip.getSegment(i);
if (!seg.isSelected()) continue;
seg.intensity = effectIntensity;
}
} else if (macroDoublePress[b] == 247) {
// selected palette
effectPalette = map(aRead, 0, 63, 0, strip.getPaletteCount()-1);
effectChanged = true;
for (uint8_t i = 0; i < strip.getMaxSegments(); i++) {
WS2812FX::Segment& seg = strip.getSegment(i);
if (!seg.isSelected()) continue;
seg.palette = effectPalette;
}
} else {
// otherwise use "double press" for segment selection
Expand Down
11 changes: 10 additions & 1 deletion wled00/data/settings_time.htm
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,20 @@ <h3>Button actions</h3>
<td>short<br>on-&gt;off</td>
<td>long<br>off-&gt;on</td>
<td>double<br>N/A</td>
</tr>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div>For analog button set <i>duble</i> to:
<ul>
<li>250=global brightness</li>
<li>249=effect speed</li>
<li>248=effect intensity</li>
<li>247=palette</li>
<li>0..32=segment X opacity</li>
</ul>
</div>
<h3>Time-controlled presets</h3>
<div style="display: inline-block">
<table id="TMT">
Expand Down
11 changes: 7 additions & 4 deletions wled00/html_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,13 @@ name="MC" type="number" min="0" max="250" required><br>
Timed-Light-Over Presets: <input name="MN" type="number" min="0" max="250"
required><br><h3>Button actions</h3><table style="margin:0 auto" id="macros">
<thead><tr><td>push<br>switch</td><td>short<br>on-&gt;off</td><td>long<br>
off-&gt;on</td><td>double<br>N/A</td></tr></thead><tbody></tbody></table><h3>
Time-controlled presets</h3><div style="display:inline-block"><table id="TMT">
</table></div><hr><button type="button" onclick="B()">Back</button><button
type="submit">Save</button></form></body></html>)=====";
off-&gt;on</td><td>double<br>N/A</td></tr></thead><tbody></tbody></table><div>
For analog button set <i>duble</i> to:<ul><li>250=global brightness</li><li>
249=effect speed</li><li>248=effect intensity</li><li>247=palette</li><li>
0..32=segment X opacity</li></ul></div><h3>Time-controlled presets</h3><div
style="display:inline-block"><table id="TMT"></table></div><hr><button
type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form></body></html>)=====";
// Autogenerated from wled00/data/settings_sec.htm, do not edit!!
Expand Down

0 comments on commit 7e0d9cb

Please sign in to comment.