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


Python Adafruit_Thermal.setSize方法代码示例

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


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

示例1: generate_post

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import setSize [as 别名]
def generate_post():
    with open('/home/yuri/mashbotv2/cleaned.txt') as f:
        text = f.read()

    text_model = markovify.Text(text, state_size=2)
    mash_text = text_model.make_short_sentence(129) # was 140
    wrapped_text = textwrap.fill(mash_text, 32)
    output_text = "@acoluthon " + mash_text

    printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
    printer.setDefault()
    printer.justify('L')
    printer.feed(3)
    printer.boldOn()
    printer.setSize('M')
    printer.println("Mash Note")
    printer.setSize('S')
    printer.boldOff()
    printer.println(wrapped_text)
    printer.feed(2)

    # Write the status to a file, for debugging
    with open('/home/yuri/mashbotv2/history.txt', 'a') as f:
        f.write('mashed: ' + mash_text + ' | tweeted: ' + output_text + '\n')

    return output_text
开发者ID:hyperrhiz,项目名称:mashbotv2,代码行数:28,代码来源:mashbot.py

示例2:

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import setSize [as 别名]
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')
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)
开发者ID:nearengine,项目名称:Python-Thermal-Printer,代码行数:33,代码来源:printertest.py

示例3: main

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import setSize [as 别名]
def main():
  printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
  deg     = chr(0xf8) # Degree symbol on thermal printer
  events = get_events()

  # Print heading
  printer.setSize('M')
  printer.justify('C')
  printer.println( datetime.datetime.today().date().strftime("%A, %B %-d, %Y") )
  printer.justify('L')
  printer.setSize('S')

  # Print schedule
  printer.boldOn()
  printer.underlineOn()
  printer.justify('C')
  printer.println("Today's Schedule")
  printer.justify('L')
  printer.underlineOff()
  printer.boldOff()

  printer.feed(1)

  if not events:
    printer.println('No scheduled events today.')
    printer.feed(1)
  for event in events:
    start = dateutil.parser.parse(event['start'].get('dateTime', event['start'].get('date'))).strftime("%-I:%M%p")
    end = dateutil.parser.parse(event['end'].get('dateTime', event['end'].get('date'))).strftime("%-I:%M%p")
    location = event.get('location', '')
    printer.println(event['summary'])
    if start == end:
      if location:
        printer.println(start + ", " + location)
      else:
        printer.println(start)
    else:
      if location == "":
        printer.println(start + " - " + end)
      else:
        printer.println(start + " - " + end + ", " + location)
    printer.feed(1)

  printer.feed(1)

  # Print weather
  weather = get_weather()

  printer.boldOn()
  printer.underlineOn()
  printer.justify('C')
  printer.println("Today's Weather")
  printer.justify('L')
  printer.underlineOff()
  printer.boldOff()

  printer.feed(1)

  printer.println("Temperature: " + str(weather.temp_now) + ". Feels like " + str(weather.feels_like_now))
  printer.feed(1)

  printer.println("Today: " + weather.weather_today)
  printer.feed(1)

  printer.println("Tonight: " + weather.weather_tonight)
  printer.feed(1)

  downcase_first = lambda s: s[:1].lower() + s[1:] if s else ''
  printer.println("Tomorrow: " + weather.weather_tomorrow + " Tomorrow night, " + downcase_first(weather.weather_tomorrow_night))
  printer.feed(1)

  printer.feed(2)
开发者ID:zeiv,项目名称:Python-Thermal-Printer,代码行数:74,代码来源:schedule.py

示例4: Adafruit_Thermal

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import setSize [as 别名]
from flask import Flask, request, redirect
from Adafruit_Thermal import *
import twilio.twiml
import logging, socket, sys

printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)

question = str(sys.argv[1])
 
app = Flask(__name__)

printer.setSize('S')
printer.println("listening for messages!")

def thermalPrintMessage(message):
    printer.setSize('S')
    # printer.feed(1)
    printer.println(question)
    printer.setSize('M')
    printer.println(message)
    printer.setSize('S')
    printer.feed(1)
    printer.println('________________________________')

def logMessage(from_number,message):
    logging.warn(from_number+"\t"+message)
 
@app.route("/", methods=['GET', 'POST'])
def hello_monkey():

    message = "Thanks for participating!\n- The Printer Discourse"
开发者ID:jhaip,项目名称:printer_discourse,代码行数:33,代码来源:run.py

示例5: address

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import setSize [as 别名]
printer.printImage(Image.open("gfx/hello.png"), True)
printer.feed(1)
subprocess.call("./timetemp.py")

# Show IP address (if network is available)
try:
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect(("8.8.8.8", 0))
    printer.println("My IP address is " + s.getsockname()[0])
except:
    printer.boldOn()
    printer.println("Network is unreachable.")
    printer.boldOff()

printer.inverseOn()
printer.setSize("L")
printer.println("     INGLES    ")
printer.setSize("S")
printer.inverseOff()

# Google Docs account email, password, and spreadsheet name.
GDOCS_EMAIL = "*******@gmail.com"
GDOCS_PASSWORD = "******"
GDOCS_SPREADSHEET_NAME = "palabras_ingles"


def login_open_sheet(email, password, spreadsheet):
    """Connect to Google Docs spreadsheet and return the first worksheet."""
    try:
        gc = gspread.login(email, password)
        worksheet = gc.open(spreadsheet).sheet1
开发者ID:martinalberto,项目名称:albert-ideas,代码行数:33,代码来源:ingles.py

示例6: Adafruit_Thermal

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import setSize [as 别名]
#!/usr/bin/env python

from Adafruit_Thermal import *
import sys

printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
printer.setDefault() # Restore printer to defaults

printer.setSize('S') # Small font size

# Print out what was piped in
text = sys.stdin.read() 
printer.println(text)
printer.feed(1)

printer.sleep()      # Tell printer to sleep
printer.wake()       # Call wake() before printing again, even if reset
printer.setDefault() # Restore printer to defaults
开发者ID:exploration,项目名称:compliment-bot,代码行数:20,代码来源:print_text.py

示例7: Adafruit_Thermal

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import setSize [as 别名]
#!/usr/bin/python

import sys
sys.path.append("/home/pi/git/Python-Thermal-Printer")

import Image
from Adafruit_Thermal import *

printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)

printer.justify('C')
printer.boldOn()
printer.setSize('L')
printer.println("Tim Sucks")
printer.feed(1)

image = Image.open('gfx/art.png')
image = image.rotate(90,expand=1)
(width, height) = image.size
scaledWidth = 384
scaleRatio = scaledWidth / width
scaledHeight = int(height * scaledWidth / width)
image = image.resize((scaledWidth,scaledHeight))
printer.printImage(image,True)

printer.feed(1)
printer.setDefault() # Restore printer to defaults
开发者ID:pwnkip,项目名称:hacks,代码行数:29,代码来源:printImage.py


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