Example #1
0
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)
Example #2
0
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()
Example #3
0
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):
    """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 - 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)
Example #6
0
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)
Example #7
0
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(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)
Example #9
0
File: Qock.py Project: issess/qock
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)
Example #10
0
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)
Example #11
0
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)
Example #12
0
    def render(self):
        fin = self.img.rotate(90)
        # fin.save("halibut.png", 'png')

        epd = EPD()
        epd.clear()
        epd.display(fin)
        epd.update()
Example #13
0
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)
Example #14
0
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)
Example #15
0
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()
Example #16
0
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)
Example #17
0
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()
Example #18
0
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)
Example #19
0
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)
Example #20
0
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 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)
Example #22
0
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)
Example #23
0
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()
Example #24
0
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)
Example #25
0
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()
Example #26
0
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)       
Example #27
0
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)
Example #28
0
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)
Example #29
0
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()
Example #30
0
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)
Example #31
0
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
Example #32
0
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)
Example #33
0
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)
Example #34
0
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)
Example #35
0
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)
Example #36
0
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()
 def __init__(self):
     global epd #bring it in scope
     self.screen = False
     self.pause = False
     epd = EPD()
     epd.clear()
Example #38
0
def main(argv):
    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))
    display_file(epd, argv)
Example #39
0
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)
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)

    t = time.localtime()
    h, m, s = t[3:6]
    hh = h + m /60
    draw.text((0,0), '{:02d}.{:02d}.{:02d} '.format(h, m, s), font=font)
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)