本文整理汇总了Python中Adafruit_Thermal.print方法的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_Thermal.print方法的具体用法?Python Adafruit_Thermal.print怎么用?Python Adafruit_Thermal.print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adafruit_Thermal
的用法示例。
在下文中一共展示了Adafruit_Thermal.print方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Adafruit_Thermal
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
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)
printer.begin() # Reset default heat time
示例2: print
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
#print("Message Action:", i[3])
#print('')
#print("Message #:", i[0])
print(i[1])
#print("Message Type:", i[2])
print(i[2])
print(i[3])
print('')
if i[2] == "T":
#printer.doubleWidthOn()
#printer.inverseOn()
printer.printImage(Image.open('40in20out_trade.bmp'), True)
printer.feed(1)
printer.inverseOn()
printer.print ('{:<32}'.format(i[1]))
#printer.print(i[1])
printer.inverseOff()
printer.feed(1)
printer.boldOn()
printer.print(i[3])
printer.boldOff()
#printer.doubleWidthOff()
printer.feed(3)
if i[2] == "2":
#printer.doubleWidthOn()
#printer.inverseOn()
printer.printImage(Image.open('40in20out_2min.bmp'), True)
printer.feed(1)
printer.inverseOn()
示例3: button
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
# Enable LED and button (w/pull-up on latter)
GPIO.setup(ledPin, GPIO.OUT)
GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# LED on while working
GPIO.output(ledPin, GPIO.HIGH)
# Processor load is heavy at startup; wait a moment to avoid
# stalling during greeting.
time.sleep(30)
# 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.print('Welcome to the Tatadada Table! \n My IP address is ' + s.getsockname()[0])
printer.feed(3)
except:
printer.boldOn()
printer.println('Network is unreachable.')
printer.boldOff()
printer.print('Connect display and keyboard\n'
'for network troubleshooting.')
printer.feed(3)
exit(0)
# Print greeting image
# printer.printImage(Image.open('gfx/welcome.png'), True)
# printer.feed(3)
printer.printImage(Image.open('gfx/logo-tatadada.png'), True)
示例4: button
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
# Enable LED and button (w/pull-up on latter)
GPIO.setup(ledPin, GPIO.OUT)
GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# LED on while working
GPIO.output(ledPin, GPIO.HIGH)
# Processor load is heavy at startup; wait a moment to avoid
# stalling during greeting.
# time.sleep(30)
# Print greeting image
printer.feed(1)
printer.printImage(Image.open('40in20out_logo.bmp'), True)
printer.feed(1)
printer.print("40in20out")
printer.feed(1)
printer.print("Presented by...")
printer.feed(1)
printer.printImage(Image.open('totemasset_logo.bmp'), True)
printer.feed(2)
GPIO.output(ledPin, GPIO.LOW)
# 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.print('My IP address is ' + s.getsockname()[0])
ip = s.getsockname()[0]
printer.feed(3)
except:
示例5: timedelta
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
None,
{'Host' : host,
'User-Agent' : agent,
'Accept-Encoding' : 'gzip',
'Authorization' : 'Bearer ' + token})
# Display results. ---------------------------------------------------------
maxId = data['search_metadata']['max_id_str']
for tweet in data['statuses']:
printer.doubleWidthOn()
#printer.inverseOn()
printer.print(' ' + '{:<31}'.format(tweet['user']['screen_name']))
#print (' ' + '{:<31}'.format(tweet['user']['screen_name']))
printer.doubleWidthOff()
printer.inverseOn()
#printer.print('{:<32}'.format(tweet['created_at']))
clean_timestamp = datetime.strptime(tweet['created_at'],'%a %b %d %H:%M:%S +0000 %Y')
offset_hours = -5 #offset in hours for CST/EST timezone
#account for offset from UTC using timedelta
local_timestamp = clean_timestamp + timedelta(hours=offset_hours)
#convert to am/pm format for easy reading
final_timestamp = datetime.strftime(local_timestamp,'%Y-%m-%d %I:%M:%S %p')
final_timestamp = datetime.strftime(local_timestamp,'%a %b %d %I:%M:%S %p')
#print ('{:<32}'.format(tweet['created_at']))
printer.print ('{:<32}'.format(final_timestamp))
printer.inverseOff()
示例6: address
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
GPIO.setup(ledPin, GPIO.OUT)
GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# LED on while working
GPIO.output(ledPin, GPIO.HIGH)
# Processor load is heavy at startup; wait a moment to avoid
# stalling during greeting.
time.sleep(5)
if logonFlag == False:
# hit the url
url = "http://www.40in20out.com/boxlogon.asp?action=LOGON&boxid=" + cBoxID
queryString = urllib.urlopen(url).read()
printer.print(queryString)
printer.feed(1)
logonFlag = True
# 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.print('IP address: ' + s.getsockname()[0])
ip = s.getsockname()[0]
printer.feed(1)
except:
printer.boldOn()
printer.println('Network is unreachable.')
printer.boldOff()
示例7: str
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
printer.print(day + ': low ' + str(lo) )
printer.print(deg)
printer.print(' high ' + str(hi))
printer.print(deg)
printer.println(' ' + cond.replace(u'\u2013', '-').encode('utf-8')) # take care of pesky unicode dash
printer = Adafruit_Thermal("/dev/serial0", 19200, timeout=5)
deg = chr(0xf8) # Degree symbol on thermal printer
url = "https://api.darksky.net/forecast/"+API_KEY+"/"+LAT+","+LONG+"?exclude=[alerts,minutely,hourly,flags]&units=us"
response = urllib.urlopen(url)
data = json.loads(response.read())
# Print heading
printer.inverseOn()
printer.print('{:^32}'.format("DarkSky.Net Forecast"))
printer.inverseOff()
# Print current conditions
printer.boldOn()
printer.print('{:^32}'.format('Current conditions:'))
printer.boldOff()
temp = data['currently']['temperature']
cond = data['currently']['summary']
printer.print(temp)
printer.print(deg)
printer.println(' ' + cond)
printer.boldOn()
示例8: Adafruit_Thermal
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
sensor_pin = 'P9_40'
extreme_lo = ['dark','inky','shadowed','midnight''black','sinister','dour','glowering','glum','moody','morose','saturnine','sour','sullen','benighted','obscure','blue','dingy','disconsolate','dismal','gloomy','grim','sorry','drab','drear','dreary','colored','coloured','dark-skinned','non-white','depressing','dispiriting']
mid_lo = ['shady','dim','grey','faint','weak','dim','shadowy','vague','wispy','feeble','light','swooning','light-headed','lightheaded','fainthearted','timid','faint-hearted','cloudy','muddy','murky','turbid']
mid_hi = ['light','shiny','clear','lustrous','diaphanous','filmy','gauze-like','gossamer','see-through','sheer','transparent','vaporous','vapourous','cobwebby']
extreme_hi = ['blinding','superbright','brilliant','vivid','brilliant','vivid','smart','burnished','lustrous','shining','shiny','undimmed','promising','sunny','sunshiny']
preamble = ['Now it is hella ','Oh, just a bit ','It is quite ','Gosh it is ','Well looky here, it is ','Suddenly: ','Call the police, it is ','After awhile: ','Things have changed; now it\'s more ']
v = vcnl.VCNL4000()
printer = Adafruit_Thermal("/dev/ttyO2", 19200, timeout=5)
printer.begin()
printer.upsideDownOn()
printer.feed(1)
printer.print('i am awake and i am dreaming')
printer.feed(1)
printer.print(str(time.ctime()))
printer.feed(1)
rPast = 0
emission_threshold = 100
def parseLen(text):
L = []
# add newlines to cause text to print properly
# we need this because we're printing upside-down text
# "call the police, it is faint-hearted" should be printed as
# "rted" then linebreak then "Call the police, it is faint-hea"
# which is "rted\nCall the police, it is faint-hea"
if len(text) > Adafruit_Thermal.maxColumn: # 32 is defined by the printer; max chars per line
示例9: Adafruit_Thermal
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [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/tty.NoZAP-PL2303-00005014", 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)
示例10: Adafruit_Thermal
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
printer.print(' / Max. ' + hi)
printer.print(deg)
printer.feed(1)
printer.println(conditions[int(cond)])
printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
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?u=' + tempUnit +
'&w=' + WOEID).read())
# Print heading
printer.inverseOn()
printer.print('{:^32}'.format(
dom.getElementsByTagName('description')[0].firstChild.data))
printer.feed(1)
printer.inverseOff()
# Print current conditions
printer.feed(1)
printer.boldOn()
printer.print('{:^32}'.format('Weersomstandigheden:'))
printer.boldOff()
printer.print(dom.getElementsByTagName('pubDate')[0].firstChild.data)
temp = dom.getElementsByTagName('yweather:condition')[0].getAttribute('temp')
cond = dom.getElementsByTagName('yweather:condition')[0].getAttribute('code')
printer.feed(1)
printer.boldOn()
printer.print(temp)
printer.print(deg)
示例11: Adafruit_Thermal
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [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)
示例12: Adafruit_Thermal
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
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)
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:"))
printer.boldOff()
printer.print("{:^32}".format(dom.getElementsByTagName("pubDate")[0].firstChild.data))
temp = dom.getElementsByTagName("yweather:condition")[0].getAttribute("temp")
cond = dom.getElementsByTagName("yweather:condition")[0].getAttribute("text")
printer.print(temp)
printer.print(deg)
printer.println(" " + cond)
printer.boldOn()
# Print forecast
示例13: print
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
except:
print(lastId)
exit(0)
# Display results. ---------------------------------------------------------
maxId = data['search_metadata']['max_id_str']
for tweet in data['statuses']:
decoded_text = unidecode(HTMLParser.HTMLParser().unescape(tweet['text']))
if (ignore_replies and decoded_text[0] == '@'):
continue
printer.inverseOn()
printer.print(' ' + '{:<31}'.format(tweet['user']['screen_name']))
printer.inverseOff()
printer.underlineOn()
printer.print('{:<32}'.format(tweet['created_at']))
printer.underlineOff()
# max_id_str is not always present, so check tweet IDs as fallback
id = tweet['id_str']
if(id > maxId): maxId = id # String compare is OK for this
# Remove HTML escape sequences
# and remap Unicode values to nearest ASCII equivalents
printer.print(decoded_text)
printer.feed(3)
示例14: mapVals
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
def mapVals(val, inMin, inMax, outMin, outMax):
toRet = float(outMin + float(outMax - outMin) * float(float(val - inMin) / float(inMax - inMin)))
return clamp(toRet, outMin, outMax)
def clamp(val, tmin, tmax):
if val > tmax:
val = tmax
if val < tmin:
val = tmin
return val
uart.setup("UART2")
printer = Adafruit_Thermal("/dev/ttyO2", 19200, timeout=5)
printer.begin()
printer.upsideDownOn()
printer.feed(3)
printer.print(parse('i am awake and I am MUG (thermal)'))
printer.feed(1)
rPast = 0
rMax = 0 # all-time max sensor reading
rMin = 0 # 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.7
while True:
checkSensor()
time.sleep(0.5)
示例15: mapVals
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import print [as 别名]
def mapVals(val, inMin, inMax, outMin, outMax):
toRet = float(outMin + (float(outMax - outMin) * (float(val - inMin) / float(inMax - inMin))))
# return 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")
printer = Adafruit_Thermal("/dev/ttyO2", 19200, timeout=5)
printer.begin()
printer.upsideDownOn()
printer.feed(3)
printer.print(parse('i am awake and I am BLOCKS (presence)'))
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 = 5 # changed this for vcnl4000, used to be 0.7
while True:
checkSensor()
time.sleep(0.5)