Skip to content

Commit 24401e6

Browse files
authored
Merge pull request #4052 from EmVee381/feat/pomoplus
pomoplus: feat: add advanced configurable notification with buzz patterns and r…
2 parents 60fbb5e + 9420c74 commit 24401e6

File tree

5 files changed

+78
-15
lines changed

5 files changed

+78
-15
lines changed

apps/pomoplus/ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
0.07: Make fonts and buttons larger for legibility and ease of use. Hide
66
buttons when screen is locked. Toggle the graphical presentation when
77
pressing the (middle) hardware button.
8+
0.08: Configurable buzz patterns for short, long, and work notifications; the
9+
number of pattern repetitions and the delay are shared for all three types.
10+
(emvee381)

apps/pomoplus/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ bruceblore
3939

4040
## Contributors
4141

42-
notEvil, thyttan
42+
notEvil, thyttan, emvee381

apps/pomoplus/common.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ if (!exports.settings) {
2323
longBreak: 900000, //15 minute long break
2424
numShortBreaks: 3, //3 short breaks for every long break
2525
pausedTimerExpireTime: 21600000, //If the timer was left paused for >6 hours, reset it on next launch
26-
widget: false //If a widget is added in the future, whether the user wants it
26+
widget: false, //If a widget is added in the future, whether the user wants it
27+
notifyShortPattern: "=", // pattern for short break notification
28+
notifyLongPattern: "=", // pattern for long break notification
29+
notifyWorkPattern: "==", // pattern for work session notification
30+
notifyReps: 2, // number of pattern repetitions
31+
notifyRepsDelay: 50, // delay between repetitions (in ms)
2732
};
2833
}
2934

@@ -80,13 +85,6 @@ exports.getNextPhase = function () {
8085

8186
//Change to the next phase and update numShortBreaks, and optionally vibrate. DOES NOT WRITE STATE CHANGE TO STORAGE!
8287
exports.nextPhase = function (vibrate) {
83-
a = {
84-
startTime: 0, //When the timer was last started. Difference between this and now is how long timer has run continuously.
85-
pausedTime: 0, //When the timer was last paused. Used for expiration and displaying timer while paused.
86-
elapsedTime: 0, //How much time the timer had spent running before the current start time. Update on pause or user skipping stages.
87-
phase: exports.PHASE_WORKING, //What phase the timer is currently in
88-
numShortBreaks: 0 //Number of short breaks that have occured so far
89-
}
9088
let now = (new Date()).getTime();
9189
exports.state.startTime = now; //The timer is being reset, so say it starts now.
9290
exports.state.pausedTime = now; //This prevents a paused timer from having the start time moved to the future and therefore having been run for negative time.
@@ -105,13 +103,30 @@ exports.nextPhase = function (vibrate) {
105103

106104
if (vibrate) {
107105
if (exports.state.phase == exports.PHASE_WORKING) {
108-
Bangle.buzz(800, 1);
106+
exports.doNotify(exports.settings.notifyWorkPattern, exports.settings.notifyReps,exports.settings.notifyRepsDelay);
107+
109108
} else if (exports.state.phase == exports.PHASE_SHORT_BREAK) {
110-
Bangle.buzz();
111-
setTimeout(Bangle.buzz, 400);
109+
exports.doNotify(exports.settings.notifyShortPattern, exports.settings.notifyReps,exports.settings.notifyRepsDelay);
110+
112111
} else {
113-
Bangle.buzz();
114-
setTimeout(Bangle.buzz, 400, 400);
112+
exports.doNotify(exports.settings.notifyLongPattern, exports.settings.notifyReps,exports.settings.notifyRepsDelay);
115113
}
116114
}
117115
}
116+
117+
exports.doNotify = function(pattern, repetitions, repeatDelay) {
118+
const buzz = require("buzz");
119+
120+
let i = 0;
121+
122+
function doBuzz() {
123+
buzz.pattern(pattern).then(() => {
124+
i++;
125+
if (i < repetitions) {
126+
setTimeout(doBuzz, repeatDelay);
127+
}
128+
});
129+
}
130+
131+
doBuzz();
132+
}

apps/pomoplus/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "pomoplus",
33
"name": "Pomodoro Plus",
4-
"version": "0.07",
4+
"version": "0.08",
55
"description": "A configurable pomodoro timer that runs in the background.",
66
"icon": "icon.png",
77
"type": "app",

apps/pomoplus/settings.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ const storage = require("Storage");
1212
pausedTimerExpireTime: 21600000, //If the timer was left paused for >6 hours, reset it on next launch
1313
showClock: false, //Show clock after start/resume
1414
widget: false, //If a widget is added in the future, whether the user wants it
15+
notifyShortPattern: "=", // pattern for short break notification
16+
notifyLongPattern: "=", // pattern for long break notification
17+
notifyWorkPattern: "==", // pattern for work session notification
18+
notifyReps: 2, // number of pattern repetitions
19+
notifyRepsDelay: 50, // delay between repetitions (in ms)
1520
};
1621
}
1722

@@ -75,6 +80,46 @@ const storage = require("Storage");
7580
return '' + (value / 60000) + 'm'
7681
}
7782
},
83+
'Notify work': require("buzz_menu").pattern(settings.notifyWorkPattern, value =>{
84+
settings.notifyWorkPattern = value;
85+
save();
86+
require("buzz").pattern(value);
87+
88+
}),
89+
'Notify short': require("buzz_menu").pattern(settings.notifyShortPattern, value =>{
90+
settings.notifyShortPattern = value;
91+
save();
92+
require("buzz").pattern(value);
93+
94+
}),
95+
'Notify long': require("buzz_menu").pattern(settings.notifyLongPattern, value =>{
96+
settings.notifyLongPattern = value;
97+
save();
98+
}),
99+
'Notify reps': {
100+
value: settings.notifyReps,
101+
step: 1,
102+
min: 1,
103+
max: 50,
104+
onchange: function (value) {
105+
settings.notifyReps = value;
106+
save();
107+
require("pomoplus-com.js").doNotify(settings.notifyLongPattern, settings.notifyReps,settings.notifyRepsDelay);
108+
109+
}
110+
},
111+
'Reps. delay': {
112+
value: settings.notifyRepsDelay || 50,
113+
step: 50,
114+
min: 0,
115+
max: 5000,
116+
wrap: true,
117+
onchange: function (value) {
118+
settings.notifyRepsDelay = value;
119+
save();
120+
require("pomoplus-com.js").doNotify(settings.notifyLongPattern, settings.notifyReps,settings.notifyRepsDelay);
121+
}
122+
},
78123
'Timer expiration': {
79124
value: settings.pausedTimerExpireTime,
80125
step: 900000, //15 minutes

0 commit comments

Comments
 (0)