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


Python Adafruit_Thermal.sleep方法代码示例

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


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

示例1: print_seed

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import sleep [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

示例2: wake

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import sleep [as 别名]
##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)

#import gfx.aaa as smile
#printer.printBitmap(smile.width, smile.height, smile.data, LaaT=True)

#import gfx.dither as smile
#printer.printBitmap(smile.width, smile.height, smile.data, LaaT=True)
from PIL import Image
imgpath = "static/symbols/aaa.png"
symbolimg = Image.open(imgpath)
printer.printImage(symbolimg)
#print("printed")

## Print the 135x135 pixel QR code in adaqrcode.py
#import gfx.adaqrcode as adaqrcode
#printer.printBitmap(adaqrcode.width, adaqrcode.height, adaqrcode.data)
#printer.println("Adafruit!")
#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:lordheart,项目名称:thermy,代码行数:32,代码来源:printertest.py

示例3:

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import sleep [as 别名]
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)

# Print the 135x135 pixel QR code in adaqrcode.py
import gfx.adaqrcode as adaqrcode
printer.printBitmap(adaqrcode.width, adaqrcode.height, adaqrcode.data)
printer.println("Adafruit!")
printer.feed(3)

# Reset printer
printer.setDefault()
printer.flush()
printer.sleep()
开发者ID:nearengine,项目名称:Python-Thermal-Printer,代码行数:31,代码来源:printertest.py

示例4: print_keypair

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import sleep [as 别名]

#.........这里部分代码省略.........

#---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_M,
	    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)


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

	keyLength = len(privkey)

#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 = privkey[(x*17)+y]
			charSize = draw.textsize(theChar, font=font)
			#print charSize
			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(privkeyImg, (125, 560))

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



#create the divider
	rightMarkText = "Piperwallet.com"


	font = ImageFont.truetype("/usr/share/fonts/ttf/swansea.ttf", 20)

	rightMarkSize = draw.textsize(rightMarkText, font=font)

	rightMarkOrigin = (384-rightMarkSize[0]-10, 10)


	dividerLineImg = Image.open("/home/pi/Printer/dividerline.bmp")
#font = ImageFont.truetype("/home/pi/Helvetica.ttf", 20)
	draw = ImageDraw.Draw(dividerLineImg)

	draw.text(rightMarkOrigin,rightMarkText, font=font, fill=(255,255,255))





#do the actual printing

	printer.printImage(finalImg)

	printer.printChar(privkey[:17]+"\n")
	printer.justify('R')
	printer.printChar(privkey[17:34]+"\n")
	printer.justify('L')
	printer.printChar(privkey[34:]+"\n")

	#print the divider line
	time.sleep(0.4)
	printer.printImage(dividerLineImg)
	
	#print some blank space so we can get a clean tear of the paper
	time.sleep(0.4)
	printer.feed(1)
	time.sleep(0.4)
	printer.feed(1)
	time.sleep(0.4)
	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:piperwallet,项目名称:electrum,代码行数:104,代码来源:piper.py

示例5: print_keypair

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import sleep [as 别名]

#.........这里部分代码省略.........

#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_M,
	    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)


#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 = privkey[(x*17)+y]
			charSize = draw.textsize(theChar, font=font)
			#print charSize
			if y == 0:
				draw.text((startPos[0],startPos[1]+(lineHeight*x)),theChar, font=font, fill=0)
				lastCharPos = startPos[0]+charSize[0]+(charDist-charSize[0])
			else:
				draw.text((lastCharPos,startPos[1]+(lineHeight*x)),theChar, font=font, fill=0)
				lastCharPos = lastCharPos + charSize[0] + (charDist-charSize[0])

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



#create the divider
	rightMarkText = "ArchReactor.org"


	font = ImageFont.truetype("/usr/share/fonts/ttf/swansea.ttf", 20)

	rightMarkSize = draw.textsize(rightMarkText, font=font)

	leftMarkOrigin = (10, 15)
	rightMarkOrigin = (384-rightMarkSize[0]-10, 15)

	dividerLineImg = Image.open("/home/pi/build/Piper/dividerline.bmp")
    
	draw = ImageDraw.Draw(dividerLineImg)    
	draw.text(leftMarkOrigin, leftBorderText, font=font, fill=0)
	draw.text(rightMarkOrigin,rightMarkText, font=font, fill=0)


	#finalImg.save('file.png')
	#dividerLineImg.save('file2.png')
    #do the actual printing
	usd = 1.0/float(curbtc)
	returnamt = usd*float(inputamt)
	printer.println("1BTC=$"+str(curbtc))
	printer.println("1USD=B"+str(usd))
	printer.println("Input=$"+str(inputamt))
	printer.println("Return=B"+str(returnamt))
	printer.println("Transaction Hash: "+str(tx_hash))
	printer.printImage(finalImg)
	
	#if(len(privkey) <= 51):
	#	printer.println(privkey[:17]+"\n")
	#	printer.justify('R')
	#	printer.println(privkey[17:34]+"\n")
	#	printer.justify('L')
	#	printer.println(privkey[34:]+"\n")
	#else:
	#	printer.println(privkey)

	#print the divider line
	printer.printImage(dividerLineImg)
	
	#print some blank space so we can get a clean tear of the paper
	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:Chankster,项目名称:BitBox,代码行数:104,代码来源:piper.py

示例6: print_keypair

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import sleep [as 别名]

#.........这里部分代码省略.........
    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)

    # 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 = privkey[(x * 17) + y]
            charSize = draw.textsize(theChar, font=font)
            # print charSize
            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])

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

    # do the actual printing

    printer.printImage(finalImg, True)

    # print some blank space so we can get a clean tear of the paper
    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,代码行数:104,代码来源:piper.py


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