コード例 #1
0
# Because printed sections have different "grip" characteristics than
# blank paper, as this progresses the paper will usually at some point
# jam -- either uniformly, making a short bar, or at one side or the
# other, making a wedge shape.  In some cases, the Pi may reset for
# lack of power.
#
# Whatever the outcome, take the last number printed BEFORE any
# distorted bar and enter in in Adafruit_Thermal.py as defaultHeatTime
# (around line 53).
#
# You may need to pull on the paper as it reaches the jamming point,
# and/or just abort the program, press the feed button and take the
# last good number.

from __future__ import print_function
from AdafruitThermal import *

printer = AdafruitThermal("/dev/cu.usbserial-AH02DXOC", 9600, timeout=5)

for i in range(0,256,15):
    print('Heat parameter is currently on {0}'.format(i))
    printer.begin(i)
    printer.print('helo')
    printer.print_line(i)                 # Print heat time
    printer.inverse_on()
    printer.print('{:^32}'.format('')) # Print 32 spaces (inverted)
    printer.inverse_off()

printer.begin() # Reset heat time to default
printer.feed(4)