Added logic for the stunned face to the render and state scripts
This commit is contained in:
parent
cbdddf065e
commit
919961a578
2 changed files with 19 additions and 1 deletions
15
rpi/State.py
15
rpi/State.py
|
@ -21,6 +21,7 @@ class StateSingleton:
|
|||
cls._instance.animations_ready = False
|
||||
cls._instance.blink_animation_FrameCanvases = []
|
||||
cls._instance.angry_animation_FrameCanvases = []
|
||||
cls._instance.stun_animation_FrameCanvases = []
|
||||
|
||||
|
||||
|
||||
|
@ -31,9 +32,16 @@ class StateSingleton:
|
|||
self.blink_animation_FrameCanvases = blink_animation_FrameCanvases
|
||||
print("blink animations set")
|
||||
|
||||
|
||||
def set_angry_animation_frames(self, angry_animation_FrameCanvases):
|
||||
self.angry_animation_FrameCanvases = angry_animation_FrameCanvases
|
||||
print("angry animations set")
|
||||
|
||||
|
||||
def set_stun_animation_frames(self, stun_animation_FrameCanvases):
|
||||
self.stun_animation_FrameCanvases = stun_animation_FrameCanvases
|
||||
print("angry animations set")
|
||||
|
||||
|
||||
def set_desired_expression(self, state):
|
||||
if state in self.states:
|
||||
|
@ -78,6 +86,13 @@ class StateSingleton:
|
|||
elif self.current_expression == self.states[1] or self.desired_expression == self.states[1]:
|
||||
self.matrix.SwapOnVSync(self.blink_animation_FrameCanvases[self.transition_count])
|
||||
|
||||
# stun faces
|
||||
elif self.current_expression == self.desired_expression == self.states[2]:
|
||||
self.matrix.SwapOnVSync(self.stun_animation_FrameCanvases[10])
|
||||
|
||||
elif self.current_expression == self.states[3] or self.desired_expression == self.states[3]:
|
||||
self.matrix.SwapOnVSync(self.stun_animation_FrameCanvases[self.transition_count])
|
||||
|
||||
# angry faces
|
||||
elif self.current_expression == self.desired_expression == self.states[3]:
|
||||
self.matrix.SwapOnVSync(self.angry_animation_FrameCanvases[10])
|
||||
|
|
|
@ -93,10 +93,12 @@ def generate_face_frames(emote_eye_png, emote_mouth_png, emote_nose_png):
|
|||
def animate():
|
||||
blink_animation_FrameCanvases = []
|
||||
angry_animation_FrameCanvases = []
|
||||
stun_animation_FrameCanvases = []
|
||||
|
||||
for emote_FrameCanvasses, emote_eye_png, emote_mouth_png, emote_nose_png in [
|
||||
(blink_animation_FrameCanvases, "faces/eyeLeftClosed.png", "faces/mouthLeft.png", "faces/noseLeft.png"),
|
||||
(angry_animation_FrameCanvases, "faces/eyeLeftAngry.png", "faces/mouthLeft.png", "faces/noseLeft.png")
|
||||
(angry_animation_FrameCanvases, "faces/eyeLeftAngry.png", "faces/mouthLeft.png", "faces/noseLeft.png"),
|
||||
(stun_animation_FrameCanvases, "faces/eyeLeftStunned.png", "faces/mouthLeftSad.png", "faces/noseLeft.png")
|
||||
]:
|
||||
print("generating face with features: " + emote_eye_png +" "+ emote_mouth_png +" "+ emote_nose_png)
|
||||
face_frames = generate_face_frames(emote_eye_png, emote_mouth_png, emote_nose_png)
|
||||
|
@ -105,6 +107,7 @@ def animate():
|
|||
state = StateSingleton()
|
||||
state.set_blink_animation_frames(blink_animation_FrameCanvases)
|
||||
state.set_angry_animation_frames(angry_animation_FrameCanvases)
|
||||
state.set_stun_animation_frames(stun_animation_FrameCanvases)
|
||||
|
||||
state.set_animations_ready()
|
||||
|
||||
|
|
Loading…
Reference in a new issue