本文整理汇总了Python中EPD.EPD.clear方法的典型用法代码示例。如果您正苦于以下问题:Python EPD.clear方法的具体用法?Python EPD.clear怎么用?Python EPD.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EPD.EPD
的用法示例。
在下文中一共展示了EPD.clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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)
示例2: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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()
示例3: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [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
示例4: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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"
示例5: main_program
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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)
示例6: render
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
def render(self):
fin = self.img.rotate(90)
# fin.save("halibut.png", 'png')
epd = EPD()
epd.clear()
epd.display(fin)
epd.update()
示例7: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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)
示例8: initialise_display
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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()
示例9: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
def main():
"""main program - draw and display a test image"""
conf = get_config()
apikey = conf["weather"]["apikey"]
urlbase = conf["weather"]["urlbase"]
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)
wfont = ImageFont.truetype(FONT_FILE, FONT_SIZE/2)
counter = get_ip_address('eth0')
cities = conf["weather"]["cities"]
while True:
for city in cities:
weather = get_weather(city, urlbase, apikey)
temp = u"%d°C" % (weather["main"]["temp"] - 273.15)
fp = urllib2.urlopen(weather["iconlink"])
f = cStringIO.StringIO(fp.read())
pic = Image.open(f)
pic = ImageOps.grayscale(pic)
rs = pic.resize((epd.width/2, epd.height/2))
bw = rs
now = datetime.today()
draw.rectangle((0, 0, width, height), fill=WHITE, outline=WHITE)
draw.text((0, 150), '{c:s}'.format(c=counter), fill=BLACK, font=wfont)
draw.text((0, 160), '{h:02d}:{m:02d}:{s:02d}'.format(h=now.hour, m=now.minute, s=now.second), fill=BLACK, font=wfont)
draw.text((0, 0), weather["name"], fill=BLACK, font=font)
draw.text((0, 20), temp, fill=BLACK, font=font)
draw.text((0, 50), weather["weather"][0]["description"], fill=BLACK, font=font)
image.paste(bw, (epd.width - epd.width/2, epd.height - epd.height/2))
# display image on the panel
epd.display(image)
epd.partial_update()
time.sleep(10)
示例10: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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)
示例11: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
def main():
"""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()
# 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)
wfont = ImageFont.truetype(FONT_FILE, FONT_SIZE/2)
counter = get_ip_address('eth0')
lmin = datetime.today().minute
conf = get_config()
while True:
for rss_url in conf["RSS"]:
feed = feedparser.parse(rss_url)
for item in feed["items"]:
now = datetime.today()
draw.rectangle((0, 0, width, height), fill=WHITE, outline=WHITE)
draw.text((0, 150), '{c:s}'.format(c=counter), fill=BLACK, font=wfont)
draw.text((0, 160), '{h:02d}:{m:02d}:{s:02d}'.format(h=now.hour, m=now.minute, s=now.second), fill=BLACK, font=wfont)
ttl = strip_tags(item["title"])
ttl.strip()
sum = strip_tags(item["summary"])
sum.strip()
y = -20
for line in textwrap.wrap(ttl, 20):
y += 20
if y < 150:
draw.text((0, y), line, fill=BLACK, font=font)
y += 10
for line in textwrap.wrap(sum, 40):
y += 10
if y < 150:
draw.text((0, y), line, fill=BLACK, font=wfont)
# display image on the panel
epd.display(image)
epd.partial_update()
time.sleep(30)
示例12: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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)
示例13: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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)
示例14: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
def main():
# initialize EPD
epd = EPD()
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
# load font
font = ImageFont.truetype(FONT_FILE, FONT_SIZE)
# initialize image
draw.rectangle((0, 0, width, height), fill=WHITE, outline=WHITE)
# read data files
output_in = subprocess.check_output(["cat", FILE_TEMPERATURE_INSIDE])
output_out = subprocess.check_output(["cat", FILE_TEMPERATURE_OUTSIDE])
# insert image inside
in_image = Image.open(FILE_IMAGE_INSIDE)
resized_image = in_image.resize((70,70))
bw_rs_image = resized_image.convert("1", dither=Image.FLOYDSTEINBERG)
offset = 0, 0
image.paste(bw_rs_image, offset)
# insert image outside
out_image = Image.open(FILE_IMAGE_OUTSIDE)
resized_image = out_image.resize((70,70))
bw_rs_image = resized_image.convert("1", dither=Image.FLOYDSTEINBERG)
offset = 0, (height/2)
image.paste(bw_rs_image, offset)
# Draw data to image
# Add degree by adding "+ chr(176) + "C""
draw.text((75, 0), str(output_in), fill=BLACK, font=font)
draw.text((75, height/2), str(output_out), fill=BLACK, font=font)
# Draw image at screen
epd.display(image)
epd.partial_update()
示例15: main
# 需要导入模块: from EPD import EPD [as 别名]
# 或者: from EPD.EPD import clear [as 别名]
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)