From 1eab970caabb0921520b6e41734868f2ea6eed62 Mon Sep 17 00:00:00 2001 From: Alessandro Cocco Date: Sun, 24 Apr 2022 16:25:36 +0200 Subject: [PATCH] [Scheduler] Add "Default Repeat" to settings --- apps/sched/ChangeLog | 1 + apps/sched/README.md | 3 ++- apps/sched/lib.js | 5 +++-- apps/sched/metadata.json | 2 +- apps/sched/settings.js | 9 +++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/sched/ChangeLog b/apps/sched/ChangeLog index 7372f9c4a..ec157cb1c 100644 --- a/apps/sched/ChangeLog +++ b/apps/sched/ChangeLog @@ -4,3 +4,4 @@ 0.04: Fix `getTimeToAlarm` to check for next dow if alarm.t lower currentTime. 0.05: Export new functions (`newDefaultAlarm/Timer`), add Settings page 0.06: Refactor some methods to library +0.07: Update settings diff --git a/apps/sched/README.md b/apps/sched/README.md index 47507fc14..57acdc0b7 100644 --- a/apps/sched/README.md +++ b/apps/sched/README.md @@ -16,6 +16,7 @@ Global Settings - `Unlock at Buzz` - If `Yes` the alarm/timer will unlock the watch - `Default Auto Snooze` - Default _Auto Snooze_ value for newly created alarms (_Alarms_ only) - `Default Snooze` - Default _Snooze_ value for newly created alarms/timers +- `Default Repeat` - Default _Repeat_ value for newly created alarms (_Alarms_ only) - `Buzz Count` - The number of buzzes before the watch goes silent - `Buzz Interval` - The interval between one buzz and the next - `Default Alarm/Timer Pattern` - Default vibration pattern for newly created alarms/timers @@ -38,7 +39,7 @@ Alarms are stored in an array in `sched.json`, and take the form: // WED = 8 // THU = 16 // FRI = 32 - // SAT = 64 + // SAT = 64 date : "2022-04-04", // OPTIONAL date for the alarm, in YYYY-MM-DD format // eg (new Date()).toISOString().substr(0,10) diff --git a/apps/sched/lib.js b/apps/sched/lib.js index 58ba5daf0..32aa099f8 100644 --- a/apps/sched/lib.js +++ b/apps/sched/lib.js @@ -59,8 +59,8 @@ exports.newDefaultAlarm = function () { let alarm = { t: 12 * 3600000, // Default to 12:00 on: true, - rp: false, // repeat not the default - as: settings.defaultAutoSnooze || false, + rp: settings.defaultRepeat, + as: settings.defaultAutoSnooze, dow: 0b1111111, last: 0, vibrate: settings.defaultAlarmPattern, @@ -95,6 +95,7 @@ exports.getSettings = function () { unlockAtBuzz: false, defaultSnoozeMillis: 600000, // 10 minutes defaultAutoSnooze: false, + defaultRepeat: false, buzzCount: 10, buzzIntervalMillis: 3000, // 3 seconds defaultAlarmPattern: "..", diff --git a/apps/sched/metadata.json b/apps/sched/metadata.json index 5f61d7d04..c41e5b5b3 100644 --- a/apps/sched/metadata.json +++ b/apps/sched/metadata.json @@ -1,7 +1,7 @@ { "id": "sched", "name": "Scheduler", - "version": "0.06", + "version": "0.07", "description": "Scheduling library for alarms and timers", "icon": "app.png", "type": "scheduler", diff --git a/apps/sched/settings.js b/apps/sched/settings.js index 642e43b43..5ddb4dab2 100644 --- a/apps/sched/settings.js +++ b/apps/sched/settings.js @@ -36,6 +36,15 @@ } }, + /*LANG*/"Default Repeat": { + value: settings.defaultRepeat, + format: v => v ? /*LANG*/"Yes" : /*LANG*/"No", + onchange: v => { + settings.defaultRepeat = v; + require("sched").setSettings(settings); + } + }, + /*LANG*/"Buzz Count": { value: settings.buzzCount, min: 5,