Some more tiny improvements
This commit is contained in:
parent
ccf5cd2951
commit
a8a025bc09
9
clock.py
9
clock.py
|
@ -64,10 +64,11 @@ class MyClockWidget(FloatLayout):
|
|||
face_numbers = []
|
||||
set_alarm_timeout_counter = 0
|
||||
alarm_modified = False
|
||||
seconds_to_next_alarm = False
|
||||
seconds_to_next_alarm = 0
|
||||
led_color = [0, 0, 0]
|
||||
# sound_source = "https://icecast.omroep.nl/radio1-bb-mp3"
|
||||
sound_source = "Woodpecker Chirps - QuickSounds.com.mp3"
|
||||
seconds_to_sunrise = 30 * 60
|
||||
|
||||
def draw_face(self):
|
||||
"""
|
||||
|
@ -141,7 +142,7 @@ class MyClockWidget(FloatLayout):
|
|||
|
||||
def sun_rise(self):
|
||||
# to do: calculate brightness and color according to sun rise instead of linear increment
|
||||
intensity = math.floor((1.0 - self.seconds_to_next_alarm / (1.0 * 60.0)) * 256.0)
|
||||
intensity = math.floor((1.0 - self.seconds_to_next_alarm / self.seconds_to_sunrise) * 256.0)
|
||||
if intensity < 0:
|
||||
intensity = 0
|
||||
|
||||
|
@ -156,7 +157,7 @@ class MyClockWidget(FloatLayout):
|
|||
if self.alarm_activated == False:
|
||||
return
|
||||
|
||||
if self.seconds_to_next_alarm < 30 * 60:
|
||||
if self.seconds_to_next_alarm < self.seconds_to_sunrise:
|
||||
self.sun_rise()
|
||||
|
||||
def check_play_sound(self):
|
||||
|
@ -208,6 +209,8 @@ class MyClockWidget(FloatLayout):
|
|||
hands.canvas.clear()
|
||||
with hands.canvas:
|
||||
if self.set_alarm_mode:
|
||||
# if not grabbed, set_alarm_timeout_counter is incremented at every update call (ie: 60 Hz);
|
||||
# this is used to blink the hands at 1 Hz when setting the alarm and releasing the hand
|
||||
if self.grabbed != "" or self.set_alarm_timeout_counter < 1 * 60 or self.set_alarm_timeout_counter % 60 <= 30 or self.alarm_modified == False:
|
||||
Color(0.9, 0.0, 0.0)
|
||||
Line(points=[hands.center_x, hands.center_y, hours_hand.x, hours_hand.y], width=3, cap="round")
|
||||
|
|
Loading…
Reference in New Issue