本文整理汇总了Python中EPD.EPD.update方法的典型用法代码示例。如果您正苦于以下问题:Python EPD.update方法的具体用法?Python EPD.update怎么用?Python EPD.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EPD.EPD
的用法示例。
在下文中一共展示了EPD.update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import update [as 别名]
def main():
"""main program - display list of images"""
epd = EPD()
epd.clear()
print(
"panel = {p:s} {w:d} x {h:d} version={v:s} COG={g:d} FILM={f:d}".format(
p=epd.panel, w=epd.width, h=epd.height, v=epd.version, g=epd.cog, f=epd.film
)
)
while True:
for cam in cams:
fp = urllib2.urlopen(cam)
file_name = cStringIO.StringIO(fp.read())
image = Image.open(file_name)
image = ImageOps.grayscale(image)
rs = image.resize((epd.width, epd.height))
bw = rs.convert("1", dither=Image.FLOYDSTEINBERG)
epd.display(bw)
epd.update()
time.sleep(5) # delay in seconds
示例2: main_display
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import update [as 别名]
def main_display():
from EPD import EPD
epd = EPD()
#epd.clear()
previous_messages = []
while True:
try:
messages = json.loads(urllib2.urlopen("http://fjas.no:8181/messages").read())
except: #urllib2.URLError:
print "Got problems, sleeping 13s"
time.sleep(13)
continue
#messages = [ { 'x': 25, 'y': 70, 'text':'hei på deg', 'fontsize': 22 } ]
if not listsDifferent(messages, previous_messages):
print "No change, sleeping 1.3s"
time.sleep(1.300)
continue
previous_messages = messages
print "Got new message, updating screen"
image = getImage(epd.size, messages)
epd.display(image)
epd.update()
示例3: render
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import update [as 别名]
def render(self):
fin = self.img.rotate(90)
# fin.save("halibut.png", 'png')
epd = EPD()
epd.clear()
epd.display(fin)
epd.update()
示例4: send_to_display
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import update [as 别名]
def send_to_display(canvas):
try:
epd = EPD()
epd.display(canvas)
epd.update()
except IOError:
print("EPD not supported")
canvas.show()
示例5: demo
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import update [as 别名]
def demo(now):
epd = EPD('/dev/epd')
#print('panel = {p:s} {w:d} x {h:d} version={v:s} COG={g:d}'.format(p=epd.panel, w=epd.width, h=epd.height, v=epd.version, g=epd.cog))
#epd.clear()
#font = ImageFont.truetype("freesansbold.ttf", 12)
font = ImageFont.truetype('/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf', 56)
image = Image.new('1', epd.size, WHITE)
draw = ImageDraw.Draw(image)
draw.text((30, 30), '%s' % now.strftime('%H:%M'), fill=BLACK, font=font)
epd.display(image)
epd.update()
示例6: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import update [as 别名]
def main(argv):
"""main program - display image"""
# print('panel = {p:s} {w:d} x {h:d} version={v:s} COG={g:d} FILM={f:d}'.format(p=epd.panel, w=epd.width, h=epd.height, v=epd.version, g=epd.cog, f=epd.film))
# open image and convert to grayscale
image = Image.open(sys.argv[1])
image = ImageOps.grayscale(image)
# convert to 8-bit format
bw = image.convert("1", dither=Image.FLOYDSTEINBERG)
# display the image
epd = EPD()
epd.display(bw)
epd.update()
示例7: display_file
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import update [as 别名]
def display_file(file_name):
epd = EPD()
epd.clear()
print('panel = {p:s} {w:d} x {h:d} version={v:s}'.format(p=epd.panel, w=epd.width, h=epd.height, v=epd.version))
# Open image and convert to black and white
image = PImage.open(file_name)
image = PImageOps.grayscale(image)
# Cropping the image as too large to display on panel.
# Note: the height and width are backwards on purpose as I am forcing it to portrait and rotate the image a bit further down
# (I couldn't get xhtml2pdf to recognise the flag in the html style sheet, but could be the version of the lib...)
cropped = image.crop((0, 0, epd.height, epd.width))
bw = cropped.convert("1", dither=PImage.FLOYDSTEINBERG)
bw = bw.rotate(90)
epd.display(bw)
epd.update()
示例8: EPD
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import update [as 别名]
from PIL import Image
from PIL import ImageDraw
from EPD import EPD
import commands
WHITE = 1
BLACK = 0
epd = EPD()
epd.clear()
# initially set all white background
image = Image.new('1', epd.size, WHITE)
# prepare for drawing
draw = ImageDraw.Draw(image)
# stuff
output = commands.getoutput('hostname -I');
# text
draw.text((30, 30), output, fill=BLACK)
epd.display(image)
epd.update()
示例9: __init__
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import update [as 别名]
class PiBus:
options = None
scheduler = None
currentJSON = None
logger = None
session = None
fontTiny = None
fontMedium = None
fontLarge = None
fontHuge = None
panel = None
partialCount = None
lastFetchTime = None
renderSuspended = None
def __init__(self, options, scheduler):
self.options = options
self.scheduler = scheduler
self.logger = logging.getLogger("PiBus")
self.session = requests.Session()
if options.debug:
self.logger.setLevel(logging.DEBUG)
self.logger.debug("Command line options: %s" % self.options)
if not self.options.busStopID or not self.options.busLine:
self.logger.error("You must provide both bus stop and bus route")
sys.exit(1)
self.partialCount = 0
self.renderSuspended = False
self.fontTiny = ImageFont.truetype("font.ttf", size=10)
self.fontMedium = ImageFont.truetype("font.ttf", size=20)
self.fontLarge = ImageFont.truetype("font.ttf", size=75)
self.fontHuge = ImageFont.truetype("font.ttf", size=150)
try:
self.panel = EPD()
self.logger.debug("Panel: {w:d}x{h:d}".format(w=self.panel.width,
h=self.panel.height))
except Exception as e:
self.panel = None
self.logger.warn("No panel found: %s" % e)
self.scheduler.add_job(self.updateBusInfo,
trigger='interval',
seconds=30,
next_run_time=datetime.datetime.now(),
max_instances=1)
self.scheduler.add_job(self.renderBusInfo,
trigger='interval',
seconds=10,
next_run_time=datetime.datetime.now(),
max_instances=1)
def prettifyJSON(self, jsonText):
"""Neatly format JSON to make it human readable"""
return json.dumps(jsonText, sort_keys=True, indent=4,
separators=(',', ': '))
def fetchBusJSON(self, baseURL, stopID):
"""Fetch the JSON for a bus stop"""
try:
url = "%s/StopPoint/%s/arrivals" % (baseURL, stopID)
self.logger.debug("Fetching: %s" % url)
result = self.session.get(url, timeout=20)
except Exception as e:
self.logger.error("fetchBusJSON error. Stop %s: %s" % (stopID, e))
return None
jsonResult = result.json()
self.logger.debug("Raw JSON: %s" % self.prettifyJSON(jsonResult))
return jsonResult
def updateBusInfo(self):
"""Update the bus information"""
rawJSON = self.fetchBusJSON(self.options.baseURL,
self.options.busStopID)
if not rawJSON:
self.currentJSON = None
self.lastFetchTime = -1
return False
self.currentJSON = []
for busItem in rawJSON:
if busItem[u'lineName'].lower() == \
self.options.busLine.lower():
self.currentJSON.append(busItem)
self.lastFetchTime = time.strftime("%H:%M:%S %d/%m/%Y",
time.localtime())
return True
def getTimes(self):
"""Fetch the number of minutes until each bus is due"""
#.........这里部分代码省略.........