Add configurable printer width#79
Open
Igglybuff wants to merge 3 commits into
Open
Conversation
The serve command gains a --width flag (also readable from the PRINTER_WIDTH env var) specifying the printer's dot width. Defaults to 576 to match the TSP650II. Set to 384 for 58mm printers like the Star mC-Print2. All server handlers (photo, patterns, weave, receipt) now derive the print width from the configured value instead of a hardcoded reference to PrinterConfig::TSP650II. Dividers in the patterns and weave handlers derive their character width from the printer dot width so they don't wrap on narrower paper. Adds PrinterConfig::MCP21 (384 dots, 58mm) alongside the existing TSP650II constant, and a PrinterConfig::with_width() constructor for building a config from an arbitrary dot width. PRINTER_DEVICE and LISTEN_ADDR env vars are also added to the other serve options for consistency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Same fix as patterns and weave: derive chars_per_line from printer_width instead of using Divider::default(), which assumed TSP650II column count. Also threads printer_width into the preview handler. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The env attribute on #[arg] requires clap's env feature flag. The PrinterConfig import in receipt.rs was unused after refactoring build_receipt to take a raw u16 width. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced May 24, 2026
Author
|
I suppose since the Star print protocol should be pretty universal for these printers, the main (only?) thing preventing this project from supporting any old Star Micronics printer is the paper width? You just need to provide the right parameters for your printer and it should just work. What you probably don't want is a bunch of model-specific code everywhere, but then you put more responsibility on the user to configure estrella correctly for their model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
PRINTER_WIDTHenvironment variable (default576, matching the existing 80mm TSP650II behaviour) so the service works correctly with narrower printers like the 58mm mC-Print2 (384dots).The width is used to calculate
chars_per_linefor word wrapping and the divider width in the receipt handler. Previously these were hardcoded or calculated from a fixed width, which produced incorrect output on narrower paper.Also fixes a build error: adds the missing
envfeature to theclapdependency.🤖 Generated with Claude Code