1
0
Fork 0

More notification testing

master
Salim Blume 2022-03-05 00:32:07 -06:00
parent 5e3e7a0c0f
commit 35d1cf85e8
2 changed files with 50 additions and 4 deletions

View File

@ -74,6 +74,14 @@ for (var i=0;i<statIDs.length;i+=2) {
]});
if (sa) sa.on('changed', e=>layout[e.id].label = e.getString());
if (sb) sb.on('changed', e=>layout[e.id].label = e.getString());
if (sa) sa.on('notify', (e)=>{
Bangle.buzz();
console.log(`notify from ${JSON.stringify(e)}`);
});
if (sb) sa.on('notify', (e)=>{
Bangle.buzz();
console.log(`notify from ${JSON.stringify(e)}`);
});
}
// At the bottom put time/GPS state/etc
lc.push({ type:"h", filly:1, c:[

View File

@ -166,6 +166,9 @@ exports.getList = function() {
exports.getStats = function(statIDs, options) {
options = options||{};
options.paceLength = options.paceLength||1000;
options.notifyDistance = options.notifyDistance||0;
options.notifyTime = options.notifyTime||0;
options.notifySteps = options.notifySteps||0;
var needGPS,needHRM;
// ======================
if (statIDs.includes("time")) {
@ -266,6 +269,18 @@ exports.getStats = function(statIDs, options) {
state.curSpeed = 0;
state.BPM = 0;
state.BPMage = 0;
state.notifyTime = options.notifyTime;
state.notifyDistance = options.notifyDistance;
state.notifySteps = options.notifySteps;
if (options.notifyTime) {
state.nextNotifyTime = state.startTime + options.notifyTime;
}
if (options.notifyDistance) {
state.nextNotifyDist = state.distance + options.notifyDistance;
}
if (options.notifySteps) {
state.nextNotifySteps = state.lastSteps + options.notifySteps;
}
}
reset();
return {
@ -292,12 +307,35 @@ exports.appendMenuItems = function(menu, settings, saveSettings) {
saveSettings();
},
};
var distNames = ['Off', ...paceNames];
var distAmts = [0, ...paceAmts];
menu['Ntfy Dist'] = {
min :0, max: paceNames.length-1,
value: Math.max(paceAmts.indexOf(settings.paceLength),0),
format: v => paceNames[v],
min :0, max: distNames.length-1,
value: Math.max(distAmts.indexOf(settings.notifyDistance),0),
format: v => distNames[v],
onchange: v => {
state.notifyDistance = paceAmts[v];
settings.notifyDistance = distAmts[v];
saveSettings();
},
};
var timeNames = ['Off', '30s', '1min', '2min', '5min', '10min', '30min', '1hr'];
var timeAmts = [0, 30000, 60000, 120000, 300000, 600000, 1800000, 3600000];
menu['Ntfy Time'] = {
min :0, max: timeNames.length-1,
value: Math.max(timeAmts.indexOf(settings.notifyTime),0),
format: v => timeNames[v],
onchange: v => {
settings.notifyTime = timeAmts[v];
saveSettings();
},
};
var stepAmts = [0, 100, 500, 1000, 5000, 10000];
menu['Ntfy Steps'] = {
min :0, max: stepAmts.length-1,
value: Math.max(stepAmts.indexOf(settings.notifySteps),0),
format: v => stepAmts[v],
onchange: v => {
settings.notifySteps = stepAmts[v];
saveSettings();
},
};