So, I tried to make an app that toggles the Quiet Mode of the watch. So when opening the app via the launcher, it shall query the quiet status and set the opposite (later that will be configurable). It works quite good. When starting, it switches from "quiet mode off" (i.e. "noisy") to "silent" and after starting it again, it switches back.
BUT:
Having it started once, it will set the watch to silent - regardless if it tries to bring back the "quiet mode off" state. In this case even the settings app shows "quiet mode off", but the watch does not do notifications anymore. The only solution to this is opening the settings app and set "quiet mode off" again - even if it already shows "quiet mode off".
Any ideas what I'm doing wrong?
Full code:
const modeNames = [/*LANG*/"Noisy", /*LANG*/"Alarms", /*LANG*/"Silent"];
let bSettings = require('Storage').readJSON('setting.json',true)||{};
let current = 0|bSettings.quiet;
//0 off
//1 alarms
//2 silent
console.log("old: " + current);
switch (current) {
case 0:
bSettings.quiet = "2";
Bangle.buzz();
setTimeout('Bangle.buzz();',500);
break;
case 1:
bSettings.quiet = "0";
Bangle.buzz();
break;
case 2:
bSettings.quiet = "0";
Bangle.buzz();
break;
default:
bSettings.quiet = "0";
Bangle.buzz();
}
console.log("new: " + bSettings.quiet);
E.showMessage(modeNames[current] + " -> " + modeNames[bSettings.quiet]);
setTimeout('exitApp();', 2000);
function exitApp(){
require("Storage").writeJSON("setting.json", bSettings);
// reload clocks with new theme, otherwise just wait for user to switch apps
if (Bangle.CLOCK) load(global.__FILE__);
load()
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
So, I tried to make an app that toggles the Quiet Mode of the watch. So when opening the app via the launcher, it shall query the quiet status and set the opposite (later that will be configurable). It works quite good. When starting, it switches from "quiet mode off" (i.e. "noisy") to "silent" and after starting it again, it switches back.
BUT:
Having it started once, it will set the watch to silent - regardless if it tries to bring back the "quiet mode off" state. In this case even the settings app shows "quiet mode off", but the watch does not do notifications anymore. The only solution to this is opening the settings app and set "quiet mode off" again - even if it already shows "quiet mode off".
Any ideas what I'm doing wrong?
Full code: