1
0
Fork 0

Tweaks to appease the sanity checker

master
Gordon Williams 2020-05-12 08:08:19 +01:00
parent 30e982f06a
commit 4391b48aeb
7 changed files with 34 additions and 34 deletions

View File

@ -6,7 +6,7 @@ Bangle.js App Loader (and Apps)
* Try the **release version** at [banglejs.com/apps](https://banglejs.com/apps) * Try the **release version** at [banglejs.com/apps](https://banglejs.com/apps)
* Try the **development version** at [github.io](https://espruino.github.io/BangleApps/) * Try the **development version** at [github.io](https://espruino.github.io/BangleApps/)
**All software (including apps) in this repository is MIT Licensed - see [LICENSE](LICENSE)** By **All software (including apps) in this repository is MIT Licensed - see [LICENSE](LICENSE)** By
submitting code to this repository you confirm that you are happy with it being MIT licensed, submitting code to this repository you confirm that you are happy with it being MIT licensed,
and that it is not licensed in another way that would make this impossible. and that it is not licensed in another way that would make this impossible.
@ -203,7 +203,7 @@ and which gives information about the app for the Launcher.
// added by BangleApps loader on upload - lists all files // added by BangleApps loader on upload - lists all files
// that belong to the app so it can be deleted // that belong to the app so it can be deleted
"data":"appid.data.json,appid.data?.json;appidStorageFile,appidStorageFile*" "data":"appid.data.json,appid.data?.json;appidStorageFile,appidStorageFile*"
// added by BangleApps loader on upload - lists files that // added by BangleApps loader on upload - lists files that
// the app might write, so they can be deleted on uninstall // the app might write, so they can be deleted on uninstall
// typically these files are not uploaded, but created by the app // typically these files are not uploaded, but created by the app
// these can include '*' or '?' wildcards // these can include '*' or '?' wildcards
@ -251,7 +251,7 @@ and which gives information about the app for the Launcher.
"storageFile":true // if supplied, file is treated as storageFile "storageFile":true // if supplied, file is treated as storageFile
}, },
{"wildcard":"appid.data.*" // wildcard of filenames used in storage {"wildcard":"appid.data.*" // wildcard of filenames used in storage
}, // this is mutually exclusive with using "name" }, // this is mutually exclusive with using "name"
], ],
"sortorder" : 0, // optional - choose where in the list this goes. "sortorder" : 0, // optional - choose where in the list this goes.
// this should only really be used to put system // this should only really be used to put system
@ -341,9 +341,12 @@ See [apps/gpsrec/interface.html](the GPS Recorder) for a full example.
Apps (or widgets) can add their own settings to the "Settings" menu under "App/widget settings". Apps (or widgets) can add their own settings to the "Settings" menu under "App/widget settings".
To do so, the app needs to include a `settings.js` file, containing a single function To do so, the app needs to include a `settings.js` file, containing a single function
that handles configuring the app. that handles configuring the app.
When the app settings are opened, this function is called with one When the app settings are opened, this function is called with one
argument, `back`: a callback to return to the settings menu. argument, `back`: a callback to return to the settings menu.
Usually it will save any information in `app.json` where `app` is the name
of your app - so you should change the example accordingly.
Example `settings.js` Example `settings.js`
```js ```js
// make sure to enclose the function in parentheses // make sure to enclose the function in parentheses
@ -352,7 +355,7 @@ Example `settings.js`
function save(key, value) { function save(key, value) {
settings[key] = value; settings[key] = value;
require('Storage').write('app.json',settings); require('Storage').write('app.json',settings);
} }
const appMenu = { const appMenu = {
'': {'title': 'App Settings'}, '': {'title': 'App Settings'},
'< Back': back, '< Back': back,

View File

@ -168,7 +168,7 @@
"name": "Image background clock", "name": "Image background clock",
"shortName":"Image Clock", "shortName":"Image Clock",
"icon": "app.png", "icon": "app.png",
"version":"0.05", "version":"0.06",
"description": "A clock with an image as a background", "description": "A clock with an image as a background",
"tags": "clock", "tags": "clock",
"type" : "clock", "type" : "clock",
@ -1469,7 +1469,7 @@
"name": "Round clock with seconds, minutes and date", "name": "Round clock with seconds, minutes and date",
"shortName":"Round Clock", "shortName":"Round Clock",
"icon": "app.png", "icon": "app.png",
"version":"0.02", "version":"0.03",
"description": "Designed round clock with ticks for minutes and seconds and heart rate indication", "description": "Designed round clock with ticks for minutes and seconds and heart rate indication",
"tags": "clock", "tags": "clock",
"type": "clock", "type": "clock",
@ -1572,7 +1572,7 @@
"id": "largeclock", "id": "largeclock",
"name": "Large Clock", "name": "Large Clock",
"icon": "largeclock.png", "icon": "largeclock.png",
"version": "0.02", "version": "0.03",
"description": "A readable and informational digital watch, with date, seconds and moon phase", "description": "A readable and informational digital watch, with date, seconds and moon phase",
"readme": "README.md", "readme": "README.md",
"tags": "clock", "tags": "clock",
@ -1591,12 +1591,10 @@
{ {
"name": "largeclock.settings.js", "name": "largeclock.settings.js",
"url": "settings.js" "url": "settings.js"
},
{
"name": "largeclock.json",
"url": "largeclock.json",
"evaluate": true
} }
],
"data": [
{"name":"largeclock.json"}
] ]
}, },
{ "id": "smtswch", { "id": "smtswch",
@ -1699,7 +1697,7 @@
"version": "0.01", "version": "0.01",
"description": "A clock for time travellers. The light pie segment shows the minutes, the black circle, the hour. The dial itself reads 'time' just in case you forget.", "description": "A clock for time travellers. The light pie segment shows the minutes, the black circle, the hour. The dial itself reads 'time' just in case you forget.",
"tags": "clock", "tags": "clock",
"readme": "README.md", "readme": "README.md",
"type": "clock", "type": "clock",
"allow_emulator":true, "allow_emulator":true,
"storage": [ "storage": [
@ -1708,7 +1706,7 @@
{ "name": "gallifr.settings.js", "url": "settings.js" } { "name": "gallifr.settings.js", "url": "settings.js" }
], ],
"data": [ "data": [
{"name":"app.json"} {"name":"gallifr.json"}
] ]
} }
] ]

View File

@ -10,7 +10,7 @@ const cirRad = 2*Math.PI;
const proportion = 0.3; // relative size of hour hand const proportion = 0.3; // relative size of hour hand
const thickness = 4; // thickness of decorative lines const thickness = 4; // thickness of decorative lines
// retrieve settings from menu // retrieve settings from menu
let settings = require('Storage').readJSON('app.json',1)||{}; let settings = require('Storage').readJSON('gallifr.json',1)||{};
const decoration = !settings.decoration; const decoration = !settings.decoration;
const widgets = !settings.widgets; const widgets = !settings.widgets;
if (widgets) { if (widgets) {
@ -133,21 +133,21 @@ const drawDecoration = () => {
drawSegment(params); drawSegment(params);
params = { params = {
fromX: 0.4, fromX: 0.4,
fromY: 0.2, fromY: 0.2,
toX: 0.6, toX: 0.6,
toY: 0.1 toY: 0.1
}; };
drawThickLine(params); drawThickLine(params);
params = { params = {
fromX: -0.2, fromX: -0.2,
fromY: -0.05, fromY: -0.05,
toX: -0.7, toX: -0.7,
toY: -0.7 toY: -0.7
}; };
drawThickLine(params); drawThickLine(params);
params = { params = {
fromX: -0.3, fromX: -0.3,
fromY: 0.05, fromY: 0.05,
toX: -0.95, toX: -0.95,
toY: -0.3 toY: -0.3
}; };
@ -166,7 +166,7 @@ const drawMinuteHand = () => {
break; break;
case "blue": case "blue":
g.setColor(0,0,1); g.setColor(0,0,1);
break; break;
case "80s": case "80s":
g.setColor(1,0,0); g.setColor(1,0,0);
break; break;
@ -203,7 +203,7 @@ const drawClockFace = () => {
break; break;
case "blue": case "blue":
g.setColor(0,0.3,0.8); g.setColor(0,0.3,0.8);
break; break;
case "80s": case "80s":
g.setColor(1,1,1); g.setColor(1,1,1);
break; break;

View File

@ -1,11 +1,11 @@
// make sure to enclose the function in parentheses // make sure to enclose the function in parentheses
(function (back) { (function (back) {
let settings = require('Storage').readJSON('app.json',1)||{}; let settings = require('Storage').readJSON('gallifr.json',1)||{};
let colours = ["green","red","blue","80s"]; let colours = ["green","red","blue","80s"];
let onoff = ["on","off"]; let onoff = ["on","off"];
function save(key, value) { function save(key, value) {
settings[key] = value; settings[key] = value;
require('Storage').write('app.json',settings); require('Storage').writeJSON('gallifr.json',settings);
} }
const appMenu = { const appMenu = {
'': {'title': 'Clock Settings'}, '': {'title': 'Clock Settings'},
@ -21,13 +21,13 @@
min:0,max:1, min:0,max:1,
format: m => onoff[m], format: m => onoff[m],
onchange: m => {save('widgets', m)} onchange: m => {save('widgets', m)}
}, },
'Decoration': { 'Decoration': {
value: 0|settings['decoration'], value: 0|settings['decoration'],
min:0,max:1, min:0,max:1,
format: m => onoff[m], format: m => onoff[m],
onchange: m => {save('decoration', m)} onchange: m => {save('decoration', m)}
} }
}; };
E.showMenu(appMenu) E.showMenu(appMenu)
}) })

View File

@ -1,2 +1,3 @@
0.01: Init 0.01: Init
0.02: fix 3/4 moon orientation 0.02: fix 3/4 moon orientation
0.03: Change `largeclock.json` to 'data' file to allow settings to be preserved

View File

@ -9,10 +9,8 @@ const moonX = 215;
const moonY = 50; const moonY = 50;
const settings = require("Storage").readJSON("largeclock.json", 1); const settings = require("Storage").readJSON("largeclock.json", 1);
const BTN1app = settings.BTN1; const BTN1app = settings.BTN1 || "";
const BTN3app = settings.BTN3; const BTN3app = settings.BTN3 || "";
console.log("BTN1app", BTN1app);
console.log("BTN3app", BTN3app);
function drawMoon(d) { function drawMoon(d) {
const BLACK = 0, const BLACK = 0,
@ -174,14 +172,14 @@ Bangle.setLCDMode();
// Show launcher when middle button pressed // Show launcher when middle button pressed
clearWatch(); clearWatch();
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" }); setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });
setWatch( if (BTN1app) setWatch(
function() { function() {
load(BTN1app); load(BTN1app);
}, },
BTN1, BTN1,
{ repeat: false, edge: "rising" } { repeat: false, edge: "rising" }
); );
setWatch( if (BTN3app) setWatch(
function() { function() {
load(BTN3app); load(BTN3app);
}, },

View File

@ -34,7 +34,7 @@
function onchange(v) { function onchange(v) {
settings[btn] = v; settings[btn] = v;
s.write("largeclock.json", settings); s.writeJSON("largeclock.json", settings);
} }
const btnMenu = { const btnMenu = {