mirror of https://github.com/espruino/BangleApps
astrocalc azimuth fixes
- Fixes #2651 azimuth value: 0° is south, so add 180° - Show all values in degreespull/2982/head
parent
918be9e7bb
commit
b45bcab181
|
@ -3,3 +3,4 @@
|
||||||
0.03: Use 'modules/suncalc.js' to avoid it being copied 8 times for different apps
|
0.03: Use 'modules/suncalc.js' to avoid it being copied 8 times for different apps
|
||||||
0.04: Compatibility with Bangle.js 2, get location from My Location
|
0.04: Compatibility with Bangle.js 2, get location from My Location
|
||||||
0.05: Enable widgets
|
0.05: Enable widgets
|
||||||
|
0.06: Fix azimuth (bug #2651), only show degrees
|
||||||
|
|
|
@ -140,14 +140,15 @@ function drawData(title, obj, startX, startY) {
|
||||||
function drawMoonPositionPage(gps, title) {
|
function drawMoonPositionPage(gps, title) {
|
||||||
const pos = SunCalc.getMoonPosition(new Date(), gps.lat, gps.lon);
|
const pos = SunCalc.getMoonPosition(new Date(), gps.lat, gps.lon);
|
||||||
const moonColor = g.theme.dark ? {r: 1, g: 1, b: 1} : {r: 0, g: 0, b: 0};
|
const moonColor = g.theme.dark ? {r: 1, g: 1, b: 1} : {r: 0, g: 0, b: 0};
|
||||||
|
const azimuth = pos.azimuth + Math.PI; // 0 is south, we want 0 to be north
|
||||||
|
|
||||||
const pageData = {
|
const pageData = {
|
||||||
Azimuth: pos.azimuth.toFixed(2),
|
Azimuth: parseInt(azimuth * 180 / Math.PI + 0.5) + '°',
|
||||||
Altitude: pos.altitude.toFixed(2),
|
Altitude: parseInt(pos.altitude * 180 / Math.PI + 0.5) + '°',
|
||||||
Distance: `${pos.distance.toFixed(0)} km`,
|
Distance: `${pos.distance.toFixed(0)} km`,
|
||||||
"Parallactic Ang": pos.parallacticAngle.toFixed(2),
|
"Parallactic Ang": parseInt(pos.parallacticAngle * 180 / Math.PI + 0.5) + '°',
|
||||||
};
|
};
|
||||||
const azimuthDegrees = parseInt(pos.azimuth * 180 / Math.PI);
|
const azimuthDegrees = parseInt(azimuth * 180 / Math.PI + 0.5);
|
||||||
|
|
||||||
drawData(title, pageData, null, g.getHeight()/2 - Object.keys(pageData).length/2*20);
|
drawData(title, pageData, null, g.getHeight()/2 - Object.keys(pageData).length/2*20);
|
||||||
drawPoints();
|
drawPoints();
|
||||||
|
@ -189,12 +190,14 @@ function drawMoonTimesPage(gps, title) {
|
||||||
|
|
||||||
// Draw the moon rise position
|
// Draw the moon rise position
|
||||||
const risePos = SunCalc.getMoonPosition(times.rise, gps.lat, gps.lon);
|
const risePos = SunCalc.getMoonPosition(times.rise, gps.lat, gps.lon);
|
||||||
const riseAzimuthDegrees = parseInt(risePos.azimuth * 180 / Math.PI);
|
const riseAzimuth = risePos.azimuth + Math.PI; // 0 is south, we want 0 to be north
|
||||||
|
const riseAzimuthDegrees = parseInt(riseAzimuth * 180 / Math.PI);
|
||||||
drawPoint(riseAzimuthDegrees, 8, moonColor);
|
drawPoint(riseAzimuthDegrees, 8, moonColor);
|
||||||
|
|
||||||
// Draw the moon set position
|
// Draw the moon set position
|
||||||
const setPos = SunCalc.getMoonPosition(times.set, gps.lat, gps.lon);
|
const setPos = SunCalc.getMoonPosition(times.set, gps.lat, gps.lon);
|
||||||
const setAzimuthDegrees = parseInt(setPos.azimuth * 180 / Math.PI);
|
const setAzimuth = setPos.azimuth + Math.PI; // 0 is south, we want 0 to be north
|
||||||
|
const setAzimuthDegrees = parseInt(setAzimuth * 180 / Math.PI);
|
||||||
drawPoint(setAzimuthDegrees, 8, moonColor);
|
drawPoint(setAzimuthDegrees, 8, moonColor);
|
||||||
|
|
||||||
Bangle.setUI({mode: "custom", back: () => moonIndexPageMenu(gps)});
|
Bangle.setUI({mode: "custom", back: () => moonIndexPageMenu(gps)});
|
||||||
|
@ -207,16 +210,15 @@ function drawSunShowPage(gps, key, date) {
|
||||||
const mins = ("0" + date.getMinutes()).substr(-2);
|
const mins = ("0" + date.getMinutes()).substr(-2);
|
||||||
const secs = ("0" + date.getMinutes()).substr(-2);
|
const secs = ("0" + date.getMinutes()).substr(-2);
|
||||||
const time = `${hrs}:${mins}:${secs}`;
|
const time = `${hrs}:${mins}:${secs}`;
|
||||||
|
const azimuth = pos.azimuth + Math.PI; // 0 is south, we want 0 to be north
|
||||||
|
|
||||||
const azimuth = Number(pos.azimuth.toFixed(2));
|
const azimuthDegrees = parseInt(azimuth * 180 / Math.PI + 0.5) + '°';
|
||||||
const azimuthDegrees = parseInt(pos.azimuth * 180 / Math.PI);
|
const altitude = parseInt(pos.altitude * 180 / Math.PI + 0.5) + '°';
|
||||||
const altitude = Number(pos.altitude.toFixed(2));
|
|
||||||
|
|
||||||
const pageData = {
|
const pageData = {
|
||||||
Time: time,
|
Time: time,
|
||||||
Altitude: altitude,
|
Altitude: altitude,
|
||||||
Azimumth: azimuth,
|
Azimuth: azimuthDegrees,
|
||||||
Degrees: azimuthDegrees
|
|
||||||
};
|
};
|
||||||
|
|
||||||
drawData(key, pageData, null, g.getHeight()/2 - Object.keys(pageData).length/2*20 + 5);
|
drawData(key, pageData, null, g.getHeight()/2 - Object.keys(pageData).length/2*20 + 5);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"id": "astrocalc",
|
"id": "astrocalc",
|
||||||
"name": "Astrocalc",
|
"name": "Astrocalc",
|
||||||
"version": "0.05",
|
"version": "0.06",
|
||||||
"description": "Calculates interesting information on the sun like sunset and sunrise and moon cycles for the current day based on your location from MyLocation app",
|
"description": "Calculates interesting information on the sun like sunset and sunrise and moon cycles for the current day based on your location from MyLocation app",
|
||||||
"icon": "astrocalc.png",
|
"icon": "astrocalc.png",
|
||||||
"tags": "app,sun,moon,cycles,tool",
|
"tags": "app,sun,moon,cycles,tool,outdoors",
|
||||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||||
"allow_emulator": true,
|
"allow_emulator": true,
|
||||||
"dependencies": {"mylocation":"app"},
|
"dependencies": {"mylocation":"app"},
|
||||||
|
|
Loading…
Reference in New Issue