Skip to content

Add buzzer() command - #1405

Open
zaydmulani09 wants to merge 1 commit into
mike42:developmentfrom
zaydmulani09:add-buzzer-command
Open

zaydmulani09 wants to merge 1 commit into
mike42:developmentfrom
zaydmulani09:add-buzzer-command

Conversation

@zaydmulani09

Copy link
Copy Markdown

Closes #174.

Adds a buzzer($times, $duration) method that sends ESC B n t to trigger the printer's internal buzzer, for printers that have one (referenced in #174 by two people with Metapace/Sewoo/Epson hardware).

I couldn't find a live copy of the Epson ESC/POS reference linked in the issue (epson-biz.com now redirects to a closure notice), so I cross-checked against python-escpos's buzzer(), which implements the same ESC B n t command and is a maintained, tested reference: https://github.com/python-escpos/python-escpos/blob/main/src/escpos/escpos.py#L1548. Both n (times) and t (duration) are restricted to 1-9 there, so I kept the same bounds.

I don't own a printer with a buzzer, so this is unverified against real hardware — it's implemented and tested the same way as the existing pulse() command (byte-for-byte assertions in EscposTest.php), but someone with one of the printers mentioned in the issue should confirm it actually beeps before merge.

Ran the full suite locally (phpunit, phpcs --standard=psr2): 266 tests, same 22 pre-existing Windows-only failures as on a clean development checkout (shell-quoting differences in WindowsPrintConnectorTest, unrelated to this change).

Sends ESC B n t to trigger the printer's buzzer, matching the byte
sequence used by python-escpos's buzzer() implementation. n and t
are both restricted to 1-9 per that command's spec.

Closes mike42#174
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.

Add beep command

1 participant