示例#1
0
 def update_display(self):
     ip_addr = ni.ifaddresses('eth0')[ni.AF_INET][0]['addr']
     now = time()
     if now < self.display_expiry:
         im = Image.new('1', (84, 48))
         draw = ImageDraw.Draw(im)
         draw.text((0, 5), self.latest_raw_val, font=disp_font, fill=1)
         draw.text((0, 0), ip_addr, font=disp_font_sm, fill=1)
         draw.text((5, 36), "mm to surface", font=disp_font_sm, fill=1)
         lcd.show_image(im)
         # clean up
         del draw
         del im
         lcd.set_contrast(disp_contrast_on)
     else:
         lcd.set_contrast(disp_contrast_off)
         lcd.cls()
示例#2
0
            #lcd.init()
            # New b-w image
            im = Image.new('1', (84,48))
            # New drawable on image
            draw = ImageDraw.Draw(im)

            lcd.cls()
            lcd.backlight(0)
            rTitle = str(ch[int(recent['channel']['channelId'])][1])
            rAddress = str(ch[int(recent['channel']['channelId'])][0])
            song = recent['title']
            title = recent['artistName']

            draw.text((0,-2), rTitle, fill=1, font=font)
            draw.text((0,10), rAddress, fill=1, font=font)
            draw.text((0,20), song, fill=1, font=font)
            draw.text((0,30), title, fill=1, font=font)

            # Copy it to the display
            lcd.show_image(im)
            # clean up
            del draw
            del im

            if isHolding :
                lcd.text("   Hold  ")
            else:
                tea.test(ch[int(recent['channel']['channelId'])][0])

GPIO.cleanup()
示例#3
0
    ## Generate an image with PIL and put on the display
    # load an available True Type font
    font = ImageFont.truetype(
        "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf", 14)

    # New b-w image
    im = Image.new('1', (84, 48))
    # New drawable on image
    draw = ImageDraw.Draw(im)
    # Full screen and half-screen ellipses
    draw.ellipse((0, 0, im.size[0] - 1, im.size[1] - 1), outline=1)
    draw.ellipse((im.size[0] / 4, im.size[1] / 4, im.size[0] / 4 * 3 - 1,
                  im.size[1] / 4 * 3 - 1),
                 outline=1)
    # Some simple text for a test (first with TT font, second with default
    draw.text((10, 10), "hello", font=font, fill=1)
    draw.text((10, 24), "world", fill=1)
    # Check what happens when text exceeds width (clipped)
    draw.text((0, 0), "ABCabcDEFdefGHIghi", fill=1)
    # Copy it to the display
    lcd.show_image(im)
    # clean up
    del draw
    del im
    time.sleep(10)
except KeyboardInterrupt:
    pass
finally:
    lcd.cls()
    lcd.backlight(OFF)