Skip to content

Commit 3fdd644

Browse files
authored
Merge pull request #4042 from RKBoss6/clkinfohaptics
[Clock Info] Add option for haptics when changing infos
2 parents 0479437 + ea44834 commit 3fdd644

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

apps/clock_info/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
0.19: Fix Altitude ClockInfo after BLE added
2121
Tapping Altitude now updates the reading
2222
0.20: Altitude ClockInfo now uses the distance units set in locale.
23+
0.21: Add haptics when changing infos and a setting to toggle it on or off

apps/clock_info/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ and previously focussed Clock Infos
4040
progress/percent indicator may be shown. The percentage for altitude will be how far towards
4141
the Max Altitude you are. If you go higher than `Max Altitude` the correct altitude will still
4242
be shown - the percent indicator will just read 100%
43+
* `Haptics` - Whether or not to use a slight vibration when cycling between different infos, or lists (with a slightly stronger buzz).
4344

4445
## API (Software development)
4546

apps/clock_info/lib.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exports.loadSettings = function() {
2323
hrmOn : 0, // 0(Always), 1(Tap)
2424
defocusOnLock : true,
2525
maxAltitude : 3000,
26+
haptics:true,
2627
apps : {}
2728
},
2829
require("Storage").readJSON("clock_info.json",1)||{}
@@ -293,13 +294,15 @@ exports.addInteractive = function(menu, options) {
293294
var oldMenuItem;
294295
if (ud) {
295296
if (menu[options.menuA].items.length==1) return; // 1 item - can't move
297+
if(settings.haptics) Bangle.buzz(30);
296298
oldMenuItem = menu[options.menuA].items[options.menuB];
297299
options.menuB += ud;
298300
if (options.menuB<0) options.menuB = menu[options.menuA].items.length-1;
299301
if (options.menuB>=menu[options.menuA].items.length) options.menuB = 0;
300302
} else if (lr) {
301303
if (menu.length==1) return; // 1 item - can't move
302304
oldMenuItem = menu[options.menuA].items[options.menuB];
305+
if(settings.haptics) Bangle.buzz(44);
303306
do {
304307
options.menuA += lr;
305308
if (options.menuA<0) options.menuA = menu.length-1;
@@ -355,7 +358,7 @@ exports.addInteractive = function(menu, options) {
355358
if (!options.focus) {
356359
focus();
357360
} else if (menu[options.menuA].items[options.menuB].run) {
358-
Bangle.buzz(100, 0.7);
361+
if(settings.haptics) Bangle.buzz(100, 0.7);
359362
menu[options.menuA].items[options.menuB].run(options); // allow tap on an item to run it (eg home assistant)
360363
}
361364
};

apps/clock_info/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{ "id": "clock_info",
22
"name": "Clock Info Module",
33
"shortName": "Clock Info",
4-
"version":"0.20",
4+
"version":"0.21",
55
"description": "A library used by clocks to provide extra information on the clock face (Altitude, BPM, etc)",
66
"icon": "app.png",
77
"type": "module",

apps/clock_info/settings.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
min: 500, max: 10000, step: 500,
2525
format: v => v+"m",
2626
onchange: x => save('maxAltitude', x),
27+
},
28+
/*LANG*/'Haptics': {
29+
value: !!settings.haptics,
30+
onchange: x => save('haptics', x),
2731
}
2832
};
2933
E.showMenu(menu);

0 commit comments

Comments
 (0)