Skip to content

Commit

Permalink
Allow animations to receive boops
Browse files Browse the repository at this point in the history
  • Loading branch information
oskirby committed Aug 9, 2024
1 parent f60e032 commit e7d9f5e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions initfs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit e7d9f5e

Please sign in to comment.