Example #1
0
def printloop():
    global pos, stopped
    while not stopped:
        it = q.get()
        if it is None:
            break

        # TODO support cutting operation ...
        print('Print img')
        px = it.load()
        for y in range(it.size[1]):
            pos = y
            if ENABLED:
                con.write(b'\x11')
            for i in range(72):
                p = 0
                for j in range(8):
                    p *= 2
                    if i * 8 + j < it.size[0] and px[i * 8 + j, y] == 0:
                        p += 1
                if ENABLED:
                    con.write(bytes([p]))
            if not ENABLED:
                time.sleep(0.001)

        pos = -1
        qgui.put('REM')

        q.task_done()
        time.sleep(1)
Example #2
0
File: cut.py Project: cdn/thermal
from connection import con

con.write(b'\x19')
Example #3
0
from connection import con

print('Beeping')
con.write(b'\x1b\x07')

con.write(b'\x1f\x56')
ver = con.read(8).decode()
print('Boot version: {}, Flash version: {}'.format(ver[:4], ver[4:]))

con.write(b'\x1d\x49\x40\x27')
model = con.read(17).decode()
print('Model: {}'.format(model))
Example #4
0
    print('Provide image path')
    sys.exit(1)

orig = Image.open(sys.argv[1])
orig.convert('L')  # grayscale

maxs = 576
if len(sys.argv) > 2:
    maxs = int(sys.argv[2])
orig.thumbnail((maxs, maxs), Image.NEAREST)
gs = Image.new('L', orig.size, (255))
gs.paste(orig)

bw = gs.point(lambda x: 0 if x < 128 else 255, '1')
bw.show()

# PREVIEW ONLY?
#sys.exit()

px = bw.load()
print('Printing {} lines of {} columns'.format(bw.size[1], bw.size[0]))
for y in range(bw.size[1]):
    con.write(b'\x11')
    for i in range(72):
        p = 0
        for j in range(8):
            p *= 2
            if i * 8 + j < bw.size[0] and px[i * 8 + j, y] == 0:
                p += 1
        con.write(bytes([p]))
Example #5
0
from connection import con

#con.write(b'\x11')
#for i in range(72):
#    con.write(bytes([2**i]))

#for i in range(8):
#i = 2
for i in range(1, 7):
    con.write(b'\x11')
    for _ in range(72):
        con.write(bytes([2**i]))

#i = 7
#con.write(b'\x11')
#for _ in range(72):
#    con.write(bytes([2**i]))