1
0
Fork 0

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.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.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.
(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

View File

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

View File

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