Fix bug, update window size and adjust backlight based on led intensity

This commit is contained in:
Admar Schoonen 2023-04-10 23:12:31 +02:00
parent e0483d7667
commit c7b874fe15
1 changed files with 22 additions and 8 deletions

View File

@ -22,10 +22,10 @@ if is_arm():
from rgbw_colorspace_converter.colors.converters import HSV, RGB
from hsluv import hsluv_to_rgb
#Config.set('graphics', 'width', '800')
#Config.set('graphics', 'height', '480')
Config.set('graphics', 'width', '667')
Config.set('graphics', 'height', '400')
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '480')
#Config.set('graphics', 'width', '750')
#Config.set('graphics', 'height', '450')
import board
import neopixel
@ -287,7 +287,7 @@ class Touch():
class TouchEvent():
def __init__(self, x=None):
self.time = time.time()
self.touch = copy.deepcopy(x)
self.touch = copy.copy(x)
class MyClockWidget(FloatLayout):
grabbed = ""
@ -366,7 +366,8 @@ class MyClockWidget(FloatLayout):
y = c**x + offset
z = max(1, round(y))
self.backlight.brightness = z
if self.is_arm:
self.backlight.brightness = z
def hide_widget(self, widget, hide=True):
if hasattr(widget, 'saved_attrs'):
@ -521,6 +522,16 @@ class MyClockWidget(FloatLayout):
return led_color
def update_backlight(self):
alarm_settings = App.get_running_app().alarm_settings
# make sure brightness of display is never lower than intensity of leds
brightness_min = 20 * self.intensity_curr
if alarm_settings.display_brightness < brightness_min:
self.set_backlight(brightness_min)
else:
self.set_backlight(alarm_settings.display_brightness)
def set_leds(self):
if self.intensity_prev != self.intensity_curr:
self.intensity_prev = self.intensity_curr
@ -609,6 +620,7 @@ class MyClockWidget(FloatLayout):
self.calc_seconds_to_next_alarm()
self.process_led_state()
self.set_leds()
self.update_backlight()
self.check_play_sound()
def update_clock(self):
@ -803,8 +815,6 @@ class MyClockWidget(FloatLayout):
alarm_settings = App.get_running_app().alarm_settings
alarm_settings.display_brightness = int(args[1])
if self.is_arm:
self.set_backlight(alarm_settings.display_brightness)
def on_light_button_pressed(self):
print("light button pressed from view " + self.view)
@ -1074,6 +1084,10 @@ class MyApp(App):
Clock.schedule_once(clock_widget.update_display, 0)
# then update at update_rate times per second
Clock.schedule_interval(clock_widget.update_display, 1.0/update_rate)
if is_arm():
Window.borderless = True
return clock_widget
def except_hook(type, value, tb):