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


Python Adafruit_Thermal.upsideDownOn方法代码示例

本文整理汇总了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')
开发者ID:nearengine,项目名称:Python-Thermal-Printer,代码行数:33,代码来源:printertest.py

示例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)
开发者ID:wqz9822,项目名称:PortalCam,代码行数:90,代码来源:lobby.py


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