Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNDtoggle - Initial release #2125

Merged
merged 14 commits into from Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/a_dndtoggle/ChangeLog
@@ -0,0 +1 @@
0.01: Initial version
13 changes: 13 additions & 0 deletions apps/a_dndtoggle/README.md
@@ -0,0 +1,13 @@
# a_dndtoggle - Toggle Quiet Mode of the watch

When Quiet mode is off, just start this app to set quiet mode. Start it again to turn off quiet mode.
Work in progress.

#ToDo
Settings page, current status indicator.

## Creator

Hank - contact at http://forum.espruino.com


43 changes: 43 additions & 0 deletions apps/a_dndtoggle/a_dndtoggle.app.js
@@ -0,0 +1,43 @@

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();
}
Comment on lines +11 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last three cases are all the same, and we always buzz, so you could just replace it with

if (current === 0) {
    bSettings.quiet = 2;
    setTimeout('Bangle.buzz();',500);
} else {
    bSettings.quiet = 0;
}
Bangle.buzz(); 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for future use. I will make the behavior configurable.


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

load()

}
Binary file added apps/a_dndtoggle/a_dndtoggle.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/a_dndtoggle/app-icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions apps/a_dndtoggle/metadata.json
@@ -0,0 +1,16 @@
{
"id": "a_dndtoggle",
"name": "a_dndtoggle - Toggle Quiet Mode of the watch",
"shortName": "A_DND Toggle",
"version": "0.01",
"description": "Toggle Quiet Mode of the watch just by starting this app.",
"icon": "a_dndtoggle.png",
"type": "app",
"tags": "tool",
"supports": ["BANGLEJS","BANGLEJS2"],
"storage": [
{"name":"a_dndtoggle.app.js","url":"a_dndtoggle.app.js"},
{"name":"a_dndtoggle.img","url":"app-icon.js","evaluate":true}
],
"readme": "README.md"
}