diff options
author | Ben Burwell <ben@benburwell.com> | 2018-05-24 23:19:26 -0400 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2018-05-24 23:19:26 -0400 |
commit | 65b8fb514db9fc5125494b3393699bf666ed9cb2 (patch) | |
tree | 1403327124796b215ebdb1982af135943732e6cd /colortemp.go | |
parent | a3786c8698f8b7c85d09e241cf09dc0e8ced9da2 (diff) |
Get lat/long from config file
Diffstat (limited to 'colortemp.go')
-rw-r--r-- | colortemp.go | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/colortemp.go b/colortemp.go index 8cf3454..f7209a1 100644 --- a/colortemp.go +++ b/colortemp.go @@ -11,18 +11,15 @@ import ( type ColorTemperature uint -const LATITUDE = 42.348333 -const LONGITUDE = 71.1675 - // Get the correct color temperature for a given time. If the time is between // sunrise and sunset, a high CT is selected. Otherise, during night, a low // color temperature is used. // // TODO: This is a naive approach and should be revisited -func getDesiredColorTemperature(t time.Time) ColorTemperature { +func getDesiredColorTemperature(t time.Time, latitude, longitude float64) ColorTemperature { log.Printf("Calculating sunrise/sunset for: %s\n", t.Format(time.RFC3339)) - sunrise := astrotime.CalcSunrise(t, LATITUDE, LONGITUDE) - sunset := astrotime.CalcSunset(t, LATITUDE, LONGITUDE) + sunrise := astrotime.CalcSunrise(t, latitude, longitude) + sunset := astrotime.CalcSunset(t, latitude, longitude) log.Printf("Sunrise: %s, Sunset: %s\n", sunrise.Format(time.RFC3339), sunset.Format(time.RFC3339)) if t.After(sunrise) && t.Before(sunset) { log.Println("Daytime, setting high CT") |