added rounding to 1/8th of a dollar for price

This commit is contained in:
Joe Lothan 2026-06-15 18:38:54 -04:00
parent ff248a9b68
commit 6efed3be72
2 changed files with 274 additions and 2 deletions

View file

@ -14,6 +14,8 @@ import sys
from escpos.printer import Dummy
from glyphs import price_to_fraction, upload_fractions
# TM-T88V with 90° rotation: Font A chars are 24 dots wide (instead of 12),
# so 512 printable dots / 24 = 21 chars fit across the 80mm paper width.
LINE_WIDTH = 21
@ -21,10 +23,11 @@ LINE_WIDTH = 21
def print_trade(p, symbol, lots, price):
"""Print a single trade as ticker tape characters, one per row."""
frac = price_to_fraction(price)
if lots > 1:
price_str = f"{lots}s{price:.2f}"
price_str = f"{lots}s{frac}"
else:
price_str = f"{price:.2f}"
price_str = frac
# Symbol characters at the top (right-aligned)
for ch in symbol:
@ -49,6 +52,8 @@ def main():
# ESC 3 n: set line spacing to n/180 inch. Font A chars are 12 dots wide,
# so n=12 makes rotated characters sit flush with no gap.
p._raw(b"\x1b\x33\x0c")
# Upload custom fraction glyphs (⅛ ¼ ⅜ ½ ⅝ ¾ ⅞)
upload_fractions(p)
with open(csv_file) as f:
reader = csv.reader(f)