1
0
Fork 0
msdeibel 2020-04-15 17:12:03 +02:00
commit 9ab5a36fa6
11 changed files with 102 additions and 58 deletions

View File

@ -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 * `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 * Added optional `README.md` file for apps
* Remove 2v04 version warning, add links in About to official/developer versions * Remove 2v04 version warning, add links in About to official/developer versions
* Fix issue removing an app that was just installed (Fix #253) * Fix issue removing an app that was just installed (fix #253)
* Add `Favourite` functionality * Add `Favourite` functionality
* Version number now clickable even when you're at the latest version (fix #291)

View File

@ -119,7 +119,7 @@
{ "id": "setting", { "id": "setting",
"name": "Settings", "name": "Settings",
"icon": "settings.png", "icon": "settings.png",
"version":"0.13", "version":"0.14",
"description": "A menu for setting up Bangle.js", "description": "A menu for setting up Bangle.js",
"tags": "tool,system", "tags": "tool,system",
"storage": [ "storage": [
@ -1164,7 +1164,7 @@
"name": "Battery Chart", "name": "Battery Chart",
"shortName":"Battery Chart", "shortName":"Battery Chart",
"icon": "app.png", "icon": "app.png",
"version":"0.05", "version":"0.07",
"description": "A widget and an app for recording and visualizing battery percentage over time.", "description": "A widget and an app for recording and visualizing battery percentage over time.",
"tags": "app,widget,battery,time,record,chart,tool", "tags": "app,widget,battery,time,record,chart,tool",
"storage": [ "storage": [
@ -1191,7 +1191,7 @@
"name": "Numerals Clock", "name": "Numerals Clock",
"shortName": "Numerals Clock", "shortName": "Numerals Clock",
"icon": "numerals.png", "icon": "numerals.png",
"version":"0.01", "version":"0.02",
"description": "A simple big numerals clock", "description": "A simple big numerals clock",
"tags": "numerals,clock", "tags": "numerals,clock",
"type":"clock", "type":"clock",

View File

@ -3,3 +3,5 @@
0.03: Rotate log files once a week. 0.03: Rotate log files once a week.
0.04: chart in the app is now active. 0.04: chart in the app is now active.
0.05: Display temperature and LCD state in chart 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

View File

@ -71,7 +71,10 @@ function loadData() {
let topUpLogFileName = "bclog" + previousDay; let topUpLogFileName = "bclog" + previousDay;
let remainingLines = MaxValueCount - dataLines.length; let remainingLines = MaxValueCount - dataLines.length;
let topUpLines = loadLinesFromFile(remainingLines, topUpLogFileName); let topUpLines = loadLinesFromFile(remainingLines, topUpLogFileName);
dataLines = topUpLines.concat(dataLines);
if(topUpLines) {
dataLines = topUpLines.concat(dataLines);
}
previousDay = decrementDay(previousDay); previousDay = decrementDay(previousDay);
} }
@ -142,7 +145,7 @@ function renderData(dataArray) {
g.setPixel(GraphXZero + i, GraphYZero - scaledTemp); g.setPixel(GraphXZero + i, GraphYZero - scaledTemp);
// LCD state // LCD state
if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.lcd == switchableConsumers.lcd) { if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.lcd) {
g.setColor(1, 1, 1); g.setColor(1, 1, 1);
g.setFontAlign(1, -1, 0); g.setFontAlign(1, -1, 0);
g.drawString("LCD", GraphXZero - GraphMarkerOffset, GraphLcdY - 2, true); g.drawString("LCD", GraphXZero - GraphMarkerOffset, GraphLcdY - 2, true);
@ -150,7 +153,7 @@ function renderData(dataArray) {
} }
// Compass state // Compass state
if (switchables & switchableConsumers.lcd == switchableConsumers.lcd) { if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.compass) {
g.setColor(0, 1, 0); g.setColor(0, 1, 0);
g.setFontAlign(-1, -1, 0); g.setFontAlign(-1, -1, 0);
g.drawString("Compass", GraphXMax + GraphMarkerOffset, GraphCompassY - 2, true); g.drawString("Compass", GraphXMax + GraphMarkerOffset, GraphCompassY - 2, true);
@ -166,7 +169,7 @@ function renderData(dataArray) {
// } // }
// Gps state // Gps state
if (switchables & switchableConsumers.lcd == switchableConsumers.lcd) { if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.gps) {
g.setColor(0.8, 0.5, 0.24); g.setColor(0.8, 0.5, 0.24);
g.setFontAlign(-1, -1, 0); g.setFontAlign(-1, -1, 0);
g.drawString("GPS", GraphXMax + GraphMarkerOffset, GraphGpsY - 2, true); g.drawString("GPS", GraphXMax + GraphMarkerOffset, GraphGpsY - 2, true);
@ -174,7 +177,7 @@ function renderData(dataArray) {
} }
// Hrm state // Hrm state
if (switchables & switchableConsumers.lcd == switchableConsumers.lcd) { if (parseInt(dataInfo[switchabelsIndex]) & switchableConsumers.hrm) {
g.setColor(1, 0, 0); g.setColor(1, 0, 0);
g.setFontAlign(1, -1, 0); g.setFontAlign(1, -1, 0);
g.drawString("HRM", GraphXZero - GraphMarkerOffset, GraphHrmY - 2, true); g.drawString("HRM", GraphXZero - GraphMarkerOffset, GraphHrmY - 2, true);
@ -185,6 +188,16 @@ function renderData(dataArray) {
dataArray = null; 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() { function renderBatteryChart() {
renderCoordinateSystem(); renderCoordinateSystem();
let data = loadData(); let data = loadData();
@ -192,21 +205,30 @@ function renderBatteryChart() {
data = null; data = null;
} }
// Show launcher when middle button pressed
function switchOffApp(){
Bangle.showLauncher();
}
// special function to handle display switch on // special function to handle display switch on
Bangle.on('lcdPower', (on) => { Bangle.on('lcdPower', (on) => {
if (on) { if (on) {
// call your app function here // call your app function here
// If you clear the screen, do Bangle.drawWidgets(); // If you clear the screen, do Bangle.drawWidgets();
g.clear() g.clear();
Bangle.loadWidgets(); Bangle.loadWidgets();
Bangle.drawWidgets(); Bangle.drawWidgets();
renderBatteryChart(); renderBatteryChart();
} }
}); });
setWatch(switchOffApp, BTN2, {edge:"rising", debounce:50, repeat:true});
g.clear(); g.clear();
Bangle.loadWidgets(); Bangle.loadWidgets();
Bangle.drawWidgets(); Bangle.drawWidgets();
// call your app function here // call your app function here
renderHomeIcon();
renderBatteryChart(); renderBatteryChart();

View File

@ -22,31 +22,44 @@
// draw your widget // draw your widget
function draw() { 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.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() { function getEnabledConsumersValue() {
var enabledConsumers = switchableConsumers.none; var enabledConsumers = switchableConsumers.none;
Bangle.on('mag', (() => { Bangle.on('mag', onMag);
console.log("mag received"); Bangle.on('GPS', onGps);
compassEventReceived = true; Bangle.on('HRM', onHrm);
}));
Bangle.on('GPS', (() => {
console.log("GPS received");
gpsEventReceived = true;
}));
Bangle.on('HRM', (() => {
console.log("HRM received");
hrmEventReceived = true;
}));
// Wait two seconds, that should be enough for each of the events to get raised once // Wait two seconds, that should be enough for each of the events to get raised once
setTimeout(() => { setTimeout(() => {
Bangle.removeAllListeners; Bangle.removeAllListeners();
}, 2000); }, 2000);
if (Bangle.isLCDOn()) if (Bangle.isLCDOn())
@ -66,36 +79,41 @@
gpsEventReceived = false; gpsEventReceived = false;
hrmEventReceived = false; hrmEventReceived = false;
console.log("Enabled: " + enabledConsumers); return enabledConsumers.toString();
return enabledConsumers;
} }
function logBatteryData() { function logBatteryData() {
const previousWriteLogName = "bcprvday"; const previousWriteLogName = "bcprvday";
const previousWriteDay = Storage.read(previousWriteLogName); const previousWriteDay = parseInt(Storage.open(previousWriteLogName, "r").readLine());
const currentWriteDay = new Date().getDay(); const currentWriteDay = new Date().getDay();
const logFileName = "bclog" + currentWriteDay; const logFileName = "bclog" + currentWriteDay;
// Change log target on day change // Change log target on day change
if (previousWriteDay != currentWriteDay) { if (!isNaN(previousWriteDay)
&& previousWriteDay != currentWriteDay) {
//Remove a log file containing data from a week ago //Remove a log file containing data from a week ago
Storage.open(logFileName, "r")­.erase(); Storage.open(logFileName, "r").erase();
Storage.write(previousWriteLogName, currentWriteDay); Storage.open(previousWriteLogName, "w").write(parseInt(currentWriteDay));
} }
var bcLogFileA = Storage.open(logFileName, "a"); var bcLogFileA = Storage.open(logFileName, "a");
if (bcLogFileA) { if (bcLogFileA) {
console.log([getTime().toFixed(0), E.getBattery(), E.getTemperature(), getEnabledConsumersValue()].join(",")); let logTime = getTime().toFixed(0);
bcLogFileA.write([[getTime().toFixed(0), E.getBattery(), E.getTemperature(), getEnabledConsumersValue()].join(",")].join(",")+"\n"); let logPercent = E.getBattery();
let logTemperature = E.getTemperature();
let logConsumers = getEnabledConsumersValue();
let logString = [logTime, logPercent, logTemperature, logConsumers].join(",");
bcLogFileA.write(logString + "\n");
} }
} }
function reload() { function reload() {
WIDGETS["batchart"].width = 24; WIDGETS["batchart"].width = 24;
recordingInterval = setInterval(logBatteryData, recordingInterval10S); recordingInterval = setInterval(logBatteryData, recordingInterval10Min);
logBatteryData(); logBatteryData();
} }
@ -105,6 +123,7 @@
reload(); reload();
Bangle.drawWidgets(); // relayout all widgets Bangle.drawWidgets(); // relayout all widgets
}}; }};
// load settings, set correct widget width // load settings, set correct widget width
reload(); reload();
})() })()

View File

@ -1 +1,2 @@
0.01: New App! 0.01: New App!
0.02: Use BTN2 for settings menu like other clocks

View File

@ -70,7 +70,7 @@ function draw(drawMode){
Bangle.setLCDMode(); Bangle.setLCDMode();
clearWatch(); clearWatch();
setWatch(Bangle.showLauncher, BTN1, {repeat:false,edge:"falling"}); setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
g.clear(); g.clear();
clearInterval(); clearInterval();

View File

@ -15,3 +15,4 @@
0.13: Fix memory leak for App settings 0.13: Fix memory leak for App settings
Make capitalization more consistent Make capitalization more consistent
Move LCD Brightness menu into more general LCD menu Move LCD Brightness menu into more general LCD menu
0.14: Reduce memory usage when running app settings page

View File

@ -325,8 +325,6 @@ function showClockMenu() {
return E.showMenu(clockMenu); return E.showMenu(clockMenu);
} }
function showSetTimeMenu() { function showSetTimeMenu() {
d = new Date(); d = new Date();
const timemenu = { const timemenu = {
@ -419,8 +417,8 @@ function showAppSettingsMenu() {
'< Back': ()=>showMainMenu(), '< Back': ()=>showMainMenu(),
} }
const apps = storage.list(/\.info$/) const apps = storage.list(/\.info$/)
.map(app => storage.readJSON(app, 1)) .map(app => {var a=storage.readJSON(app, 1);return (a&&a.settings)?a:undefined})
.filter(app => app && app.settings) .filter(app => app) // filter out any undefined apps
.sort((a, b) => a.sortorder - b.sortorder) .sort((a, b) => a.sortorder - b.sortorder)
if (apps.length === 0) { if (apps.length === 0) {
appmenu['No app has settings'] = () => { }; appmenu['No app has settings'] = () => { };

View File

@ -40,7 +40,7 @@ uploadApp : (app,skipReset) => { // expects an apps.json structure (i.e. with `s
currentBytes += f.content.length; currentBytes += f.content.length;
// Chould check CRC here if needed instead of returning 'OK'... // Chould check CRC here if needed instead of returning 'OK'...
// E.CRC32(require("Storage").read(${JSON.stringify(app.name)})) // 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") { if (!result || result.trim()!="OK") {
Progress.hide({sticky:true}); Progress.hide({sticky:true});
return reject("Unexpected response "+(result||"")); return reject("Unexpected response "+(result||""));

View File

@ -56,7 +56,7 @@ function getVersionInfo(appListing, appInstalled) {
if (appListing.version) if (appListing.version)
versionText = clicky("v"+appListing.version); versionText = clicky("v"+appListing.version);
} else { } 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 != appInstalled.version) {
if (appListing.version) versionText += ", latest "+clicky("v"+appListing.version); if (appListing.version) versionText += ", latest "+clicky("v"+appListing.version);
canUpdate = true; canUpdate = true;