forked from FOSS/BangleApps
Merge branch 'espruino:master' into master
commit
adc274d1d3
12
README.md
12
README.md
|
@ -384,14 +384,18 @@ Example `settings.js`
|
||||||
```js
|
```js
|
||||||
// make sure to enclose the function in parentheses
|
// make sure to enclose the function in parentheses
|
||||||
(function(back) {
|
(function(back) {
|
||||||
function get(key, def) { return require('Settings').get('myappid', key, def); }
|
let settings = require('Storage').readJSON('myappid.json',1)||{};
|
||||||
function set(key, value) { require('Settings').set('myappid', key, value); }
|
if (typeof settings.monkeys !== "number") settings.monkeys = 12; // default value
|
||||||
|
function save(key, value) {
|
||||||
|
settings[key] = value;
|
||||||
|
require('Storage').write('myappid.json', settings);
|
||||||
|
}
|
||||||
const appMenu = {
|
const appMenu = {
|
||||||
'': {'title': 'App Settings'},
|
'': {'title': 'App Settings'},
|
||||||
'< Back': back,
|
'< Back': back,
|
||||||
'Monkeys': {
|
'Monkeys': {
|
||||||
value: get('monkeys', 12),
|
value: settings.monkeys,
|
||||||
onchange: (m) => set('monkeys', m)
|
onchange: (m) => {save('monkeys', m)}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
E.showMenu(appMenu)
|
E.showMenu(appMenu)
|
||||||
|
|
15
apps.json
15
apps.json
|
@ -87,7 +87,7 @@
|
||||||
"id": "health",
|
"id": "health",
|
||||||
"name": "Health Tracking",
|
"name": "Health Tracking",
|
||||||
"version": "0.08",
|
"version": "0.08",
|
||||||
"description": "Logs health data and provides an app to view it (BETA - requires firmware 2v11)",
|
"description": "Logs health data and provides an app to view it (requires firmware 2v10.100 or later)",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "tool,system,health",
|
"tags": "tool,system,health",
|
||||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
"id": "launch",
|
"id": "launch",
|
||||||
"name": "Launcher",
|
"name": "Launcher",
|
||||||
"shortName": "Launcher",
|
"shortName": "Launcher",
|
||||||
"version": "0.08",
|
"version": "0.09",
|
||||||
"description": "This is needed to display a menu allowing you to choose your own applications. You can replace this with a customised launcher.",
|
"description": "This is needed to display a menu allowing you to choose your own applications. You can replace this with a customised launcher.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
|
@ -4150,7 +4150,7 @@
|
||||||
"id": "waveclk",
|
"id": "waveclk",
|
||||||
"name": "Wave Clock",
|
"name": "Wave Clock",
|
||||||
"version": "0.02",
|
"version": "0.02",
|
||||||
"description": "A clock using a wave image by [Lillith May](https://www.instagram.com/_lilustrations_/). **Note: This requires firmware 2v11 or later Bangle.js 1**",
|
"description": "A clock using a wave image by [Lillith May](https://www.instagram.com/_lilustrations_/). **Note: Works on any Bangle.js 2, but requires firmware 2v11 or later on Bangle.js 1**",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"screenshots": [{"url":"screenshot.png"}],
|
"screenshots": [{"url":"screenshot.png"}],
|
||||||
"type": "clock",
|
"type": "clock",
|
||||||
|
@ -4166,7 +4166,7 @@
|
||||||
"id": "floralclk",
|
"id": "floralclk",
|
||||||
"name": "Floral Clock",
|
"name": "Floral Clock",
|
||||||
"version": "0.01",
|
"version": "0.01",
|
||||||
"description": "A clock with a flower background by [Lillith May](https://www.instagram.com/_lilustrations_/). **Note: This requires firmware 2v11 or later Bangle.js 1**",
|
"description": "A clock with a flower background by [Lillith May](https://www.instagram.com/_lilustrations_/). **Note: Works on any Bangle.js 2 but requires firmware 2v11 or later on Bangle.js 1**",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"screenshots": [{"url":"screenshot_floral.png"}],
|
"screenshots": [{"url":"screenshot_floral.png"}],
|
||||||
"type": "clock",
|
"type": "clock",
|
||||||
|
@ -4310,7 +4310,7 @@
|
||||||
"name": "Q Alarm and Timer",
|
"name": "Q Alarm and Timer",
|
||||||
"shortName": "Q Alarm",
|
"shortName": "Q Alarm",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version": "0.02",
|
"version": "0.03",
|
||||||
"description": "Alarm and timer app with days of week and 'hard' option.",
|
"description": "Alarm and timer app with days of week and 'hard' option.",
|
||||||
"tags": "tool,alarm,widget",
|
"tags": "tool,alarm,widget",
|
||||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||||
|
@ -4535,7 +4535,7 @@
|
||||||
"description": "Simple app to power off your Bangle.js",
|
"description": "Simple app to power off your Bangle.js",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "poweroff, shutdown",
|
"tags": "poweroff, shutdown",
|
||||||
"supports" : ["BANGLEJS", "BANGLEJS2"],
|
"supports" : ["BANGLEJS", "BANGLEJS2"],
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"poweroff.app.js","url":"app.js"},
|
{"name":"poweroff.app.js","url":"app.js"},
|
||||||
|
@ -4628,7 +4628,7 @@
|
||||||
"id": "pebble",
|
"id": "pebble",
|
||||||
"name": "Pebble Clock",
|
"name": "Pebble Clock",
|
||||||
"shortName": "Pebble",
|
"shortName": "Pebble",
|
||||||
"version": "0.01",
|
"version": "0.02",
|
||||||
"description": "A pebble style clock to keep the rebellion going",
|
"description": "A pebble style clock to keep the rebellion going",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"icon": "pebble.png",
|
"icon": "pebble.png",
|
||||||
|
@ -4638,6 +4638,7 @@
|
||||||
"supports": ["BANGLEJS2"],
|
"supports": ["BANGLEJS2"],
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"pebble.app.js","url":"pebble.app.js"},
|
{"name":"pebble.app.js","url":"pebble.app.js"},
|
||||||
|
{"name":"pebble.settings.js","url":"pebble.settings.js"},
|
||||||
{"name":"pebble.img","url":"pebble.icon.js","evaluate":true}
|
{"name":"pebble.img","url":"pebble.icon.js","evaluate":true}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,3 +6,5 @@
|
||||||
0.06: Use Bangle.setUI for buttons
|
0.06: Use Bangle.setUI for buttons
|
||||||
0.07: Theme colours fix
|
0.07: Theme colours fix
|
||||||
0.08: Merge Bangle.js 1 and 2 launchers
|
0.08: Merge Bangle.js 1 and 2 launchers
|
||||||
|
0.09: Bangle.js 2 - pressing the button goes back to clock (fix #971)
|
||||||
|
After 10s of being locked, the launcher goes back to the clock screen
|
||||||
|
|
|
@ -64,3 +64,12 @@ Bangle.setUI("updown",dir=>{
|
||||||
});
|
});
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
|
// 10s of inactivity goes back to clock
|
||||||
|
if (Bangle.setLocked) Bangle.setLocked(false); // unlock initially
|
||||||
|
var lockTimeout;
|
||||||
|
Bangle.on('lock', locked => {
|
||||||
|
if (lockTimeout) clearTimeout(lockTimeout);
|
||||||
|
lockTimeout = undefined;
|
||||||
|
if (locked)
|
||||||
|
lockTimeout = setTimeout(_=>load(), 10000);
|
||||||
|
});
|
||||||
|
|
|
@ -46,3 +46,16 @@ E.showScroller({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// pressing button goes back
|
||||||
|
setWatch(_=>load(), BTN1, {edge:"falling"});
|
||||||
|
|
||||||
|
// 10s of inactivity goes back to clock
|
||||||
|
Bangle.setLocked(false); // unlock initially
|
||||||
|
var lockTimeout;
|
||||||
|
Bangle.on('lock', locked => {
|
||||||
|
if (lockTimeout) clearTimeout(lockTimeout);
|
||||||
|
lockTimeout = undefined;
|
||||||
|
if (locked)
|
||||||
|
lockTimeout = setTimeout(_=>load(), 10000);
|
||||||
|
});
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
0.01: first release
|
0.01: first release
|
||||||
|
0.02: included deployment of pebble.settings.js in apps.json
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*a Pebble style clock with configurable background color, to keep the revolution going*
|
*a Pebble style clock with configurable background color, to keep the revolution going*
|
||||||
|
|
||||||
* Designed specifically for Bangle 2
|
* Designed specifically for Bangle 2
|
||||||
* A choice of 6 different background colous through its setting menu
|
* A choice of 6 different background colous through its setting menu. Goto Settings, App/Widget settings, Pebble.
|
||||||
* Supports the Light and Dark themes
|
* Supports the Light and Dark themes
|
||||||
* Uses pedometer widget to get latest step count
|
* Uses pedometer widget to get latest step count
|
||||||
* Dependant apps are installed when Pebble installs
|
* Dependant apps are installed when Pebble installs
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
0.01: First version!
|
0.01: First version!
|
||||||
0.02: Fixed alarms not working and localised days of week.
|
0.02: Fixed alarms not working and localised days of week.
|
||||||
|
0.03: Fix unfreed memory, and clearInterval that disabled all clocks at midnight
|
||||||
|
Fix app icon
|
||||||
|
Change menu order so 'back' is at the top
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
require("heatshrink").decompress(atob("/wA/AH4A/AH4AF0WiF1wwtF73GB53MAAgkY4wABFqIxPEhQuXGB4vUFxYwMEpBpGBwouNGAwfFF5I1KF6ZQHGAwNLFx4wHF/4v/F/4v/AoYGDF6gaFF5AwHL7QuMBJQvWEpwvxBQ4uRGBAkJT4wuWGBIuIRjKRNF8wwXFy4wWFzIwU53NFzPN5wuR5/PGK4tBDYSNQ5wVCCwIzBAAQoIAAQWGSJ5HFDYYAQIYTCRKRIeBAAYmDAAZsJMCQAbeCAybFiQ0XFTQAIzgAGFcYvz0QAGF84wGF1AwFF1QA/AH4A/ADQ="))
|
require("heatshrink").decompress(atob("mEw4UA///gH+93+oH9Jf8AgfABZMP+ALRmADCitUAgUMAQP8AQMBqtVoAFBn4CBDwUFBYNQFAQLEioLBEgQLBgfwE4IKBAAI3BBYXAE4ILE/gJBAIM8HQQ8CngL/n4LFKYR3BhgLFNYSDCBYqPFBZKzBUwSoDWYTLBUwSoDZYQABBQa0DBZCoBAAY6EcojhEHgoACkoLFrALD1WVBQdW1QLDtQMDBQOpHQmqAAg8DIwQKEJAg6FMApfLDIoJFAAX//4KIBbE/aAIAIh7oBAH4A=="))
|
||||||
|
|
|
@ -41,6 +41,7 @@ function getCurrentTime() {
|
||||||
function showMainMenu() {
|
function showMainMenu() {
|
||||||
const menu = {
|
const menu = {
|
||||||
"": { title: "Alarms" },
|
"": { title: "Alarms" },
|
||||||
|
"< Back" : () => load(),
|
||||||
"New Alarm": () => showEditAlarmMenu(-1),
|
"New Alarm": () => showEditAlarmMenu(-1),
|
||||||
"New Timer": () => showEditTimerMenu(-1),
|
"New Timer": () => showEditTimerMenu(-1),
|
||||||
};
|
};
|
||||||
|
@ -54,9 +55,7 @@ function showMainMenu() {
|
||||||
else showEditAlarmMenu(idx);
|
else showEditAlarmMenu(idx);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
menu["< Back"] = () => {
|
menu
|
||||||
load();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (WIDGETS["qalarm"]) WIDGETS["qalarm"].reload();
|
if (WIDGETS["qalarm"]) WIDGETS["qalarm"].reload();
|
||||||
return E.showMenu(menu);
|
return E.showMenu(menu);
|
||||||
|
@ -86,6 +85,7 @@ function showEditAlarmMenu(alarmIndex, alarm) {
|
||||||
|
|
||||||
const menu = {
|
const menu = {
|
||||||
"": { title: alarm.msg ? alarm.msg : "Alarms" },
|
"": { title: alarm.msg ? alarm.msg : "Alarms" },
|
||||||
|
"< Back" : showMainMenu,
|
||||||
Hours: {
|
Hours: {
|
||||||
value: hrs,
|
value: hrs,
|
||||||
onchange: function (v) {
|
onchange: function (v) {
|
||||||
|
@ -162,7 +162,6 @@ function showEditAlarmMenu(alarmIndex, alarm) {
|
||||||
showMainMenu();
|
showMainMenu();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
menu["< Back"] = showMainMenu;
|
|
||||||
return E.showMenu(menu);
|
return E.showMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +205,7 @@ function showEditTimerMenu(timerIndex) {
|
||||||
|
|
||||||
const menu = {
|
const menu = {
|
||||||
"": { title: "Timer" },
|
"": { title: "Timer" },
|
||||||
|
"< Back" : showMainMenu,
|
||||||
Hours: {
|
Hours: {
|
||||||
value: hrs,
|
value: hrs,
|
||||||
onchange: function (v) {
|
onchange: function (v) {
|
||||||
|
@ -264,7 +264,7 @@ function showEditTimerMenu(timerIndex) {
|
||||||
showMainMenu();
|
showMainMenu();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
menu["< Back"] = showMainMenu;
|
|
||||||
return E.showMenu(menu);
|
return E.showMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
eval(require("Storage").read("qalarmcheck.js"));
|
(function() { eval(require("Storage").read("qalarmcheck.js")); })()
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
print("Checking for alarms...");
|
print("Checking for alarms...");
|
||||||
|
|
||||||
clearInterval();
|
if (Bangle.QALARM) {
|
||||||
|
clearInterval(Bangle.QALARM);
|
||||||
|
Bangle.QALARM = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function getCurrentTime() {
|
function getCurrentTime() {
|
||||||
let time = new Date();
|
let time = new Date();
|
||||||
|
@ -29,13 +32,13 @@ let nextAlarms = (require("Storage").readJSON("qalarm.json", 1) || [])
|
||||||
.sort((a, b) => a.t - b.t);
|
.sort((a, b) => a.t - b.t);
|
||||||
|
|
||||||
if (nextAlarms[0]) {
|
if (nextAlarms[0]) {
|
||||||
setTimeout(() => {
|
Bangle.QALARM = setTimeout(() => {
|
||||||
eval(require("Storage").read("qalarmcheck.js"));
|
eval(require("Storage").read("qalarmcheck.js"));
|
||||||
load("qalarm.js");
|
load("qalarm.js");
|
||||||
}, nextAlarms[0].t - t);
|
}, nextAlarms[0].t - t);
|
||||||
} else {
|
} else {
|
||||||
// No alarms found: will re-check at midnight
|
// No alarms found: will re-check at midnight
|
||||||
setTimeout(() => {
|
Bangle.QALARM = setTimeout(() => {
|
||||||
eval(require("Storage").read("qalarmcheck.js"));
|
eval(require("Storage").read("qalarmcheck.js"));
|
||||||
}, 86400000 - t);
|
}, 86400000 - t);
|
||||||
}
|
}
|
||||||
|
|
2
core
2
core
|
@ -1 +1 @@
|
||||||
Subproject commit 50aa45f13f06cc2f40684971d4c0a68d061b1f3c
|
Subproject commit cd3b4def869cac4d7f18e7329e640e51b26758c8
|
|
@ -1,101 +0,0 @@
|
||||||
/*
|
|
||||||
- Read/write app settings, stored in <appid>.json
|
|
||||||
- Read/write global settings (stored in setting.json)
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
```
|
|
||||||
// read a single app setting
|
|
||||||
value = require('Settings').get(appid, key, default);
|
|
||||||
// omit key to read all app settings
|
|
||||||
value = require('Settings').get(appid);
|
|
||||||
// write a single app setting
|
|
||||||
require('Settings').set(appid, key, value)
|
|
||||||
// omit key and pass an object as values to overwrite all settings
|
|
||||||
require('Settings').set(appid, values)
|
|
||||||
|
|
||||||
// read Bangle settings by passing the Bangle object instead of an app name
|
|
||||||
value = require('Settings').get(Bangle, key, default);
|
|
||||||
// read all global settings
|
|
||||||
values = require('Settings').get(Bangle);
|
|
||||||
// write a global setting
|
|
||||||
require('Settings').set(Bangle, key, value)
|
|
||||||
```
|
|
||||||
|
|
||||||
For example:
|
|
||||||
```
|
|
||||||
require('Settings').set('test', 'foo', 123); // writes to 'test.json'
|
|
||||||
require('Settings').set('test', 'bar', 456); // updates 'test.json'
|
|
||||||
// 'test.json' now contains {baz:123,bam:456}
|
|
||||||
baz = require('Settings').get('test', 'foo'); // baz = 123
|
|
||||||
def = require('Settings').get('test', 'jkl', 789); // def = 789
|
|
||||||
all = require('Settings').get('test'); // all = {foo: 123, bar: 456}
|
|
||||||
baz = require('Settings').get('test', 'baz'); // baz = undefined
|
|
||||||
|
|
||||||
// read global setting
|
|
||||||
vibrate = require('Settings').get(Bangle, 'vibrate', true);
|
|
||||||
|
|
||||||
// Hint: if your app reads multiple settings, you can create a helper function:
|
|
||||||
function s(key, def) { return require('Settings').get('myapp', key, def); }
|
|
||||||
var foo = s('foo setting', 'default value'), bar = s('bar setting');
|
|
||||||
```
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read setting value from file
|
|
||||||
*
|
|
||||||
* @param {string} file Settings file
|
|
||||||
* @param {string} key Setting to get, omit to get all settings as object
|
|
||||||
* @param {*} def Default value
|
|
||||||
* @return {*} Setting value (or default if not found)
|
|
||||||
*/
|
|
||||||
function get(file, key, def) {
|
|
||||||
var s = require("Storage").readJSON(file);
|
|
||||||
if (def===undefined && ["object", "undefined"].includes(typeof key)) {
|
|
||||||
// get(file) or get(file, def): get all settings
|
|
||||||
return (s!==undefined) ? s : key;
|
|
||||||
}
|
|
||||||
return ((typeof s==="object") && (key in s)) ? s[key] : def;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write setting value to file
|
|
||||||
*
|
|
||||||
* @param {string} file Settings file
|
|
||||||
* @param {string} key Setting to change, omit to replace all settings
|
|
||||||
* @param {*} value Value to store
|
|
||||||
*/
|
|
||||||
function set(file, key, value) {
|
|
||||||
if (value===undefined && typeof key==="object") {
|
|
||||||
// set(file, value): overwrite settings completely
|
|
||||||
require("Storage").writeJSON(file, key);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var s = require("Storage").readJSON(file, 1);
|
|
||||||
if (typeof s!=="object") s = {};
|
|
||||||
s[key] = value;
|
|
||||||
require("Storage").write(file, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read setting value
|
|
||||||
*
|
|
||||||
* @param {string|object} app App name or Bangle
|
|
||||||
* @param {string} key Setting to get, omit to get all settings as object
|
|
||||||
* @param {*} def Default value
|
|
||||||
* @return {*} Setting value (or default if not found)
|
|
||||||
*/
|
|
||||||
exports.get = function(app, key, def) {
|
|
||||||
return get((app===Bangle) ? 'setting.json' : app+".json", key, def);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write setting value
|
|
||||||
*
|
|
||||||
* @param {string|object} app App name or Bangle
|
|
||||||
* @param {string} key Setting to change, omit to replace all settings
|
|
||||||
* @param {*} val Value to store
|
|
||||||
*/
|
|
||||||
exports.set = function(app, key, val) {
|
|
||||||
set((app===Bangle) ? 'setting.json' : app+".json", key, val);
|
|
||||||
};
|
|
Loading…
Reference in New Issue