gbmusic: `Simple button` setting to disable double/triple pressing

For music players which handle multiple button presses themselves.
see http://forum.espruino.com/comments/15984222/
master
Richard de Boer 2021-05-13 15:48:41 +02:00
parent 14c4bfdb8b
commit d642ad5c80
4 changed files with 23 additions and 6 deletions

View File

@ -2,4 +2,4 @@
0.02: Increase text brightness, improve controls, (try to) reduce memory usage 0.02: Increase text brightness, improve controls, (try to) reduce memory usage
0.03: Only auto-start if active app is a clock, auto close after 1 hour of inactivity 0.03: Only auto-start if active app is a clock, auto close after 1 hour of inactivity
0.04: Setting to disable touch controls, minor bugfix 0.04: Setting to disable touch controls, minor bugfix
0.05: Remove touch controls setting, reduce fadeout flicker 0.05: Setting to disable double/triple press control, remove touch controls setting, reduce fadeout flicker

View File

@ -22,6 +22,9 @@ You can change these under `Settings`->`App/Widget Settings`->`Music Controls`.
Automatically load the app when you play music and close when the music stops. Automatically load the app when you play music and close when the music stops.
(If the app opened automatically, it closes after music has been paused for 5 minutes.) (If the app opened automatically, it closes after music has been paused for 5 minutes.)
**Simple button**:
Disable double/triple pressing Button 2: always simply toggle play/pause.
(For music players which handle multiple button presses themselves.)
## Controls ## Controls

View File

@ -485,11 +485,19 @@ function startButtonWatches() {
tPress = setTimeout(() => {Bangle.showLauncher();}, 3000); tPress = setTimeout(() => {Bangle.showLauncher();}, 3000);
} }
}, BTN2, {repeat: true, edge: "rising"}); }, BTN2, {repeat: true, edge: "rising"});
setWatch(() => { const s = require("Storage").readJSON("gbmusic.json", 1) || {};
nPress++; if (s.simpleButton) {
clearTimeout(tPress); setWatch(() => {
tPress = setTimeout(handleButton2Press, 500); clearTimeout(tPress);
}, BTN2, {repeat: true, edge: "falling"}); togglePlay();
}, BTN2, {repeat: true, edge: "falling"});
} else {
setWatch(() => {
nPress++;
clearTimeout(tPress);
tPress = setTimeout(handleButton2Press, 500);
}, BTN2, {repeat: true, edge: "falling"});
}
} }
function handleButton2Press() { function handleButton2Press() {
tPress = null; tPress = null;

View File

@ -9,6 +9,7 @@
// initialize with default settings... // initialize with default settings...
let s = { let s = {
autoStart: true, autoStart: true,
simpleButton: false,
}; };
// ...and overwrite them with any saved values // ...and overwrite them with any saved values
// This way saved values are preserved if a new version adds more settings // This way saved values are preserved if a new version adds more settings
@ -34,6 +35,11 @@
format: yesNo, format: yesNo,
onchange: save("autoStart"), onchange: save("autoStart"),
}; };
menu[translate("Simple button")] = {
value: !!s.simpleButton,
format: yesNo,
onchange: save("simpleButton"),
};
E.showMenu(menu); E.showMenu(menu);
}); });