Bangle.js2 tweaks

pull/847/head
Gordon Williams 2021-10-11 14:29:58 +01:00
parent e8d8de648b
commit 54d98db6c8
7 changed files with 29 additions and 22 deletions

View File

@ -511,7 +511,7 @@
{ "id": "gpsrec", { "id": "gpsrec",
"name": "GPS Recorder", "name": "GPS Recorder",
"icon": "app.png", "icon": "app.png",
"version":"0.23", "version":"0.24",
"interface": "interface.html", "interface": "interface.html",
"description": "Application that allows you to record a GPS track. Can run in background", "description": "Application that allows you to record a GPS track. Can run in background",
"tags": "tool,outdoors,gps,widget", "tags": "tool,outdoors,gps,widget",
@ -687,7 +687,7 @@
{ "id": "widbt", { "id": "widbt",
"name": "Bluetooth Widget", "name": "Bluetooth Widget",
"icon": "widget.png", "icon": "widget.png",
"version":"0.05", "version":"0.06",
"description": "Show the current Bluetooth connection status in the top right of the clock", "description": "Show the current Bluetooth connection status in the top right of the clock",
"tags": "widget,bluetooth,b2", "tags": "widget,bluetooth,b2",
"type":"widget", "type":"widget",
@ -1316,7 +1316,7 @@
{ "id": "widid", { "id": "widid",
"name": "Bluetooth ID Widget", "name": "Bluetooth ID Widget",
"icon": "widget.png", "icon": "widget.png",
"version":"0.02", "version":"0.03",
"description": "Display the last two tuple of your Bangle.js MAC address in the widget section. This is useful for figuring out which Bangle.js to connect to if you have more than one Bangle.js!", "description": "Display the last two tuple of your Bangle.js MAC address in the widget section. This is useful for figuring out which Bangle.js to connect to if you have more than one Bangle.js!",
"tags": "widget,address,mac", "tags": "widget,address,mac",
"type":"widget", "type":"widget",

View File

@ -25,3 +25,4 @@
0.21: Fix issue where a period of 1s recorded every 2s, 5s every 6s, and so on 0.21: Fix issue where a period of 1s recorded every 2s, 5s every 6s, and so on
0.22: Ensure Bangle.setGPSPower uses 'gpsrec' as a tag 0.22: Ensure Bangle.setGPSPower uses 'gpsrec' as a tag
0.23: Fix issue where tracks wouldn't record when running from OpenStMap if a period hadn't been set up first 0.23: Fix issue where tracks wouldn't record when running from OpenStMap if a period hadn't been set up first
0.24: Better support for Bangle.js 2, avoid widget area for Graphs, smooth graphs more

View File

@ -102,7 +102,8 @@ function getTrackInfo(fn) {
var lfactor = Math.cos(minLat*Math.PI/180); var lfactor = Math.cos(minLat*Math.PI/180);
var ylen = (maxLat-minLat); var ylen = (maxLat-minLat);
var xlen = (maxLong-minLong)* lfactor; var xlen = (maxLong-minLong)* lfactor;
var scale = xlen>ylen ? 200/xlen : 200/ylen; var screenSize = g.getHeight()-48; // 24 for widgets, plus a border
var scale = xlen>ylen ? screenSize/xlen : screenSize/ylen;
return { return {
fn : fn, fn : fn,
filename : filename, filename : filename,
@ -110,6 +111,7 @@ function getTrackInfo(fn) {
records : nl, records : nl,
minLat : minLat, maxLat : maxLat, minLat : minLat, maxLat : maxLat,
minLong : minLong, maxLong : maxLong, minLong : minLong, maxLong : maxLong,
lat : (minLat+maxLat)/2, lon : (minLong+maxLong)/2,
lfactor : lfactor, lfactor : lfactor,
scale : scale, scale : scale,
duration : Math.round(duration/1000) duration : Math.round(duration/1000)
@ -180,16 +182,18 @@ function plotTrack(info) {
getMapXY = osm.latLonToXY.bind(osm); getMapXY = osm.latLonToXY.bind(osm);
} else { } else {
getMapXY = function(lat, lon) { "ram" getMapXY = function(lat, lon) { "ram"
var ix = 30 + Math.round((long - info.minLong)*info.lfactor*info.scale); return {x:cx + Math.round((long - info.lon)*info.lfactor*info.scale),
var iy = 210 - Math.round((lat - info.minLat)*info.scale); y:cy + Math.round((info.lat - lat)*info.scale)};
return {x:ix, y:iy};
} }
} }
E.showMenu(); // remove menu E.showMenu(); // remove menu
E.showMessage("Drawing...","GPS Track "+info.fn);
g.flip(); // on buffered screens, draw a not saying we're busy
g.clear(1);
var s = require("Storage"); var s = require("Storage");
var cx = g.getWidth()/2; var cx = g.getWidth()/2;
var cy = g.getHeight()/2; var cy = 24 + (g.getHeight()-24)/2;
g.setColor(1,0.5,0.5); g.setColor(1,0.5,0.5);
g.setFont("Vector",16); g.setFont("Vector",16);
g.drawString("Track"+info.fn.toString()+" - Loading",10,220); g.drawString("Track"+info.fn.toString()+" - Loading",10,220);
@ -203,8 +207,8 @@ function plotTrack(info) {
g.drawString("N",2,40); g.drawString("N",2,40);
g.setColor(1,1,1); g.setColor(1,1,1);
} else { } else {
osm.lat = (info.minLat+info.maxLat)/2; osm.lat = info.lat;
osm.lon = (info.minLong+info.maxLong)/2; osm.lon = info.lon;
osm.draw(); osm.draw();
g.setColor(0, 0, 0); g.setColor(0, 0, 0);
} }
@ -251,7 +255,8 @@ function plotTrack(info) {
g.drawString("Back",230,200); g.drawString("Back",230,200);
setWatch(function() { setWatch(function() {
viewTrack(info.fn, info); viewTrack(info.fn, info);
}, BTN3); }, global.BTN3||BTN1);
Bangle.drawWidgets();
g.flip(); g.flip();
} }
@ -260,8 +265,8 @@ function plotGraph(info, style) {
E.showMenu(); // remove menu E.showMenu(); // remove menu
E.showMessage("Calculating...","GPS Track "+info.fn); E.showMessage("Calculating...","GPS Track "+info.fn);
var filename = getFN(info.fn); var filename = getFN(info.fn);
var infn = new Float32Array(200); var infn = new Float32Array(80);
var infc = new Uint16Array(200); var infc = new Uint16Array(80);
var title; var title;
var lt = 0; // last time var lt = 0; // last time
var tn = 0; // count for each time period var tn = 0; // count for each time period
@ -278,7 +283,7 @@ function plotGraph(info, style) {
title = "Altitude (m)"; title = "Altitude (m)";
while(l!==undefined) { while(l!==undefined) {
++nl;c=l.split(","); ++nl;c=l.split(",");
i = Math.round(200*(c[0]/1000 - strt)/dur); i = Math.round(80*(c[0]/1000 - strt)/dur);
infn[i]+=+c[3]; infn[i]+=+c[3];
infc[i]++; infc[i]++;
l = f.readLine(f); l = f.readLine(f);
@ -289,7 +294,7 @@ function plotGraph(info, style) {
var t,dx,dy,d,lt = c[0]/1000; var t,dx,dy,d,lt = c[0]/1000;
while(l!==undefined) { while(l!==undefined) {
++nl;c=l.split(","); ++nl;c=l.split(",");
i = Math.round(200*(c[0]/1000 - strt)/dur); i = Math.round(80*(c[0]/1000 - strt)/dur);
t = c[0]/1000; t = c[0]/1000;
p = Bangle.project({lat:c[1],lon:c[2]}); p = Bangle.project({lat:c[1],lon:c[2]});
dx = p.x-lp.x; dx = p.x-lp.x;
@ -320,9 +325,9 @@ function plotGraph(info, style) {
// draw // draw
g.clear(1).setFont("6x8",1); g.clear(1).setFont("6x8",1);
var r = require("graph").drawLine(g, infn, { var r = require("graph").drawLine(g, infn, {
x:4,y:0, x:4,y:24,
width: g.getWidth()-24, width: g.getWidth()-24,
height: g.getHeight()-8, height: g.getHeight()-(24+8),
axes : true, axes : true,
gridy : grid, gridy : grid,
gridx : 50, gridx : 50,
@ -334,7 +339,7 @@ function plotGraph(info, style) {
g.drawString("Back",230,200); g.drawString("Back",230,200);
setWatch(function() { setWatch(function() {
viewTrack(info.fn, info); viewTrack(info.fn, info);
}, BTN3); }, global.BTN3||BTN1);
g.flip(); g.flip();
} }

View File

@ -2,3 +2,4 @@
0.03: Ensure redrawing works with variable size widget system 0.03: Ensure redrawing works with variable size widget system
0.04: Fix automatic update of Bluetooth connection status 0.04: Fix automatic update of Bluetooth connection status
0.05: Make Bluetooth widget thinner, and when on a bright theme use light grey for disabled color 0.05: Make Bluetooth widget thinner, and when on a bright theme use light grey for disabled color
0.06: Tweaking colors for dark/light themes and low bpp screens

View File

@ -2,9 +2,9 @@
function draw() { function draw() {
g.reset(); g.reset();
if (NRF.getSecurityStatus().connected) if (NRF.getSecurityStatus().connected)
g.setColor("#07f"); g.setColor((g.getBPP()>8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f"));
else else
g.setColor(g.theme.bg ? "#AAA" : "#555"); g.setColor(g.theme.dark ? "#666" : "#999");
g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="),2+this.x,2+this.y); g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="),2+this.x,2+this.y);
} }
function changed() { function changed() {

View File

@ -1,2 +1,3 @@
0.01: New Widget! 0.01: New Widget!
0.02: Tweaks for variable size widget system 0.02: Tweaks for variable size widget system
0.03: Tweaking colors for dark/light themes

View File

@ -1,8 +1,7 @@
/* jshint esversion: 6 */
(() => { (() => {
function draw() { function draw() {
var id = NRF.getAddress().substr().substr(12).split(":"); var id = NRF.getAddress().substr().substr(12).split(":");
g.reset().setColor(0, 0.49, 1).setFont("6x8", 1); g.reset().setColor(g.theme.dark ? "#0ff" : "#00f").setFont("6x8", 1);
g.drawString(id[0], this.x+2, this.y+4, true); g.drawString(id[0], this.x+2, this.y+4, true);
g.drawString(id[1], this.x+2, this.y+14, true); g.drawString(id[1], this.x+2, this.y+14, true);
} }