kopia lustrzana https://github.com/peterhinch/micropython-samples
astronomy: RiSet fix bug in .has_risen() and .has_set().
rodzic
8f6463845d
commit
6d639f0008
|
@ -243,20 +243,22 @@ class RiSet:
|
||||||
self.lto = round(t * 3600) # Localtime offset in secs
|
self.lto = round(t * 3600) # Localtime offset in secs
|
||||||
|
|
||||||
def has_risen(self, sun: bool):
|
def has_risen(self, sun: bool):
|
||||||
now = round(time.time()) + self.lto # UTC
|
now = round(time.time()) # Machine time
|
||||||
rt = self.sunrise(1) if sun else self.moonrise(1)
|
rt = self.sunrise(1) if sun else self.moonrise(1) # Machine time
|
||||||
if rt is None:
|
if rt is None:
|
||||||
|
now += self.lto # UTC
|
||||||
t = (now % 86400) / 3600 # Time as UTC hour of day (float)
|
t = (now % 86400) / 3600 # Time as UTC hour of day (float)
|
||||||
return self.sin_alt(t, sun) > 0 # Above horizon
|
return self.sin_alt(t, sun) > 0 # Above horizon
|
||||||
return rt < now
|
return rt < now
|
||||||
|
|
||||||
def has_set(self, sun: bool):
|
def has_set(self, sun: bool):
|
||||||
now = round(time.time()) + self.lto # UTC
|
now = round(time.time())
|
||||||
st = self.sunset(1) if sun else self.moonset(1)
|
st = self.sunset(1) if sun else self.moonset(1)
|
||||||
if st is None:
|
if st is None:
|
||||||
|
now += self.lto # UTC
|
||||||
t = (now % 86400) / 3600 # Time as UTC hour of day (float)
|
t = (now % 86400) / 3600 # Time as UTC hour of day (float)
|
||||||
return self.sin_alt(t, sun) < 0
|
return self.sin_alt(t, sun) < 0
|
||||||
return st > now
|
return st < now
|
||||||
|
|
||||||
def is_up(self, sun: bool): # Return current state of sun or moon
|
def is_up(self, sun: bool): # Return current state of sun or moon
|
||||||
return self.has_risen(sun) and not self.has_set(sun)
|
return self.has_risen(sun) and not self.has_set(sun)
|
||||||
|
|
Ładowanie…
Reference in New Issue