From 7ea95ddce8e680377759e584e8ccd823ba173ba5 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 7 Nov 2019 21:49:47 +0000 Subject: [PATCH] add JSON for widgets, and fix filenames for settings (only 8 chars allowed, so '@setting') --- README.md | 1 + apps.json | 18 +++++++++++------- apps/animals.json | 2 +- apps/asteroids.json | 2 +- apps/bootloader.js | 2 +- apps/clock.json | 2 +- apps/compass.json | 2 +- apps/files.json | 2 +- apps/gpstime.json | 2 +- apps/heartrate.json | 2 +- apps/hid-keyboard.js | 2 +- apps/hid-keyboard.json | 2 +- apps/hid-music.js | 2 +- apps/hid-music.json | 2 +- apps/openlocation.json | 2 +- apps/settings-init.js | 2 +- apps/settings.js | 16 ++++++++-------- apps/settings.json | 2 +- apps/speedo.json | 2 +- apps/spiritlevel.json | 2 +- apps/stopwatch.json | 2 +- apps/trex.json | 2 +- apps/widget-battery.json | 4 ++++ apps/widget-bluetooth.json | 4 ++++ 24 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 apps/widget-battery.json create mode 100644 apps/widget-bluetooth.json diff --git a/README.md b/README.md index db5cbb33f..79708bd76 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ the *default* of `To RAM` "name": "Readable name", // readable name "icon": "icon.png", // icon in apps/ "description": "...", // long description + "type":"...", // optional(if app) - 'app' or 'widget' "tags": "", // comma separated tag list for searching "custom": "custom.html", // if supplied, apps/custom.html is loaded in an diff --git a/apps.json b/apps.json index 2e977475e..24ff4cfb2 100644 --- a/apps.json +++ b/apps.json @@ -98,17 +98,17 @@ {"name":"*slevel","url":"spiritlevel-icon.js","evaluate":true} ] }, - { "id": "settings", + { "id": "setting", "name": "Settings", "icon": "settings.png", "description": "Show the current angle of the watch, so you can use it to make sure something is absolutely flat", "tags": "tool,system", "storage": [ - {"name":"+settings","url":"settings.json"}, - {"name":"-settings","url":"settings.js"}, - {"name":"=settings","url":"settings-init.js"}, - {"name":"@settings","url":"settings-default.json","evaluate":true}, - {"name":"*settings","url":"settings-icon.js","evaluate":true} + {"name":"+setting","url":"settings.json"}, + {"name":"-setting","url":"settings.js"}, + {"name":"=setting","url":"settings-init.js"}, + {"name":"@setting","url":"settings-default.json","evaluate":true}, + {"name":"*setting","url":"settings-icon.js","evaluate":true} ] }, { "id": "files", @@ -127,16 +127,20 @@ "icon": "widget-battery.png", "description": "Show the current battery level and charging status in the top right of the clock", "tags": "widget,battery", + "type":"widget", "storage": [ + {"name":"+sbat","url":"widget-battery.json"}, {"name":"=sbat","url":"widget-battery.js"} ] }, { "id": "sbt", - "name": "Bluetooth Widget", + "name": "c Widget", "icon": "widget-bluetooth.png", "description": "Show the current Bluetooth connection status in the top right of the clock", "tags": "widget,bluetooth", + "type":"widget", "storage": [ + {"name":"+sbt","url":"widget-bluetooth.json"}, {"name":"=sbt","url":"widget-bluetooth.js"} ] }, diff --git a/apps/animals.json b/apps/animals.json index 5dd6f747b..a2d24941f 100644 --- a/apps/animals.json +++ b/apps/animals.json @@ -1,5 +1,5 @@ { - "name":"Animals Game", + "name":"Animals Game", "type":"app", "icon":"*animals", "src":"-animals" } diff --git a/apps/asteroids.json b/apps/asteroids.json index 87dedc86d..7215be590 100644 --- a/apps/asteroids.json +++ b/apps/asteroids.json @@ -1,5 +1,5 @@ { - "name":"Asteroids!", + "name":"Asteroids!","type":"app", "icon":"*astroid", "src":"-astroid" } diff --git a/apps/bootloader.js b/apps/bootloader.js index 28c74a10e..f247bb36d 100644 --- a/apps/bootloader.js +++ b/apps/bootloader.js @@ -11,7 +11,7 @@ setWatch(function() { apps = s.list().filter(a=>a[0]=='+').map(app=>{ try { return s.readJSON(app); } catch (e) { return {name:"DEAD: "+app.substr(1)} } - }); + }).filter(app=>app.type=="app" || !app.type); var selected = 0; var menuScroll = 0; var menuShowing = false; diff --git a/apps/clock.json b/apps/clock.json index 1440a2ba2..6326bdae5 100644 --- a/apps/clock.json +++ b/apps/clock.json @@ -1,5 +1,5 @@ { - "name":"Clock", + "name":"Clock","type":"app", "icon":"*clock", "src":"-clock" } diff --git a/apps/compass.json b/apps/compass.json index a5766784f..7abc9a733 100644 --- a/apps/compass.json +++ b/apps/compass.json @@ -1,5 +1,5 @@ { - "name":"Compass", + "name":"Compass","type":"app", "icon":"*compass", "src":"-compass" } diff --git a/apps/files.json b/apps/files.json index 9442ac1f6..db43a7cdc 100644 --- a/apps/files.json +++ b/apps/files.json @@ -1,5 +1,5 @@ { - "name":"App Manager", + "name":"App Manager","type":"app", "icon":"*files", "src":"-files" } diff --git a/apps/gpstime.json b/apps/gpstime.json index d8416f676..813914e08 100644 --- a/apps/gpstime.json +++ b/apps/gpstime.json @@ -1,5 +1,5 @@ { - "name":"GPS Time", + "name":"GPS Time","type":"app", "icon":"*gpstime", "src":"-gpstime" } diff --git a/apps/heartrate.json b/apps/heartrate.json index 16b927bc9..72b86993e 100644 --- a/apps/heartrate.json +++ b/apps/heartrate.json @@ -1,5 +1,5 @@ { - "name":"Heart Rate", + "name":"Heart Rate","type":"app", "icon":"*hrm", "src":"-hrm" } diff --git a/apps/hid-keyboard.js b/apps/hid-keyboard.js index 9ef95eb8a..e87fd709f 100644 --- a/apps/hid-keyboard.js +++ b/apps/hid-keyboard.js @@ -1,6 +1,6 @@ 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; diff --git a/apps/hid-keyboard.json b/apps/hid-keyboard.json index 77e848a95..11653b803 100644 --- a/apps/hid-keyboard.json +++ b/apps/hid-keyboard.json @@ -1,5 +1,5 @@ { - "name": "Keyboard Control", + "name": "Keyboard Control","type":"app", "icon": "*hidkbd", "src": "-hidkbd" } diff --git a/apps/hid-music.js b/apps/hid-music.js index f106b67ef..d4dbd5f45 100644 --- a/apps/hid-music.js +++ b/apps/hid-music.js @@ -1,6 +1,6 @@ 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; diff --git a/apps/hid-music.json b/apps/hid-music.json index 23a1e39d2..419ed196e 100644 --- a/apps/hid-music.json +++ b/apps/hid-music.json @@ -1,5 +1,5 @@ { - "name": "Music Control", + "name": "Music Control","type":"app", "icon": "*hidmsic", "src": "-hidmsic" } diff --git a/apps/openlocation.json b/apps/openlocation.json index 82ca91e08..2abc1a727 100644 --- a/apps/openlocation.json +++ b/apps/openlocation.json @@ -1,4 +1,4 @@ { - "name":"Open Location", + "name":"Open Location","type":"app", "src":"-openloc" } diff --git a/apps/settings-init.js b/apps/settings-init.js index bf211a7a9..a4209c50e 100644 --- a/apps/settings-init.js +++ b/apps/settings-init.js @@ -1,5 +1,5 @@ (function() { - var s = require('Storage').readJSON('@settings'); + var s = require('Storage').readJSON('@setting'); var adv = { uart: true }; if (s.HID) { // Report from https://notes.iopush.net/custom-usb-hid-device-descriptor-media-keyboard/ diff --git a/apps/settings.js b/apps/settings.js index 602a0ab79..204e0e798 100644 --- a/apps/settings.js +++ b/apps/settings.js @@ -12,8 +12,8 @@ function debug(msg, arg) { function updateSettings() { debug('updating settings', settings); - storage.erase('@settings'); - storage.write('@settings', settings); + storage.erase('@setting'); + storage.write('@setting', settings); } function resetSettings() { @@ -30,7 +30,7 @@ function resetSettings() { } try { - settings = storage.readJSON('@settings'); + settings = storage.readJSON('@setting'); } catch (e) {} if (!settings) resetSettings(); @@ -121,11 +121,11 @@ function showResetMenu() { }, // this is include for debugging. remove for production /*'Erase': () => { - storage.erase('=settings'); - storage.erase('-settings'); - storage.erase('@settings'); - storage.erase('*settings'); - storage.erase('+settings'); + storage.erase('=setting'); + storage.erase('-setting'); + storage.erase('@setting'); + storage.erase('*setting'); + storage.erase('+setting'); E.reboot(); }*/ }; diff --git a/apps/settings.json b/apps/settings.json index 8bc94fa87..1cdda08fe 100644 --- a/apps/settings.json +++ b/apps/settings.json @@ -1,5 +1,5 @@ { - "name": "Settings", + "name": "Settings","type":"app", "icon": "*settings", "src": "-settings" } diff --git a/apps/speedo.json b/apps/speedo.json index 70a0eda81..ce1c8b82e 100644 --- a/apps/speedo.json +++ b/apps/speedo.json @@ -1,5 +1,5 @@ { - "name":"Speedo", + "name":"Speedo","type":"app", "icon":"*speedo", "src":"-speedo" } diff --git a/apps/spiritlevel.json b/apps/spiritlevel.json index 3529320b1..0a77fd60f 100644 --- a/apps/spiritlevel.json +++ b/apps/spiritlevel.json @@ -1,5 +1,5 @@ { - "name":"Spirit Level", + "name":"Spirit Level","type":"app", "icon":"*slevel", "src":"-slevel" } diff --git a/apps/stopwatch.json b/apps/stopwatch.json index 0edc9304f..ab4d401f5 100644 --- a/apps/stopwatch.json +++ b/apps/stopwatch.json @@ -1,5 +1,5 @@ { - "name":"Stopwatch", + "name":"Stopwatch","type":"app", "icon":"*swatch", "src":"-swatch" } diff --git a/apps/trex.json b/apps/trex.json index afebc0b5c..e54d4ddb6 100644 --- a/apps/trex.json +++ b/apps/trex.json @@ -1,5 +1,5 @@ { - "name":"T-Rex", + "name":"T-Rex","type":"app", "icon":"*trex", "src":"-trex" } diff --git a/apps/widget-battery.json b/apps/widget-battery.json new file mode 100644 index 000000000..14cea82b3 --- /dev/null +++ b/apps/widget-battery.json @@ -0,0 +1,4 @@ +{ + "name":"Battery Level","type":"widget", + "src":"=sbat" +} diff --git a/apps/widget-bluetooth.json b/apps/widget-bluetooth.json new file mode 100644 index 000000000..249db6fe4 --- /dev/null +++ b/apps/widget-bluetooth.json @@ -0,0 +1,4 @@ +{ + "name":"bluetooth","type":"widget", + "src":"=sbt" +}