Hi
I'm trying to use this excellent class for calculating sunrise / sunset, and it looks fairly easy thanks to this class.
But I have a small problem.
When I add the code below, I get an errormessage: Permission required.
var info = Position.getInfo();
But when I try to add permission for positioning in the manifest file, this item is greyed out and can't be selected.
App minimum SDK version is set to 1.3.X and build target is set to fenix 3 HR
What am I doing wrong here?
Thanks a lot in advance
Kenth
How to use
var loc = Toybox.Activity.getActivityInfo().currentLocation;
in Watch face !
doesn't work !
loc = null !
That means you have to first get a GPS fix.
Do that by going into activity mode and wait for GPS signal, then return to watch face.
That is why code checks for loc != null
EDIT:
------
Oh, and btw, it will always be null in simulator. Only works on real device assuming GPS fix was obtained.
What's GPS fix ? i must get a API before !
i try also to put the apps on my real Watch EPIX and no return value !
thanks for your help !
You have to manually on the watch acquire a GPS signal in an activity. Once the GPS signal has been acquired / fixed / locked, you can return to the watch face.
The currentLocation is then available in the watch face for a short while.
Best to save the location to the object store.
using SunPhases as Sun;
function onUpdate(dc) {
View.onUpdate(dc);
var width = dc.getWidth();
var height = dc.getHeight();
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
dc.clear();
var sundata = Sun.vypocet();
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
dc.drawText(width/2, height/2 - 10, Gfx.FONT_XTINY, sundata[1], Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);
dc.drawText(width/2, height/2 + 10, Gfx.FONT_XTINY,sundata[0], Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);
}
}