diff --git a/README.md b/README.md index c54dc99f1..1058787bb 100644 --- a/README.md +++ b/README.md @@ -255,8 +255,11 @@ and which gives information about the app for the Launcher. // 'app' - an application // 'clock' - a clock - required for clocks to automatically start // 'widget' - a widget + // 'module' - this provides a module that can be used with 'require'. + // 'provides_modules' should be used if type:module is specified // 'bootloader' - an app that at startup (app.boot.js) but doesn't have a launcher entry for 'app.js' // 'settings' - apps that appear in Settings->Apps (with appname.settings.js) but that have no 'app.js' + // 'clkinfo' - Provides a 'myapp.clkinfo.js' file that can be used to display info in clocks - see modules/clock_info.js // 'RAM' - code that runs and doesn't upload anything to storage // 'launch' - replacement 'Launcher' // 'textinput' - provides a 'textinput' library that allows text to be input on the Bangle @@ -265,9 +268,16 @@ and which gives information about the app for the Launcher. // 'notify' - provides 'notify' library for showing notifications // 'locale' - provides 'locale' library for language-specific date/distance/etc // (a version of 'locale' is included in the firmware) - // 'module' - this provides a module that can be used with 'require'. - // 'provides_modules' should be used if type:module is specified "tags": "", // comma separated tag list for searching + // common types are: + // 'clock' - it's a clock + // 'widget' - it is (or provides) a widget + // 'outdoors' - useful for outdoor activities + // 'tool' - a useful utility (timer, calculator, etc) + // 'game' - a game + // 'bluetooth' - uses Bluetooth LE + // 'system' - used by the system + // 'clkinfo' - provides or uses clock_info module for data on your clock face (see modules/clock_info.js) "supports": ["BANGLEJS2"], // List of device IDs supported, either BANGLEJS or BANGLEJS2 "dependencies" : { "notify":"type" } // optional, app 'types' we depend on (see "type" above) "dependencies" : { "messages":"app" } // optional, depend on a specific app ID diff --git a/apps/agenda/metadata.json b/apps/agenda/metadata.json index 6d91455f0..4436e143c 100644 --- a/apps/agenda/metadata.json +++ b/apps/agenda/metadata.json @@ -5,7 +5,7 @@ "description": "Simple agenda", "icon": "agenda.png", "screenshots": [{"url":"screenshot_agenda_overview.png"}, {"url":"screenshot_agenda_event1.png"}, {"url":"screenshot_agenda_event2.png"}], - "tags": "agenda", + "tags": "agenda,clkinfo", "supports": ["BANGLEJS","BANGLEJS2"], "readme": "README.md", "allow_emulator": true, diff --git a/apps/aptsciclk/metadata.json b/apps/aptsciclk/metadata.json index c450d926e..77e40f843 100644 --- a/apps/aptsciclk/metadata.json +++ b/apps/aptsciclk/metadata.json @@ -5,6 +5,7 @@ "version": "0.08", "description": "A clock based on the portal series", "icon": "app.png", + "screenshots": [{"url":"screenshot.png"}], "type": "clock", "tags": "clock", "supports": ["BANGLEJS2"], diff --git a/apps/aptsciclk/screenshot.png b/apps/aptsciclk/screenshot.png new file mode 100644 index 000000000..4803e4b13 Binary files /dev/null and b/apps/aptsciclk/screenshot.png differ diff --git a/apps/bwclk/metadata.json b/apps/bwclk/metadata.json index fbae0e1e7..fa0f7b01f 100644 --- a/apps/bwclk/metadata.json +++ b/apps/bwclk/metadata.json @@ -7,7 +7,7 @@ "icon": "app.png", "screenshots": [{"url":"screenshot.png"}, {"url":"screenshot_2.png"}, {"url":"screenshot_3.png"}, {"url":"screenshot_4.png"}], "type": "clock", - "tags": "clock", + "tags": "clock,clkinfo", "supports": ["BANGLEJS2"], "allow_emulator": true, "storage": [ diff --git a/apps/clkinfosunrise/ChangeLog b/apps/clkinfosunrise/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/clkinfosunrise/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/clkinfosunrise/app.png b/apps/clkinfosunrise/app.png new file mode 100644 index 000000000..a1d53946d Binary files /dev/null and b/apps/clkinfosunrise/app.png differ diff --git a/apps/clkinfosunrise/clkinfo.js b/apps/clkinfosunrise/clkinfo.js new file mode 100644 index 000000000..1454a83f3 --- /dev/null +++ b/apps/clkinfosunrise/clkinfo.js @@ -0,0 +1,33 @@ +(function() { + // get today's sunlight times for lat/lon + var sunrise, sunset; + + function calculate() { + var SunCalc = require("https://raw.githubusercontent.com/mourner/suncalc/master/suncalc.js"); + const locale = require("locale"); + var location = require("Storage").readJSON("mylocation.json",1)||{}; + location.lat = location.lat||51.5072; + location.lon = location.lon||0.1276; + location.location = location.location||"London"; + var times = SunCalc.getTimes(new Date(), location.lat, location.lon); + sunrise = locale.time(times.sunrise,1); + sunset = locale.time(times.sunset,1); + /* do we want to re-calculate this every day? Or we just assume + that 'show' will get called once a day? */ + } + + return { + name: "Bangle", + items: [ + { name : "Sunrise", + get : () => ({ text : sunrise, + img : atob("GBiBAAAAAAAAAAAAAAAYAAA8AAB+AAD/AAAAAAAAAAAAAAAYAAAYAAQYIA4AcAYAYAA8AAB+AAD/AAH/gD///D///AAAAAAAAAAAAA==") }), + show : calculate, hide : () => {} + }, { name : "Sunset", + get : () => ({ text : sunset, + img : atob("GBiBAAAAAAAAAAAAAAB+AAA8AAAYAAAYAAAAAAAAAAAAAAAYAAAYAAQYIA4AcAYAYAA8AAB+AAD/AAH/gD///D///AAAAAAAAAAAAA==") }), + show : calculate, hide : () => {} + } + ] + }; +}) diff --git a/apps/clkinfosunrise/metadata.json b/apps/clkinfosunrise/metadata.json new file mode 100644 index 000000000..f8b68e11f --- /dev/null +++ b/apps/clkinfosunrise/metadata.json @@ -0,0 +1,12 @@ +{ "id": "clkinfosunrise", + "name": "Sunrise Clockinfo", + "version":"0.01", + "description": "For clocks that display 'clockinfo' (messages that can be cycled through using the clock_info module) this displays sunrise and sunset based on the location from the 'My Location' app", + "icon": "app.png", + "type": "clkinfo", + "tags": "clkinfo,sunrise", + "supports" : ["BANGLEJS2"], + "storage": [ + {"name":"sunrise.clkinfo.js","url":"clkinfo.js"} + ] +} diff --git a/apps/ha/metadata.json b/apps/ha/metadata.json index 052e82fe0..fad052544 100644 --- a/apps/ha/metadata.json +++ b/apps/ha/metadata.json @@ -5,7 +5,7 @@ "description": "Integrates your BangleJS into HomeAssistant.", "icon": "ha.png", "type": "app", - "tags": "tool", + "tags": "tool,clkinfo", "readme": "README.md", "supports": ["BANGLEJS2"], "custom": "custom.html", diff --git a/apps/smpltmr/metadata.json b/apps/smpltmr/metadata.json index 5f1329dfc..ce526d1ba 100644 --- a/apps/smpltmr/metadata.json +++ b/apps/smpltmr/metadata.json @@ -5,7 +5,7 @@ "version": "0.04", "description": "A very simple app to start a timer.", "icon": "app.png", - "tags": "tool,alarm,timer", + "tags": "tool,alarm,timer,clkinfo", "dependencies": {"scheduler":"type"}, "supports": ["BANGLEJS2"], "screenshots": [{"url":"screenshot_1.png"}, {"url": "screenshot_2.png"}, {"url": "screenshot_3.png"}, {"url": "screenshot_4.png"}], diff --git a/apps/weather/metadata.json b/apps/weather/metadata.json index 125041ec4..e28a282d6 100644 --- a/apps/weather/metadata.json +++ b/apps/weather/metadata.json @@ -5,7 +5,7 @@ "description": "Show Gadgetbridge weather report", "icon": "icon.png", "screenshots": [{"url":"screenshot.png"}], - "tags": "widget,outdoors", + "tags": "widget,outdoors,clkinfo", "supports": ["BANGLEJS","BANGLEJS2"], "readme": "readme.md", "storage": [ diff --git a/bin/sanitycheck.js b/bin/sanitycheck.js index 9ed699007..7ee07bebc 100755 --- a/bin/sanitycheck.js +++ b/bin/sanitycheck.js @@ -81,7 +81,7 @@ const APP_KEYS = [ const STORAGE_KEYS = ['name', 'url', 'content', 'evaluate', 'noOverwite', 'supports', 'noOverwrite']; const DATA_KEYS = ['name', 'wildcard', 'storageFile', 'url', 'content', 'evaluate']; const SUPPORTS_DEVICES = ["BANGLEJS","BANGLEJS2"]; // device IDs allowed for 'supports' -const METADATA_TYPES = ["app","clock","widget","bootloader","RAM","launch","scheduler","notify","locale","settings","waypoints","textinput","module"]; // values allowed for "type" field +const METADATA_TYPES = ["app","clock","widget","bootloader","RAM","launch","scheduler","notify","locale","settings","waypoints","textinput","module","clkinfo"]; // values allowed for "type" field const FORBIDDEN_FILE_NAME_CHARS = /[,;]/; // used as separators in appid.info const VALID_DUPLICATES = [ '.tfmodel', '.tfnames' ]; const GRANDFATHERED_ICONS = ["s7clk", "snek", "astral", "alpinenav", "slomoclock", "arrow", "pebble", "rebble"]; diff --git a/modules/clock_info.js b/modules/clock_info.js index bf1967276..1e54db26c 100644 --- a/modules/clock_info.js +++ b/modules/clock_info.js @@ -129,13 +129,16 @@ Simply supply the menu data (from .load) and a function to draw the clock info. For example: -var clockInfoMenu = require("clock_info").addInteractive(require("clock_info").load(), (itm, info) => { - var y = 0; - g.reset().setFont("6x8:2").setFontAlign(-1,0); - g.clearRect(0,y,g.getWidth(),y+23); - g.drawImage(info.img, 0,y); - g.drawString(info.text, 48,y+12); +let clockInfoMenu = require("clock_info").addInteractive(require("clock_info").load(), (itm, info) => { + var x = 20, y = 20, w=80, h=48; + g.reset().clearRect(x,y,x+w-1,y+h-1); + g.drawRect(x,y,x+w-1,y+h-1); // debug - just to show where we are + g.drawImage(info.img, x+w/2-12,y+4); + g.setFont("6x8:2").setFontAlign(0,0).drawString(info.text, x+w/2,y+36); }); +// then when clock 'unloads': +clockInfoMenu.remove(); +delete clockInfoMenu; Then if you need to unload the clock info so it no longer uses memory or responds to swipes, you can call clockInfoMenu.remove()