diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2025-03-15 16:19:29 +0000 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2025-03-15 16:19:29 +0000 |
| commit | 932a17ad8375940ef5840bc3d6f0359ba0e9150e (patch) | |
| tree | d9b526229d788ecfc6aa47523fc516f3e1cac1ac | |
| parent | 74f6d7aa403c397368ff29c24b97fafa03d0e20b (diff) | |
Add init printer
| -rw-r--r-- | main.py | 2 | ||||
| -rw-r--r-- | printer.py | 12 |
2 files changed, 8 insertions, 6 deletions
@@ -16,6 +16,8 @@ with open("config.yaml", "r") as f: logger = logging.getLogger('uvicorn.error') lock = threading.Lock() +printer.init_printer(bytes.fromhex(config['printer']['maj']), bytes.fromhex(config['printer']['min'])) + app = FastAPI() group = 1 @@ -1,13 +1,14 @@ from PIL import Image -from escpos.printer import Usb +from escpos.printer import Usb, Dummy from typing import Optional, Union -import logging -logger = logging.getLogger(__name__) -p = Usb(0x1fc9,0x2016,0,profile="TM-P80") +p = Dummy() + +def init_printer(maj: bytes, min: bytes): + global p + p = Usb(maj, min, 0, profile="TM-P80") def print_pass(name_image: Union[str, Image.Image], pronouns_image: Union[str, Image.Image], reference: str, ticket_type: str, slug: str): - logger.info(f"Printing pass for {ticket_type}") p.linedisplay_clear() p.image("birminghack-logo-raster-bw-rs.png",center=True) p.ln() @@ -32,7 +33,6 @@ def print_pass(name_image: Union[str, Image.Image], pronouns_image: Union[str, I p.cut() def print_food(issued_to: str, pizza_type: str, group: str, d_req: Optional[str] = None): - logger.info(f"Printing pizza token for {issued_to}") p.linedisplay_clear() p.ln() p.set(align="center",bold=True,custom_size=True,width=3,height=3,smooth=True) |
