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


Python Adafruit_Thermal.begin方法代码示例

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


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

示例1: get_printer

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
def get_printer(heat=200):
	global printer
	if printer:
		return printer
	else:
		# open the printer itself
		printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
		printer.begin(200)
开发者ID:ace-n,项目名称:Piper,代码行数:10,代码来源:piper.py

示例2: genAndPrintKeys

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
def genAndPrintKeys(remPubKey, remPrivKey, numCopies, password):


	#open serial number file which tracks the serial number
#	snumfile = open('serialnumber.txt', 'r+')
#	snum = snumfile.read()

	#open the printer itself
	printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
	printer.begin(200)


	#this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
	import genkeys as btckeys

	btckeys.genKeys()

	import wallet_enc as WalletEnc
	#encrypt the keys if needed
	if(password != ""):
		privkey = WalletEnc.pw_encode(btckeys.pubkey, btckeys.privkey, password)
	else:
		privkey = btckeys.privkey


	rememberKeys = False
	sqlitePubKey = ""
	sqlitePrivKey = ""
	strToWrite = ""
	if remPubKey:
		strToWrite = "\nPublic Key: "+btckeys.pubkey
		sqlitePubKey = btckeys.pubkey
		rememberKeys = True

	if remPrivKey:
		strToWrite = strToWrite + "\nPrivate Key: "+privkey
		sqlitePrivKey = privkey
		rememberKeys = True


	if rememberKeys == True:
		#store it in a flat file on the sd card
		f = open("keys.txt", 'a+')
		strToWrite = strToWrite
		f.write(strToWrite);
		f.write("\n---------------------------------\n")
		f.close()



	#do the actual printing
	for x in range(0, numCopies):

		#piper.print_keypair(pubkey, privkey, leftBorderText)
		print_keypair(btckeys.pubkey, privkey)
开发者ID:ryanralph,项目名称:Piper,代码行数:57,代码来源:piper.py

示例3: print_seed

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
def print_seed(seed):

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

    printer.println(seed)

    printer.feed(3)

    printer.sleep()  # Tell printer to sleep
    printer.wake()  # Call wake() before printing again, even if reset
    printer.setDefault()  # Restore printer to defaults
开发者ID:ryanralph,项目名称:DIY-Piper,代码行数:14,代码来源:piper.py

示例4: Adafruit_Thermal

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
from __future__ import print_function
import RPi.GPIO as GPIO
import subprocess, time, Image, socket
from Adafruit_Thermal import *

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

# Print greeting image
# Because the hello/goodbye images are overall fairly light, we can
# get away with using a darker heat time for these, then reset to the
# default afterward.
ht = printer.defaultHeatTime * 2
if(ht > 255): ht = 255

printer.begin(ht) # Set temporary dark heat time
image_file = Image.open('gfx/partlycloudy.gif')
image_100 = image_file.resize((100,100),Image.ANTIALIAS)
image_200 = image_file.resize((200,200),Image.ANTIALIAS)
image_file = image_file.convert('L')
image_100 = image_100.convert('L')
image_200 = image_200.convert('L')
printer.print("Image 50x50")
printer.printImage(image_file, True)
printer.feed(3)
printer.print("Image 100x100")
printer.printImage(image_100, True)
printer.feed(3)
printer.print("Image 200x200")
printer.printImage(image_200, True)
printer.feed(3)
开发者ID:SmartCoda,项目名称:Python-Thermal-Printer,代码行数:32,代码来源:pimage.py

示例5: clamp

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
        toRet = clamp(toRet, outMin, outMax)
        return toRet

def clamp(val, tmin, tmax):
    if val > tmax:
        val = tmax
    if val < tmin:
        val = tmin
    return val


uart.setup("UART2")
adc.setup()
atexit.register(exit_handler)
printer = Adafruit_Thermal("/dev/ttyO2", 19200, timeout=5)
printer.begin()
printer.upsideDownOn()
printer.feed(3)
printer.print(parse('i am awake and I am APPLE (light)'))
printer.feed(1)
rPast = 0
rMax = 0 # all-time max sensor reading
rMin = 100000 # all-time min sensor reading
WINDOW_SIZE = 30 # size of moving-window avg
noop = 0 # number of intervals passed without a trigger
noop_threshold = 480
emission_threshold = 0.1 # changed this for vcnl4000, used to be 0.7

while True:
    checkSensor()
    time.sleep(0.5)
开发者ID:digideskio,项目名称:hotpants,代码行数:33,代码来源:hotpants-photocell.py

示例6: Adafruit_Thermal

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
#
# Prints a series of black bars with increasing "heat time" settings.
# Because printed sections have different "grip" characteristics than
# blank paper, as this progresses the paper will usually at some point
# jam -- either uniformly, making a short bar, or at one side or the
# other, making a wedge shape.  In some cases, the Pi may reset for
# lack of power.
#
# Whatever the outcome, take the last number printed BEFORE any
# distorted bar and enter in in Adafruit_Thermal.py as defaultHeatTime
# (around line 53).
#
# You may need to pull on the paper as it reaches the jamming point,
# and/or just abort the program, press the feed button and take the
# last good number.

from __future__ import print_function
from Adafruit_Thermal import *

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

for i in range(0,256,15):
	printer.begin(i)
	printer.println(i)                 # Print heat time
	printer.inverseOn()
	printer.print('{:^32}'.format('')) # Print 32 spaces (inverted)
	printer.inverseOff()

printer.begin() # Reset heat time to default
printer.feed(4)
开发者ID:AKAMEDIASYSTEM,项目名称:Python-Thermal-Printer,代码行数:32,代码来源:calibrate.py

示例7: hold

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
import RPi.GPIO as GPIO
import subprocess, time, Image, socket, random
from Adafruit_Thermal import *

buttonPin    = 18
holdTime     = 2     # Duration for button hold (shutdown)
tapTime      = 0.01  # Debounce time for button taps
nextInterval = 0.0   # Time of next recurring operation
dailyFlag    = False # Set after daily trigger occurs
lastId       = '1'   # State information passed to/from interval script
printer      = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)


# Initialization

# Use Broadcom pin numbers (not Raspberry Pi pin numbers) for GPIO
GPIO.setmode(GPIO.BCM)

# Enable LED and button (w/pull-up on latter)
GPIO.setup(buttonPin, GPIO.IN)

prevButtonState = GPIO.input(buttonPin)
# Main loop
printer.begin(255)
while(True):
  buttonState = GPIO.input(buttonPin)
  if buttonState != True:
    reve ='reves/reve-'+ str(random.randint(1,3)) +'.png'
    printer.printImage(Image.open(reve), True)
    printer.feed(2)
开发者ID:martin-letellier,项目名称:boiteareves,代码行数:32,代码来源:reves.py

示例8: print_keypair

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
def print_keypair(pubkey, privkey):
    # Specify System Font Location and a font to use
    fontLocation = "/usr/share/fonts/truetype/droid/DroidSansMono.ttf"
    # open the printer itself
    printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
    printer.begin(200)
    finalImgName = "btc"
    coinName = "btc"
    printCoinName = finalImgName == "blank"

    finalImgName += "-wallet"
    # load a blank image of the paper wallet with no QR codes or keys on it which we will draw on
    if len(privkey) > 51:
        finalImgName += "-enc"
    else:
        finalImgName += "-blank"
    finalImgName += ".bmp"

    finalImgFolder = "/home/pi/DIY-Piper/Images/"
    finalImg = Image.open(finalImgFolder + finalImgName)

    # ---begin the public key qr code generation and drawing section---

    # we begin the QR code creation process
    # feel free to change the error correct level as you see fit
    qr = qrcode.QRCode(version=None, error_correction=qrcode.constants.ERROR_CORRECT_H, box_size=10, border=0)

    qr.add_data(pubkey)
    qr.make(fit=True)

    pubkeyImg = qr.make_image()

    # resize the qr code to match our design
    pubkeyImg = pubkeyImg.resize((175, 175), Image.NEAREST)

    font = ImageFont.truetype(fontLocation, 60)
    draw = ImageDraw.Draw(finalImg)

    if printCoinName:
        draw.text((45, 400), coinName, font=font, fill=(0, 0, 0))

    font = ImageFont.truetype(fontLocation, 20)
    startPos = (110, 38)
    charDist = 15
    lineHeight = 23
    lastCharPos = 0

    keyLength = len(pubkey)

    while keyLength % 17 != 0:
        pubkey += " "
        keyLength = len(pubkey)

    # draw 2 lines of 17 characters each.  keyLength always == 34 so keylength/17 == 2
    for x in range(0, keyLength / 17):
        lastCharPos = 0
        # print a line
        for y in range(0, 17):
            theChar = pubkey[(x * 17) + y]
            charSize = draw.textsize(theChar, font=font)

            # if y is 0 then this is the first run of this loop, and we should use startPos[0] for the x coordinate instead of the lastCharPos
            if y == 0:
                draw.text((startPos[0], startPos[1] + (lineHeight * x)), theChar, font=font, fill=(0, 0, 0))
                lastCharPos = startPos[0] + charSize[0] + (charDist - charSize[0])
            else:
                draw.text((lastCharPos, startPos[1] + (lineHeight * x)), theChar, font=font, fill=(0, 0, 0))
                lastCharPos = lastCharPos + charSize[0] + (charDist - charSize[0])

    # draw the QR code on the final image
    finalImg.paste(pubkeyImg, (150, 106))

    # ---end the public key qr code generation and drawing section---

    # ---begin the private key qr code generation and drawing section---

    # we begin the QR code creation process
    # feel free to change the error correct level as you see fit
    qr = qrcode.QRCode(version=None, error_correction=qrcode.constants.ERROR_CORRECT_H, box_size=10, border=0)
    qr.add_data(privkey)
    qr.make(fit=True)

    privkeyImg = qr.make_image()

    # resize the qr code to match our design
    privkeyImg = privkeyImg.resize((220, 220), Image.NEAREST)

    # draw the QR code on the final image
    finalImg.paste(privkeyImg, (125, 560))

    startPos = (110, 807)
    charDist = 15
    lineHeight = 23
    lastCharPos = 0

    keyLength = len(privkey)

    while keyLength % 17 != 0:
        privkey += " "
        keyLength = len(privkey)
#.........这里部分代码省略.........
开发者ID:ryanralph,项目名称:DIY-Piper,代码行数:103,代码来源:piper.py

示例9: Adafruit_Thermal

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
#!/usr/bin/python
from __future__ import print_function
import RPi.GPIO as GPIO
import subprocess, time, Image, socket
from Adafruit_Thermal import *

printer      = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
printer.begin(60)
printer.printImage(Image.open('gfx/hello.png'), True)
printer.print('Hello World blabla blabla blabla')
printer.feed(3)
开发者ID:martin-letellier,项目名称:boiteareves,代码行数:13,代码来源:martin.py

示例10: forecast

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
# Dumps one forecast line to the printer
def forecast(idx):
	tag     = 'yweather:forecast'
	day     = dom.getElementsByTagName(tag)[idx].getAttribute('day')
	lo      = dom.getElementsByTagName(tag)[idx].getAttribute('low')
	hi      = dom.getElementsByTagName(tag)[idx].getAttribute('high')
	cond    = dom.getElementsByTagName(tag)[idx].getAttribute('text')
	printer.print(day + ': low ' + lo )
	printer.print(deg)
	printer.print(' high ' + hi)
	printer.print(deg)
	printer.println(' ' + cond)

printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
printer.begin(heatTime=200)
deg     = chr(0xf8) # Degree symbol on thermal printer

# Fetch forecast data from Yahoo!, parse resulting XML
dom = parseString(urllib.urlopen(
        'http://weather.yahooapis.com/forecastrss?w=' + WOEID).read())

# Print heading
printer.inverseOn()
printer.print('{:^32}'.format(
  dom.getElementsByTagName('description')[0].firstChild.data))
printer.inverseOff()

# Print current conditions
printer.boldOn()
printer.print('{:^32}'.format('Current conditions:'))
开发者ID:lordheart,项目名称:thermy,代码行数:32,代码来源:forecast.py

示例11: get_printer

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import begin [as 别名]
def get_printer(heat=200):
	# open the printer itself
	printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
	printer.begin(heat)
	return printer
开发者ID:uiucsigcoin,项目名称:Piper,代码行数:7,代码来源:piper.py

示例12: Adafruit_Thermal

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

import Image, os, sys
from Adafruit_Thermal import *

printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
printer.begin(75)    # Increase the heat

image_path = sys.argv[1]
os.system('convert ' + image_path + ' -resize 382x764 tmp.png')
printer.printImage(Image.open('tmp.png'), True)
printer.feed(2)
os.system('rm tmp.png')

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,代码行数:19,代码来源:print_image.py


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