diff --git a/CHANGELOG.md b/CHANGELOG.md index 6368c2c46..9480f2ace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,5 +6,6 @@ Changed for individual apps are listed in `apps/appname/ChangeLog` * `Remove All Apps` now doesn't perform a reset before erase - fixes inability to update firmware if settings are wrong * Added optional `README.md` file for apps * Remove 2v04 version warning, add links in About to official/developer versions -* Fix issue removing an app that was just installed (Fix #253) -* Add `Favourite` functionality +* Fix issue removing an app that was just installed (fix #253) +* Add `Favourite` functionality +* Version number now clickable even when you're at the latest version (fix #291) diff --git a/apps.json b/apps.json index 47618e1a8..95b299688 100644 --- a/apps.json +++ b/apps.json @@ -119,7 +119,7 @@ { "id": "setting", "name": "Settings", "icon": "settings.png", - "version":"0.13", + "version":"0.14", "description": "A menu for setting up Bangle.js", "tags": "tool,system", "storage": [ @@ -1164,7 +1164,7 @@ "name": "Battery Chart", "shortName":"Battery Chart", "icon": "app.png", - "version":"0.05", + "version":"0.07", "description": "A widget and an app for recording and visualizing battery percentage over time.", "tags": "app,widget,battery,time,record,chart,tool", "storage": [ @@ -1191,7 +1191,7 @@ "name": "Numerals Clock", "shortName": "Numerals Clock", "icon": "numerals.png", - "version":"0.01", + "version":"0.02", "description": "A simple big numerals clock", "tags": "numerals,clock", "type":"clock", @@ -1209,7 +1209,7 @@ "version":"0.02", "description": "Detect BLE devices and show some informations.", "tags": "app,bluetooth,tool", - "readme": "README.md", + "readme": "README.md", "storage": [ {"name":"bledetect.app.js","url":"bledetect.js"}, {"name":"bledetect.img","url":"bledetect-icon.js","evaluate":true} @@ -1222,7 +1222,7 @@ "version":"0.01", "description": "The classic snake game. Eat apples and don't bite your tail:", "tags": "game,fun", - "readme": "README.md", + "readme": "README.md", "storage": [ {"name":"snake.app.js","url":"snake.js"}, {"name":"snake.img","url":"snake-icon.js","evaluate":true} diff --git a/apps/batchart/ChangeLog b/apps/batchart/ChangeLog index f57805b6a..ba9e4e847 100644 --- a/apps/batchart/ChangeLog +++ b/apps/batchart/ChangeLog @@ -2,4 +2,6 @@ 0.02: Widget stores data to file (1 dataset/10min) 0.03: Rotate log files once a week. 0.04: chart in the app is now active. -0.05: Display temperature and LCD state in chart \ No newline at end of file +0.05: Display temperature and LCD state in chart +0.06: Fixes widget events and charting of component states +0.07: Improve logging and charting of component states and add widget icon \ No newline at end of file diff --git a/apps/batchart/app.js b/apps/batchart/app.js index 569fecfd1..deb406d8b 100644 --- a/apps/batchart/app.js +++ b/apps/batchart/app.js @@ -71,8 +71,11 @@ function loadData() { let topUpLogFileName = "bclog" + previousDay; let remainingLines = MaxValueCount - dataLines.length; let topUpLines = loadLinesFromFile(remainingLines, topUpLogFileName); - dataLines = topUpLines.concat(dataLines); - + + if(topUpLines) { + dataLines = topUpLines.concat(dataLines); + } + previousDay = decrementDay(previousDay); } @@ -142,7 +145,7 @@ function renderData(dataArray) { g.setPixel(GraphXZero + i, GraphYZero - scaledTemp); // LCD state - if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.lcd == switchableConsumers.lcd) { + if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.lcd) { g.setColor(1, 1, 1); g.setFontAlign(1, -1, 0); g.drawString("LCD", GraphXZero - GraphMarkerOffset, GraphLcdY - 2, true); @@ -150,7 +153,7 @@ function renderData(dataArray) { } // Compass state - if (switchables & switchableConsumers.lcd == switchableConsumers.lcd) { + if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.compass) { g.setColor(0, 1, 0); g.setFontAlign(-1, -1, 0); g.drawString("Compass", GraphXMax + GraphMarkerOffset, GraphCompassY - 2, true); @@ -166,7 +169,7 @@ function renderData(dataArray) { // } // Gps state - if (switchables & switchableConsumers.lcd == switchableConsumers.lcd) { + if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.gps) { g.setColor(0.8, 0.5, 0.24); g.setFontAlign(-1, -1, 0); g.drawString("GPS", GraphXMax + GraphMarkerOffset, GraphGpsY - 2, true); @@ -174,7 +177,7 @@ function renderData(dataArray) { } // Hrm state - if (switchables & switchableConsumers.lcd == switchableConsumers.lcd) { + if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.hrm) { g.setColor(1, 0, 0); g.setFontAlign(1, -1, 0); g.drawString("HRM", GraphXZero - GraphMarkerOffset, GraphHrmY - 2, true); @@ -185,6 +188,16 @@ function renderData(dataArray) { dataArray = null; } +function renderHomeIcon() { + //Home for Btn2 + g.setColor(1, 1, 1); + g.drawLine(220, 118, 227, 110); + g.drawLine(227, 110, 234, 118); + + g.drawPoly([222,117,222,125,232,125,232,117], false); + g.drawRect(226,120,229,125); +} + function renderBatteryChart() { renderCoordinateSystem(); let data = loadData(); @@ -192,21 +205,30 @@ function renderBatteryChart() { data = null; } +// Show launcher when middle button pressed +function switchOffApp(){ + Bangle.showLauncher(); +} + // 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(); - g.clear() + g.clear(); Bangle.loadWidgets(); Bangle.drawWidgets(); renderBatteryChart(); } }); +setWatch(switchOffApp, BTN2, {edge:"rising", debounce:50, repeat:true}); + g.clear(); Bangle.loadWidgets(); Bangle.drawWidgets(); // call your app function here +renderHomeIcon(); + renderBatteryChart(); diff --git a/apps/batchart/widget.js b/apps/batchart/widget.js index c45515fe5..53f8b3549 100644 --- a/apps/batchart/widget.js +++ b/apps/batchart/widget.js @@ -12,8 +12,8 @@ var batChartFile; // file for battery percentage recording const recordingInterval10Min = 60 * 10 * 1000; - const recordingInterval1Min = 60*1000; //For testing - const recordingInterval10S = 10*1000; //For testing + const recordingInterval1Min = 60*1000; //For testing + const recordingInterval10S = 10*1000; //For testing var recordingInterval = null; var compassEventReceived = false; @@ -22,31 +22,44 @@ // draw your widget function draw() { + let x = this.x; + let y = this.y; + + g.setColor(0, 1, 0); + g.fillPoly([x+5, y, x+5, y+4, x+1, y+4, x+1, y+20, x+18, y+20, x+18, y+4, x+13, y+4, x+13, y], true); + + g.setColor(0,0,0); + g.drawPoly([x+5, y+6, x+8, y+12, x+13, y+12, x+16, y+18], false); + g.reset(); - g.drawString("BC", this.x, this.y); + } + + function onMag(){ + compassEventReceived = true; + // Stop handling events when no longer necessarry + Bangle.removeListener("mag", onMag); + } + + function onGps() { + gpsEventReceived = true; + Bangle.removeListener("GPS", onGps); + } + + function onHrm() { + hrmEventReceived = true; + Bangle.removeListener("HRM", onHrm); } function getEnabledConsumersValue() { var enabledConsumers = switchableConsumers.none; - Bangle.on('mag', (() => { - console.log("mag received"); - compassEventReceived = true; - })); - - Bangle.on('GPS', (() => { - console.log("GPS received"); - gpsEventReceived = true; - })); - - Bangle.on('HRM', (() => { - console.log("HRM received"); - hrmEventReceived = true; - })); + Bangle.on('mag', onMag); + Bangle.on('GPS', onGps); + Bangle.on('HRM', onHrm); // Wait two seconds, that should be enough for each of the events to get raised once setTimeout(() => { - Bangle.removeAllListeners; + Bangle.removeAllListeners(); }, 2000); if (Bangle.isLCDOn()) @@ -60,42 +73,47 @@ enabledConsumers = enabledConsumers | switchableConsumers.hrm; //if (Bangle.isBluetoothOn()) // enabledConsumers = enabledConsumers | switchableConsumers.bluetooth; - + // Reset the event registration vars compassEventReceived = false; gpsEventReceived = false; hrmEventReceived = false; - console.log("Enabled: " + enabledConsumers); - - return enabledConsumers; + return enabledConsumers.toString(); } function logBatteryData() { const previousWriteLogName = "bcprvday"; - const previousWriteDay = Storage.read(previousWriteLogName); + const previousWriteDay = parseInt(Storage.open(previousWriteLogName, "r").readLine()); const currentWriteDay = new Date().getDay(); const logFileName = "bclog" + currentWriteDay; // Change log target on day change - if (previousWriteDay != currentWriteDay) { + if (!isNaN(previousWriteDay) + && previousWriteDay != currentWriteDay) { //Remove a log file containing data from a week ago - Storage.open(logFileName, "r")­.erase(); - Storage.write(previousWriteLogName, currentWriteDay); + Storage.open(logFileName, "r").erase(); + Storage.open(previousWriteLogName, "w").write(parseInt(currentWriteDay)); } var bcLogFileA = Storage.open(logFileName, "a"); if (bcLogFileA) { - console.log([getTime().toFixed(0), E.getBattery(), E.getTemperature(), getEnabledConsumersValue()].join(",")); - bcLogFileA.write([[getTime().toFixed(0), E.getBattery(), E.getTemperature(), getEnabledConsumersValue()].join(",")].join(",")+"\n"); + let logTime = getTime().toFixed(0); + let logPercent = E.getBattery(); + let logTemperature = E.getTemperature(); + let logConsumers = getEnabledConsumersValue(); + + let logString = [logTime, logPercent, logTemperature, logConsumers].join(","); + + bcLogFileA.write(logString + "\n"); } } function reload() { WIDGETS["batchart"].width = 24; - recordingInterval = setInterval(logBatteryData, recordingInterval10S); + recordingInterval = setInterval(logBatteryData, recordingInterval10Min); logBatteryData(); } @@ -105,6 +123,7 @@ reload(); Bangle.drawWidgets(); // relayout all widgets }}; + // load settings, set correct widget width reload(); })() \ No newline at end of file diff --git a/apps/numerals/ChangeLog b/apps/numerals/ChangeLog index 5560f00bc..a8396e26b 100644 --- a/apps/numerals/ChangeLog +++ b/apps/numerals/ChangeLog @@ -1 +1,2 @@ 0.01: New App! +0.02: Use BTN2 for settings menu like other clocks diff --git a/apps/numerals/numerals.app.js b/apps/numerals/numerals.app.js index 648a1005a..fbfe5b9ed 100644 --- a/apps/numerals/numerals.app.js +++ b/apps/numerals/numerals.app.js @@ -11,7 +11,7 @@ var numerals = { 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]], + 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]], @@ -47,7 +47,7 @@ if (!settings) { function drawNum(num,col,x,y,func){ g.setColor(col); let tx = x*100+35; - let ty = y*100+35; + let ty = y*100+35; for (let i=0;i0) g.setColor((func==fill)?"#000000":col); func(translate(tx, ty,numerals[num][i])); @@ -57,7 +57,7 @@ function drawNum(num,col,x,y,func){ function draw(drawMode){ let d = new Date(); let h1 = Math.floor(d.getHours()/10); - let h2 = d.getHours()%10; + let h2 = d.getHours()%10; let m1 = Math.floor(d.getMinutes()/10); let m2 = d.getMinutes()%10; g.clearRect(0,24,240,240); @@ -70,9 +70,9 @@ function draw(drawMode){ Bangle.setLCDMode(); clearWatch(); -setWatch(Bangle.showLauncher, BTN1, {repeat:false,edge:"falling"}); +setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); -g.clear(); +g.clear(); clearInterval(); if (settings.color>0) _rCol=settings.color-1; interval=setInterval(draw, REFRESH_RATE, settings.drawMode); @@ -80,7 +80,7 @@ draw(settings.drawMode); Bangle.on('lcdPower', function(on) { if (on) { - if (settings.color==0) _rCol = Math.floor(Math.random()*_hCol.length); + if (settings.color==0) _rCol = Math.floor(Math.random()*_hCol.length); draw(settings.drawMode); interval=setInterval(draw, REFRESH_RATE, settings.drawMode); }else @@ -90,4 +90,4 @@ Bangle.on('lcdPower', function(on) { }); Bangle.loadWidgets(); -Bangle.drawWidgets(); \ No newline at end of file +Bangle.drawWidgets(); diff --git a/apps/setting/ChangeLog b/apps/setting/ChangeLog index 5c5a26c61..6c4c19230 100644 --- a/apps/setting/ChangeLog +++ b/apps/setting/ChangeLog @@ -14,4 +14,5 @@ Move LCD Timeout to wakeup menu 0.13: Fix memory leak for App settings Make capitalization more consistent - Move LCD Brightness menu into more general LCD menu \ No newline at end of file + Move LCD Brightness menu into more general LCD menu +0.14: Reduce memory usage when running app settings page diff --git a/apps/setting/settings.js b/apps/setting/settings.js index 71a6a181e..d0d6578dc 100644 --- a/apps/setting/settings.js +++ b/apps/setting/settings.js @@ -325,8 +325,6 @@ function showClockMenu() { return E.showMenu(clockMenu); } - - function showSetTimeMenu() { d = new Date(); const timemenu = { @@ -419,8 +417,8 @@ function showAppSettingsMenu() { '< Back': ()=>showMainMenu(), } const apps = storage.list(/\.info$/) - .map(app => storage.readJSON(app, 1)) - .filter(app => app && app.settings) + .map(app => {var a=storage.readJSON(app, 1);return (a&&a.settings)?a:undefined}) + .filter(app => app) // filter out any undefined apps .sort((a, b) => a.sortorder - b.sortorder) if (apps.length === 0) { appmenu['No app has settings'] = () => { }; diff --git a/js/comms.js b/js/comms.js index 12989e089..604ef19ed 100644 --- a/js/comms.js +++ b/js/comms.js @@ -40,7 +40,7 @@ uploadApp : (app,skipReset) => { // expects an apps.json structure (i.e. with `s currentBytes += f.content.length; // Chould check CRC here if needed instead of returning 'OK'... // E.CRC32(require("Storage").read(${JSON.stringify(app.name)})) - Puck.write(`\x10${f.cmd};Bluetooth.println("OK")\n`,(result) => { + Puck.write(`${f.cmd};Bluetooth.println("OK")\n`,(result) => { if (!result || result.trim()!="OK") { Progress.hide({sticky:true}); return reject("Unexpected response "+(result||"")); diff --git a/js/utils.js b/js/utils.js index 4913c7129..d8c1b8063 100644 --- a/js/utils.js +++ b/js/utils.js @@ -56,7 +56,7 @@ function getVersionInfo(appListing, appInstalled) { if (appListing.version) versionText = clicky("v"+appListing.version); } else { - versionText = (appInstalled.version ? ("v"+appInstalled.version) : "Unknown version"); + versionText = (appInstalled.version ? (clicky("v"+appInstalled.version)) : "Unknown version"); if (appListing.version != appInstalled.version) { if (appListing.version) versionText += ", latest "+clicky("v"+appListing.version); canUpdate = true;