forked from FOSS/BangleApps
Merge remote-tracking branch 'upstream/master' into jekyll-apps.json
commit
9a0b3f07e8
|
@ -2,3 +2,5 @@
|
|||
0.02: Add support for ZIPs
|
||||
Find and download ZIPs direct from the Espruino website
|
||||
Take 'beta' tag off
|
||||
0.03: Improve bootloader update safety. Now sets unsafeFlash:1 to allow flash with 2v11 and later
|
||||
Add CRC checks for common bootloaders that we know don't work
|
||||
|
|
|
@ -60,6 +60,7 @@ function onInit(device) {
|
|||
document.getElementById("fw-unknown").style = "display:none";
|
||||
document.getElementById("fw-ok").style = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkForFileOnServer() {
|
||||
|
@ -264,6 +265,8 @@ function createJS_app(binary, startAddress, endAddress) {
|
|||
bin32[3] = VERSION; // VERSION! Use this to test ourselves
|
||||
console.log("CRC 0x"+bin32[2].toString(16));
|
||||
hexJS = "";//`\x10if (E.CRC32(E.memoryArea(${startAddress},${endAddress-startAddress}))==${bin32[2]}) { print("FIRMWARE UP TO DATE!"); load();}\n`;
|
||||
hexJS += `\x10if (E.CRC32(E.memoryArea(0xF7000,0x7000))==1339551013) { print("BOOTLOADER 2v10.219 needs update"); load();}\n`;
|
||||
hexJS += `\x10if (E.CRC32(E.memoryArea(0xF7000,0x7000))==1207580954) { print("BOOTLOADER 2v10.236 needs update"); load();}\n`;
|
||||
hexJS += '\x10var s = require("Storage");\n';
|
||||
hexJS += '\x10s.erase(".firmware");\n';
|
||||
var CHUNKSIZE = 2048;
|
||||
|
@ -291,20 +294,14 @@ function createJS_bootloader(binary, startAddress, endAddress) {
|
|||
var chunk = btoa(new Uint8Array(binary.buffer, binary.byteOffset+i, l));
|
||||
hexJS += '\x10_fw.set(atob("'+chunk+'"), 0x'+(i).toString(16)+');\n';
|
||||
}
|
||||
// hexJS += `\x10(function() {
|
||||
// if (E.CRC32(_fw)!=${crc}) throw "Invalid CRC!";
|
||||
// var f = require("Flash");
|
||||
// for (var i=${startAddress};i<${endAddress};i+=4096) f.erasePage(i);
|
||||
// f.write(_fw,${startAddress});
|
||||
// E.reboot();
|
||||
// })();\n`;
|
||||
hexJS += `\x10if (E.CRC32(_fw)!=${crc}) throw "Invalid CRC: 0x"+E.CRC32(_fw).toString(16);\n`;
|
||||
hexJS += '\x10var f = require("Flash");\n';
|
||||
hexJS += `\x10(function() { if (E.CRC32(_fw)!=${crc}) throw "Invalid CRC: 0x"+E.CRC32(_fw).toString(16);\n`;
|
||||
hexJS += 'E.showMessage("Flashing Bootloader...")\n';
|
||||
hexJS += 'E.setFlags({unsafeFlash:1})\n';
|
||||
hexJS += 'var f = require("Flash");\n';
|
||||
for (var i=startAddress;i<endAddress;i+=4096)
|
||||
hexJS += '\x10f.erasePage(0x'+i.toString(16)+');\n';
|
||||
hexJS += `\x10f.write(_fw,${startAddress});\n`;
|
||||
// hexJS += '\x10setTimeout(()=>E.showMessage("Rebooting..."),50);\n';
|
||||
// hexJS += '\x10setTimeout(()=>E.reboot(), 2000);\n';
|
||||
hexJS += 'f.erasePage(0x'+i.toString(16)+');\n';
|
||||
hexJS += `f.write(_fw,${startAddress});\n`;
|
||||
hexJS += `})()\n`;
|
||||
}
|
||||
|
||||
function fileLoaded() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "fwupdate",
|
||||
"name": "Firmware Update",
|
||||
"version": "0.02",
|
||||
"version": "0.03",
|
||||
"description": "[BETA] Uploads new Espruino firmwares to Bangle.js 2. For now, please use the instructions under https://www.espruino.com/Bangle.js2#firmware-updates",
|
||||
"icon": "app.png",
|
||||
"type": "RAM",
|
||||
|
|
|
@ -4,3 +4,4 @@
|
|||
0.05: Refactor to use 'layout' library for multi-device support
|
||||
0.06: Add number of satellites in view and fix crash with GPS time
|
||||
0.07: Resolve one FIFO_FULL case and exit App with button press
|
||||
0.08: Leave GPS power switched on on exit (will switch off after 0.5 seconds anyway)
|
||||
|
|
|
@ -132,9 +132,6 @@ Bangle.on('GPS', onGPS);
|
|||
Bangle.on('GPS-raw', onGPSraw);
|
||||
|
||||
function exitApp() {
|
||||
Bangle.setGPSPower(0, "app");
|
||||
Bangle.removeListener('GPS-raw', onGPSraw);
|
||||
Bangle.removeListener('GPS', onGPS);
|
||||
load();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "gpsinfo",
|
||||
"name": "GPS Info",
|
||||
"version": "0.07",
|
||||
"version": "0.08",
|
||||
"description": "An application that displays information about altitude, lat/lon, satellites and time",
|
||||
"icon": "gps-info.png",
|
||||
"type": "app",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
1.00: Release for Bangle 2 (2021/11/18)
|
||||
1.01: Internal id update to wid_* as per Gordon's request (2021/11/21)
|
||||
1.02: Support dark themes
|
||||
1.03: Increase screen update rate when charging
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "A Battery Widget (with percentage)",
|
||||
"shortName":"A Battery Widget",
|
||||
"icon": "widget.png",
|
||||
"version":"1.02",
|
||||
"version":"1.03",
|
||||
"type": "widget",
|
||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
(function(){
|
||||
const intervalLow = 60000; // update time when not charging
|
||||
const intervalHigh = 2000; // update time when charging
|
||||
|
||||
let COLORS = {
|
||||
'white': g.theme.dark ? "#000" : "#fff",
|
||||
'black': g.theme.dark ? "#fff" : "#000",
|
||||
|
@ -36,10 +39,14 @@
|
|||
g.setFontAlign(0,0);
|
||||
g.setFont('6x8');
|
||||
g.drawString(l, x + 14, y + 10);
|
||||
|
||||
if (Bangle.isCharging()) changeInterval(id, intervalHigh);
|
||||
else changeInterval(id, intervalLow);
|
||||
}
|
||||
|
||||
|
||||
Bangle.on('charging',function(charging) { draw(); });
|
||||
setInterval(()=>WIDGETS["wid_a_battery_widget"].draw(), 60000);
|
||||
var id = setInterval(()=>WIDGETS["wid_a_battery_widget"].draw(), intervalLow);
|
||||
|
||||
WIDGETS["wid_a_battery_widget"]={area:"tr",width:30,draw:draw};
|
||||
})();
|
||||
|
|
|
@ -20,3 +20,4 @@
|
|||
Fix issue with widget overwrite in large font mode
|
||||
Memory usage enhancements
|
||||
0.20: Fix issue where step count would randomly reset
|
||||
0.21: Memory usage improvements, fix widget initial width (fix #1170)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "widpedom",
|
||||
"name": "Pedometer widget",
|
||||
"version": "0.20",
|
||||
"version": "0.21",
|
||||
"description": "Daily pedometer widget",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
(() => {
|
||||
const PEDOMFILE = "wpedom.json"
|
||||
// Last time Bangle.on('step' was called
|
||||
let lastUpdate = new Date();
|
||||
// Last step count when Bangle.on('step' was called
|
||||
|
@ -8,19 +7,14 @@
|
|||
let settings;
|
||||
|
||||
function loadSettings() {
|
||||
const d = require('Storage').readJSON(PEDOMFILE, 1) || {};
|
||||
settings = d.settings || {};
|
||||
}
|
||||
|
||||
function setting(key) {
|
||||
if (!settings) { loadSettings() }
|
||||
const DEFAULTS = {
|
||||
const d = require('Storage').readJSON("wpedom.json", 1) || {};
|
||||
settings = Object.assign({
|
||||
'goal': 10000,
|
||||
'progress': false,
|
||||
'large': false,
|
||||
'hide': false
|
||||
}
|
||||
return (key in settings) ? settings[key] : DEFAULTS[key];
|
||||
}, d.settings || {});
|
||||
return d;
|
||||
}
|
||||
|
||||
Bangle.on('step', stepCount => {
|
||||
|
@ -31,10 +25,10 @@
|
|||
if (lastUpdate.getDate() == date.getDate()){
|
||||
stp_today += steps;
|
||||
} else {
|
||||
// TODO: could save this to PEDOMFILE for lastUpdate's day?
|
||||
// TODO: could save this to "wpedom.json" for lastUpdate's day?
|
||||
stp_today = steps;
|
||||
}
|
||||
if (stp_today === setting('goal')
|
||||
if (stp_today === settings.goal
|
||||
&& !(require('Storage').readJSON('setting.json',1)||{}).quiet) {
|
||||
let b = 3, buzz = () => {
|
||||
if (b--) Bangle.buzz().then(() => setTimeout(buzz, 100))
|
||||
|
@ -51,29 +45,31 @@
|
|||
});
|
||||
// When unloading, save state
|
||||
E.on('kill', () => {
|
||||
if (!settings) { loadSettings() }
|
||||
let d = {
|
||||
require("Storage").writeJSON("wpedom.json",{
|
||||
lastUpdate : lastUpdate.valueOf(),
|
||||
stepsToday : stp_today,
|
||||
settings : settings,
|
||||
};
|
||||
require("Storage").write(PEDOMFILE,d);
|
||||
});
|
||||
});
|
||||
|
||||
// add your widget
|
||||
WIDGETS["wpedom"]={area:"tl",width:26,
|
||||
redraw:function() { // work out the width, and queue a full redraw if needed
|
||||
let stps = stp_today.toString();
|
||||
WIDGETS["wpedom"]={area:"tl",width:0,
|
||||
getWidth:function() {
|
||||
let newWidth = 24;
|
||||
if (setting('hide'))
|
||||
if (settings.hide)
|
||||
newWidth = 0;
|
||||
else {
|
||||
if (setting('large')) {
|
||||
if (settings.large) {
|
||||
newWidth = 12 * stps.length + 3;
|
||||
if (setting('progress'))
|
||||
if (settings.progress)
|
||||
newWidth += 24;
|
||||
}
|
||||
}
|
||||
return newWidth;
|
||||
},
|
||||
redraw:function() { // work out the width, and queue a full redraw if needed
|
||||
let stps = stp_today.toString();
|
||||
let newWidth = this.getWidth();
|
||||
if (newWidth!=this.width) {
|
||||
// width has changed, re-layout all widgets
|
||||
this.width = newWidth;
|
||||
|
@ -84,14 +80,14 @@
|
|||
}
|
||||
},
|
||||
draw:function() {
|
||||
if (setting('hide')) return;
|
||||
if (settings.hide) return;
|
||||
if (stp_today > 99999)
|
||||
stp_today = stp_today % 100000; // cap to five digits + comma = 6 characters
|
||||
let stps = stp_today.toString();
|
||||
g.reset().clearRect(this.x, this.y, this.x + this.width, this.y + 23); // erase background
|
||||
if (setting('progress')) {
|
||||
if (settings.progress) {
|
||||
const width = 23, half = 11;
|
||||
const goal = setting('goal'), left = Math.max(goal-stps,0);
|
||||
const goal = settings.goal, left = Math.max(goal-stps,0);
|
||||
// blue or dark green
|
||||
g.setColor(left ? "#08f" : "#080").fillCircle(this.x + half, this.y + half, half);
|
||||
if (left) {
|
||||
|
@ -113,10 +109,10 @@
|
|||
}
|
||||
g.reset();
|
||||
}
|
||||
if (setting('large')) {
|
||||
if (settings.large) {
|
||||
g.setFont("6x8",2);
|
||||
g.setFontAlign(-1, 0);
|
||||
g.drawString(stps, this.x + (setting('progress')?28:4), this.y + 12);
|
||||
g.drawString(stps, this.x + (settings.progress?28:4), this.y + 12);
|
||||
} else {
|
||||
let w = 24;
|
||||
if (stps.length > 3){
|
||||
|
@ -137,11 +133,12 @@
|
|||
getSteps:()=>stp_today
|
||||
};
|
||||
// Load data at startup
|
||||
let pedomData = require("Storage").readJSON(PEDOMFILE,1);
|
||||
let pedomData = loadSettings();
|
||||
if (pedomData) {
|
||||
if (pedomData.lastUpdate)
|
||||
lastUpdate = new Date(pedomData.lastUpdate);
|
||||
stp_today = pedomData.stepsToday|0;
|
||||
delete pedomData;
|
||||
}
|
||||
WIDGETS["wpedom"].width = WIDGETS["wpedom"].getWidth();
|
||||
})()
|
||||
|
|
Loading…
Reference in New Issue