Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display_image method ignoring duration. #48

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed display_image not waiting for timeout
Signed-off-by: Aitor Miguel Blanco <[email protected]>
  • Loading branch information
gimait committed Apr 20, 2021
commit db48870b7abbbf865fb1e175443d5e0ce2271cd7
6 changes: 6 additions & 0 deletions pycozmo/anim_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ def play_audio(self, pkts: List[protocol_encoder.OutputAudio]) -> None:

def display_image(self, pkt: protocol_encoder.DisplayImage) -> None:
self.queue.put_image(pkt)
self.playing_animation = True

def clear_screen(self) -> None:
pkt = protocol_encoder.DisplayImage(image=b"\x3f\x3f")
self.queue.put_image(pkt)
self.playing_animation = False

def play_anim_frame(
self,
Expand Down
6 changes: 1 addition & 5 deletions pycozmo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,18 +453,14 @@ def enable_camera(self, enable: bool = True, color: bool = False) -> None:
pkt = protocol_encoder.EnableColorImages(enable=color)
self.conn.send(pkt)

def clear_screen(self) -> None:
pkt = protocol_encoder.DisplayImage(image=b"\x3f\x3f")
self.anim_controller.display_image(pkt)

def display_image(self, im: Image, duration: Optional[float] = None) -> None:
encoder = image_encoder.ImageEncoder(im)
buf = bytes(encoder.encode())
pkt = protocol_encoder.DisplayImage(image=buf)
self.anim_controller.display_image(pkt)
if duration is not None:
time.sleep(duration)
self.clear_screen()
self.anim_controller.clear_screen()

def _load_clips(self, fspec: str) -> None:

Expand Down