From e7d9f5eb9ec1b8b227a46b36e2f2dbaad7fe9bd8 Mon Sep 17 00:00:00 2001 From: Naomi Kirby Date: Thu, 8 Aug 2024 19:41:35 -0700 Subject: [PATCH] Allow animations to receive boops --- initfs/main.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/initfs/main.py b/initfs/main.py index bfaba1b..3b82b59 100644 --- a/initfs/main.py +++ b/initfs/main.py @@ -94,7 +94,7 @@ def __init__(self): self.pallet = [array.array("f", [0.0,0.0,0.0]) for i in range(1024)] self.pallet_functions[self.pallet_index](self.pallet) - print("Dreams are messages from the deep") + print("Oh what a day. WHAT A LOVELY DAY!") self.timer = Timer(mode=Timer.PERIODIC, freq=15, callback=self.isr_update) def next(self, seek=1): @@ -118,14 +118,21 @@ def isr_update(self,*args): def update(self,*args): self.touch.update() if (self.touch.channels[0].level > 0.3) or (self.touch.channels[1].level > 0.3): + # Invoke the animation's boop method, if present. + if (hasattr(self.animation_current, "boop") and + callable(self.animation_current.boop) and + self.blush_count < 50): + self.animation_current.boop() + + # Start blushing self.blush_count = 50 if self.blush_mix < 1.0: self.blush_mix += 0.5 else: + # Fade out the blush if self.blush_count > 0: self.blush_count -= 1 - else: - if self.blush_mix > 0.0: + elif self.blush_mix > 0.0: self.blush_mix -= 0.05 self.sw4_state <<= 1