summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.py2
-rw-r--r--printer.py12
2 files changed, 8 insertions, 6 deletions
diff --git a/main.py b/main.py
index e7ff570..d4c5149 100644
--- a/main.py
+++ b/main.py
@@ -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
diff --git a/printer.py b/printer.py
index 6bf69e9..e975fa6 100644
--- a/printer.py
+++ b/printer.py
@@ -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)