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

Add support for --no-resize option and --keep-awake functionality #79

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sofiaferro
Copy link

@sofiaferro sofiaferro commented Jan 25, 2025

This pull request introduces two new features to enhance the functionality of the printer script:

  1. --no-resize option:
  • If the image width is smaller than the paper width, it prints without resizing.
  • This is particularly useful for printing custom designs or tickets where preserving the layout is crucial.
    Usage:
./print.py --no-resize image.png
  1. --keep-awake functionality:

Adds a process to prevent the printer from entering sleep mode by sending periodic "keep-alive" commands.
This can be activated via the Node.js server by including the --keep-awake argument. Here’s the implementation I worked on: sofiaferro/catprinter-manager.
Usage:

node server.js --keep-awake

Both changes include the necessary updates to the CLI and documentation. These features improve flexibility and address edge cases for printing workflows.

Copy link
Owner

@rbaron rbaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sofiaferro. I was very happy to see catprinter used in your art installation!

@@ -0,0 +1,64 @@
import asyncio
Copy link
Owner

@rbaron rbaron Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dummy-print.py shares a lot of code with print.py. I would suggest adding a --send-keepalive to print.py instead. It will make maintenance easier.

Maybe we can also mention it in the README.md instead of the nodejs application there. Something like "To prevent the printer from sleeping, call print.py --send-keepalive every x seconds". I think that would be helpful to others.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that dummy-print.py shares a lot of code with ble.py. The keep-alive functionality currently requires a parent process to keep the printer awake between prints, which isn't something handled directly by print.py or ble.py.

Alternatively, we could move this functionality to ble.py to avoid duplication, or let dummy-print.py exist in a fork if it's too specific for the main branch. This way, the main codebase stays clean while supporting this use case. Let me know your thoughts!

Copy link
Owner

@rbaron rbaron Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about something like adding a --send-keepalive "dummy switch" to print.py that only pings the printer with the functionality you already implemented. I think this would be great already.

Then users can choose if/how to periodically run the keepalive loop. For example, some may be happy with a quick and dirty bash loop like:

$ while true; do python3 print.py --send-keep-alive; sleep 30; done

So I think we could get rid of dummy-print.py and use the same print.py with an additional if-else send_keepalive. In your manager, I think it would be enough to change this line to print.py --send-keepalive here.

I would still link your catprinter-manager in the README because it has nice features for advanced users (queue, better keepalive etc), and we get to keep this one very simple. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants