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


Python Adafruit_Thermal类代码示例

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


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

示例1: main

def main():
    # Get the current time, format it as the file name
    timeNow = makeTimeStamp() 
    fileToSave = savePath + timeNow + EXTENSION
    # Find the unprint picture
    fileList = findFileInOrder()
    if (len(fileList)==0):
        takePicture(fileToSave)
        printImage(fileToSave, timeNow, timeNow, 'lobby')
    else:
        result = getFileToPrint(fileList)
        if result is None:
            takePicture(fileToSave)
            printImage(fileToSave, timeNow, timeNow, 'lobby')
        else:
            fileToPrint = printPath + '/' + result + EXTENSION
            # Take the current picture
            takePicture(fileToSave)
            # Print the unprint picture
            printImage(fileToPrint, result, timeNow, 'A10')
            # Upload the current picture
    try:
        uploadFile(fileToSave, timeNow, EXTENSION) 
    except:
        printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
        printer.println("Error Upload")
开发者ID:wqz9822,项目名称:PortalCam,代码行数:26,代码来源:lobby.py

示例2: printout

def printout():
    if request.method == 'POST':
        printText=request.form['printtext']
        printer      = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
        printer.println(printText)
        printer.feed(10)
        redirect("/printer")
开发者ID:obiwan314,项目名称:k9os,代码行数:7,代码来源:k9webserver.py

示例3: upload_file

def upload_file():
    if request.method == 'POST':
        uploadedFile = request.files['file']
        printer      = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
        printer.printImage(Image.open(uploadedFile), True)
        printer.feed(10)
        redirect("/printer")
开发者ID:obiwan314,项目名称:k9os,代码行数:7,代码来源:k9webserver.py

示例4: get_printer

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

示例5: genAndPrintKeys

def genAndPrintKeys(curbtc, inputamt, numCopies, password, lcd):
	remPubKey = False
	remPrivKey = False

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


	#load a blank image of the paper wallet with no QR codes or keys on it which we will draw on
	finalImg = Image.open("btc-wallet-blank.bmp")
	lcd_display(lcd, "Generating", "address")
	#this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
	import genkeys as btckeys

	btckeys.genKeys()

	if btckeys.keysAreValid == False:
		printer.write("Error: The generated keys (public/private) are not the correct length.  Please try again.")
		
	#import wallet_enc as WalletEnc
	#encrypt the keys if needed
	#if(password != ""):
	#	privkey = WalletEnc.pw_encode(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 to the sqlite db
		con = None
		try:
			con = sqlite3.connect('/home/pi/build/Piper/keys.db3')
		        con.execute("INSERT INTO keys (serialnum, public, private) VALUES (?,?,?)", (snum, sqlitePubKey, sqlitePrivKey))
		except sqlite3.Error, e:
			print "Error %s:" % e.args[0]
			sys.exit(1)
		finally:
开发者ID:Chankster,项目名称:BitBox,代码行数:56,代码来源:piper.py

示例6: genAndPrintKeys

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

示例7: genAndPrintKeys

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)



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

	btckeys.genKeys()

	if btckeys.keysAreValid == False:
		printer.write("Error: The generated keys (public/private) are not the correct length.  Please try again.")
		
	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 to the sqlite db
		con = None
		try:
			con = sqlite3.connect('/home/pi/Printer/keys.db3')
		        con.execute("INSERT INTO keys (serialnum, public, private) VALUES (?,?,?)", (snum, sqlitePubKey, sqlitePrivKey))
		except sqlite3.Error, e:
			print "Error %s:" % e.args[0]
			sys.exit(1)
		finally:
开发者ID:silky,项目名称:Piper,代码行数:53,代码来源:piper.py

示例8: print_image

def print_image(filename):
	printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
        printer.feed(5)
	image = Image.open(filename)
        image = image.rotate(90, expand=1)
        image = ImageEnhance.Contrast(image).enhance(1.3)  # add contrast
	printer.printImage(image, True)
	printer.feed(5)
开发者ID:pwnkip,项目名称:hacks,代码行数:8,代码来源:runcheckout.py

示例9: print_seed

def print_seed(seed):

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

    printer.println(seed)

    printer.feed(3)

    printer.setDefault()  # Restore printer to defaults
开发者ID:aussiehash,项目名称:Piper,代码行数:9,代码来源:piper.py

示例10: encodeQRAndPrint

def encodeQRAndPrint(ttp):
	qrSize = (340, 340)

	finalImg = Image.new("RGB", (384, 440), "white")
	finalImg.paste(getQR(ttp, qrSize), (30, 55))

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

	printer.printImage(finalImg, True)
	
	printer.feed(3)

	printer.setDefault() # Restore printer to defaults
开发者ID:AJamesPhillips,项目名称:Piper,代码行数:13,代码来源:piper.py

示例11: printImage

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

示例12: Adafruit_Thermal

#!/usr/bin/python

from Adafruit_Thermal import *

printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5,
			heattime=255, dtr=18)
printer.reset()
printer.setDefault()
## Test inverse on & off
#printer.inverseOn()
#printer.println("Inverse ON")
#printer.inverseOff()
#
## Test character double-height on & off
#printer.doubleHeightOn()
#printer.println("Double Height ON")
#printer.doubleHeightOff()
#
## Set justification (right, center, left) -- accepts 'L', 'C', 'R'
#printer.justify('R')
#printer.println("Right justified")
#printer.justify('C')
#printer.println("Center justified")
#printer.justify('L')
#printer.println("Left justified")
#
## Test more styles
#printer.boldOn()
#printer.println("Bold text")
#printer.boldOff()
#
开发者ID:lordheart,项目名称:thermy,代码行数:31,代码来源:printertest.py

示例13: Adafruit_Thermal

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

示例14: hold

# http://www.adafruit.com/products/597 Mini Thermal Receipt Printer
# http://www.adafruit.com/products/600 Printer starter pack

from __future__ import print_function
import RPi.GPIO as GPIO
import subprocess, time, Image, socket
from Adafruit_Thermal import *

ledPin       = 18
buttonPin    = 23
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)


# Called when button is briefly tapped.  Invokes time/temperature script.
def tap():
  GPIO.output(ledPin, GPIO.HIGH)  # LED on while working
  subprocess.call(["python", "40in20out_positions.py"])
  GPIO.output(ledPin, GPIO.LOW)


# Called when button is held down.  Prints image, invokes shutdown process.
def hold():
  GPIO.output(ledPin, GPIO.HIGH)
  printer.printImage(Image.open('goodbye40in20out.png'), True)
  printer.feed(3)
  subprocess.call("sync")
开发者ID:strazco,项目名称:40in20out-Printer,代码行数:31,代码来源:mainbk.py

示例15: Adafruit_Thermal

#!/usr/bin/python

from Adafruit_Thermal import *

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

printer.setDefault()
printer.setTimes(33000, 2500)

# 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(1)

printer.sleep()      # Tell printer to sleep
printer.wake()       # Call wake() before printing again, even if reset
printer.setDefault() # Restore printer to defaults
开发者ID:martin-letellier,项目名称:boiteareves,代码行数:28,代码来源:printertestImage.py


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