From a0d2083b0184feb718d046cc100d388d185a1b1c Mon Sep 17 00:00:00 2001 From: Jonas Zeunert Date: Wed, 31 Aug 2022 17:32:30 +0200 Subject: [PATCH] more random --- lamps/LampGroup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lamps/LampGroup.py b/lamps/LampGroup.py index f8fee97..493636b 100644 --- a/lamps/LampGroup.py +++ b/lamps/LampGroup.py @@ -41,10 +41,14 @@ class LampGroup: self.currentLampPtr -= 1 def toggleRandom(self, sleepTime): - random_lamp = random.choice(self.lamps) - random_lamp.activate() + count = random.randint(1,8) + random_lamps = random.choices(self.lamps, count) + for lamp in random_lamps: + lamp.activate() time.sleep(sleepTime) - random_lamp.deactivate() + for lamp in random_lamps: + lamp.deactivate() + def cycle(self): if self.currentLamp: self.currentLamp.deactivate()