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)
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()
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)""" 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() print( 'Button presses left to right will flash red, green, blue and white, exits when all have been tested' ) button_test()
def main(argv): """main program - draw HH:MM clock on 2.70" size panel""" global settings 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)) if 'EPD 2.7' == epd.panel: settings = Settings27() elif 'EPD 2.0' == epd.panel: settings = Settings20() else: print('incorrect panel size') sys.exit(1) epd.clear() demo(epd, settings)
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)
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"
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} 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, objects, frames)
def main(argv): """main program - display list of images""" subprocess.call(shlex.split('/home/pi/speedtest-cron/speedtest2.sh')) x = 0 with open('graph.txt') as f: lines = f.readlines() y = [line.split()[0] for line in lines] with open('graph2.txt') as f2: lines = f2.readlines() y2 = [line.split()[0] for line in lines] #x = [x++1 for line in lines] fig = plt.figure() ax1 = fig.add_subplot(111) ax1.set_title("Speed Test") ax1.plot(y, c='r', label='Down') ax1.plot(y2, c='b', label='Up') leg = ax1.legend() fig.set_size_inches(3.8, 2.5) fig.savefig('temp.png', dpi=75) 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)
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)
def main(): """main program - display list of images""" epd = EPD() liste = [] # The display adapter has a button connected to pin 15 # on the RaspberryPi pin list. Pin 15 is BCM GPIO22, # where BCM stands for Broadcom SoC. GPIO.setmode(GPIO.BCM) GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(22, GPIO.FALLING, callback=button_pressed, bouncetime=300) epd.clear() file_name = get_img() #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)) #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)) process_src_file(liste, file_name, epd.size) display_file(epd, liste)
def send_to_display(canvas): try: epd = EPD() epd.display(canvas) epd.update() except IOError: print("EPD not supported") canvas.show()
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)
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)
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()
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()
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()
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)
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)
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)
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()
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()
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
def main(argv): epd = EPD() 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)
def main(): epd = EPD() try: while True: if button2.is_pressed: display_running(epd) get_all_pi(epd) except KeyboardInterrupt: print("Exiting Appliance")
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)
def main( argv ): DIR = os.path.abspath(os.path.dirname(__file__)) epd = EPD() if len(argv) == 0: epd.clear() epd.clear() # Doubled clear to avoid ghosting elif argv[0] == 'biba': EPD_display_img(epd, DIR + '/Images/biba_logo.xbm') elif argv[0] == 'bibaqr': EPD_display_img(epd, DIR + '/Images/biba_qr.xbm') elif argv[0] == 'test1': json_file = open(DIR + '/json_dummies/json_input_1.json', 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data) elif argv[0] == 'test2': json_file = open(DIR + '/json_dummies/json_input_2.json', 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data) elif argv[0] == 'test3': json_file = open(DIR + '/json_dummies/json_input_3.json', 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data) elif argv[0] == 'test4': json_file = open(DIR + '/json_dummies/json_input_4.json', 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data) elif argv[0] == 'ip': EPD_ip(epd) else: json_file = open(argv[0], 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data)
def main(argv): DIR = os.path.abspath(os.path.dirname(__file__)) epd = EPD() if len(argv) == 0: epd.clear() epd.clear() # Doubled clear to avoid ghosting elif argv[0] == 'biba': EPD_display_img(epd, DIR + '/Images/biba_logo.xbm') elif argv[0] == 'bibaqr': EPD_display_img(epd, DIR + '/Images/biba_qr.xbm') elif argv[0] == 'test1': json_file = open(DIR + '/json_dummies/json_input_1.json', 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data) elif argv[0] == 'test2': json_file = open(DIR + '/json_dummies/json_input_2.json', 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data) elif argv[0] == 'test3': json_file = open(DIR + '/json_dummies/json_input_3.json', 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data) elif argv[0] == 'test4': json_file = open(DIR + '/json_dummies/json_input_4.json', 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data) elif argv[0] == 'ip': EPD_ip(epd) else: json_file = open(argv[0], 'r') json_data = json.load(json_file) json_file.close() EPD_display_values(epd, json_data)
def render(self): fin = self.img.rotate(90) # fin.save("halibut.png", 'png') epd = EPD() epd.clear() epd.display(fin) epd.update()
def main(argv): """main program - draw and display a test image""" #cont = "y" #while cont == "y": 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() #while True: # ewString = '' for line in sys.stdin: newString = line[:-1] #ewString = raw_input('your text') #if ewString != '': #newString = "Please wait... Tlonating: " + ewString demo(epd, newString)
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)""" 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() print ('Button presses left to right will flash red, green, blue and white, exits when all have been tested') button_test()
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} FILM={f:d}'. format(p=epd.panel, w=epd.width, h=epd.height, v=epd.version, g=epd.cog, f=epd.film)) clock = AlarmClock(epd) clock.run()
def main(argv): """main program - display list of images""" # The display adapter has a button connected to pin 15 # on the RaspberryPi pin list. Pin 15 is BCM GPIO22, # where BCM stands for Broadcom SoC. GPIO.setmode(GPIO.BCM) GPIO.setup(22, GPIO.IN, pull_up_down = GPIO.PUD_UP) GPIO.add_event_detect(22, GPIO.FALLING, callback=button_pressed, bouncetime=300) 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)) 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) GPIO.remove_event_detect(22)
def main(argv): """main program - draw HH:MM clock on 2.70" size panel""" global settings 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 ) ) if "EPD 2.7" == epd.panel: settings = Settings27() elif "EPD 2.0" == epd.panel: settings = Settings20() else: print("incorrect panel size") sys.exit(1) epd.clear() demo(epd, settings)
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() FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s' logging.basicConfig(format=FORMAT) logger = logging.getLogger("clock.py") logger.info("process starting") while True: try: demo(epd) except Exception as e: logger.error(e) pass
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)
def main(argv): # use broadcom GPIO designations GPIO.setmode(GPIO.BCM) # warning messages GPIO.setwarnings(True) # set button listeners for button in constants.BUTTONS: GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(button, GPIO.FALLING, callback=on_click, bouncetime=500) # clear screen 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() # start main loop main_loop(epd)
def main(argv): """main program - draw and display a test image""" #cont = "y" #while cont == "y": 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() #while True: # ewString = '' for line in sys.stdin: newString = line[:-1] #ewString = raw_input('your text') #if ewString != '': #newString = "Please wait... Tlonating: " + ewString demo(epd, newString)
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)
def main(): epd = EPD() try: while True: # loop forever # Check if the first button is pressed and reload the screen if button1.is_active: display_eedata(epd) # Check if the second button is pressed and run a fresh speedtest, then reload the screen. # This will run over either the Ethernet or the wireless dongle if it is connected to a hot-spot. if button2.is_active: display_running(epd) # ToDo: Run this in pure python - for now another shell script is used subprocess.call(shlex.split('/home/pi/speedtest-cron/speedtest.sh')) display_eedata(epd) except KeyboardInterrupt: print ("Exiting Appliance Code")
def main(): epd = EPD() try: while True: # loop forever # Check if the first button is pressed and reload the screen if button3.is_active: display_running(epd) subprocess.call( shlex.split( '/home/pi/speedtest-cron/ImageDemo.py temp.png')) if button2.is_active: display_running(epd) # ToDo: Run this in pure python - for now another shell script is used subprocess.call( shlex.split('/home/pi/speedtest-cron/speedtest.sh')) display_eedata(epd) except KeyboardInterrupt: print("Exiting Appliance Code")
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()
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 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()
def main(): """main program - draw and display a test image""" conf = get_config() tickerlist = conf["symbols"] 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) ip = get_ip_address('eth0') while True: now = datetime.today() draw.rectangle((0, 0, width, height), fill=WHITE, outline=WHITE) draw.text((0, 160), '%04d-%02d-%02d %02d:%02d:%02d' % (now.year, now.month, now.day, now.hour, now.minute, now.second), fill=BLACK, font=wfont) draw.text((0, 150), '{c:s}'.format(c=ip), fill=BLACK, font=wfont) y = -20 for symbol in tickerlist[:7]: y += 20 draw.text((0, y), get_quote(symbol), fill=BLACK, font=font) # display image on the panel epd.display(image) epd.partial_update() tickerlist.insert(0,tickerlist.pop()) time.sleep(10)
from timerthread import TimerThread import RPi.GPIO as GPIO COLW = 64 WHITE = 1 BLACK = 0 textfont = ImageFont.truetype('fonts/LiberationSans-Regular.ttf', 60) chessfont = ImageFont.truetype('fonts/CASEFONT.TTF', 45) CLOCK_FONT_SIZE = 40 DATE_FONT_SIZE = 30 MAX_START = 0xffff epd = EPD() image = Image.new('1', epd.size, WHITE) draw = ImageDraw.Draw(image) width, height = image.size games = [ { 'name': 'Fischer', 'duration': timedelta(seconds=600), }, { 'name': 'Bronstein', 'duration': timedelta(seconds=600), }, { 'name': 'Simple delay',
import sys 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()
""" # put the figure pixmap into a numpy array buf = fig2data ( fig ) w, h, d = buf.shape return Image.fromstring( "RGBA", ( w ,h ), buf.tostring( ) ) dates = numpy.array([]) rollingTemperatures = numpy.zeros(shape=(12)) temperatures = numpy.array([]) updateCounter = 0 fullRefreshCounter = 5 lineSetup = False font = ImageFont.truetype("/home/pi/Quicksand-Bold.otf", 30) font2 = ImageFont.truetype("/home/pi/Quicksand-Bold.otf", 15) epd = EPD() figure = 0 ax = 0 if (os.path.isfile("dates.npy")): dates = numpy.load("dates.npy") if (os.path.isfile("temperatures.npy")): temperatures = numpy.load("temperatures.npy") def setupFigure(): global figure, ax figure = matplotlib.pyplot.figure(frameon=False, figsize=(3.3,2.2), facecolor='white') ax = figure.add_axes([0.13, 0, 0.87, 0.8]) ax.axis('on', antialiased=False) ax.xaxis.set_ticks_position('top')
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}'.format(p=epd.panel, w=epd.width, h=epd.height, v=epd.version)) # initially set all white background image = Image.new('1', epd.size, WHITE) # prepare for drawing draw = ImageDraw.Draw(image) # set a longer timeout on socket operations socket.setdefaulttimeout(60) # find some fonts # fonts are in different places on Raspbian/Angstrom so search possible_name_fonts = [ # '/usr/share/fonts/truetype/freefont/FreeSans.ttf', # R.Pi '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf', # R.Pi '/usr/share/fonts/truetype/freefont/FreeMono.ttf', # R.Pi '/usr/share/fonts/truetype/LiberationMono-Bold.ttf', # B.B '/usr/share/fonts/truetype/DejaVuSansMono-Bold.ttf' # B.B '/usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf' # Arch ] possible_message_fonts = [ '/usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf', # R.Pi '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf', # R.Pi '/usr/share/fonts/truetype/freefont/FreeMono.ttf', # R.Pi '/usr/share/fonts/truetype/LiberationSans-Regular.ttf', # B.B '/usr/share/fonts/truetype/DejaVuSans.ttf' # B.B '/usr/share/fonts/TTF/DejaVuSans.ttf' # Arch ] name_font_name = find_font(possible_name_fonts) if '' == name_font_name: raise 'no name font file found' message_font_name = find_font(possible_message_fonts) if '' == message_font_name: raise 'no message font file found' name_font = ImageFont.truetype(name_font_name, 14) message_font = ImageFont.truetype(message_font_name, 12) # start up tweepy streaming if tweepy_auth.basic: auth = tweepy.BasicAuthHandler(tweepy_auth.USERNAME, tweepy_auth.PASSWORD) else: auth = tweepy.OAuthHandler(tweepy_auth.CONSUMER_KEY, tweepy_auth.CONSUMER_SECRET) auth.set_access_token(tweepy_auth.ACCESS_TOKEN, tweepy_auth.ACCESS_TOKEN_SECRET) listener = StreamMonitor(epd, image, draw, name_font, message_font) stream = tweepy.Stream(auth, listener) setTerms = argv # stream.sample() # low bandwidth public stream stream.filter(track=setTerms)
import sys 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()
# Ghosting test: Version of e-paper clock running on Raspberry Pi import sys, time, math from PIL import Image from PIL import ImageDraw, ImageFont from EPD import EPD WHITE = 1 BLACK = 0 origin = 100, 100 # of clock face def polar_line(radians, length, width): x_end = origin[0] + length * math.sin(radians) y_end = origin[1] - length * math.cos(radians) draw.line([(origin[0], origin[1]), (x_end, y_end)], fill = BLACK, width = width) 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) width, height = image.size # prepare for drawing draw = ImageDraw.Draw(image) font = ImageFont.truetype("LiberationSerif-Regular.ttf", 36) while True: draw.rectangle((0, 0, width, height), fill=WHITE, outline=WHITE) draw.ellipse((origin[0] -55, origin[1] -55, origin[0] +55, origin[1] +55), fill=WHITE, outline=BLACK)
def main(args): epdFound = True if len(args) != 2: sys.stderr.write("Please provide project name !\n") return 1 projectName = args[1] redmine = Redmine(RedmineCredential.host, key=RedmineCredential.key, requests={'verify': RedmineCredential.request_verify}) imageSize = [SCREEN_SIZE_X + 1, SCREEN_SIZE_Y + 1] try: 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)) imageSize = epd.size except IOError: sys.stderr.write("Hooops no EPD found. Auto fallback to '" + IMAGE_PATH + "'\n") epdFound = False counter = 0 try: while True: global issues issues = [] image = createImage(imageSize) # prepare for drawing draw = ImageDraw.Draw(image) #drawDots(draw) # column title: text columnsTitleSize = drawColumnTitles(draw) headerLineHeight = columnsTitleSize[1] + 2 ipAddress = getIpAddress() issuesNew = issuesInProgress = issuesResolved = issuesNeedFeed = issuesClosed = [] try: issuesNew = listIdsForStatus(redmine, projectName, STATUS_ID_NEW) issuesInProgress = listIdsForStatus(redmine, projectName, STATUS_ID_IN_PROGRESS) issuesResolved = listIdsForStatus(redmine, projectName, STATUS_ID_RESOLVED) issuesNeedFeed = listIdsForStatus(redmine, projectName, STATUS_ID_NEED_FEED) issuesClosed = listIdsForStatus(redmine, projectName, STATUS_ID_CLOSED) except Exception as e: print e drawLines(draw, headerLineHeight) drawIpAddress(draw, ipAddress) drawClock(draw) drawMultiColumnContent(draw, headerLineHeight, 5, issuesNew) drawMultiColumnContent(draw, headerLineHeight, 95, issuesInProgress) drawMultiColumnContent(draw, headerLineHeight, 185, issuesResolved) headerLineHeightSecondScreen = SCREEN_SIZE_Y / 2 + headerLineHeight drawMultiColumnContent(draw, headerLineHeightSecondScreen, 5, issuesNeedFeed) drawMultiColumnContent(draw, headerLineHeightSecondScreen, 95, issuesClosed) # drawMultiColumnContent(draw, headerLineHeightSecondScreen, 185, issuesWait) if epdFound: transferToEpd(epd, image, counter % (60 * 15) == 0) else: transferToScreen(image) time.sleep(60) counter += 60 except KeyboardInterrupt: # Exit by typing CTRL-C print("You hit CTRL-C") return 0
def main(argv): """print the latest headlines from an RSS feed""" epd = EPD() demo(epd)
from EPD import EPD WHITE = 1 BLACK = 0 origin = 100, 100 # of clock face def polar_line(radians, length, width): x_end = origin[0] + length * math.sin(radians) y_end = origin[1] - length * math.cos(radians) draw.line([(origin[0], origin[1]), (x_end, y_end)], fill=BLACK, width=width) 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) width, height = image.size # prepare for drawing