def main(): #get command line arguments arguments = sys.argv #One Line can only show 12 letters epd = epd1in54.EPD() epd.init(epd.lut_full_update) # For simplicity, the arguments are explicit numerical coordinates image = Image.new('1', (epd1in54.EPD_WIDTH, epd1in54.EPD_HEIGHT), 255) # 255: clear the frame draw = ImageDraw.Draw(image) font = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 60) font2 = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 20) for i in range(1, 9): draw.text((10, int(i - 1) * 25), arguments[i], font=font2, fill=0) epd.clear_frame_memory(0xFF) epd.set_frame_memory(image, 0, 0) epd.display_frame()
def test(): print('start\n') epd = epd1in54.EPD() epd.init(epd.lut_full_update) print('epd init finish \n') epd.clear_frame_memory(0xff) epd.set_frame_memory(gImage_imag, 200, 200, 0, 0) epd.display_frame() epd.delay_ms(2000)
def main(): epd = epd1in54.EPD() epd.init(epd.lut_full_update) # For simplicity, the arguments are explicit numerical coordinates image = Image.new('1', (epd1in54.EPD_WIDTH, epd1in54.EPD_HEIGHT), 255) # 255: clear the frame draw = ImageDraw.Draw(image) font = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 24) draw.rectangle((0, 10, 200, 34), fill=0) draw.text((8, 12), 'Hello world!', font=font, fill=255) draw.text((8, 36), 'e-Paper Demo', font=font, fill=0) draw.line((16, 60, 56, 60), fill=0) draw.line((56, 60, 56, 110), fill=0) draw.line((16, 110, 56, 110), fill=0) draw.line((16, 110, 16, 60), fill=0) draw.line((16, 60, 56, 110), fill=0) draw.line((56, 60, 16, 110), fill=0) draw.arc((90, 60, 150, 120), 0, 360, fill=0) draw.rectangle((16, 130, 56, 180), fill=0) draw.chord((90, 130, 150, 190), 0, 360, fill=0) epd.clear_frame_memory(0xFF) epd.set_frame_memory(image, 0, 0) epd.display_frame() epd.delay_ms(2000) # for partial update epd.init(epd.lut_partial_update) image = Image.open('monocolor.bmp') ## # there are 2 memory areas embedded in the e-paper display # and once the display is refreshed, the memory area will be auto-toggled, # i.e. the next action of SetFrameMemory will set the other memory area # therefore you have to set the frame memory twice. ## epd.set_frame_memory(image, 0, 0) epd.display_frame() epd.set_frame_memory(image, 0, 0) epd.display_frame() time_image = Image.new('1', (96, 32), 255) # 255: clear the frame draw = ImageDraw.Draw(time_image) font = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 32) image_width, image_height = time_image.size while (True): # draw a rectangle to clear the image draw.rectangle((0, 0, image_width, image_height), fill=255) draw.text((0, 0), time.strftime('%M:%S'), font=font, fill=0) epd.set_frame_memory(time_image.rotate(90), 80, 80) epd.display_frame()
def main(): epd = epd1in54.EPD() epd.init(epd.lut_full_update) image = Image.open('bobby.bmp') draw = ImageDraw.Draw(image) font = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/dejavu/DejaVuSans-Bold.ttf', 26) draw.text((0, 0), 'Bobby!', font=font, fill=0) epd.clear_frame_memory(0xFF) epd.set_frame_memory(image, 0, 0) epd.display_frame() epd.set_frame_memory(image, 0, 0) epd.display_frame()
def main(): epd = epd1in54.EPD() epd.init(epd.lut_full_update) # For simplicity, the arguments are explicit numerical coordinates image = Image.new('1', (epd1in54.EPD_WIDTH, epd1in54.EPD_HEIGHT), 255) # 255: clear the frame draw = ImageDraw.Draw(image) font = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 24) draw.rectangle((0, 0, epd1in54.EPD_WIDTH, epd1in54.EPD_HEIGHT), fill=255) #draw.text((20, 12), 'Hello world!', font = font, fill = 255) epd.clear_frame_memory(0xFF) epd.set_frame_memory(image, 0, 0) epd.display_frame() #epd.delay_ms(2000) # for partial update epd.init(epd.lut_partial_update) #image = Image.open('monocolor.bmp') ## # there are 2 memory areas embedded in the e-paper display # and once the display is refreshed, the memory area will be auto-toggled, # i.e. the next action of SetFrameMemory will set the other memory area # therefore you have to set the frame memory twice. ## epd.set_frame_memory(image, 0, 0) epd.display_frame() epd.set_frame_memory(image, 0, 0) epd.display_frame() time_image = Image.new('1', (120, 120), 255) # 255: clear the frame draw = ImageDraw.Draw(time_image) font1 = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 24) font2 = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 32) image_width, image_height = time_image.size while (True): # draw a rectangle to clear the image draw.rectangle((0, 0, image_width, image_height), fill=255) localtime = time.strftime("%H:%M") cputemp = '%.1f' % gettemp() + '°C'[1:] draw.text((8, 0), '%s' % cputemp, font=font1, fill=0) draw.text((0, 30), '%s' % localtime, font=font2, fill=0) epd.set_frame_memory(time_image, 80, 80) epd.display_frame() epd.delay_ms(2000)
def epdisplay(date,names,locations): header = date +": "+ str(len(names)) + " frei" epd = epd1in54.EPD() epd.init(epd.lut_full_update) # For simplicity, the arguments are explicit numerical coordinates image = Image.new('1', (epd1in54.EPD_WIDTH, epd1in54.EPD_HEIGHT), 255) # 255: clear the frame draw = ImageDraw.Draw(image) font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 12) draw.rectangle((0, 10, 200, 34), fill = 0) draw.text((8, 12), header, font = font, fill = 255) line_offset = 36 for name,location in zip(names,locations): line = "".join([name,": ",location]) draw.text((8, line_offset), line, font = font, fill = 0) line_offset += 15 epd.clear_frame_memory(0xFF) epd.set_frame_memory(image, 0, 0) epd.display_frame() epd.delay_ms(2000)
def displaySong(self, threadName, songName): # initialise the display epd = epd1in54.EPD() epd.init(epd.lut_full_update) # For simplicity, the arguments are explicit numerical coordinates # 255: clear the frame image = Image.new( '1', (epd1in54.EPD_HEIGHT, epd1in54.EPD_WIDTH), 255) draw = ImageDraw.Draw(image) font = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 14) # get the display name of the song, which has just the name without underscores or file type if songName != BEGINMESSAGE: slashIndex = songName.index("/") + 1 dotIndex = songName.index(".mp3") songDisplayName = songName[slashIndex:dotIndex].replace( "_", " ").replace("1-", "") else: songDisplayName = songName # get the textSize as a (widht, height) tuple textSize = draw.textsize(songDisplayName, font=font) # calculate the x and y position based on the display and text dimensions xPosition = (epd1in54.EPD_HEIGHT - textSize[0]) / 2 yPosition = (epd1in54.EPD_WIDTH - textSize[1]) / 2 # draw the song name at the appropriate spot, which is in the middle draw.text((xPosition, yPosition), songDisplayName, font=font, fill=0) # rotate the current image rotatedImage = image.rotate(90, expand=1) # send the image to the display epd.clear_frame_memory(0xFF) epd.set_frame_memory(rotatedImage, 0, 0) epd.display_frame()
def main(): epd = epd1in54.EPD() """ epd.init(epd.lut_full_update) # For simplicity, the arguments are explicit numerical coordinates image = Image.new('1', (epd1in54.EPD_WIDTH, epd1in54.EPD_HEIGHT), 255) # 255: clear the frame draw = ImageDraw.Draw(image) font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 24) draw.rectangle((0, 10, 200, 34), fill = 0) draw.text((8, 12), 'Hello world!', font = font, fill = 255) draw.text((8, 36), 'e-Paper Demo', font = font, fill = 0) draw.line((16, 60, 56, 60), fill = 0) draw.line((56, 60, 56, 110), fill = 0) draw.line((16, 110, 56, 110), fill = 0) draw.line((16, 110, 16, 60), fill = 0) draw.line((16, 60, 56, 110), fill = 0) draw.line((56, 60, 16, 110), fill = 0) draw.arc((90, 60, 150, 120), 0, 360, fill = 0) draw.rectangle((16, 130, 56, 180), fill = 0) draw.chord((90, 130, 150, 190), 0, 360, fill = 0) epd.clear_frame_memory(0xFF) epd.set_frame_memory(image, 0, 0) epd.display_frame() epd.delay_ms(2000) """ # for partial update # #image = Image.open('monocolor.bmp') ## # there are 2 memory areas embedded in the e-paper display # and once the display is refreshed, the memory area will be auto-toggled, # i.e. the next action of SetFrameMemory will set the other memory area # therefore you have to set the frame memory twice. ## #epd.set_frame_memory(image, 0, 0) #epd.display_frame() #epd.set_frame_memory(image, 0, 0) #epd.display_frame() arguments = sys.argv fontTypes = [ ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 30), ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 20) ] updateType = arguments[1] if updateType == "full": epd.init(epd.lut_full_update) else: epd.init(epd.lut_partial_update) texts = arguments[2:8] #texts = [" Status ","-192.168.110.15-","Port: 3000","Akku: 10.5V","Clients: 1","Menu -"] backgrounds = [255, 0, 0, 0, 0, 255] fonts = arguments[8:14] epd.clear_frame_memory(0xFF) epd.clear_frame_memory(0xFF) for i in range(0, 6): time_image = Image.new('1', (200, 30), 255) # 255: clear the frame draw = ImageDraw.Draw(time_image) image_width, image_height = time_image.size draw.rectangle((0, 0, image_width, image_height), fill=255 - backgrounds[i]) myFont = fontTypes[int(fonts[i])] draw.text((1, 0), texts[i], font=myFont, fill=backgrounds[i]) epd.set_frame_memory(time_image, 0, i * 30 + i * 4) # display changes epd.display_frame()
def get_epd1in54(): return epd1in54.EPD()