-
• #2
Not very up on my basic astrophysics so sorry if this is an easy equation
-
• #3
That's a neat idea - yes, it should be possible. Although most people won't have their GPS on most of the time so I don't know how useful it'd be unless it remembered the last known position.
I'd imagine there's some JS out there that'll take lat/lon and time and give you sunrise/sunset... It can't be too painful
-
• #4
I think this would do it (https://gist.github.com/ruiokada/b28076d4911820ddcbbc) thou I think I can make it a bit faster for the bangle as we have a function for the date etc.
Also would be a good example of how to get the lat/lon from bangle? I am thinking one of the moon apps would be a good place to start?
-
• #5
@DrBard One thing to watch out for is the acos part, which is one of the last calculations you have to do - there is an issue in the Bangle firmware with that function on negative values and you'll get strange results. There are several ways to estimate acos you can find online and I've used one of those for now myself and it's close enough for this kind of thing. It's a known issue but fairly new so fixed for Espruino but it's not in the latest standard Bangle firmware.
function acos_estimate(x) {
return (-0.69813170079773212 * x * x - 0.87266462599716477) * x + 1.5707963267948966;
}
-
• #6
Thanks @BenJabituya.
Looking at your very cool clock, I assume that you are getting the GPS (when not already saved) from ...Bangle.on('GPS', function (g) { if (g.fix) { astral_settings.lat = g.lat; astral_settings.lon = g.lon; astral_settings.astral_default = false; config_file = require("Storage").open("astral.config.txt", "w"); config_file.write(JSON.stringify(astral_settings)); }
I have never worked with bangles GPS so trying to workout the best way to call the lat/lon without scrwing something up and calling the GPS all the time or something lol
-
• #7
@DrBard yep that's basiscally it. BTW there's actually another app that does specific sun and moon calcs which you might want to look at also: https://banglejs.com/apps/#astroc
I'm not getting correct metrics from that app though but again I think it's just because of the acos issue; I've actually found a better function for that now than the one I gave before (Don't know what voodoo magic they do to work these out!): https://developer.download.nvidia.com/cg/acos.html
Hi
I was thinking if bangle knows the GPS and the current time (as part of that) could it not work out if time till sunset etc?
I was thinking of just adding this as information to a watch face I wanted to make but I think it could also be useful in automating some things with the brightness of some apps etc, I.e. higher after dark etc, or even change the colours as it gets "darker".