本文整理汇总了Python中EPD.EPD类的典型用法代码示例。如果您正苦于以下问题:Python EPD类的具体用法?Python EPD怎么用?Python EPD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EPD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main_display
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()
示例2: main
def main(argv):
"""main program - display logo, report product details, test led, optional test buttons
print 'Number of arguments:', len(sys.argv)
print 'Argument List:', str(sys.argv)"""
try:
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))
for file_name in argv:
if not os.path.exists(file_name):
sys.exit('error: image file{f:s} does not exist'.format(f=file_name))
print('display: {f:s}'.format(f=file_name))
display_file(epd, file_name)
print ('Now some text')
display_eedata(epd)
print ('Next we test the LED')
led_test()
if (argv[1] == 'y' or argv[1] == 'Y'):
print ('Left button press flashes red, right button press flashes green, CONTROL-C to exit')
button_test()
else:
print ('Buttons not tested')
except KeyboardInterrupt:
print"\nControl-C pressed.\n"
示例3: main
def main(argv):
"""main program - draw and display a test image"""
try:
objects = int(argv[0])
except ValueError:
sys.exit('object count is not an integer: {o:s}'.format(o=argv[0]))
if objects < 1 or objects > MAX_OBJECTS:
sys.exit('object count is out of range [1..{m:d}: {o:d}'.format(m=MAX_OBJECTS, o=objects))
try:
frames = int(argv[1])
except ValueError:
sys.exit('frame count is not an integer: {f:s}'.format(f=argv[1]))
if frames < 1 or frames > MAX_FRAMES:
sys.exit('frame count is out of range [1..{m:d}: {f:d}'.format(m=MAX_FRAMES, o=frames))
epd = EPD()
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))
epd.clear()
demo(epd, objects, frames)
示例4: main_program
def main_program():
"""main program - draw HH:MM clock on 2.70" size panel"""
global settings
global owm
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
while True:
if os.path.isfile("/dev/epd/version"):
logger.debug("epd..ok!")
break
else:
logger.debug("epd init..")
time.sleep(1)
logger.debug("qock start!")
logger.debug("current path=" + str(os.getcwd()))
epd = EPD()
logger.debug('panel={p:s} width={w:d} height={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))
if 'EPD 2.7' == epd.panel:
settings = Settings27()
else:
logger.debug('incorrect panel size')
sys.exit(1)
epd.clear()
owm = pyowm.OWM(owm_config.weather_api_key)
initGPIO()
loop(epd, settings)
示例5: send_to_display
def send_to_display(canvas):
try:
epd = EPD()
epd.display(canvas)
epd.update()
except IOError:
print("EPD not supported")
canvas.show()
示例6: main
def main(argv):
"""main program - draw and display a test image"""
epd = EPD()
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))
epd.clear()
demo(epd)
示例7: initialise_display
def initialise_display ():
epd = EPD()
logger.debug(('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)))
if 'EPD 2.7' != epd.panel:
logger.error('incorrect panel size')
print('incorrect panel size')
sys.exit(1)
epd.clear()
示例8: main
def main(argv):
"""main program - draw and display a test image"""
epd = EPD()
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
)
)
epd.clear()
demo(epd)
示例9: main
def main(argv):
"""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))
for file_name in argv:
if not os.path.exists(file_name):
sys.exit('error: image file{f:s} does not exist'.format(f=file_name))
print('display: {f:s}'.format(f=file_name))
display_file(epd, file_name)
示例10: demo
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()
示例11: main
def main(argv):
"""main program - draw HH:MM clock on 2.70" size panel"""
epd = 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))
if 'EPD 2.7' != epd.panel:
print('incorrect panel size')
sys.exit(1)
epd.clear()
demo(epd)
示例12: main
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()
示例13: main
def main():
"""main program - draw and display a test image"""
now = datetime.today()
epd = EPD()
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))
epd.clear()
# initially set all white background
image = Image.new('1', epd.size, WHITE)
# prepare for drawing
draw = ImageDraw.Draw(image)
width, height = image.size
font = ImageFont.truetype(FONT_FILE, FONT_SIZE)
ethaddr = get_ip_address('eth0')
draw.rectangle((0, 0, width, height), fill=WHITE, outline=WHITE)
draw.text((0, 0), '{c:s}'.format(c=ethaddr), fill=BLACK, font=font)
draw.text((5, 20), '{h:02d}:{m:02d}:{s:02d}'.format(h=now.hour, m=now.minute, s=now.second), fill=BLACK, font=font)
# display image on the panel
epd.display(image)
epd.partial_update()
示例14: main
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
示例15: main
def main(argv):
"""main program - draw and display a test image"""
try:
start = int(argv[0])
except ValueError:
sys.exit('start is not an integer: {s:s}'.format(s=argv[0]))
if start < 0 or start > MAX_START:
sys.exit('object count is out of range [0..0x{m:04x}: 0x{s:04x}'.format(m=MAX_START, s=start))
epd = EPD()
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))
epd.clear()
demo(epd, start)