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

feat: keep the computer awake while knitting #698 #699

Open
wants to merge 2 commits into
base: main
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Pre-releases are marked with a suffix, e.g. `1.0.0-rc1`, which stands for "relea
- GUI: 10 second timeout for firmware flash (#206).
- GUI: Feedback while flashing firmware (#145).
- GUI: Stretch and reflect to image actions submenu (#131,#261).
- GUI: Keep the screen awake during the knitting progress (#698)

### Fixed

Expand Down
1 change: 1 addition & 0 deletions requirements.build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ simpleaudio==1.0.4
numpy==1.26.4
charset-normalizer<3.0.0
requests==2.31.0
wakepy==0.9.1
60 changes: 31 additions & 29 deletions src/main/python/main/ayab/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from PySide6.QtCore import QCoreApplication, Signal
from PySide6.QtWidgets import QDockWidget
from wakepy import keep

from .. import utils
from ..machine import Machine
Expand Down Expand Up @@ -166,37 +167,38 @@ def run(self, operation: Operation) -> None:
self.config.portname = self.__read_portname()
self.control.start(self.pattern, self.config, operation)

while True:
# continue operating
# typically each step involves some communication with the device
output = self.control.operate(operation)
if output != self.control.notification:
self.__feedback.handle(output)
self.control.notification = output
if operation == Operation.KNIT:
self.__handle_status()
if self.__canceled or self.control.state == State.FINISHED:
break

self.control.stop()
with keep.presenting(on_fail="pass"):
while True:
# continue operating
# typically each step involves some communication with the device
output = self.control.operate(operation)
if output != self.control.notification:
self.__feedback.handle(output)
self.control.notification = output
if operation == Operation.KNIT:
self.__handle_status()
if self.__canceled or self.control.state == State.FINISHED:
break

self.control.stop()

if operation == Operation.KNIT:
if self.__canceled:
self.emit_notification("Knitting canceled.")
self.__logger.info("Knitting canceled.")
if operation == Operation.KNIT:
if self.__canceled:
self.emit_notification("Knitting canceled.")
self.__logger.info("Knitting canceled.")
else:
# operation == Operation.TEST:
self.__logger.info("Finished knitting.")
# small delay to finish printing to knit progress window
# before "finish.wav" sound plays
sleep(1)
else:
# operation == Operation.TEST:
self.__logger.info("Finished knitting.")
# small delay to finish printing to knit progress window
# before "finish.wav" sound plays
sleep(1)
else:
# TODO: provide translations for these messages
self.__logger.info("Finished testing.")

# send signal to finish operation
# "finish.wav" sound only plays if knitting was not canceled
self.emit_operation_finisher(operation, not self.__canceled)
# TODO: provide translations for these messages
self.__logger.info("Finished testing.")

# send signal to finish operation
# "finish.wav" sound only plays if knitting was not canceled
self.emit_operation_finisher(operation, not self.__canceled)

def __handle_status(self) -> None:
if self.status.active:
Expand Down