參考引用來源:printing QR codes through an ESC/POS thermal printer
--
def test_qrcode (printer, text, print_also_text=false, qr_size=6.chr)
s = text.size + 3
lsb = (s % 256).chr
msb = (s / 256).chr
# https://code.google.com/p/python-escpos/wiki/Usage
escpos = ""
escpos << "\x1D\x28\x6B\x03\x00\x31\x43#{qr_size}"
escpos << "\x1D\x28\x6B\x03\x00\x31\x45\x33"
escpos << "\x1D\x28\x6B#{lsb}#{msb}\x31\x50\x30"
escpos << text #
escpos << "\x1D\x28\x6B\x03\x00\x31\x51\x30"
# writing byte streams directly to the serial port
printer.write escpos
end
沒有留言:
張貼留言