Skip to content

Commit 1bc698a

Browse files
committed
Button 0 long press factory reset
JS simplification
1 parent 1b2134d commit 1bc698a

File tree

6 files changed

+2246
-2236
lines changed

6 files changed

+2246
-2236
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
### Builds after release 0.12.0
44

5+
#### Build 2203140
6+
7+
- Added factory reset by pressing button 0 for >10 seconds
8+
- Added ability to set presets from DMX Effect mode
9+
- Simplified label hiding JS in user interface
10+
- Fixed JSON `{"live":true}` indefinite realtime mode
11+
512
#### Build 2203080
613

714
- Disabled auto white mode in segments with no RGB bus

wled00/button.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
* Physical IO
55
*/
66

7-
#define WLED_DEBOUNCE_THRESHOLD 50 //only consider button input of at least 50ms as valid (debouncing)
8-
#define WLED_LONG_PRESS 600 //long press if button is released after held for at least 600ms
9-
#define WLED_DOUBLE_PRESS 350 //double press if another press within 350ms after a short press
10-
#define WLED_LONG_REPEATED_ACTION 300 //how often a repeated action (e.g. dimming) is fired on long press on button IDs >0
11-
#define WLED_LONG_AP 6000 //how long the button needs to be held to activate WLED-AP
7+
#define WLED_DEBOUNCE_THRESHOLD 50 // only consider button input of at least 50ms as valid (debouncing)
8+
#define WLED_LONG_PRESS 600 // long press if button is released after held for at least 600ms
9+
#define WLED_DOUBLE_PRESS 350 // double press if another press within 350ms after a short press
10+
#define WLED_LONG_REPEATED_ACTION 300 // how often a repeated action (e.g. dimming) is fired on long press on button IDs >0
11+
#define WLED_LONG_AP 5000 // how long button 0 needs to be held to activate WLED-AP
12+
#define WLED_LONG_FACTORY_RESET 10000 // how long button 0 needs to be held to trigger a factory reset
1213

1314
static const char _mqtt_topic_button[] PROGMEM = "%s/button/%d"; // optimize flash usage
1415

@@ -236,8 +237,14 @@ void handleButton()
236237
bool doublePress = buttonWaitTime[b]; //did we have a short press before?
237238
buttonWaitTime[b] = 0;
238239

239-
if (b == 0 && dur > WLED_LONG_AP) { //long press on button 0 (when released)
240-
WLED::instance().initAP(true);
240+
if (b == 0 && dur > WLED_LONG_AP) { // long press on button 0 (when released)
241+
if (dur > WLED_LONG_FACTORY_RESET) { // factory reset if pressed > 10 seconds
242+
WLED_FS.format();
243+
clearEEPROM();
244+
doReboot = true;
245+
} else {
246+
WLED::instance().initAP(true);
247+
}
241248
} else if (!buttonLongPressed[b]) { //short press
242249
if (b != 1 && !macroDoublePress[b]) { //don't wait for double press on buttons without a default action if no double press macro set
243250
shortPressAction(b);

wled00/data/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ button {
287287
.tab-label {
288288
margin: 0 0 -5px 0;
289289
padding-bottom: 4px;
290+
display: var(--bhd);
290291
}
291292

292293
.overlay {
@@ -538,12 +539,14 @@ input[type=range]:active + .sliderbubble {
538539
display: none;
539540
}
540541

542+
/* Slider wrapper div */
541543
.sliderwrap {
542544
height: 30px;
543545
width: 240px;
544546
position: relative;
545547
}
546548

549+
/* Segment power button + brightness slider wrapper div */
547550
.sbs {
548551
margin: 0px -20px 5px -6px;
549552
}
@@ -553,6 +556,7 @@ input[type=range]:active + .sliderbubble {
553556
margin-left: -7px;
554557
}
555558

559+
/* Dynamically hide brightness slider label */
556560
.hd {
557561
display: var(--bhd);
558562
}

wled00/data/index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,9 @@ function applyCfg()
100100
if (bg) sCol('--c-1', bg);
101101
if (lastinfo.leds) updateUI(); // update component visibility
102102
var l = cfg.comp.labels;
103-
var e = d.querySelectorAll('.tab-label');
104-
for (var i of e)
105-
i.style.display = l ? "block":"none";
106-
e = d.querySelector('.hd');
107-
e.style.display = l ? "block":"none";
108103
sCol('--tbp',l ? "14px 14px 10px 14px":"10px 22px 4px 22px");
109104
sCol('--bbp',l ? "9px 0 7px 0":"10px 0 4px 0");
110-
sCol('--bhd',l ? "block":"none");
105+
sCol('--bhd',l ? "block":"none"); // hides/shows button labels
111106
sCol('--bmt',l ? "0px":"5px");
112107
sCol('--t-b', cfg.theme.alpha.tab);
113108
size();
@@ -1076,12 +1071,12 @@ function readState(s,command=false) {
10761071
}
10771072

10781073
colors = i.col;
1079-
for (let e = 2; e >= 0; e--)
1074+
for (let e = 0; e < 3; e++)
10801075
{
10811076
if (i.col[e].length > 3) whites[e] = parseInt(i.col[e][3]);
10821077
setCSL(e);
1083-
selectSlot(csel);
10841078
}
1079+
selectSlot(csel);
10851080
if (i.cct != null && i.cct>=0) d.getElementById("sliderA").value = i.cct;
10861081

10871082
d.getElementById('sliderSpeed').value = i.sx;

0 commit comments

Comments
 (0)