Make application work on non-arm by removing dependencies on colorspace converters for non-arm
This commit is contained in:
parent
32685b777f
commit
59ef86575a
22
clock.py
22
clock.py
|
@ -6,8 +6,6 @@ import sys
|
|||
import traceback
|
||||
import copy
|
||||
import os
|
||||
from rgbw_colorspace_converter.colors.converters import HSV, RGB
|
||||
from hsluv import hsluv_to_rgb
|
||||
from kivy.config import Config
|
||||
|
||||
def is_arm():
|
||||
|
@ -20,6 +18,8 @@ if is_arm():
|
|||
# Do not forget to create udev rule:
|
||||
# echo 'SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"' | sudo tee -a /etc/udev/rules.d/backlight-permissions.rules
|
||||
from rpi_backlight import Backlight
|
||||
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')
|
||||
|
@ -231,13 +231,15 @@ class AlarmSettings():
|
|||
alarm_playing = False
|
||||
|
||||
alarm_modified = False
|
||||
led_color_rgbw = HSV(0, 0, 0).rgbw
|
||||
|
||||
if is_arm():
|
||||
led_color_rgbw = HSV(0, 0, 0).rgbw
|
||||
|
||||
# sound_selected = "NPO Radio 1"
|
||||
# sound_source = "https://icecast.omroep.nl/radio1-bb-mp3"
|
||||
sound_selected = "Birds"
|
||||
sound_source = "Woodpecker Chirps - QuickSounds.com.mp3"
|
||||
seconds_to_sunrise = 1 * 60 # 30 minutes
|
||||
seconds_to_sunrise = 30 * 60 # 30 minutes
|
||||
sunrise_state = "off" # "off", "active" or "completed"
|
||||
|
||||
volume = 15
|
||||
|
@ -278,7 +280,8 @@ class MyClockWidget(FloatLayout):
|
|||
set_alarm_timeout_counter = 0
|
||||
seconds_to_next_alarm = 0
|
||||
|
||||
led_color_rgbw = HSV(0, 0, 0).rgbw
|
||||
if is_arm():
|
||||
led_color_rgbw = HSV(0, 0, 0).rgbw
|
||||
|
||||
# view can be one of the following strings:
|
||||
# - "clock"
|
||||
|
@ -465,6 +468,9 @@ class MyClockWidget(FloatLayout):
|
|||
self.draw_list_curr_frame.append(["Rectangle", settings_button.canvas, settings_button.size, settings_button.pos, source])
|
||||
|
||||
def intensity_to_rgbw(self, intensity):
|
||||
if self.is_arm == False:
|
||||
return None
|
||||
|
||||
if intensity < 0:
|
||||
intensity = 0
|
||||
elif intensity > 1:
|
||||
|
@ -488,6 +494,9 @@ class MyClockWidget(FloatLayout):
|
|||
|
||||
intensity = (1.0 - self.seconds_to_next_alarm / alarm_settings.seconds_to_sunrise)
|
||||
|
||||
if self.is_arm == False:
|
||||
return
|
||||
|
||||
led_color = self.intensity_to_rgbw(intensity)
|
||||
|
||||
if self.led_color_rgbw != led_color.rgbw:
|
||||
|
@ -505,6 +514,9 @@ class MyClockWidget(FloatLayout):
|
|||
if self.seconds_to_next_alarm < alarm_settings.seconds_to_sunrise:
|
||||
self.sunrise()
|
||||
else:
|
||||
if self.is_arm == False:
|
||||
return
|
||||
|
||||
led_color_off = RGB(0, 0, 0)
|
||||
if (alarm_settings.sunrise_state == "off") and (self.led_color_rgbw != led_color_off.rgbw):
|
||||
self.led_color_rgbw = led_color_off.rgbw
|
||||
|
|
Loading…
Reference in New Issue