diff --git a/apps/numerals/ChangeLog b/apps/numerals/ChangeLog index a8396e26b..ec465a83f 100644 --- a/apps/numerals/ChangeLog +++ b/apps/numerals/ChangeLog @@ -1,2 +1,3 @@ 0.01: New App! 0.02: Use BTN2 for settings menu like other clocks +0.03: maximize numerals, make menu button configurable, change icon to mac palette, add default settings file, respect 12hour setting \ No newline at end of file diff --git a/apps/numerals/numerals-default.json b/apps/numerals/numerals-default.json new file mode 100644 index 000000000..aa6a25047 --- /dev/null +++ b/apps/numerals/numerals-default.json @@ -0,0 +1,5 @@ +{ + color:0, + drawMode:"fill", + menuButton:22 +} \ No newline at end of file diff --git a/apps/numerals/numerals-icon.js b/apps/numerals/numerals-icon.js index 7e471fb0d..7ef609874 100644 --- a/apps/numerals/numerals-icon.js +++ b/apps/numerals/numerals-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("mEwwhC/ABMBzIADyAJIAAkQBoMZBIoXCBIwADyIkIGAIuKGAQkIBJIwEEKQANC/4XWR58RiIHFWpAXFe4QRFcpAXFewQRFcxAXEFwQwGA4QXKiAXDGAgX/C/4X/C/4X/C7uQCwcBBwYXNBwYuEC54wCFwgXPzMRiIHFC54AHC/4XiCAoXRhIHDyK3GAAwOBJA0QG45VGC4YwCD4YwKFwgABcgIfEAwIAHBwgA/AAgA==")) \ No newline at end of file +require("heatshrink").decompress(atob("mEwwhC/ABXdAAfQBJAAEBgUNBJ4mGBKAmFEhAuLEwQhSABoX/C6yPPYw61IB4r3DHxoIFCwQIHC5YuDCIo3HC4oWEBI4X/C/4X/C/4X/C7XQC4gOEC5gwEBA4XLGAYOFC5oPCA44XNAA4X/C8SAGC6q4CCxb4EG5guICAgfIFxQA/ADg")) \ No newline at end of file diff --git a/apps/numerals/numerals.app.js b/apps/numerals/numerals.app.js index fbfe5b9ed..b24e8bc5e 100644 --- a/apps/numerals/numerals.app.js +++ b/apps/numerals/numerals.app.js @@ -7,57 +7,59 @@ */ var numerals = { - 0:[[9,1,82,1,90,9,90,82,82,90,9,90,1,82,1,9,9,1],[30,21,61,21,69,29,69,61,61,69,30,69,22,61,22,29,30,21]], - 1:[[59,1,82,1,90,9,90,82,82,90,73,90,65,82,65,27,59,27,51,19,51,9,59,1]], - 2:[[9,1,82,1,90,9,90,47,82,55,21,55,21,64,82,64,90,72,90,82,82,90,9,90,1,82,1,43,9,35,70,35,70,25,9,25,1,17,1,9,9,1]], - 3:[[9,1,82,1,90,9,90,82,82,90,9,90,1,82,1,74,9,66,70,66,70,57,9,57,1,49,1,41,9,33,70,33,70,25,9,25,1,17,1,9,9,1]], - 4:[[9,1,14,1,22,9,22,34,69,34,69,9,77,1,82,1,90,9,90,82,82,90,78,90,70,82,70,55,9,55,1,47,1,9,9,1]], - 5:[[9,1,82,1,90,9,90,17,82,25,21,25,21,35,82,35,90,43,90,82,82,90,9,90,1,82,1,72,9,64,71,64,71,55,9,55,1,47,1,9,9,1]], - 6:[[9,1,82,1,90,9,90,14,82,22,22,22,22,36,82,36,90,44,90,82,82,90,9,90,1,82,1,9,9,1],[22,55,69,55,69,69,22,69,22,55]], - 7:[[9,1,82,1,90,9,90,15,15,90,9,90,1,82,1,76,54,23,9,23,1,15,1,9,9,1]], - 8:[[9,1,82,1,90,9,90,82,82,90,9,90,1,82,1,9,9,1],[22,22,69,22,69,36,22,36,22,22],[22,55,69,55,69,69,22,69,22,55]], - 9:[[9,1,82,1,90,9,90,82,82,90,9,90,1,82,1,77,9,69,69,69,69,55,9,55,1,47,1,9,9,1],[22,22,69,22,69,36,22,36,22,22]], + 0:[[9,1,82,1,90,9,90,92,82,100,9,100,1,92,1,9],[30,25,61,25,69,33,69,67,61,75,30,75,22,67,22,33]], + 1:[[59,1,82,1,90,9,90,92,82,100,73,100,65,92,65,27,59,27,51,19,51,9]], + 2:[[9,1,82,1,90,9,90,53,82,61,21,61,21,74,82,74,90,82,90,92,82,100,9,100,1,92,1,48,9,40,70,40,70,27,9,27,1,19,1,9]], + 3:[[9,1,82,1,90,9,90,92,82,100,9,100,1,92,1,82,9,74,70,74,70,61,9,61,1,53,1,48,9,40,70,40,70,27,9,27,1,19,1,9]], + 4:[[9,1,14,1,22,9,22,36,69,36,69,9,77,1,82,1,90,9,90,92,82,100,78,100,70,92,70,61,9,61,1,53,1,9]], + 5:[[9,1,82,1,90,9,90,19,82,27,21,27,21,40,82,40,90,48,90,92,82,100,9,100,1,92,1,82,9,74,71,74,71,61,9,61,1,53,1,9]], + 6:[[9,1,82,1,90,9,90,19,82,27,22,27,22,40,82,40,90,48,90,92,82,100,9,100,1,92,1,9],[22,60,69,60,69,74,22,74]], + 7:[[9,1,82,1,90,9,90,15,20,98,9,98,1,90,1,86,56,22,9,22,1,14,1,9]], + 8:[[9,1,82,1,90,9,90,92,82,100,9,100,1,92,1,9],[22,27,69,27,69,43,22,43],[22,58,69,58,69,74,22,74]], + 9:[[9,1,82,1,90,9,90,92,82,100,9,100,1,92,1,82,9,74,69,74,69,61,9,61,1,53,1,9],[22,27,69,27,69,41,22,41]], }; +var _12hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"]||false; var _hCol = ["#ff5555","#ffff00","#FF9901","#2F00FF"]; var _mCol = ["#55ff55","#ffffff","#00EFEF","#FFBF00"]; var _rCol = 0; var interval = 0; const REFRESH_RATE = 10E3; -function translate(tx, ty, p) { +function translate(tx, ty, p){ return p.map((x, i)=> x+((i%2)?ty:tx)); } function fill(poly){ - return g.fillPoly(poly); + return g.fillPoly(poly,true); } function frame(poly){ - return g.drawPoly(poly); + return g.drawPoly(poly,true); } let settings = require('Storage').readJSON('numerals.json',1); if (!settings) { settings = { - color: 0, - drawMode: "fill" + color:0, + drawMode:"fill", + menuButton:24 }; } function drawNum(num,col,x,y,func){ g.setColor(col); - let tx = x*100+35; - let ty = y*100+35; + let tx = x*100+25; + let ty = y*104+32; for (let i=0;i0) g.setColor((func==fill)?"#000000":col); - func(translate(tx, ty,numerals[num][i])); + func(translate(tx,ty,numerals[num][i])); } } function draw(drawMode){ let d = new Date(); - let h1 = Math.floor(d.getHours()/10); - let h2 = d.getHours()%10; + let h1 = Math.floor((_12hour?d.getHours()%12:d.getHours())/10); + let h2 = (_12hour?d.getHours()%12:d.getHours())%10; let m1 = Math.floor(d.getMinutes()/10); let m2 = d.getMinutes()%10; g.clearRect(0,24,240,240); @@ -70,7 +72,7 @@ function draw(drawMode){ Bangle.setLCDMode(); clearWatch(); -setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); +setWatch(Bangle.showLauncher, settings.menuButton, {repeat:false,edge:"falling"}); g.clear(); clearInterval(); @@ -78,8 +80,8 @@ if (settings.color>0) _rCol=settings.color-1; interval=setInterval(draw, REFRESH_RATE, settings.drawMode); draw(settings.drawMode); -Bangle.on('lcdPower', function(on) { - if (on) { +Bangle.on('lcdPower', function(on){ + if (on){ if (settings.color==0) _rCol = Math.floor(Math.random()*_hCol.length); draw(settings.drawMode); interval=setInterval(draw, REFRESH_RATE, settings.drawMode); @@ -90,4 +92,4 @@ Bangle.on('lcdPower', function(on) { }); Bangle.loadWidgets(); -Bangle.drawWidgets(); +Bangle.drawWidgets(); \ No newline at end of file diff --git a/apps/numerals/numerals.settings.js b/apps/numerals/numerals.settings.js index f9c417da6..2d388525c 100644 --- a/apps/numerals/numerals.settings.js +++ b/apps/numerals/numerals.settings.js @@ -4,15 +4,17 @@ }; function resetSettings() { numeralsSettings = { - color: 0, - drawMode: "fill" + color:0, + drawMode:"fill", + menuButton:22 }; updateSettings(); } let numeralsSettings = storage.readJSON('numerals.json',1); if (!numeralsSettings) resetSettings(); let dm = ["fill","frame"]; - let col = ["rnd","r/g","y/w","o/c","b/y"] + let col = ["rnd","r/g","y/w","o/c","b/y"]; + let btn = [[24,"BTN1"],[22,"BTN2"],[23,"BTN3"],[11,"BTN4"],[16,"BTN5"]]; var menu={ "" : { "title":"Numerals"}, "Colors": { @@ -27,6 +29,12 @@ format: v=>dm[v], onchange: v=> { numeralsSettings.drawMode=dm[v]; updateSettings();} }, + "Menu button": { + value: 1|btn[numeralsSettings.menuButton], + min:0,max:4, + format: v=>btn[v][1], + onchange: v=> { numeralsSettings.menuButton=btn[v][0]; updateSettings();} + }, "< back": back }; E.showMenu(menu);