Merge pull request #3118 from nxdefiant/master

openstmap & widmp fixes
pull/3125/head
Gordon Williams 2023-12-01 08:40:41 +00:00 committed by GitHub
commit 35105e3bd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 14 deletions

View File

@ -30,4 +30,5 @@
0.23: Bugfix: Enable Compass if needed
0.24: Allow zooming by clicking the screen
0.25: Enable scaled image filtering on 2v19+ firmware
0.26: Ensure that when redrawing, we always cancel any in-progress track draw
0.26: Ensure that when redrawing, we always cancel any in-progress track draw
0.27: Display message if no map is installed

View File

@ -268,7 +268,12 @@ function showMap() {
}, btn: () => showMenu() });
}
showMap();
if (m.maps.length === 0) {
E.showPrompt(/*LANG*/'Please upload a map first.', {buttons : {/*LANG*/"Ok":true}}).then(v => load());
} else {
showMap();
}
// Write settings on exit via button
setWatch(() => writeSettings(), BTN, { repeat: true, edge: "rising" });

View File

@ -2,7 +2,7 @@
"id": "openstmap",
"name": "OpenStreetMap",
"shortName": "OpenStMap",
"version": "0.26",
"version": "0.27",
"description": "Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are. Once installed this also adds map functionality to `GPS Recorder` and `Recorder` apps",
"readme": "README.md",
"icon": "app.png",

View File

@ -33,9 +33,11 @@ m.maps = require("Storage").list(/openstmap\.\d+\.json/).map(f=>{
m.maps.sort((a,b) => b.scale-a.scale); // sort by scale so highest resolution is drawn last
// we base our start position on the middle of the first map
m.map = m.maps[0];
m.scale = m.map.scale; // current scale (based on first map)
m.lat = m.map.lat; // position of middle of screen
m.lon = m.map.lon; // position of middle of screen
if (m.map) {
m.scale = m.map.scale; // current scale (based on first map)
m.lat = m.map.lat; // position of middle of screen
m.lon = m.map.lon; // position of middle of screen
}
// return number of tiles drawn
exports.draw = function() {

View File

@ -6,3 +6,4 @@
0.06: Darkmode, custom colours, and fix a bug with acting on mylocation changes
0.07: Use default Bangle formatter for booleans
0.08: Better formula for the moon's phase
0.09: Fix variable declaration

View File

@ -1,7 +1,7 @@
{
"id": "widmp",
"name": "Moon Phase",
"version": "0.08",
"version": "0.09",
"description": "Display the current moon phase in blueish (in light mode) or white (in dark mode) for both hemispheres. In the southern hemisphere the 'My Location' app is needed.",
"icon": "widget.png",
"type": "widget",

View File

@ -6,11 +6,11 @@
// https://github.com/deirdreobyrne/LunarPhase
function moonPhase(sec) {
d = (4.847408287988257 + sec/406074.7465115577) % (2.0*Math.PI);
m = (6.245333801867877 + sec/5022682.784840698) % (2.0*Math.PI);
l = (4.456038755040014 + sec/378902.2499653011) % (2.0*Math.PI);
t = d+1.089809730923715e-01 * Math.sin(l)-3.614132757006379e-02 * Math.sin(m)+2.228248661252023e-02 * Math.sin(d+d-l)+1.353592753655652e-02 * Math.sin(d+d)+4.238560208195022e-03 * Math.sin(l+l)+1.961408105275610e-03 * Math.sin(d);
k = (1.0 - Math.cos(t))/2.0;
let d = (4.847408287988257 + sec/406074.7465115577) % (2.0*Math.PI);
let m = (6.245333801867877 + sec/5022682.784840698) % (2.0*Math.PI);
let l = (4.456038755040014 + sec/378902.2499653011) % (2.0*Math.PI);
let t = d+1.089809730923715e-01 * Math.sin(l)-3.614132757006379e-02 * Math.sin(m)+2.228248661252023e-02 * Math.sin(d+d-l)+1.353592753655652e-02 * Math.sin(d+d)+4.238560208195022e-03 * Math.sin(l+l)+1.961408105275610e-03 * Math.sin(d);
let k = (1.0 - Math.cos(t))/2.0;
if ((t >= Math.PI) && (t < 2.0*Math.PI)) {
k = -k;
}
@ -19,7 +19,7 @@
function loadLocation() {
// "mylocation.json" is created by the "My Location" app
location = require("Storage").readJSON("mylocation.json",1)||{"lat":50.1236,"lon":8.6553,"location":"Frankfurt"};
let location = require("Storage").readJSON("mylocation.json",1)||{"lat":50.1236,"lon":8.6553,"location":"Frankfurt"};
southernHemisphere = (location.lat < 0);
}
@ -63,12 +63,13 @@
function draw() {
const CenterX = this.x + 12, CenterY = this.y + 12, Radius = 11;
let leftFactor, rightFactor;
loadLocation();
g.reset().setColor(g.theme.bg);
g.fillRect(CenterX - Radius, CenterY - Radius, CenterX + Radius, CenterY + Radius);
millis = (new Date()).getTime();
let millis = (new Date()).getTime();
if ((millis - lastCalculated) >= 7000000) { // if it's more than 7,000 sec since last calculation, re-calculate!
phase = moonPhase(millis/1000);
lastCalculated = millis;