From d25b643c49e086108e24558c572b9eed536bb843 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Mon, 19 Aug 2024 22:33:39 +0200 Subject: [PATCH] sixths: start testing Sun time/pos --- apps/sixths/sixths.app.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/sixths/sixths.app.js b/apps/sixths/sixths.app.js index 857adc564..c6fe4234f 100644 --- a/apps/sixths/sixths.app.js +++ b/apps/sixths/sixths.app.js @@ -185,6 +185,8 @@ let gps = { /* sun version 0.0.1 */ let sun = { SunCalc: null, + lat: 50, + lon: 14, init: function() { try { this.SunCalc = require("suncalc"); // from modules folder @@ -193,10 +195,24 @@ let sun = { } print("Have suncalc: ", this.SunCalc); - } + }, + get_sun_pos: function() { + let d = new Date(); + let sun = this.SunCalc.getPosition(d, this.lat, this.lon); + print(sun.azimuth, sun.altitude); + return sun; + }, + get_sun_time: function() { + let d = new Date(); + let sun = this.SunCalc.getTimes(d, this.lat, this.lon); + print(sun.sunrise, sun.sunrise.getHour()); + return sun; + }, }; sun.init(); +sun.get_sun_pos(); +sun.get_sun_time(); fmt.init(); gps.init();