]> OzVa Git service - doomsday-clock/commitdiff
Fixed tabulator formatting
authorwill <greenwoodw50@gmail.com>
Mon, 19 Aug 2024 12:34:25 +0000 (13:34 +0100)
committerwill <greenwoodw50@gmail.com>
Mon, 19 Aug 2024 12:34:25 +0000 (13:34 +0100)
clock.py

index 2cbbc8a7cd2281dd3e6cefac847bfc4a62064fac..12e150cc5726babe4b76803a972903f70b903743 100644 (file)
--- a/clock.py
+++ b/clock.py
@@ -4,86 +4,86 @@ import sacn
 import RPi.GPIO as GPIO
 
 class clock:
-    def __init__(self):
-        self.url = "https://data.ozva.co.uk/shopping/clock.json"
-
-        self.request_speed = 0.1
-        
-        self.light_speed = 0.5
-        self.cues = 0
-
-        self.current_position = 0
-        self.last_position = 0
-        self.movement_speed = 10
-        self.function = "linear"
-
-        get_loop = Process(target=self.get(), daemon = True)
-        move_loop = Process(target=self.move(), daemon = True)
-        light_loop = Process(target=self.light(), daemon = True)
-        get_loop.start()
-        move_loop.start()
-        light_loop.start()
-
-    def get(self):
-        try:
-            while True:
-                t = time.time()
-
-                r = requests.get(self.url)
-                data = r.json()
-
-                new_target = int(data["currentPosition"])
-                if new_target != self.target_position:
-                    self.last_position = self.current_position
-                    self.target_position = new_target
-
-                self.movement_speed = int(data["movementSpeed"])
-                self.function = data["function"]
-                self.cues = data["lightingCues"]
-
-                time.sleep(self.request_speed - (time.time() - t))
-
-        except:
-            pass
-
-    def move(self):
-        GPIO.setmode(GPIO.BOARD)
-        GPIO.setup((11, 13, 15), GPIO.OUT)
-
-        try:
-            while True:
-                t = time.time()
-
-                parked = self.current_position != self.target_position
-                forward = self.target_position >= self.current_position
-                if forward and (not parked):
-                    GPIO.output(13, GPIO.HIGH)
-                    GPIO.output(11, GPIO.HIGH)
-                elif (not forward) and (not parked):
-                    GPIO.output(11, GPIO.HIGH)
-
-                GPIO.output((11, 13, 15), GPIO.LOW)
-
-                time.sleep(self.movement_speed - (time.time() - t))
-
-        except:
-            GPIO.cleanup()
-
-    def light(self):
-        sender = sacn.sACNsender()
-        sender.start()
-        sender.activate_output(2)
-        sender[2].multicast = True
-            
-        try:
-            while True:
-                t = time.time()
-
-                data = tuple(255 if i == "true" else 0 for i in self.cues)
-                sender.dmx_data = data
-
-                time.sleep(self.light_speed - (time.time() - t))
-
-        except:
-            sender.stop()
+       def __init__(self):
+               self.url = "https://data.ozva.co.uk/shopping/clock.json"
+
+               self.request_speed = 0.1
+
+               self.light_speed = 0.5
+               self.cues = 0
+
+               self.current_position = 0
+               self.last_position = 0
+               self.movement_speed = 10
+               self.function = "linear"
+
+               get_loop = Process(target=self.get(), daemon = True)
+               move_loop = Process(target=self.move(), daemon = True)
+               light_loop = Process(target=self.light(), daemon = True)
+               get_loop.start()
+               move_loop.start()
+               light_loop.start()
+
+       def get(self):
+               try:
+                       while True:
+                               t = time.time()
+
+                               r = requests.get(self.url)
+                               data = r.json()
+
+                               new_target = int(data["currentPosition"])
+                               if new_target != self.target_position:
+                                       self.last_position = self.current_position
+                                       self.target_position = new_target
+
+                               self.movement_speed = int(data["movementSpeed"])
+                               self.function = data["function"]
+                               self.cues = data["lightingCues"]
+
+                               time.sleep(self.request_speed - (time.time() - t))
+
+               except:
+                       pass
+
+       def move(self):
+               GPIO.setmode(GPIO.BOARD)
+               GPIO.setup((11, 13, 15), GPIO.OUT)
+
+               try:
+                       while True:
+                               t = time.time()
+
+                               parked = self.current_position != self.target_position
+                               forward = self.target_position >= self.current_position
+                               if forward and (not parked):
+                                       GPIO.output(13, GPIO.HIGH)
+                                       GPIO.output(11, GPIO.HIGH)
+                               elif (not forward) and (not parked):
+                                       GPIO.output(11, GPIO.HIGH)
+
+                               GPIO.output((11, 13, 15), GPIO.LOW)
+
+                               time.sleep(self.movement_speed - (time.time() - t))
+
+               except:
+                       GPIO.cleanup()
+
+       def light(self):
+               sender = sacn.sACNsender()
+               sender.start()
+               sender.activate_output(2)
+               sender[2].multicast = True
+
+               try:
+                       while True:
+                               t = time.time()
+
+                               data = tuple(255 if i == "true" else 0 for i in self.cues)
+                               sender.dmx_data = data
+
+                               time.sleep(self.light_speed - (time.time() - t))
+
+               except:
+                       sender.stop()