diff --git a/apps/_example_app/app.js b/apps/_example_app/app.js index af367779a..06c254a36 100644 --- a/apps/_example_app/app.js +++ b/apps/_example_app/app.js @@ -1,12 +1,34 @@ // place your const, vars, functions or classes here -// special function to handle display switch on -Bangle.on('lcdPower', (on) => { - if (on) { - // call your app function here - // If you clear the screen, do Bangle.drawWidgets(); +// clear the screen +g.clear(); + +var n = 0; + +// redraw the screen +function draw() { + g.reset().clearRect(Bangle.appRect); + g.setFont("6x8").setFontAlign(0,0).drawString("Up / Down",g.getWidth()/2,g.getHeight()/2 - 20); + g.setFont("Vector",60).setFontAlign(0,0).drawString(n,g.getWidth()/2,g.getHeight()/2 + 30); +} + +// Respond to user input +Bangle.setUI({mode: "updown"}, function(dir) { + if (dir<0) { + n--; + draw(); + } else if (dir>0) { + n++; + draw(); + } else { + n = 0; + draw(); } }); -g.clear(); -// call your app function here +// First draw... +draw(); + +// Load widgets +Bangle.loadWidgets(); +Bangle.drawWidgets(); diff --git a/apps/altimeter/ChangeLog b/apps/altimeter/ChangeLog new file mode 100644 index 000000000..29388520e --- /dev/null +++ b/apps/altimeter/ChangeLog @@ -0,0 +1,2 @@ +0.01: New App! +0.02: Actually upload correct code diff --git a/apps/altimeter/app-icon.js b/apps/altimeter/app-icon.js new file mode 100644 index 000000000..1f8dfb637 --- /dev/null +++ b/apps/altimeter/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEw4UA///t9TmuV3+GJf4AN+ALVgf8BasP/4LVn//4ALUWgJUJBZUDBYJUIBZcP3/nKhEOt/WBZE5r+VKg0KgEVr9V3wLHqtaqt9sALElWAqoABt1QBZNeBYuq0ILCrVUBYulBYVWBYkCBYgABBZ8K1WVBYlABZegKQWqBQlVqALKqWoKQWpBYtWBZeqKRAAB1WABZZSHAANq0ALLKQ6qC1ALLKQ5UEAH4AG")) diff --git a/apps/altimeter/app.js b/apps/altimeter/app.js new file mode 100644 index 000000000..cac4e80fd --- /dev/null +++ b/apps/altimeter/app.js @@ -0,0 +1,30 @@ +Bangle.setBarometerPower(true, "app"); + +g.clear(1); +Bangle.loadWidgets(); +Bangle.drawWidgets(); +var zero = 0; +var R = Bangle.appRect; +var y = R.y + R.h/2; +var MEDIANLENGTH = 20; +var avr = [], median; +var value = 0; + +Bangle.on('pressure', function(e) { + while (avr.length>MEDIANLENGTH) avr.pop(); + avr.unshift(e.altitude); + median = avr.slice().sort(); + g.reset().clearRect(0,y-30,g.getWidth()-10,y+30); + if (median.length>10) { + var mid = median.length>>1; + value = E.sum(median.slice(mid-4,mid+5)) / 9; + g.setFont("Vector",50).setFontAlign(0,0).drawString((value-zero).toFixed(1), g.getWidth()/2, y); + } +}); + +g.reset(); +g.setFont("6x8").setFontAlign(0,0).drawString(/*LANG*/"ALTITUDE (m)", g.getWidth()/2, y-40); +g.setFont("6x8").setFontAlign(0,0,3).drawString(/*LANG*/"ZERO", g.getWidth()-5, g.getHeight()/2); +setWatch(function() { + zero = value; +}, (process.env.HWVERSION==2) ? BTN1 : BTN2, {repeat:true}); diff --git a/apps/altimeter/app.png b/apps/altimeter/app.png new file mode 100644 index 000000000..9c9d69077 Binary files /dev/null and b/apps/altimeter/app.png differ diff --git a/apps/altimeter/metadata.json b/apps/altimeter/metadata.json new file mode 100644 index 000000000..8bdbf3022 --- /dev/null +++ b/apps/altimeter/metadata.json @@ -0,0 +1,12 @@ +{ "id": "altimeter", + "name": "Altimeter", + "version":"0.02", + "description": "Simple altimeter that can display height changed using Bangle.js 2's built in pressure sensor.", + "icon": "app.png", + "tags": "tool,outdoors", + "supports" : ["BANGLEJS2"], + "storage": [ + {"name":"altimeter.app.js","url":"app.js"}, + {"name":"altimeter.img","url":"app-icon.js","evaluate":true} + ] +} diff --git a/apps/bee/ChangeLog b/apps/bee/ChangeLog new file mode 100644 index 000000000..df0907283 --- /dev/null +++ b/apps/bee/ChangeLog @@ -0,0 +1,2 @@ +0.01: New app! +0.02: Fix bug with regenerating index, fix bug in word lookups diff --git a/apps/bee/bee.app.js b/apps/bee/bee.app.js index a12ca7820..ef1582baa 100644 --- a/apps/bee/bee.app.js +++ b/apps/bee/bee.app.js @@ -31,8 +31,9 @@ function prepareLetterIdx () { function findWord (w) { "compile" var ci = w.charCodeAt(0)-97; - var f = letterIdx[ci].indexOf(w); - if (f>=0 && letterIdx[ci][f+w.length]=="\n") return true; + var f = letterIdx[ci].indexOf("\n"+w+"\n"); + if (f>=0) return true; + if (letterIdx[ci].substr(0, w.length)==w) return true; return false; } @@ -47,6 +48,7 @@ function checkWord (w) { if (foundWords.indexOf(w)>=0) return false; // already found if (findWord(w)) { foundWords.push(w); + foundWords.sort(); if (w.length==4) score++; else score += w.length; if (isPangram(w)) score += 7; diff --git a/apps/bee/metadata.json b/apps/bee/metadata.json index a89177d4e..a22e1800c 100644 --- a/apps/bee/metadata.json +++ b/apps/bee/metadata.json @@ -2,7 +2,7 @@ "name": "Bee", "shortName":"Bee", "icon": "app.png", - "version":"0.01", + "version":"0.02", "description": "Spelling bee", "supports" : ["BANGLEJS2"], "readme": "README.md", diff --git a/apps/compass/ChangeLog b/apps/compass/ChangeLog index 4bb7838ac..d1adafc4c 100644 --- a/apps/compass/ChangeLog +++ b/apps/compass/ChangeLog @@ -3,3 +3,4 @@ 0.03: Eliminate flickering 0.04: Fix for Bangle.js 2 and themes 0.05: Fix bearing not clearing correctly (visible in single or double digit bearings) +0.06: Add button for force compass calibration diff --git a/apps/compass/compass.js b/apps/compass/compass.js index 65ad83c4f..ee0d3d8ba 100644 --- a/apps/compass/compass.js +++ b/apps/compass/compass.js @@ -64,7 +64,12 @@ Bangle.on('mag', function(m) { oldHeading = m.heading; }); -g.clear(); +g.clear(1); +g.setFont("6x8").setFontAlign(0,0,3).drawString("RESET", g.getWidth()-5, g.getHeight()/2); +setWatch(function() { + Bangle.resetCompass(); +}, (process.env.HWVERSION==2) ? BTN1 : BTN2, {repeat:true}); + Bangle.loadWidgets(); Bangle.drawWidgets(); Bangle.setCompassPower(1); diff --git a/apps/compass/metadata.json b/apps/compass/metadata.json index 318d90c86..e24ca4adc 100644 --- a/apps/compass/metadata.json +++ b/apps/compass/metadata.json @@ -1,7 +1,7 @@ { "id": "compass", "name": "Compass", - "version": "0.05", + "version": "0.06", "description": "Simple compass that points North", "icon": "compass.png", "screenshots": [{"url":"screenshot_compass.png"}], diff --git a/apps/fuzzyw/ChangeLog b/apps/fuzzyw/ChangeLog new file mode 100644 index 000000000..7b83706bf --- /dev/null +++ b/apps/fuzzyw/ChangeLog @@ -0,0 +1 @@ +0.01: First release diff --git a/apps/fuzzyw/README.md b/apps/fuzzyw/README.md new file mode 100644 index 000000000..906eb167b --- /dev/null +++ b/apps/fuzzyw/README.md @@ -0,0 +1,26 @@ +# Fuzzy Text Clock + +An imprecise clock for when you're not in a rush. + +This clock is a remake of one of my favourite Pebble watchfaces, Fuzzy Text International. I use this watch for weekends and holidays, when 'within 5 minutes of the actual time' is close enough! + +By default it will use the language set on the watch, go to settings to pick: +* en_GB - English +* en_US - American +* es_ES - Spanish +* fr_FR - French +* no_NO - Norwegian +* sv_SE - Swedish +* de_DE - German + +Most translations are taken from the original Fuzzy Text International code. + +## TODO +* Bold hour word (as the pebble version has) +* Animation when changing time? + +## References +Based on Pebble app Fuzzy Text International: https://github.com/hallettj/Fuzzy-Text-International + +![](fuzzyw-light.png) +![](fuzzyw-dark.png) diff --git a/apps/fuzzyw/fuzzy_strings.json b/apps/fuzzyw/fuzzy_strings.json new file mode 100644 index 000000000..8594ad554 --- /dev/null +++ b/apps/fuzzyw/fuzzy_strings.json @@ -0,0 +1,163 @@ +{ + "en_GB":{ + "hours":[ + "midnight", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", "eleven", + "twelve", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", "eleven" + ], + "minutes":[ + "*$1 o'clock", + "five past *$1", + "ten past *$1", + "quarter past *$1", + "twenty past *$1", + "twenty five past *$1", + "half past *$1", + "twenty five to *$2", + "twenty to *$2", + "quarter to *$2", + "ten to *$2", + "five to *$2" + ], + "text_scale":3.5 + }, + "en_US":{ + "hours":[ + "midnight", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", "eleven", + "twelve", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", "eleven" + ], + "minutes":[ + "*$1 o'clock", + "five after *$1", + "ten after *$1", + "quarter after *$1", + "twenty after *$1", + "twenty five after *$1", + "half past *$1", + "twenty five to *$2", + "twenty to *$2", + "quarter to *$2", + "ten to *$2", + "five to *$2" + ], + "text_scale":3.5 + }, + "es_ES":{ + "hours":[ + "doce", "una", "dos", "tres", "cuatro", "cinco", + "seis", "siete", "ocho", "nueve", "diez", "once", + "doce", "una", "dos", "tres", "cuatro", "cinco", + "seis", "siete", "ocho", "nueve", "diez", "once" + ], + "minutes":[ + "*$1 en punto", + "*$1 y cinco", + "*$1 y diez", + "*$1 y cuarto", + "*$1 y veinte", + "*$1 y veinti- cinco", + "*$1 y media", + "*$2 menos veinti- cinco", + "*$2 menos veinte", + "*$2 menos cuarto", + "*$2 menos diez", + "*$2 menos cinco" + ], + "text_scale":3.5 + }, + "fr_FR":{ + "hours":[ + "douze", "une", "deux", "trois", "quatre", "cinq", + "six", "sept", "huit", "neuf", "dix", "onze", + "douze", "une", "deux", "trois", "quatre", "cinq", + "six", "sept", "huit", "neuf", "dix", "onze" + ], + "minutes":[ + "*$1 heures", + "*$1 heures cinq", + "*$1 heures dix", + "*$1 heures et quart", + "*$1 heures vingt", + "*$1 heures vingt- cinq", + "*$1 heures et demie", + "*$2 moins vingt- cinq", + "*$2 heures moins vingt", + "*$2 moins le quart", + "*$2 heures moins dix", + "*$2 heures moins cinq" + ], + "text_scale":3.5 + }, + "no_NB":{ + "hours":[ + "tolv", "ett", "to", "tre", "fire", "fem", + "seks", "sju", "åtte", "ni", "ti", "elleve", + "tolv", "ett", "to", "tre", "fire", "fem", + "seks", "sju", "åtte", "ni", "ti", "elleve" + ], + "minutes":[ + "klokka er *$1", + "fem over *$1", + "ti over *$1", + "kvart over *$1", + "ti på halv *$2", + "fem på halv *$2", + "halv *$2", + "fem over halv *$2", + "ti over halv *$2", + "kvart på *$2", + "ti på *$2", + "fem på *$2" + ], + "text_scale":3.5 + }, + "sv_SE":{ + "hours":[ + "tolv", "ett", "två", "tre", "fyra", "fem", + "sex", "sju", "åtta", "nio", "tio", "elva", + "tolv", "ett", "två", "tre", "fyra", "fem", + "sex", "sju", "åtta", "nio", "tio", "elva" + ], + "minutes":[ + "*$1", + "fem över *$1", + "tio över *$1", + "kvart över *$1", + "tjugo över *$1", + "fem i halv *$2", + "halv *$2", + "fem över halv *$2", + "tjugo i *$2", + "kvart i *$2", + "tio i *$2", + "fem i *$2" + ], + "text_scale":3.5 + }, + "de_DE":{ + "hours":[ + "zwölf", "eins", "zwei", "drei", "vier", "fünf", + "sechs", "sieben", "acht", "neun", "zehn", "elf", + "zwölf", "eins", "zwei", "drei", "vier", "fünf", + "sechs", "sieben", "acht", "neun", "zehn", "elf" + ], + "minutes":[ + "*$1 uhr", + "fünf nach *$1", + "zehn nach *$1", + "viertel nach *$1", + "zwanzig nach *$1", + "fünf for halb *$2", + "halb *$2", + "fünf nach halb *$2", + "zwanzig vor *$2", + "viertel vor *$2", + "zehn vor *$2", + "fünf vor *$2" + ], + "text_scale":3.5 + } +} diff --git a/apps/fuzzyw/fuzzyw-dark.png b/apps/fuzzyw/fuzzyw-dark.png new file mode 100644 index 000000000..88220e5c7 Binary files /dev/null and b/apps/fuzzyw/fuzzyw-dark.png differ diff --git a/apps/fuzzyw/fuzzyw-light.png b/apps/fuzzyw/fuzzyw-light.png new file mode 100644 index 000000000..5383e08a4 Binary files /dev/null and b/apps/fuzzyw/fuzzyw-light.png differ diff --git a/apps/fuzzyw/fuzzyw.app.js b/apps/fuzzyw/fuzzyw.app.js new file mode 100644 index 000000000..07b5c4068 --- /dev/null +++ b/apps/fuzzyw/fuzzyw.app.js @@ -0,0 +1,75 @@ +// adapted from https://github.com/hallettj/Fuzzy-Text-International/ +const fuzzy_strings = require("Storage").readJSON("fuzzy_strings.json"); + +const SETTINGS_FILE = "fuzzyw.settings.json"; +let settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'language': 'System', 'alignment':'Centre'}; + +if (settings.language == 'System') { + settings.language = require('locale').name; +} + +let fuzzy_string = fuzzy_strings[settings.language]; + +let timeout = 2.5*60; +let drawTimeout; + +function queueDraw(seconds) { + let millisecs = seconds * 1000; + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(function() { + drawTimeout = undefined; + draw(); + }, millisecs - (Date.now() % millisecs)); +} + +const h = g.getHeight(); +const w = g.getWidth(); +let align_mode = 0; +let align_pos = w/2; +if (settings.alignment =='Left') { + align_mode = -1; + align_pos = 0; +} else if (settings.alignment == 'Right') { + align_mode = 1; + align_pos = w; +} + +function getTimeString(date) { + let segment = Math.round((date.getMinutes()*60 + date.getSeconds() + 1)/300); + let hour = date.getHours() + Math.floor(segment/12); + f_string = fuzzy_string.minutes[segment % 12]; + if (f_string.includes('$1')) { + f_string = f_string.replace('$1', fuzzy_string.hours[(hour) % 24]); + } else { + f_string = f_string.replace('$2', fuzzy_string.hours[(hour + 1) % 24]); + } + return f_string; +} + +function draw() { + let time_string = getTimeString(new Date()).replace('*', ''); + // print(time_string); + g.setFont('Vector', (h-24*2)/fuzzy_string.text_scale); + g.setFontAlign(align_mode, 0); + g.clearRect(0, 24, w, h-24); + g.setColor(g.theme.fg); + g.drawString(g.wrapString(time_string, w).join("\n"), align_pos, h/2); + queueDraw(timeout); +} + +g.clear(); +draw(); + +// Stop updates when LCD is off, restart when on +Bangle.on('lcdPower',on=>{ + if (on) { + draw(); // draw immediately, queue redraw + } else { // stop draw timer + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + } +}); + +Bangle.setUI('clock'); +Bangle.loadWidgets(); +Bangle.drawWidgets(); diff --git a/apps/fuzzyw/fuzzyw.icon.js b/apps/fuzzyw/fuzzyw.icon.js new file mode 100644 index 000000000..acc7e2fcf --- /dev/null +++ b/apps/fuzzyw/fuzzyw.icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwgP/ABX8oYFD+AFE8AFE8IXE8YFKwFCj08h4FBocenEHCIPDjk4CoIFBhlwAoeMuIFEuBSBAoOI+AFD4HxGoQFB+AFD4P4uYFC8P4gYFD/w7BAFEfApfEj+B/Ecg/Ah8A+EMg/Dw0YseHj/Dw/8sfHAoPH/lhDoIFBwFwj4FB40AvkPAoU8v4dCAoIdDw04FIMP4EOgFwh47Bj8EvEfw/DJwgFXABY")) diff --git a/apps/fuzzyw/fuzzyw.png b/apps/fuzzyw/fuzzyw.png new file mode 100644 index 000000000..afd0b0f76 Binary files /dev/null and b/apps/fuzzyw/fuzzyw.png differ diff --git a/apps/fuzzyw/fuzzyw.settings.js b/apps/fuzzyw/fuzzyw.settings.js new file mode 100644 index 000000000..00219accf --- /dev/null +++ b/apps/fuzzyw/fuzzyw.settings.js @@ -0,0 +1,46 @@ +(function(back) { + const SETTINGS_FILE = "fuzzyw.settings.json"; + + var align_options = ['Left','Centre','Right']; + var language_options = ['System', 'en_GB', 'en_US', 'es_ES', 'fr_FR', 'no_NO', 'sv_SE', 'de_DE']; + + // initialize with default settings... + let s = {'language': 'System', 'alignment': 'Centre'}; + + // ...and overwrite them with any saved values + // This way saved values are preserved if a new version adds more settings + const storage = require('Storage') + let settings = storage.readJSON(SETTINGS_FILE, 1) || s; + const saved = settings || {} + for (const key in saved) { + s[key] = saved[key] + } + + function save() { + settings = s + storage.write(SETTINGS_FILE, settings) + } + + E.showMenu({ + '': { 'title': 'Fuzzy Text Clock' }, + '< Back': back, + 'Language': { + value: 0 | language_options.indexOf(s.language), + min: 0, max: language_options.length - 1, + format: v => language_options[v], + onchange: v => { + s.language = language_options[v]; + save(); + } + }, + 'Alignment': { + value: 0 | align_options.indexOf(s.alignment), + min: 0, max: align_options.length - 1, + format: v => align_options[v], + onchange: v => { + s.alignment = align_options[v]; + save(); + } + }, + }); +}) diff --git a/apps/fuzzyw/metadata.json b/apps/fuzzyw/metadata.json new file mode 100644 index 000000000..ebd20e49f --- /dev/null +++ b/apps/fuzzyw/metadata.json @@ -0,0 +1,20 @@ +{ + "id":"fuzzyw", + "name":"Fuzzy Text Clock", + "shortName": "Fuzzy Text", + "version": "0.01", + "description": "An imprecise clock for when you're not in a rush", + "readme": "README.md", + "icon":"fuzzyw.png", + "screenshots": [{"url":"fuzzyw-light.png"},{"url":"fuzzyw-dark.png"}], + "type": "clock", + "tags": "clock", + "supports": ["BANGLEJS", "BANGLEJS2"], + "allow_emulator": true, + "storage": [ + {"name":"fuzzyw.app.js","url":"fuzzyw.app.js"}, + {"name":"fuzzyw.settings.js","url":"fuzzyw.settings.js"}, + {"name":"fuzzyw.img","url":"fuzzyw.icon.js","evaluate":true}, + {"name":"fuzzy_strings.json","url":"fuzzy_strings.json"} + ] +} diff --git a/apps/game1024/README.md b/apps/game1024/README.md index 500453145..a25683b68 100644 --- a/apps/game1024/README.md +++ b/apps/game1024/README.md @@ -1,7 +1,7 @@ # Play the game of 1024 -Move the tiles by swiping to the lefthand, righthand or up- and downward side of the watch. +Move the tiles by swiping left, right, up- or downward over the watchface. When two tiles with the same number are squashed together they will add up as exponentials: @@ -21,16 +21,28 @@ Use the side **BTN** to exit the game, score and tile positions will be saved. ## Buttons on the screen - - Button **U**: Undo the last move. There are currently a maximum of 4 undo levels. The level is indicated with a small number in the lower righthand corner of the Undo button - - Button **\***: Change the text on the tile to number, capitals or Roman numbers - - Button **R**: Reset the game. The Higscore will be remembered. You will be prompted first. + - Button **U**: Undo the last move. There are currently a maximum of 9 undo levels. The level is indicated with a small number in the lower righthand corner of the Undo button + - You can set the maximum undo level in the Apps settings menu. + + - Button **R**: Reset the game. The Highscore will be remembered. You will be prompted first. + - The highscore value can be reset in the Apps settings menu. + + Apps setting: ![Screenshot of the apps settings menu](./game1024_sc_dump_app_settings.png) + + - Stuff you can change in de 1024 Game settings: + - Symbols on the cells: numerical, alphabetical or Roman + - Undo levels [0-9] + - Exit: how to exit the game: long or short press + - Debug mode: on or off. This will log all kinds of stuff in the console of the Web IDE + - Reset Highsccore: Tired of looking at the old highscore? Now you can set it to 0 again. ### Credits Game 1024 is based on Saming's 2048 and Misho M. Petkovic 1024game.org and conceptually similar to Threes by Asher Vollmer. In Dark theme with numbers: -![Screenshot from the Banglejs 2 watch with the game in dark theme](./game1024_sc_dump_dark.png) +![Screenshot from the Banglejs 2 watch with the game in dark theme](./game1024_sc_dump_dark_v0.09.png) In Light theme with characters: -![Screenshot from the Banglejs 2 watch with the game in light theme](./game1024_sc_dump_light.png) \ No newline at end of file +![Screenshot from the Banglejs 2 watch with the game in light theme](./game1024_sc_dump_light.v0.09.png) + diff --git a/apps/game1024/game1024_sc_dump_app_settings.png b/apps/game1024/game1024_sc_dump_app_settings.png new file mode 100644 index 000000000..6c50898b3 Binary files /dev/null and b/apps/game1024/game1024_sc_dump_app_settings.png differ diff --git a/apps/game1024/game1024_sc_dump_dark.png b/apps/game1024/game1024_sc_dump_dark.png deleted file mode 100644 index 87577ecfa..000000000 Binary files a/apps/game1024/game1024_sc_dump_dark.png and /dev/null differ diff --git a/apps/game1024/game1024_sc_dump_dark_v0.09.png b/apps/game1024/game1024_sc_dump_dark_v0.09.png new file mode 100644 index 000000000..6c14f78e8 Binary files /dev/null and b/apps/game1024/game1024_sc_dump_dark_v0.09.png differ diff --git a/apps/game1024/game1024_sc_dump_light.png b/apps/game1024/game1024_sc_dump_light.png deleted file mode 100644 index 06ada65ac..000000000 Binary files a/apps/game1024/game1024_sc_dump_light.png and /dev/null differ diff --git a/apps/game1024/game1024_sc_dump_light.v0.09.png b/apps/game1024/game1024_sc_dump_light.v0.09.png new file mode 100644 index 000000000..1218079e8 Binary files /dev/null and b/apps/game1024/game1024_sc_dump_light.v0.09.png differ diff --git a/apps/game1024/screenshot.png b/apps/game1024/screenshot.png index 8be52f8cb..b8d204cd3 100644 Binary files a/apps/game1024/screenshot.png and b/apps/game1024/screenshot.png differ diff --git a/apps/kbswipe/ChangeLog b/apps/kbswipe/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/kbswipe/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/kbswipe/README.md b/apps/kbswipe/README.md new file mode 100644 index 000000000..1a402a9f3 --- /dev/null +++ b/apps/kbswipe/README.md @@ -0,0 +1,36 @@ +# Swipe Keyboard + +A library that provides the ability to input text by swiping PalmOS Graffiti-style characters onto the screen. + +To get a legend of available characters, just tap the screen. + + +## Usage + +In your app's metadata, add: + +``` + "dependencies": {"textinput":"type"}, +``` + +From inside your app, call: + +``` +Bangle.loadWidgets(); +Bangle.drawWidgets(); +require("textinput").input({text:"Foo"}).then(result => { + console.log("Text input", E.toJS(result)); +}); +``` + +The first argument to `input` is an object containing the following: + +* `text` - initial text to edit + +(in the future, the ability to restrict usage of newline/etc may be added) + +## Make your own + +You can create your own keyboard input apps. Just ensure that they have +`"type":"textinput",` in their metadata and provide a library called `textinput` +that exports an `input` method. diff --git a/apps/kbswipe/app.png b/apps/kbswipe/app.png new file mode 100644 index 000000000..9564a4068 Binary files /dev/null and b/apps/kbswipe/app.png differ diff --git a/apps/kbswipe/lib.js b/apps/kbswipe/lib.js new file mode 100644 index 000000000..51f92f510 --- /dev/null +++ b/apps/kbswipe/lib.js @@ -0,0 +1,110 @@ +/* To make your own strokes, type: + +Bangle.on('stroke',print) + +on the left of the IDE, then do a stroke and copy out the Uint8Array line +*/ +exports.getStrokes = function(cb) { + cb("a", new Uint8Array([58, 159, 58, 155, 62, 144, 69, 127, 77, 106, 86, 90, 94, 77, 101, 68, 108, 62, 114, 59, 121, 59, 133, 61, 146, 70, 158, 88, 169, 107, 176, 124, 180, 135, 183, 144, 185, 152])); + cb("b", new Uint8Array([51, 47, 51, 77, 56, 123, 60, 151, 65, 163, 68, 164, 68, 144, 67, 108, 67, 76, 72, 43, 104, 51, 121, 74, 110, 87, 109, 95, 131, 117, 131, 140, 109, 152, 88, 157])); + cb("c", new Uint8Array([153, 62, 150, 62, 145, 62, 136, 62, 123, 62, 106, 65, 85, 70, 65, 75, 50, 82, 42, 93, 37, 106, 36, 119, 36, 130, 40, 140, 49, 147, 61, 153, 72, 156, 85, 157, 106, 158, 116, 158])); + cb("d", new Uint8Array([57, 178, 57, 176, 55, 171, 52, 163, 50, 154, 49, 146, 47, 135, 45, 121, 44, 108, 44, 97, 44, 85, 44, 75, 44, 66, 44, 58, 44, 48, 44, 38, 46, 31, 48, 26, 58, 21, 75, 20, 99, 26, 120, 35, 136, 51, 144, 70, 144, 88, 137, 110, 124, 131, 106, 145, 88, 153])); + cb("e", new Uint8Array([150, 72, 141, 69, 114, 68, 79, 69, 48, 77, 32, 81, 31, 85, 46, 91, 73, 95, 107, 100, 114, 103, 83, 117, 58, 134, 66, 143, 105, 148, 133, 148, 144, 148])); + cb("f", new Uint8Array([157, 52, 155, 52, 148, 52, 137, 52, 124, 52, 110, 52, 96, 52, 83, 52, 74, 52, 67, 52, 61, 52, 57, 52, 55, 52, 52, 52, 52, 54, 52, 58, 52, 64, 54, 75, 58, 97, 59, 117, 60, 130])); + cb("g", new Uint8Array([160, 66, 153, 62, 129, 58, 90, 56, 58, 57, 38, 65, 31, 86, 43, 125, 69, 152, 116, 166, 145, 154, 146, 134, 112, 116, 85, 108, 97, 106, 140, 106, 164, 106])); + cb("h", new Uint8Array([58, 50, 58, 55, 58, 64, 58, 80, 58, 102, 58, 122, 58, 139, 58, 153, 58, 164, 58, 171, 58, 177, 58, 179, 58, 181, 58, 180, 58, 173, 58, 163, 59, 154, 61, 138, 64, 114, 68, 95, 72, 84, 80, 79, 91, 79, 107, 82, 123, 93, 137, 111, 145, 130, 149, 147, 150, 154, 150, 159])); + cb("i", new Uint8Array([89, 48, 89, 49, 89, 51, 89, 55, 89, 60, 89, 68, 89, 78, 89, 91, 89, 103, 89, 114, 89, 124, 89, 132, 89, 138, 89, 144, 89, 148, 89, 151, 89, 154, 89, 156, 89, 157, 89, 158])); + cb("j", new Uint8Array([130, 57, 130, 61, 130, 73, 130, 91, 130, 113, 130, 133, 130, 147, 130, 156, 130, 161, 130, 164, 130, 166, 129, 168, 127, 168, 120, 168, 110, 168, 91, 167, 81, 167, 68, 167])); + cb("k", new Uint8Array([149, 63, 147, 68, 143, 76, 136, 89, 126, 106, 114, 123, 100, 136, 86, 147, 72, 153, 57, 155, 45, 152, 36, 145, 29, 131, 26, 117, 26, 104, 27, 93, 30, 86, 35, 80, 45, 77, 62, 80, 88, 96, 113, 116, 130, 131, 140, 142, 145, 149, 148, 153])); + cb("l", new Uint8Array([42, 55, 42, 59, 42, 69, 44, 87, 44, 107, 44, 128, 44, 143, 44, 156, 44, 163, 44, 167, 44, 169, 45, 170, 49, 170, 59, 169, 76, 167, 100, 164, 119, 162, 139, 160, 163, 159])); + cb("m", new Uint8Array([49, 165, 48, 162, 46, 156, 44, 148, 42, 138, 42, 126, 42, 113, 43, 101, 45, 91, 47, 82, 49, 75, 51, 71, 54, 70, 57, 70, 61, 74, 69, 81, 75, 91, 84, 104, 94, 121, 101, 132, 103, 137, 106, 130, 110, 114, 116, 92, 125, 75, 134, 65, 139, 62, 144, 66, 148, 83, 151, 108, 155, 132, 157, 149])); + cb("n", new Uint8Array([50, 165, 50, 160, 50, 153, 50, 140, 50, 122, 50, 103, 50, 83, 50, 65, 50, 52, 50, 45, 50, 43, 52, 52, 57, 67, 66, 90, 78, 112, 93, 131, 104, 143, 116, 152, 127, 159, 135, 160, 141, 150, 148, 125, 154, 96, 158, 71, 161, 56, 162, 49])); + cb("o", new Uint8Array([107, 58, 104, 58, 97, 61, 87, 68, 75, 77, 65, 88, 58, 103, 54, 116, 53, 126, 55, 135, 61, 143, 75, 149, 91, 150, 106, 148, 119, 141, 137, 125, 143, 115, 146, 104, 146, 89, 142, 78, 130, 70, 116, 65, 104, 62])); + cb("p", new Uint8Array([52, 59, 52, 64, 54, 73, 58, 88, 61, 104, 65, 119, 67, 130, 69, 138, 71, 145, 71, 147, 71, 148, 71, 143, 70, 133, 68, 120, 67, 108, 67, 97, 67, 89, 68, 79, 72, 67, 83, 60, 99, 58, 118, 58, 136, 63, 146, 70, 148, 77, 145, 84, 136, 91, 121, 95, 106, 97, 93, 97, 82, 97])); + cb("q", new Uint8Array([95, 59, 93, 59, 88, 59, 79, 59, 68, 61, 57, 67, 50, 77, 48, 89, 48, 103, 50, 117, 55, 130, 65, 140, 76, 145, 85, 146, 94, 144, 101, 140, 105, 136, 106, 127, 106, 113, 100, 98, 92, 86, 86, 79, 84, 75, 84, 72, 91, 69, 106, 67, 126, 67, 144, 67, 158, 67, 168, 67, 173, 67, 177, 67])); + cb("r", new Uint8Array([53, 49, 53, 62, 53, 91, 53, 127, 53, 146, 53, 147, 53, 128, 53, 94, 53, 69, 62, 44, 82, 42, 94, 50, 92, 68, 82, 85, 77, 93, 80, 102, 95, 119, 114, 134, 129, 145, 137, 150])); + cb("s", new Uint8Array([159, 72, 157, 70, 155, 68, 151, 66, 145, 63, 134, 60, 121, 58, 108, 56, 96, 55, 83, 55, 73, 55, 64, 56, 57, 60, 52, 65, 49, 71, 49, 76, 50, 81, 55, 87, 71, 94, 94, 100, 116, 104, 131, 108, 141, 114, 145, 124, 142, 135, 124, 146, 97, 153, 70, 157, 52, 158])); + cb("t", new Uint8Array([45, 55, 48, 55, 55, 55, 72, 55, 96, 55, 120, 55, 136, 55, 147, 55, 152, 55, 155, 55, 157, 55, 158, 56, 158, 60, 156, 70, 154, 86, 151, 102, 150, 114, 148, 125, 148, 138, 148, 146])); + cb("u", new Uint8Array([35, 52, 35, 59, 35, 73, 35, 90, 36, 114, 38, 133, 42, 146, 49, 153, 60, 157, 73, 158, 86, 156, 100, 152, 112, 144, 121, 131, 127, 114, 132, 97, 134, 85, 135, 73, 136, 61, 136, 56])); + cb("v", new Uint8Array([36, 55, 37, 59, 40, 68, 45, 83, 51, 100, 58, 118, 64, 132, 69, 142, 71, 149, 73, 156, 76, 158, 77, 160, 77, 159, 80, 151, 82, 137, 84, 122, 86, 111, 90, 91, 91, 78, 91, 68, 91, 63, 92, 61, 97, 61, 111, 61, 132, 61, 150, 61, 162, 61])); + cb("w", new Uint8Array([33, 58, 34, 81, 39, 127, 44, 151, 48, 161, 52, 162, 57, 154, 61, 136, 65, 115, 70, 95, 76, 95, 93, 121, 110, 146, 119, 151, 130, 129, 138, 84, 140, 56, 140, 45])); + cb("x", new Uint8Array([56, 63, 56, 67, 57, 74, 60, 89, 66, 109, 74, 129, 85, 145, 96, 158, 107, 164, 117, 167, 128, 164, 141, 155, 151, 140, 159, 122, 166, 105, 168, 89, 170, 81, 170, 73, 169, 66, 161, 63, 141, 68, 110, 83, 77, 110, 55, 134, 47, 145])); + cb("y", new Uint8Array([42, 56, 42, 70, 48, 97, 62, 109, 85, 106, 109, 90, 126, 65, 134, 47, 137, 45, 137, 75, 127, 125, 98, 141, 70, 133, 65, 126, 92, 137, 132, 156, 149, 166])); + cb("z", new Uint8Array([29, 62, 35, 62, 43, 62, 63, 62, 87, 62, 110, 62, 125, 62, 134, 62, 138, 62, 136, 63, 122, 68, 103, 77, 85, 91, 70, 107, 59, 120, 50, 132, 47, 138, 43, 143, 41, 148, 42, 151, 53, 155, 80, 157, 116, 158, 146, 158, 163, 158])); + cb("\b", new Uint8Array([183, 103, 182, 103, 180, 103, 176, 103, 169, 103, 159, 103, 147, 103, 133, 103, 116, 103, 101, 103, 85, 103, 73, 103, 61, 103, 52, 103, 38, 103, 34, 103, 29, 103, 27, 103, 26, 103, 25, 103, 24, 103])); + cb(" ", new Uint8Array([39, 118, 40, 118, 41, 118, 44, 118, 47, 118, 52, 118, 58, 118, 66, 118, 74, 118, 84, 118, 94, 118, 104, 117, 114, 116, 123, 116, 130, 116, 144, 116, 149, 116, 154, 116, 158, 116, 161, 116, 163, 116])); +}; + +exports.input = function(options) { + options = options||{}; + var text = options.text; + if ("string"!=typeof text) text=""; + +Bangle.strokes = {}; +exports.getStrokes( (id,s) => Bangle.strokes[id] = Unistroke.new(s) ); + + var flashToggle = false; + const R = Bangle.appRect; + + function draw(noclear) { + g.reset(); + if (!noclear) g.clearRect(R); + var l = g.setFont("6x8:4").wrapString(text+(flashToggle?"_":" "), R.w-8); + if (l.length>4) l=l.slice(-4); + g.drawString(l.join("\n"),R.x+4,R.y+4); + } + + function show() { + g.reset(); + g.clearRect(R).setColor("#f00"); + var n=0; + exports.getStrokes((id,s) => { + var x = n%6; + var y = (n-x)/6; + s = g.transformVertices(s, {scale:0.16, x:R.x+x*30-4, y:R.y+y*30-4}); + g.fillRect(s[0]-1,s[1]-2,s[0]+1,s[1]+1); + g.drawPoly(s); + n++; + }); + + } + + function strokeHandler(o) { + //print(o); + if (!flashInterval) + flashInterval = setInterval(() => { + flashToggle = !flashToggle; + draw(); + }, 1000); + if (o.stroke!==undefined) { + var ch = o.stroke; + if (ch=="\b") text = text.slice(0,-1); + else text += ch; + } + flashToggle = true; + draw(); + } + Bangle.on('stroke',strokeHandler); + g.reset().clearRect(R); + show(); + draw(true); + var flashInterval; + + return new Promise((resolve,reject) => { + var l;//last event + Bangle.setUI({mode:"custom", drag:e=>{ + if (l) g.reset().setColor("#f00").drawLine(l.x,l.y,e.x,e.y); + l = e.b ? e : 0; + },touch:() => { + if (flashInterval) clearInterval(flashInterval); + flashInterval = undefined; + show(); + }, back:()=>{ + Bangle.removeListener("stroke", strokeHandler); + clearInterval(flashInterval); + Bangle.setUI(); + g.clearRect(Bangle.appRect); + resolve(text); + }}); + }); +}; diff --git a/apps/kbswipe/metadata.json b/apps/kbswipe/metadata.json new file mode 100644 index 000000000..635841e62 --- /dev/null +++ b/apps/kbswipe/metadata.json @@ -0,0 +1,14 @@ +{ "id": "kbswipe", + "name": "Swipe keyboard", + "version":"0.01", + "description": "A library for text input via PalmOS style swipe gestures (beta!)", + "icon": "app.png", + "type":"textinput", + "tags": "keyboard", + "supports" : ["BANGLEJS2"], + "screenshots": [{"url":"screenshot.png"}], + "readme": "README.md", + "storage": [ + {"name":"textinput","url":"lib.js"} + ] +} diff --git a/apps/kbswipe/screenshot.png b/apps/kbswipe/screenshot.png new file mode 100644 index 000000000..11788ad87 Binary files /dev/null and b/apps/kbswipe/screenshot.png differ diff --git a/apps/kbtouch/ChangeLog b/apps/kbtouch/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/kbtouch/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/kbtouch/README.md b/apps/kbtouch/README.md new file mode 100644 index 000000000..513ba9239 --- /dev/null +++ b/apps/kbtouch/README.md @@ -0,0 +1,37 @@ +# Touch Keyboard + +A library that provides an on-screen keyboard for text input. + +## Usage + +In your app's metadata, add: + +``` + "dependencies": {"textinput":"type"}, +``` + +From inside your app, call: + +``` +Bangle.loadWidgets(); +Bangle.drawWidgets(); +require("textinput").input({text:"Foo"}).then(result => { + console.log("Text input", E.toJS(result)); +}); +``` + +The first argument to `input` is an object containing the following: + +* `text` - initial text to edit + +(in the future, the ability to restrict usage of newline/etc may be added) + +## Make your own + +You can create your own keyboard input apps. Just ensure that they have +`"type":"textinput",` in their metadata and provide a library called `textinput` +that exports an `input` method. + +## To-do + +Make this Bangle.js 1 compatible (use left/right touch and up/down buttons) diff --git a/apps/kbtouch/app.png b/apps/kbtouch/app.png new file mode 100644 index 000000000..19aec3c05 Binary files /dev/null and b/apps/kbtouch/app.png differ diff --git a/apps/kbtouch/lib.js b/apps/kbtouch/lib.js new file mode 100644 index 000000000..3dfdce00c --- /dev/null +++ b/apps/kbtouch/lib.js @@ -0,0 +1,132 @@ +exports.input = function(options) { + options = options||{}; + var text = options.text; + if ("string"!=typeof text) text=""; + + // Key Maps for Keyboard +var KEYMAPLOWER = [ + "`1234567890-=\b", + "\2qwertyuiop[]\n", + "\2asdfghjkl;'#\n", + " \\zxcvbnm,./ ", + ]; +var KEYMAPUPPER = [ + "¬!\"£$%^&*()_+\b", + "\2QWERTYUIOP{}\n", + "\2ASDFGHJKL:@~\n", + " |ZXCVBNM<>? ", + ]; +var KEYIMGL = Graphics.createImage(` + + + # + ### + ##### + # + # + # + # + # + # + # + # + # + # + # + # + # +`);KEYIMGL.transparent=0; +var KEYIMGR = Graphics.createImage(` + + + # + ## +##### + ## + # + + + +### + # + # + # + # + # +##### + ### + # + +#`);KEYIMGR.transparent=0; +/* If a char in the keymap is >=128, +subtract 128 and look in this array for +multi-character key codes*/ +var KEYEXTRA = [ + String.fromCharCode(27,91,68), // 0x80 left + String.fromCharCode(27,91,67), // 0x81 right + String.fromCharCode(27,91,65), // 0x82 up + String.fromCharCode(27,91,66), // 0x83 down + String.fromCharCode(27,91,53,126), // 0x84 page up + String.fromCharCode(27,91,54,126), // 0x85 page down +]; +// state +const R = Bangle.appRect; +var kbx = 0, kby = 0, kbdx = 0, kbdy = 0, kbShift = false, flashToggle = false; +const PX=12, PY=16, DRAGSCALE=24; +var xoff = 3, yoff = g.getHeight()-PY*4; + +function draw() { + var map = kbShift ? KEYMAPUPPER : KEYMAPLOWER; + //g.drawImage(KEYIMG,0,yoff); + g.reset().setFont("6x8:2"); + g.clearRect(R); + if (kbx>=0) + g.setColor(g.theme.bgH).fillRect(xoff+kbx*PX,yoff+kby*PY, xoff+(kbx+1)*PX-1,yoff+(kby+1)*PY-1).setColor(g.theme.fg); + g.drawImage(KEYIMGL,xoff,yoff+PY,{scale:2}); + g.drawImage(KEYIMGR,xoff+PX*13,yoff,{scale:2}); + g.drawString(map[0],xoff,yoff); + g.drawString(map[1],xoff,yoff+PY); + g.drawString(map[2],xoff,yoff+PY*2); + g.drawString(map[3],xoff,yoff+PY*3); + var l = g.setFont("6x8:4").wrapString(text+(flashToggle?"_":" "), R.w-8); + if (l.length>2) l=l.slice(-2); + g.drawString(l.join("\n"),R.x+4,R.y+4); + + g.flip(); +} + g.reset().clearRect(R); + draw(); + var flashInterval = setInterval(() => { + flashToggle = !flashToggle; + draw(); + }, 1000); + + return new Promise((resolve,reject) => { + + Bangle.setUI({mode:"custom", drag:e=>{ + kbdx += e.dx; + kbdy += e.dy; + var dx = Math.round(kbdx/DRAGSCALE), dy = Math.round(kbdy/DRAGSCALE); + kbdx -= dx*DRAGSCALE; + kbdy -= dy*DRAGSCALE; + if (dx || dy) { + kbx = (kbx+dx+15)%15; + kby = (kby+dy+4)%4; + draw(); + } + },touch:()=>{ + var map = kbShift ? KEYMAPUPPER : KEYMAPLOWER; + var ch = map[kby][kbx]; + if (ch=="\2") kbShift=!kbShift; + else if (ch=="\b") text = text.slice(0,-1); + else text += ch; + Bangle.buzz(20); + draw(); + },back:()=>{ + clearInterval(flashInterval); + Bangle.setUI(); + g.clearRect(Bangle.appRect); + resolve(text); + }}); + }); +}; diff --git a/apps/kbtouch/metadata.json b/apps/kbtouch/metadata.json new file mode 100644 index 000000000..da8b6c3c6 --- /dev/null +++ b/apps/kbtouch/metadata.json @@ -0,0 +1,14 @@ +{ "id": "kbtouch", + "name": "Touch keyboard", + "version":"0.01", + "description": "A library for text input via onscreen keyboard", + "icon": "app.png", + "type":"textinput", + "tags": "keyboard", + "supports" : ["BANGLEJS2"], + "screenshots": [{"url":"screenshot.png"}], + "readme": "README.md", + "storage": [ + {"name":"textinput","url":"lib.js"} + ] +} diff --git a/apps/kbtouch/screenshot.png b/apps/kbtouch/screenshot.png new file mode 100644 index 000000000..3aa772dda Binary files /dev/null and b/apps/kbtouch/screenshot.png differ diff --git a/apps/locale/locales.js b/apps/locale/locales.js index 073f4903f..282c808f3 100644 --- a/apps/locale/locales.js +++ b/apps/locale/locales.js @@ -39,11 +39,13 @@ these conversions */ const charFallbacks = { "ą":"a", "ā":"a", + "å":"a", "č":"c", "ć":"c", "ě":"e", "ę":"e", "ē":"e", + "æ":"e", "ģ":"g", "i":"ī", "ķ":"k", @@ -53,6 +55,7 @@ const charFallbacks = { "ņ":"n", "ő":"o", "ó":"o", + "ø":"o", "ř":"r", "ś":"s", "š":"s", @@ -681,6 +684,24 @@ var locales = { day: "Pirmdiena,Otrdiena,Trešdiena,Ceturtdiena,Piektdiena,Sestdiena,Svētdiena", trans: { yes: "jā", Yes: "Jā", no: "nē", No: "Nē", ok: "labi", on: "Ieslēgt", off: "Izslēgt", "< Back": "< Atpakaļ" } }, + "no_NB": { // Using charfallbacks + lang: "no_NB", + decimal_point: ",", + thousands_sep: " ", + currency_symbol: "kr", + int_curr_symbol: "NOK", + speed: "kmh", + distance: { 0: "m", 1: "km" }, + temperature: "°C", + ampm: { 0: "", 1: "" }, + timePattern: { 0: "%HH:%MM:%SS", 1: "%HH:%MM" }, + datePattern: { 0: "%d. %b %Y", "1": "%d.%m.%Y" }, // 1. Mar 2020 // 01.03.20 + abmonth: "Jan,Feb,Mar,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Des", + month: "Januar,Februar,Mars,April,Mai,Juni,Juli,August,September,Oktober,November,Desember", + abday: "Ma,Ti,On,To,Fr,Lø,Sø", + day: "Mandag,Tirsdag,Onsdag,Torsdag,Fredag,Lørdag,Søndag", + trans: { yes: "ja", Yes: "Ja", no: "nei", No: "Nei", ok: "ok", on: "på", off: "av", "< Back": "< Tilbake", "Delete": "Slett", "Mark Unread": "Merk som ulest" } + }, /*, "he_IL": { // This won't work until we get a font - see https://github.com/espruino/BangleApps/issues/399 codePage : "ISO8859-8", diff --git a/apps/megadenti/ChangeLog b/apps/megadenti/ChangeLog new file mode 100644 index 000000000..7f28ed46d --- /dev/null +++ b/apps/megadenti/ChangeLog @@ -0,0 +1 @@ +0.01: Create New App ! diff --git a/apps/megadenti/README.md b/apps/megadenti/README.md new file mode 100644 index 000000000..eaee2a98c --- /dev/null +++ b/apps/megadenti/README.md @@ -0,0 +1,2 @@ +Denti : +This teeth washing assistan helps you to wash your teeth diff --git a/apps/megadenti/app-icon.js b/apps/megadenti/app-icon.js new file mode 100644 index 000000000..0690cb9bd --- /dev/null +++ b/apps/megadenti/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEw4kA///A4M79/6823gvb70/qvLrXrrXdqmyzl2gvTzn0glS4ttuZh9iMQCykBvsRC6vUC6sdppIUgMb2Ol+IYBGaBGB6Oll1xGKMRpsfi/FrQXRjtHutai/uC6EBunRj9SrB5DPppeBj/njVV0IICu1xUpscqvBvgSCC5qlCuN1kqnCI5xGB69VwP1qJ2QUoMR4tcuOBA4LXOUoOKi/lq8RgMd64YMUoXCr8XFgMXs1p6JeM7cRjVS0PZtN5s2Z3oXKiKlBivHjl4swACu4XJgIWB6mxv0l0MZC4eZ3YXHKgPdolLuMR+tXC4lmzq/GQQNEonduILBDwOWC4lmBgLRG3vREQcBFwoABtfRC4kXaIKyFjAHBjtmy4EBvoXFjtBNA0X13u0N5j/O5+BEwhGBDwZICgPykUil0RwUikfqC4kR3YGCgOGwIuBCwIAB+NSkXh/3xIwlIiEBC4MbDgMaCoMl8U+AQNajXhIwcUIwIXBI4ceC4UcmVXJoMfC4nUVooABjhGC0LEBJAM+C4alBew5HCGAPu8QEBC4bsB2IXLAAk+0KlHXwoXLUop1BgK/CmQXG9ynCjtHIwUB3ZLDgJaCC4qJBLwJGDC4zvCAAbvBBoUReYZHCMAcTCYWvGgMu95CDRo7AFl8RiqmCCZSQGqKtCRwYAMgLqB4JYBmXuwIXP4UiRIXj9xyDCpTDBuUuYoWDRwYAKWIUVl4SCjXnC5I5DjORCQMxCQUf8JdNZITMEAggAvA=")) diff --git a/apps/megadenti/app.js b/apps/megadenti/app.js new file mode 100644 index 000000000..72d517935 --- /dev/null +++ b/apps/megadenti/app.js @@ -0,0 +1,99 @@ +var i = 0; +var counter = 10; +var counterInterval; + +var img = Graphics.createImage(` + + ##### ##### + # ##### # + # # + # # + ## ## + ## ## + ## ## + # #### # + # # # # + # # # # + ## ## + ## ## +`); +var img1 = Graphics.createImage(` + + + ### # ##### ## #### +# # # # # # # +# # ### # # #### +# # # ###### # # + ### #### ##### # # # # + + ##### ##### + # ##### # + # # + # # + ## ## + ## ## + ## ## + # #### # + # # # # + # # # # + ## ## + ## ## +`); +g.setColor('#012345'); + +function outOfTime() { + if (counterInterval) return; + E.showMessage("Out of Time", "My Timer"); + Bangle.beep(200, 4000) + .then(() => new Promise(resolve => setTimeout(resolve,200))) + .then(() => Bangle.beep(200, 3000)); + // again, 10 secs later + setTimeout(outOfTime, 10000); + g.setColor('#' + Math.floor(Math.random()*16777215).toString(16).padStart(6, '0')); +} + +function immagine(){ + g.drawImage(img1, 90, 20, {scale:2}); +} + +function countDown() { + counter--; + // Out of time + if (counter<=0) { + clearInterval(counterInterval); + counterInterval = undefined; + setWatch(startTimer, (process.env.HWVERSION==2) ? BTN1 : BTN2); + g.clear(img); + outOfTime(); + return; + + } + g.clear(1); + g.setFontAlign(0,0); // center font + g.setFont("Vector",80); // vector font, 80px + // draw the current counter value + g.drawImage(img, 90, 20, {scale:2}); + g.drawString(counter,120,120); + g.drawLine(50,50,180,50); + g.drawLine(50,51,180,51); + g.drawLine(50,52,180,52); + // optional - this keeps the watch LCD lit up + Bangle.setLCDPower(1); + if (counter<=5){ + immagine(); + } +} + + + +function startTimer() { + counter = 10; + countDown(); + if (!counterInterval) + counterInterval = setInterval(countDown, 1000); + + +} + + +startTimer(); diff --git a/apps/megadenti/brush-teeth.png b/apps/megadenti/brush-teeth.png new file mode 100644 index 000000000..4903c2d51 Binary files /dev/null and b/apps/megadenti/brush-teeth.png differ diff --git a/apps/megadenti/metadata.json b/apps/megadenti/metadata.json new file mode 100644 index 000000000..a44cf067c --- /dev/null +++ b/apps/megadenti/metadata.json @@ -0,0 +1,15 @@ +{ "id": "megadenti", + "name": "Denti", + "shortName":"My Denti", + "icon": "brush-teeth.png", + "version":"0.01", + "description": "This app allows you wash your teeth in an efficent way. A coloured timer guides you while your smile becomes bright!", + "tags": "game", + "supports": ["BANGLEJS"], + "allow_emulator": true, + "readme": "README.md", + "storage": [ + {"name":"megadenti.app.js","url":"app.js"}, + {"name":"megadenti.img","url":"app-icon.js","evaluate":true} + ] +} diff --git a/apps/sched/README.md b/apps/sched/README.md index 03d93c688..54c61679c 100644 --- a/apps/sched/README.md +++ b/apps/sched/README.md @@ -19,6 +19,7 @@ Alarms are stored in an array in `sched.json`, and take the form: ``` { id : "mytimer", // optional ID for this alarm/timer, so apps can easily find *their* timers + appid : "myappid", // optional app ID for alarms that you set/use for your app on : true, // is the alarm enabled? t : 23400000, // Time of day since midnight in ms (if a timer, this is set automatically when timer starts) dow : 0b1111111, // Binary encoding for days of the week to run alarm on @@ -32,7 +33,7 @@ Alarms are stored in an array in `sched.json`, and take the form: date : "2022-04-04", // OPTIONAL date for the alarm, in YYYY-MM-DD format // eg (new Date()).toISOString().substr(0,10) - msg : "Eat food", // message to display + msg : "Eat food", // message to display. last : 0, // last day of the month we alarmed on - so we don't alarm twice in one day! rp : true, // repeat the alarm every day? vibrate : "...", // OPTIONAL pattern of '.', '-' and ' ' to use for when buzzing out this alarm (defaults to '..' if not set) @@ -41,7 +42,7 @@ Alarms are stored in an array in `sched.json`, and take the form: timer : 5*60*1000, // OPTIONAL - if set, this is a timer and it's the time in ms js : "load('myapp.js')" // OPTIONAL - a JS command to execute when the alarm activates (*instead* of loading 'sched.js') // when this code is run, you're responsible for setting alarm.on=false (or removing the alarm) - data : { ... } // OPTIONAL - your app can store custom data in here if needed + data : { ... } // OPTIONAL - your app can store custom data in here if needed (don't store a lot of data here) } ``` @@ -73,10 +74,16 @@ require("sched").reload(); // loading the settings app. The alarm will not be removed/stopped // automatically. require("sched").setAlarm("customrunner", { + appid : "myapp", js : "load('setting.app.js')", timer : 1*60*1000, // 1 Minute }); + +// If you have been specifying `appid` you can also find any alarms that +// your app has created with the following: +require("sched").getAlarms().filter(a=>a.appid=="myapp"); ``` If your app requires alarms, you can specify that the alarms app needs to -be installed by adding `"dependencies": {"scheduler":"type"},` to your metadata. +be installed by adding `"dependencies": {"scheduler":"type"},` to your app's +metadata. diff --git a/apps/sched/sched.js b/apps/sched/sched.js index a19c85717..4fdc82736 100644 --- a/apps/sched/sched.js +++ b/apps/sched/sched.js @@ -18,15 +18,22 @@ function formatTime(t) { } function showAlarm(alarm) { - var msg = alarm.timer ? formatTime(alarm.timer) : formatTime(alarm.t); - var buzzCount = 10; - if (alarm.msg) + var msg = ""; + msg += alarm.timer ? formatTime(alarm.timer) : formatTime(alarm.t); + if (alarm.msg) { msg += "\n"+alarm.msg; + } else { + if (alarm.timer) + msg = atob("ACQswgD//33vRcGHIQAAABVVVAAAAAAAABVVVAAAAAAAABVVVAAAAAAAABVVVAAAAAAAABVVVAAAAAAAABVVVAAAAAAAAAP/wAAAAAAAAAP/wAAAAAAAAAqqoAPAAAAAAqqqqoP8AAAAKqqqqqv/AAACqqqqqqq/wAAKqqqlWqqvwAAqqqqlVaqrAACqqqqlVVqqAAKqqqqlVVaqgAKqaqqlVVWqgAqpWqqlVVVqoAqlWqqlVVVaoCqlV6qlVVVaqCqVVfqlVVVWqCqVVf6lVVVWqKpVVX/lVVVVqqpVVV/+VVVVqqpVVV//lVVVqqpVVVfr1VVVqqpVVVfr1VVVqqpVVVb/lVVVqqpVVVW+VVVVqqpVVVVVVVVVqiqVVVVVVVVWqCqVVVVVVVVWqCqlVVVVVVVaqAqlVVVVVVVaoAqpVVVVVVVqoAKqVVVVVVWqgAKqlVVVVVaqgACqpVVVVVqqAAAqqlVVVaqoAAAKqqVVWqqgAAACqqqqqqqAAAAAKqqqqqgAAAAAAqqqqoAAAAAAAAqqoAAAAA==")+" "+msg; + else + msg = atob("AC0swgF97///RcEpMlVVVVVVf9VVVVVVVVX/9VVf9VVf/1VVV///1Vf9VX///VVX///VWqqlV///1Vf//9aqqqqpf//9V///2qqqqqqn///V///6qqqqqqr///X//+qqoAAKqqv//3//6qoAAAAKqr//3//qqAAAAAAqq//3/+qoAADwAAKqv/3/+qgAADwAACqv/3/aqAAADwAAAqp/19qoAAADwAAAKqfV1qgAAADwAAACqXVWqgAAADwAAACqlVWqAAAADwAAAAqlVWqAAAADwAAAAqlVWqAAAADwAAAAqlVaoAAAADwAAAAKpVaoAAAADwAAAAKpVaoAAAADwAAAAKpVaoAAAAOsAAAAKpVaoAAAAOsAAAAKpVaoAAAAL/AAAAKpVaoAAAAgPwAAAKpVaoAAACAD8AAAKpVWqAAAIAA/AAAqlVWqAAAgAAPwAAqlVWqAACAAADwAAqlVWqgAIAAAAAACqlVVqgAgAAAAAACqVVVqoAAAAAAAAKqVVVaqAAAAAAAAqpVVVWqgAAAAAACqlVVVWqoAAAAAAKqlVVVVqqAAAAAAqqVVVVVaqoAAAAKqpVVVVVeqqoAAKqqtVVVVV/6qqqqqqr/VVVVX/2qqqqqqn/1VVVf/VaqqqqpV/9VVVf9VVWqqlVVf9VVVf1VVVVVVVVX9VQ==")+" "+msg; + } Bangle.loadWidgets(); Bangle.drawWidgets(); + var buzzCount = 10; E.showPrompt(msg,{ title:alarm.timer ? /*LANG*/"TIMER!" : /*LANG*/"ALARM!", - buttons : {/*LANG*/"Sleep":true,/*LANG*/"Ok":false} // default is sleep so it'll come back in 10 mins + buttons : {/*LANG*/"Snooze":true,/*LANG*/"Ok":false} // default is sleep so it'll come back in 10 mins }).then(function(sleep) { buzzCount = 0; if (sleep) {