Skip to content

Commit

Permalink
Merge pull request #2921 from nxdefiant/astrocalc
Browse files Browse the repository at this point in the history
astrocalc: Enable widgets
  • Loading branch information
gfwilliams authored Jul 31, 2023
2 parents e8157f4 + 7b7df17 commit 56b7168
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps/astrocalc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
0.02: Store last GPS lock, can be used instead of waiting for new GPS on start
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.05: Enable widgets
21 changes: 7 additions & 14 deletions apps/astrocalc/astrocalc-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

const SunCalc = require("suncalc"); // from modules folder
const storage = require("Storage");
const BANGLEJS2 = process.env.HWVERSION == 2; // check for bangle 2

function drawMoon(phase, x, y) {
const moonImgFiles = [
Expand Down Expand Up @@ -110,7 +109,7 @@ function drawPoints() {
}

function drawData(title, obj, startX, startY) {
g.clear();
g.clearRect(Bangle.appRect);
drawTitle(title);

let xPos, yPos;
Expand Down Expand Up @@ -154,9 +153,7 @@ function drawMoonPositionPage(gps, title) {
drawPoints();
drawPoint(azimuthDegrees, 8, moonColor);

let m = setWatch(() => {
let m = moonIndexPageMenu(gps);
}, BANGLEJS2 ? BTN : BTN3, {repeat: false, edge: "falling"});
Bangle.setUI({mode: "custom", back: () => moonIndexPageMenu(gps)});
}

function drawMoonIlluminationPage(gps, title) {
Expand All @@ -174,9 +171,7 @@ function drawMoonIlluminationPage(gps, title) {
drawData(title, pageData, null, 35);
drawMoon(phaseIdx, g.getWidth() / 2, g.getHeight() / 2);

let m = setWatch(() => {
let m = moonIndexPageMenu(gps);
}, BANGLEJS2 ? BTN : BTN3, {repease: false, edge: "falling"});
Bangle.setUI({mode: "custom", back: () => moonIndexPageMenu(gps)});
}


Expand All @@ -202,9 +197,7 @@ function drawMoonTimesPage(gps, title) {
const setAzimuthDegrees = parseInt(setPos.azimuth * 180 / Math.PI);
drawPoint(setAzimuthDegrees, 8, moonColor);

let m = setWatch(() => {
let m = moonIndexPageMenu(gps);
}, BANGLEJS2 ? BTN : BTN3, {repease: false, edge: "falling"});
Bangle.setUI({mode: "custom", back: () => moonIndexPageMenu(gps)});
}

function drawSunShowPage(gps, key, date) {
Expand Down Expand Up @@ -233,9 +226,7 @@ function drawSunShowPage(gps, key, date) {
// Draw the suns position
drawPoint(azimuthDegrees, 8, {r: 1, g: 1, b: 0});

m = setWatch(() => {
m = sunIndexPageMenu(gps);
}, BANGLEJS2 ? BTN : BTN3, {repeat: false, edge: "falling"});
Bangle.setUI({mode: "custom", back: () => sunIndexPageMenu(gps)});

return null;
}
Expand Down Expand Up @@ -314,7 +305,9 @@ function getCenterStringX(str) {

function init() {
let location = require("Storage").readJSON("mylocation.json",1)||{"lat":51.5072,"lon":0.1276,"location":"London"};
Bangle.loadWidgets();
indexPageMenu(location);
Bangle.drawWidgets();
}

let m;
Expand Down
2 changes: 1 addition & 1 deletion apps/astrocalc/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "astrocalc",
"name": "Astrocalc",
"version": "0.04",
"version": "0.05",
"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",
"tags": "app,sun,moon,cycles,tool",
Expand Down

0 comments on commit 56b7168

Please sign in to comment.