def main(): epd = epd7in5_V2.EPD() # Initialise and clear the screen epd.init() epd.Clear() while 1: config = read_config() update(epd, config) epd.sleep() epd7in5.epdconfig.module_exit() exit()
def __init__(self): logging.info("Initializing EInk75") fontPath = assetsdir + '/Font.ttc' print(fontPath) self.fonts = { 14: ImageFont.truetype(fontPath, 14), 18: ImageFont.truetype(fontPath, 18), 24: ImageFont.truetype(fontPath, 24), 60: ImageFont.truetype(fontPath, 60), 120: ImageFont.truetype(fontPath, 120) } logging.info("Instantiating object") self.epd = epd7in5_V2.EPD() logging.info("Calling init method") self.epd.init()
def __init__(self, horizontal=True): self.font18 = font18 self.font24 = font24 self.font30 = font30 self.font48 = font48 self.font60 = font60 self.font52 = font56 self.font20 = font20 self.font72 = font72 self.weather_font = weather_font self.weather_font_small = weather_font_small self.weather_font_tiny = weather_font_tiny self.epd = epd7in5_V2.EPD() self.epd.init() if horizontal: self.buffer = Image.new('1', (self.epd.width, self.epd.height), 255) #clear frame else: self.buffer = Image.new('1', (self.epd.height, self.epd.width), 255) self.draw = ImageDraw.Draw(self.buffer)
from PIL import Image,ImageDraw,ImageFont import time import random from waveshare_epd import epd7in5_V2 epd = epd7in5_V2.EPD() epd.init() epd.Clear() while(1): type = random.randint(0,2) print('Drawing style %d'%type) pageSize = (800, 480) gridX = int(random.triangular(1,18,4)) gridY = int(gridX * 0.6) if gridY < 1: gridY = 1 print ("grid of %d by %d blocks" %(gridX,gridY)) size = (pageSize[0]/gridX,pageSize[0]/gridX) spacerX = (pageSize[0] - (size[0] * gridX)) / gridX spacerY = (pageSize[1] - (size[1] * gridY)) / gridY print("each block is %d by %d"%size) print('with x space of %d and y space of %d'%(spacerX,spacerY)) print('making total width of %d and height of %d'%((size[0]+spacerX)*gridX, (size[1]+spacerY)*gridY))
from waveshare_epd import epd7in5_V2 from PIL import Image from waveshare_epd import epd7in5_V2 as epd image = Image.open('static/converted.jpg') epaper = epd.EPD() epaper.init() epaper.Clear() epaper.display(epaper.getbuffer(image)) epaper.sleep()
print("No videos found") sys.exit() print("Update interval: " + str(args.delay)) if not args.random: print("Frame increment: " + str(args.increment)) with open("nowPlaying", "w") as file: file.write(os.path.abspath(currentVideo)) videoFilename = os.path.basename(currentVideo) print(f"Playing '{videoFilename}'") logfile = os.path.join(logdir, videoFilename + ".progress") epd = epd_driver.EPD() width = epd.width height = epd.height # Check how many frames are in the movie videoInfo = ffmpeg.probe(currentVideo) frameCount = int(videoInfo["streams"][0]["nb_frames"]) framerate = videoInfo["streams"][0]["avg_frame_rate"] framerate = float(Fraction(framerate)) frametime = 1000 / framerate if not args.random: if args.start: currentPosition = clamp(args.start, 0, frameCount) print("Starting at frame " + str(currentPosition)) elif (os.path.isfile(logfile)):
def update_frame(photo): epaper = epd.EPD() epaper.init() #epaper.Clear() epaper.display(epaper.getbuffer(photo)) epaper.sleep()
def epaper_update(): cmd = "hostname -I | cut -d\' \' -f1" IP = subprocess.check_output(cmd, shell=True) line_gap_small = 20 line_gap_big = 30 line_top = 20 c = chia_stats.get_chia_stats() try: logging.info("ChiChi E-Paper output starting") epd = epd7in5_V2.EPD() logging.info("init and Clear") epd.init() epd.Clear() font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image logging.info("1.Drawing on the Horizontal image...") Himage = Image.new('1', (epd.width, epd.height), 255) # 255: clear the frame draw = ImageDraw.Draw(Himage) # draw.text((50, 20), 'Connected', font = font24, fill = 0) # draw.text((50, 50), 'IP: ' + str(IP), font = font24, fill = 0) # draw.text((50, 80), 'Total Gigs: 134GB', font = font24, fill = 0) # draw.text((50, 110), 'Plots Loaded: 154', font = font24, fill = 0) # draw.text((50, 140), 'Last time Eligible: ', font = font24, fill = 0) draw.text((50, 20), 'Net Space: ' + str(c.netspace), font=font24, fill=0) draw.text( (50, 20 + (line_gap_big * 2)), 'My Space: ' + str(round(float(c.loaded_plot_tb), 2)) + "TiB", font=font24, fill=0) draw.text((50, 20 + (line_gap_big * 3)), 'Plots Loaded: ' + str(c.loaded_plot_count), font=font24, fill=0) draw.text((50, 20 + (line_gap_big * 4)), 'Avg Proof Lookup Time: ' + str(c.avg_proof_time()) + "s", font=font24, fill=0) # draw.text((50, 200), 'Last win: ', font = font24, fill = 0) # draw.text((50, 230), 'Balance: ', font = font24, fill = 0) draw.text((550, line_top), '⊗ Loaded Drives', font=font24, fill=0) for i, plot in enumerate(c.plot_dirs): draw.text((550, line_top + line_gap_big + (i * line_gap_small)), "✓ - " + plot, font=font18, fill=0) Himage = Himage.rotate(180) epd.display(epd.getbuffer(Himage)) time.sleep(2) """ # Drawing on the Vertical image logging.info("2.Drawing on the Vertical image...") Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(Limage) draw.text((2, 0), 'hello world', font = font18, fill = 0) draw.text((2, 20), '7.5inch epd', font = font18, fill = 0) draw.text((20, 50), u'微雪电子', font = font18, fill = 0) draw.line((10, 90, 60, 140), fill = 0) draw.line((60, 90, 10, 140), fill = 0) draw.rectangle((10, 90, 60, 140), outline = 0) draw.line((95, 90, 95, 140), fill = 0) draw.line((70, 115, 120, 115), fill = 0) draw.arc((70, 90, 120, 140), 0, 360, fill = 0) draw.rectangle((10, 150, 60, 200), fill = 0) draw.chord((70, 150, 120, 200), 0, 360, fill = 0) epd.display(epd.getbuffer(Limage)) time.sleep(2) logging.info("3.read bmp file") Himage = Image.open(os.path.join(picdir, '7in5_V2.bmp')) epd.display(epd.getbuffer(Himage)) time.sleep(2) logging.info("4.read bmp file on window") Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame bmp = Image.open(os.path.join(picdir, '100x100.bmp')) Himage2.paste(bmp, (50,10)) epd.display(epd.getbuffer(Himage2)) time.sleep(2) logging.info("Clear...") epd.init() epd.Clear() logging.info("Goto Sleep...") epd.sleep() epd.Dev_exit() """ # epd.Dev_exit() except IOError as e: logging.info(e) except KeyboardInterrupt: logging.info("ctrl + c:") epd7in5.epdconfig.module_exit() exit()
def on_snapshot(doc_snapshot, changes, read_time): global lastMessage, lastMessageTime for doc in doc_snapshot: doc_dict = doc.to_dict() if lastMessage == "": lastMessage = doc_dict['message'] lastMessageTime = doc_dict['time'] SentBy = doc_dict['sendBy'] elif (doc_dict['time'] > lastMessageTime) & (doc_dict['message'] != lastMessage): lastMessage = doc_dict['message'] lastMessageTime = doc_dict['time'] SentBy = doc_dict['sendBy'] displayedMessage = lastMessage stringLength = len(displayedMessage) print(stringLength) sender = SentBy print(sender) logging.info("epd7in5_V2 Demo") epd = epd7in5_V2.EPD() logging.info("init and Clear") epd.init() epd.Clear() # Drawing on the Horizontal image logging.info("1.Drawing on the Horizontal image...") image = Image.new('1', (epd.width, epd.height), color=255) draw = ImageDraw.Draw(image) if 0 < stringLength < 6: fontsize = 275 elif 5 < stringLength < 8: fontsize = 220 elif 7 < stringLength < 10: fontsize = 170 elif 9 < stringLength < 12: fontsize = 150 elif stringLength == 12: fontsize = 125 elif stringLength == 13: fontsize = 120 elif stringLength == 14: fontsize = 120 else: fontsize = 120 print(fontsize) #fontsize = 125 #starting font size text_color = 0 text_start_height = 10 fnt = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), fontsize) fnt36 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 36) draw_multiple_line_text(image, displayedMessage, fnt, text_color, text_start_height) draw.text((epd.width - 300, epd.height - 45), 'From, ' + sender, font=fnt36, fill=0) epd.display(epd.getbuffer(image)) time.sleep(2)