add JSON for widgets, and fix filenames for settings (only 8 chars allowed, so '@setting')

master
Gordon Williams 2019-11-07 21:49:47 +00:00
parent 85a5dba9ad
commit 7ea95ddce8
24 changed files with 47 additions and 34 deletions

View File

@ -63,6 +63,7 @@ the *default* of `To RAM`
"name": "Readable name", // readable name "name": "Readable name", // readable name
"icon": "icon.png", // icon in apps/ "icon": "icon.png", // icon in apps/
"description": "...", // long description "description": "...", // long description
"type":"...", // optional(if app) - 'app' or 'widget'
"tags": "", // comma separated tag list for searching "tags": "", // comma separated tag list for searching
"custom": "custom.html", // if supplied, apps/custom.html is loaded in an "custom": "custom.html", // if supplied, apps/custom.html is loaded in an

View File

@ -98,17 +98,17 @@
{"name":"*slevel","url":"spiritlevel-icon.js","evaluate":true} {"name":"*slevel","url":"spiritlevel-icon.js","evaluate":true}
] ]
}, },
{ "id": "settings", { "id": "setting",
"name": "Settings", "name": "Settings",
"icon": "settings.png", "icon": "settings.png",
"description": "Show the current angle of the watch, so you can use it to make sure something is absolutely flat", "description": "Show the current angle of the watch, so you can use it to make sure something is absolutely flat",
"tags": "tool,system", "tags": "tool,system",
"storage": [ "storage": [
{"name":"+settings","url":"settings.json"}, {"name":"+setting","url":"settings.json"},
{"name":"-settings","url":"settings.js"}, {"name":"-setting","url":"settings.js"},
{"name":"=settings","url":"settings-init.js"}, {"name":"=setting","url":"settings-init.js"},
{"name":"@settings","url":"settings-default.json","evaluate":true}, {"name":"@setting","url":"settings-default.json","evaluate":true},
{"name":"*settings","url":"settings-icon.js","evaluate":true} {"name":"*setting","url":"settings-icon.js","evaluate":true}
] ]
}, },
{ "id": "files", { "id": "files",
@ -127,16 +127,20 @@
"icon": "widget-battery.png", "icon": "widget-battery.png",
"description": "Show the current battery level and charging status in the top right of the clock", "description": "Show the current battery level and charging status in the top right of the clock",
"tags": "widget,battery", "tags": "widget,battery",
"type":"widget",
"storage": [ "storage": [
{"name":"+sbat","url":"widget-battery.json"},
{"name":"=sbat","url":"widget-battery.js"} {"name":"=sbat","url":"widget-battery.js"}
] ]
}, },
{ "id": "sbt", { "id": "sbt",
"name": "Bluetooth Widget", "name": "c Widget",
"icon": "widget-bluetooth.png", "icon": "widget-bluetooth.png",
"description": "Show the current Bluetooth connection status in the top right of the clock", "description": "Show the current Bluetooth connection status in the top right of the clock",
"tags": "widget,bluetooth", "tags": "widget,bluetooth",
"type":"widget",
"storage": [ "storage": [
{"name":"+sbt","url":"widget-bluetooth.json"},
{"name":"=sbt","url":"widget-bluetooth.js"} {"name":"=sbt","url":"widget-bluetooth.js"}
] ]
}, },

View File

@ -1,5 +1,5 @@
{ {
"name":"Animals Game", "name":"Animals Game", "type":"app",
"icon":"*animals", "icon":"*animals",
"src":"-animals" "src":"-animals"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"Asteroids!", "name":"Asteroids!","type":"app",
"icon":"*astroid", "icon":"*astroid",
"src":"-astroid" "src":"-astroid"
} }

View File

@ -11,7 +11,7 @@ setWatch(function() {
apps = s.list().filter(a=>a[0]=='+').map(app=>{ apps = s.list().filter(a=>a[0]=='+').map(app=>{
try { return s.readJSON(app); } try { return s.readJSON(app); }
catch (e) { return {name:"DEAD: "+app.substr(1)} } catch (e) { return {name:"DEAD: "+app.substr(1)} }
}); }).filter(app=>app.type=="app" || !app.type);
var selected = 0; var selected = 0;
var menuScroll = 0; var menuScroll = 0;
var menuShowing = false; var menuShowing = false;

View File

@ -1,5 +1,5 @@
{ {
"name":"Clock", "name":"Clock","type":"app",
"icon":"*clock", "icon":"*clock",
"src":"-clock" "src":"-clock"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"Compass", "name":"Compass","type":"app",
"icon":"*compass", "icon":"*compass",
"src":"-compass" "src":"-compass"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"App Manager", "name":"App Manager","type":"app",
"icon":"*files", "icon":"*files",
"src":"-files" "src":"-files"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"GPS Time", "name":"GPS Time","type":"app",
"icon":"*gpstime", "icon":"*gpstime",
"src":"-gpstime" "src":"-gpstime"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"Heart Rate", "name":"Heart Rate","type":"app",
"icon":"*hrm", "icon":"*hrm",
"src":"-hrm" "src":"-hrm"
} }

View File

@ -1,6 +1,6 @@
var storage = require('Storage'); var storage = require('Storage');
const settings = storage.readJSON('@settings') || { HID: false }; const settings = storage.readJSON('@setting') || { HID: false };
var sendHid, next, prev, toggle, up, down, profile; var sendHid, next, prev, toggle, up, down, profile;

View File

@ -1,5 +1,5 @@
{ {
"name": "Keyboard Control", "name": "Keyboard Control","type":"app",
"icon": "*hidkbd", "icon": "*hidkbd",
"src": "-hidkbd" "src": "-hidkbd"
} }

View File

@ -1,6 +1,6 @@
var storage = require('Storage'); var storage = require('Storage');
const settings = storage.readJSON('@settings') || { HID: false }; const settings = storage.readJSON('@setting') || { HID: false };
var sendHid, next, prev, toggle, up, down, profile; var sendHid, next, prev, toggle, up, down, profile;

View File

@ -1,5 +1,5 @@
{ {
"name": "Music Control", "name": "Music Control","type":"app",
"icon": "*hidmsic", "icon": "*hidmsic",
"src": "-hidmsic" "src": "-hidmsic"
} }

View File

@ -1,4 +1,4 @@
{ {
"name":"Open Location", "name":"Open Location","type":"app",
"src":"-openloc" "src":"-openloc"
} }

View File

@ -1,5 +1,5 @@
(function() { (function() {
var s = require('Storage').readJSON('@settings'); var s = require('Storage').readJSON('@setting');
var adv = { uart: true }; var adv = { uart: true };
if (s.HID) { if (s.HID) {
// Report from https://notes.iopush.net/custom-usb-hid-device-descriptor-media-keyboard/ // Report from https://notes.iopush.net/custom-usb-hid-device-descriptor-media-keyboard/

View File

@ -12,8 +12,8 @@ function debug(msg, arg) {
function updateSettings() { function updateSettings() {
debug('updating settings', settings); debug('updating settings', settings);
storage.erase('@settings'); storage.erase('@setting');
storage.write('@settings', settings); storage.write('@setting', settings);
} }
function resetSettings() { function resetSettings() {
@ -30,7 +30,7 @@ function resetSettings() {
} }
try { try {
settings = storage.readJSON('@settings'); settings = storage.readJSON('@setting');
} catch (e) {} } catch (e) {}
if (!settings) resetSettings(); if (!settings) resetSettings();
@ -121,11 +121,11 @@ function showResetMenu() {
}, },
// this is include for debugging. remove for production // this is include for debugging. remove for production
/*'Erase': () => { /*'Erase': () => {
storage.erase('=settings'); storage.erase('=setting');
storage.erase('-settings'); storage.erase('-setting');
storage.erase('@settings'); storage.erase('@setting');
storage.erase('*settings'); storage.erase('*setting');
storage.erase('+settings'); storage.erase('+setting');
E.reboot(); E.reboot();
}*/ }*/
}; };

View File

@ -1,5 +1,5 @@
{ {
"name": "Settings", "name": "Settings","type":"app",
"icon": "*settings", "icon": "*settings",
"src": "-settings" "src": "-settings"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"Speedo", "name":"Speedo","type":"app",
"icon":"*speedo", "icon":"*speedo",
"src":"-speedo" "src":"-speedo"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"Spirit Level", "name":"Spirit Level","type":"app",
"icon":"*slevel", "icon":"*slevel",
"src":"-slevel" "src":"-slevel"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"Stopwatch", "name":"Stopwatch","type":"app",
"icon":"*swatch", "icon":"*swatch",
"src":"-swatch" "src":"-swatch"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"T-Rex", "name":"T-Rex","type":"app",
"icon":"*trex", "icon":"*trex",
"src":"-trex" "src":"-trex"
} }

4
apps/widget-battery.json Normal file
View File

@ -0,0 +1,4 @@
{
"name":"Battery Level","type":"widget",
"src":"=sbat"
}

View File

@ -0,0 +1,4 @@
{
"name":"bluetooth","type":"widget",
"src":"=sbt"
}