Button 0 long press factory reset

JS simplification
This commit is contained in:
cschwinne 2022-03-14 12:26:45 +01:00
parent 1b2134d7a8
commit 1bc698ae78
6 changed files with 2246 additions and 2236 deletions

View File

@ -2,6 +2,13 @@
### Builds after release 0.12.0
#### Build 2203140
- Added factory reset by pressing button 0 for >10 seconds
- Added ability to set presets from DMX Effect mode
- Simplified label hiding JS in user interface
- Fixed JSON `{"live":true}` indefinite realtime mode
#### Build 2203080
- Disabled auto white mode in segments with no RGB bus

View File

@ -4,11 +4,12 @@
* Physical IO
*/
#define WLED_DEBOUNCE_THRESHOLD 50 //only consider button input of at least 50ms as valid (debouncing)
#define WLED_LONG_PRESS 600 //long press if button is released after held for at least 600ms
#define WLED_DOUBLE_PRESS 350 //double press if another press within 350ms after a short press
#define WLED_LONG_REPEATED_ACTION 300 //how often a repeated action (e.g. dimming) is fired on long press on button IDs >0
#define WLED_LONG_AP 6000 //how long the button needs to be held to activate WLED-AP
#define WLED_DEBOUNCE_THRESHOLD 50 // only consider button input of at least 50ms as valid (debouncing)
#define WLED_LONG_PRESS 600 // long press if button is released after held for at least 600ms
#define WLED_DOUBLE_PRESS 350 // double press if another press within 350ms after a short press
#define WLED_LONG_REPEATED_ACTION 300 // how often a repeated action (e.g. dimming) is fired on long press on button IDs >0
#define WLED_LONG_AP 5000 // how long button 0 needs to be held to activate WLED-AP
#define WLED_LONG_FACTORY_RESET 10000 // how long button 0 needs to be held to trigger a factory reset
static const char _mqtt_topic_button[] PROGMEM = "%s/button/%d"; // optimize flash usage
@ -236,8 +237,14 @@ void handleButton()
bool doublePress = buttonWaitTime[b]; //did we have a short press before?
buttonWaitTime[b] = 0;
if (b == 0 && dur > WLED_LONG_AP) { //long press on button 0 (when released)
WLED::instance().initAP(true);
if (b == 0 && dur > WLED_LONG_AP) { // long press on button 0 (when released)
if (dur > WLED_LONG_FACTORY_RESET) { // factory reset if pressed > 10 seconds
WLED_FS.format();
clearEEPROM();
doReboot = true;
} else {
WLED::instance().initAP(true);
}
} else if (!buttonLongPressed[b]) { //short press
if (b != 1 && !macroDoublePress[b]) { //don't wait for double press on buttons without a default action if no double press macro set
shortPressAction(b);

View File

@ -287,6 +287,7 @@ button {
.tab-label {
margin: 0 0 -5px 0;
padding-bottom: 4px;
display: var(--bhd);
}
.overlay {
@ -538,12 +539,14 @@ input[type=range]:active + .sliderbubble {
display: none;
}
/* Slider wrapper div */
.sliderwrap {
height: 30px;
width: 240px;
position: relative;
}
/* Segment power button + brightness slider wrapper div */
.sbs {
margin: 0px -20px 5px -6px;
}
@ -553,6 +556,7 @@ input[type=range]:active + .sliderbubble {
margin-left: -7px;
}
/* Dynamically hide brightness slider label */
.hd {
display: var(--bhd);
}

View File

@ -100,14 +100,9 @@ function applyCfg()
if (bg) sCol('--c-1', bg);
if (lastinfo.leds) updateUI(); // update component visibility
var l = cfg.comp.labels;
var e = d.querySelectorAll('.tab-label');
for (var i of e)
i.style.display = l ? "block":"none";
e = d.querySelector('.hd');
e.style.display = l ? "block":"none";
sCol('--tbp',l ? "14px 14px 10px 14px":"10px 22px 4px 22px");
sCol('--bbp',l ? "9px 0 7px 0":"10px 0 4px 0");
sCol('--bhd',l ? "block":"none");
sCol('--bhd',l ? "block":"none"); // hides/shows button labels
sCol('--bmt',l ? "0px":"5px");
sCol('--t-b', cfg.theme.alpha.tab);
size();
@ -1076,12 +1071,12 @@ function readState(s,command=false) {
}
colors = i.col;
for (let e = 2; e >= 0; e--)
for (let e = 0; e < 3; e++)
{
if (i.col[e].length > 3) whites[e] = parseInt(i.col[e][3]);
setCSL(e);
selectSlot(csel);
}
selectSlot(csel);
if (i.cct != null && i.cct>=0) d.getElementById("sliderA").value = i.cct;
d.getElementById('sliderSpeed').value = i.sx;

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2203090
#define VERSION 2203140
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG