-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sunrise 0.07: account for altitude, use suncalc module #3103
Conversation
Added locale support for times; handle times with locale functions. Sea level line changes. Changed unlocking behavior & misc
…tly - finally. Draw sea level line to the screen edges. Improve xFromTime. Limit pos to screen bounds
@thyttan I'll merge this in, just wanted a second opinion before doing so - all ok by you? |
apps/sunrise/app.js
Outdated
solarNoonX = xFromTime(SunCalc.getTimes(now, lat, lon, alt).solarNoon); | ||
sr = Locale.time(SunCalc.getTimes(now, lat, lon, alt).sunrise, 1); | ||
ss = Locale.time(SunCalc.getTimes(now, lat, lon, alt).sunset, 1); | ||
fillSineLUT(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fillSineLUT()
isn't defined and so crashes the app on my watch with:
Uncaught ReferenceError: "fillSineLUT" is not defined
at line 160 col 3 in sunrise.app.js
fillSineLUT();
^
in function "initDay" called from line 243 col 11 in sunrise.app.js
initDay();
^
in function "main" called from line 249 col 6 in sunrise.app.js
main();
^
Uncaught Error: Unhandled promise rejection: Error: Unhandled promise rejection: undefined
in function "getAltitude" called from line 154 col 15 in sunrise.app.js
getAltitude();
^
in function "initDay" called from line 170 col 13 in sunrise.app.js
initDay();
^
in function "renderScreen" called from line 210 col 16 in sunrise.app.js
renderScreen();
^
in function called from system
at line 160 col 3 in sunrise.app.js
fillSineLUT();
^
in function "initDay" called from line 170 col 13 in sunrise.app.js
initDay();
^
in function "renderScreen" called from line 210 col 16 in sunrise.app.js
renderScreen();
^
in function called from system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I comment it out the app seems to work though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... but the sun doesn't snap to the sine curve anymore. Maybe that can be tracked back to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - @g-rden's comment below is spot on for fixing this
} | ||
|
||
function initDay () { | ||
getAltitude(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what I did, but I got this uncaught undefined:
Uncaught undefined
in function "getAltitude" called from line 154 col 15 in sunrise.app.js
getAltitude();
^
in function "initDay" called from line 243 col 11 in sunrise.app.js
initDay();
^
in function "main" called from line 249 col 6 in sunrise.app.js
main();
^
Uncaught Error: Unhandled promise rejection: undefined
>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got it now again just after starting the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! I wonder if this is app-specific or another way of triggering what we see in the recorder PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should reset my watch to see if it's something with my current setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's interesting - I don't see it when running either the broken or fixed version of this app, perhaps it's a strange bug on your device. What firmware are you on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, but I think I've seen it on 2v19 stable and one or two 2v19.xx ones. Currently using 2v19.74.
Have not come around to backup and reset my watch yet. But will do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, good luck! I'll keep my eye out for it appearing again too
Some images showing some weird drawing behavior like said here: #3103 (comment).
|
Ah thanks for checking, think I must've been asleep - I'll sort out that function and the sun being off |
sorry to dump this like that but i don't have much time rn.
|
Yes that's sorted it nicely, thank you! I notice the sea slope is flat on either version of the code, I've tried with a few locations so I'll need to fix that before this PR is ready too |
Flat, like completely horizontal? It's not that for me, depending on location. And it should not be very steep, it might have been incorrect in the past, idk anymore. To try out locations you have to set |
Yes I think so - shall double check and debug it to confirm. Thanks for the usage details, didn't know about the website link in particular! |
I've tried with multiple locations and I always see |
What are the values of ss and sr? Are they correct? |
Yes, here's the console output - sadly very short daylight hours this time of year!
|
Sorry, it took me until now to check. I can't get the slope to have the wrong angle. If interception of the slope and the sun sine graph is at the sunrise/sunset time then the angle of the slope ought to be correct. But I doubt that is the case, because you say the slope is exactly 0 and not a very tiny number. I am out of ideas. |
apps/sunrise/app.js
Outdated
y = y2; | ||
x += sinStep; // no need to draw all steps | ||
|
||
for (i = 0; i <= w - sinStep; i += sinStep) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sine function can look crooked at the right side of the screen.
It should be like this instead:
for (i = 0; i <= w; i += sinStep) {
The 'w - sinStep' made sense before, but not anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thank you - sorted that now
No worries, if the code on the branch works ok for you, I'm happy to merge it and I can investigate specifics of my setup |
This continues the great job done by @g-rden in #3063, bringing in those changes but adjusting for the sinLUT changes mentioned in the previous PR.