Skip to content

Commit

Permalink
fix fast-forward script for simulating wuplight usage
Browse files Browse the repository at this point in the history
  • Loading branch information
enra64 committed Aug 1, 2021
1 parent 134e3bc commit cc1914d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions host/scripts/_WakeUpLightFastForward.py
Expand Up @@ -11,13 +11,13 @@
from helpers.Color import Color


class _WakeUpLight(CustomScript):
class _WakeUpLightFastForward(CustomScript):
def __init__(self, canvas, send_object, send_object_to_all, start_script, restart_self, set_frame_period,
set_frame_rate, get_connected_clients):
super().__init__(canvas, send_object, send_object_to_all, start_script, restart_self, set_frame_period,
set_frame_rate, get_connected_clients)
# setup
self.logger = logging.getLogger("script:wakeuplight")
self.logger = logging.getLogger("script:FF_wuplight")
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
self.set_frame_rate(24)
Expand All @@ -32,6 +32,7 @@ def update(self, canvas):
force_switch = self._read_force_switch()
if force_switch != self._last_force_switch_status:
self._light_percentage = -0.2
self.logger.info("Reset light percentage")
self._last_force_switch_status = force_switch

if self._light_percentage < 0:
Expand All @@ -43,14 +44,15 @@ def update(self, canvas):

color_temp = 1400 + (5500 - 1400) * light_percentage
color_value = Color.from_temperature(color_temp, light_percentage)
self.logger.info("Color temp is {} from light percentage {}".format(color_temp, light_percentage))
self.current_color = color_value

self._light_percentage += 0.005

if self._light_percentage > 1.5:
if self._light_percentage > 1.2:
self.logger.info("Reset light percentage, was above 1.5")
self._light_percentage = -0.2


def draw(self, canvas: Canvas):
canvas.clear(self.current_color)

Expand Down

0 comments on commit cc1914d

Please sign in to comment.