当前位置: 首页>>代码示例>>Python>>正文


Python Adafruit_Thermal.setLineHeight方法代码示例

本文整理汇总了Python中Adafruit_Thermal.setLineHeight方法的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_Thermal.setLineHeight方法的具体用法?Python Adafruit_Thermal.setLineHeight怎么用?Python Adafruit_Thermal.setLineHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adafruit_Thermal的用法示例。


在下文中一共展示了Adafruit_Thermal.setLineHeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1:

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import setLineHeight [as 别名]
printer.upsideDownOff()

printer.sidewaysOn()
printer.println("Sideways ON")
printer.sidewaysOff()

printer.setSize('L')   # Set type size, accepts 'S', 'M', 'L'
printer.println("Large")
printer.setSize('M')
printer.println("Medium")
printer.setSize('S')
printer.println("Small")

printer.justify('C')
printer.println("normal\nline\nspacing")
printer.setLineHeight(50)
printer.println("Taller\nline\nspacing")
printer.setLineHeight() # Reset to default
printer.justify('L')

# Barcode examples
printer.feed(1)
# CODE39 is the most common alphanumeric barcode
printer.printBarcode("ADAFRUT", printer.CODE39)
printer.setBarcodeHeight(100)
# Print UPC line on product barcodes
printer.printBarcode("123456789123", printer.UPC_A)

# Print the 75x75 pixel logo in adalogo.py
import gfx.adalogo as adalogo
printer.printBitmap(adalogo.width, adalogo.height, adalogo.data)
开发者ID:nearengine,项目名称:Python-Thermal-Printer,代码行数:33,代码来源:printertest.py

示例2: OTP

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import setLineHeight [as 别名]
#
# OTP (or any other text file) printer.  Push the button to
# print another copy of the file.

from __future__ import print_function
import RPi.GPIO as GPIO
import sys, os, random, getopt, re
import subprocess, time, Image, socket
from Adafruit_Thermal import *

ledPin       = 18
buttonPin    = 23
holdTime     = 2     # Duration for button hold (shutdown)
tapTime      = 0.01  # Debounce time for button taps
printer      = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
printer.setLineHeight(23) # So graphical chars fit together

# Called when button is briefly tapped.  Prints one copy of the OTP.
def tap():
  GPIO.output(ledPin, GPIO.HIGH)  # LED on while working
  otp = file("/ramdisk/otp.txt")
  printer.feed(3)
  for line in otp:
    printer.println(line)  
  printer.feed(3)
  file.close(otp)
  GPIO.output(ledPin, GPIO.LOW)

# Called when button is held down.  Invokes shutdown process.
def hold():
  GPIO.output(ledPin, GPIO.HIGH)
开发者ID:Andrew415,项目名称:otp-gen,代码行数:33,代码来源:otp.py


注:本文中的Adafruit_Thermal.setLineHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。