本文整理汇总了Python中Adafruit_Thermal.upsideDownOn方法的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_Thermal.upsideDownOn方法的具体用法?Python Adafruit_Thermal.upsideDownOn怎么用?Python Adafruit_Thermal.upsideDownOn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adafruit_Thermal
的用法示例。
在下文中一共展示了Adafruit_Thermal.upsideDownOn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import upsideDownOn [as 别名]
printer.println("Bold text")
printer.boldOff()
printer.underlineOn()
printer.println("Regular underlined text")
printer.underlineOff()
printer.underlineOn(2)
printer.println("Heavy underlined text")
printer.underlineOff()
printer.strikeOn()
printer.println("Strike through text")
printer.strikeOff()
printer.upsideDownOn()
printer.println("Upside down ON")
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')
示例2: printImage
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import upsideDownOn [as 别名]
def printImage(fileToPrint, result, timeNow, location):
def imageProcessing(fileToPrint):
img = Image.open(fileToPrint)
img = img.filter(ImageFilter.EDGE_ENHANCE_MORE)
img = img.filter(ImageFilter.SHARPEN)
img = img.filter(ImageFilter.MedianFilter)
img = img.rotate(180)
return img
def getTimeElapsed(fileToPrint):
text = ''
now = datetime.now()
last = parseTimeStamp(fileToPrint)
timeElapsed = now - last
seconds = int(timeElapsed.seconds)
minutes = int(round(seconds/60))
hours = int(round(seconds/3600))
days = int(timeElapsed.days)
# days and hours
if (days > 0):
if (days == 1):
text += str(days)+'day '
else:
text += str(days)+'days '
if (hours > 0):
if (hours == 1):
text += str(hours)+'hour '
else:
text += str(hours)+'hours '
elif (days == 0):
# hours and minutes
if (hours > 0):
if (hours == 1):
text += str(hours)+'hour '
else:
text += str(hours)+'hours '
minutes = minutes - 60*hours
if (minutes > 0):
if (minutes == 1):
text += str(minutes)+'minute '
else:
text += str(minutes)+'minutes '
else:
# minutes and seconds
if (minutes > 0):
if (minutes == 1):
text += str(minutes)+'minute '
else:
text += str(minutes)+'minutes '
seconds = seconds - minutes*60
if (seconds > 0):
if (seconds == 1):
text += str(seconds)+'second '
else:
text += str(seconds)+'seconds '
# seconds
else:
text += str(seconds)+'seconds '
text += 'ago @'+location
return text
def getTimeNow(timeNow):
text ='Printed at '
timeNow = parseTimeStamp(timeNow)
year = timeNow.year
month = timeNow.month
day = timeNow.day
hour = timeNow.hour
minute = timeNow.minute
text += fmt(year)+'.'+fmt(month)+'.'+fmt(day)+' '
text += fmt(hour)+':'+fmt(minute)
return text
image = imageProcessing(fileToPrint)
printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
printer.printImage(image, True) # This does the printing
printer.upsideDownOn()
printer.justify('C')
timeElapsed = getTimeElapsed(result)
printer.println(timeElapsed)
timeNow = getTimeNow(timeNow)
printer.println(timeNow)
printer.upsideDownOff()
printer.feed(3)