Commit Graph

4 Commits (a7d5b9d1bcc9524bd2fc08a09db4ac6d9229af7e)

Author SHA1 Message Date
Amir Alexander Abdelbaki a7d5b9d1bc fix: use measured page capacity instead of derived CPI/LPI geometry
Real-world testing (pagetest.sh) showed the printer's actual per-page
line/column capacity didn't match what the A4-geometry math predicted,
and the redundant blank second page was traced to the printer
auto-advancing to a new page once content hits the bottom margin,
with our own unconditional trailing form-feed then ejecting that
already-started blank page on top of it.

Replace PRINTER_CPI/PRINTER_LPI with directly-measured
PRINTER_MAX_LINES/PRINTER_MAX_COLS in printer.conf (read via
pagetest.sh), and have txt2printr.sh skip the trailing form-feed
whenever the print job already reaches that line capacity.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-14 09:59:06 +02:00
Amir Alexander Abdelbaki c9cf7f6484 fix: correct A4 landscape sizing math to avoid page overflow
a4_landscape_chars() was sizing the capture/preview to the *final*
landscape look (assuming the physical page gets fed sideways), but
txt2printr.sh actually rotates the ascii art 90 degrees in software on
a normally-fed page. Combining both produced ~107 printed lines,
overflowing the printer's page-length capacity onto a second sheet.

Since the software rotation is cancelled out by the reader turning the
finished page 90 degrees, the capture buffer's own dimensions equal
the final visual result, but its width becomes the printed line count
post-rotation - so it must be capped by the page's line capacity along
the long edge, with height derived from the target landscape aspect
ratio (corrected for non-square character cells) instead of just
filling the available character budget.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-14 09:41:13 +02:00
Amir Alexander Abdelbaki 07cf695840 feat: add PRINTER_A4 landscape option for A4 printers
Dot-matrix printers have no hardware page-rotation, so when PRINTER_A4
is enabled in the new printer.conf, txt2printr.sh rotates the ascii art
90 degrees in software before sending it, and photobooth.py caps its
live-preview viewfinder to an A4-landscape character grid (sized from
configurable PRINTER_CPI/PRINTER_LPI) instead of just filling the
terminal, so the preview matches what actually gets printed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-14 09:27:22 +02:00
Amir Alexander Abdelbaki e295910234 add photobooth.py: curses TUI rewrite of the live preview loop
Replaces per-frame fswebcam process spawns with a persistent OpenCV/v4l2
capture handle for the highest achievable refresh rate, while still
shelling out to ascii-image-converter for conversion and txt2printr.sh
for printing. Renders a bordered live preview with a status/keybind-help
bar via curses, works on a plain TTY with no graphical environment.

Reuses webcam.conf/ascii.conf/keybinds.conf, parsed as plain key=value
(not sourced, so a config file can no longer execute arbitrary code).
Brightness/exposure now go through v4l2-ctl with percentage mapped onto
each control's actual min/max range; added DEVICE/BRIGHTNESS_CTRL_ID/
EXPOSURE_CTRL_ID to webcam.conf and KEY_QUIT to keybinds.conf for this,
kept separate from the bash-oriented keys so the existing bash scripts
are unaffected. Bash scripts are left in place as a fallback.

New deps: python-opencv, v4l-utils.
2026-07-03 13:07:53 +02:00