Added a feature to enable diabling chime at certain times

pull/2099/head
aaronrolls 2022-08-23 05:48:45 +00:00
parent 10b470193b
commit 4632b990a7
3 changed files with 28 additions and 1 deletions

View File

@ -2,7 +2,7 @@
"id": "chimer",
"name": "Chimer",
"version": "0.01",
"description": "A fork of Hour Chime. Buzz or beep on every 60, 30 or 15 minutes. 9",
"description": "A fork of Hour Chime. Buzz or beep on every 60, 30 or 15 minutes. 11",
"icon": "widget.png",
"type": "widget",
"tags": "widget",

View File

@ -42,6 +42,24 @@ var showMainMenu = () => {
settings.repeat = v;
writeSettings(settings);
}
},
"Start Hour": {
value: settings.repeat,
min: 1, max: 24,
format: v => v,
onchange: v => {
settings.start = v;
writeSettings(settings);
}
},
"End Hour": {
value: settings.repeat,
min: 1, max: 24,
format: v => v,
onchange: v => {
settings.end = v;
writeSettings(settings);
}
}
});
};
@ -52,6 +70,8 @@ var showMainMenu = () => {
type: 1,
freq: 0,
repeat: 1,
start: 6,
end: 22,
};
return settings;
};

View File

@ -7,6 +7,8 @@
type: 1,
freq: 2,
repeat: 1,
start: 6,
end: 22,
};
return settings;
};
@ -39,6 +41,11 @@ function sleep(milliseconds) {
const now = new Date(),
h = now.getHours(), m = now.getMinutes(),
s = now.getSeconds(), ms = now.getMilliseconds();
if (h > settings.end || h < settings.start){
var mLeft = 60-m, sLeft = (mLeft*60)-s, msLeft = (sLeft*1000)-ms;
setTimeout(check, msLeft);
return;
}
if (settings.freq === 1){
if (m===0 || m===30) chime();
lastHour = h;