Added light button (not yet functional)

This commit is contained in:
Admar Schoonen 2023-04-09 15:32:11 +02:00
parent 6b213a54b9
commit a2e5fbab86
4 changed files with 18 additions and 3 deletions

View File

@ -76,7 +76,7 @@ Builder.load_string('''
id: light_button
size_hint: None, None
pos_hint: {"center_x":0.1, "center_y":0.9}
size: 0.1*min(root.size), 0.1*min(root.size)
size: 0.1*125/70*min(root.size), 0.1*min(root.size)
FloatLayout
id: settings_button
@ -380,6 +380,16 @@ class MyClockWidget(FloatLayout):
center_y + round(length * math.cos(2 * math.pi * fraction)),
)
def update_light_button(self):
source = 'light_off.png'
rgb = [1.0, 1.0, 1.0]
light_button = self.ids["light_button"]
self.draw_list_curr_frame.append(["canvas.clear()", light_button])
with light_button.canvas:
self.draw_list_curr_frame.append(["Color", light_button.canvas, rgb[0], rgb[1], rgb[2]])
self.draw_list_curr_frame.append(["Rectangle", light_button.canvas, light_button.size, light_button.pos, source])
def update_play_button(self):
alarm_settings = App.get_running_app().alarm_settings
@ -572,6 +582,7 @@ class MyClockWidget(FloatLayout):
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu"], True])
self.draw_list_curr_frame.append(["self.hide_widget", self.ids["settings_menu_wake_up_sound"], True])
self.update_light_button()
self.update_play_button()
self.update_set_alarm_button()
self.update_settings_button()
@ -661,6 +672,9 @@ class MyClockWidget(FloatLayout):
if self.is_arm:
self.set_backlight(alarm_settings.display_brightness)
def on_light_button_pressed(self):
pass
def on_play_button_pressed(self):
alarm_settings = App.get_running_app().alarm_settings
if alarm_settings.alarm_playing:
@ -807,8 +821,9 @@ class MyClockWidget(FloatLayout):
minutes_hand = self.position_on_clock(time.minute/60+time.second/3600, length=0.40*hands.size[0])
hours_hand = self.position_on_clock(time.hour/12 + time.minute/720, length=0.35*hands.size[0])
print(str(touch.spos))
if (0.05 <= touch.spos[0] <= 0.15) and (0.05 <= touch.spos[1] <= 0.15):
if (0.05 <= touch.spos[0] <= 0.15) and (0.85 <= touch.spos[1] <= 0.95):
self.on_light_button_pressed()
elif (0.05 <= touch.spos[0] <= 0.15) and (0.05 <= touch.spos[1] <= 0.15):
self.on_play_button_pressed()
elif (0.85 <= touch.spos[0] <= 0.95) and (0.05 <= touch.spos[1] <= 0.15):
self.on_alarm_button_pressed()

BIN
light_off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
light_on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
reading_light_on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB