def __init__(self): epd2in13_V2.epdconfig.module_init() self.epd = epd2in13_V2.EPD() self.epd.init(self.epd.FULL_UPDATE) self.width = self.epd.height self.height = self.epd.width self.clear()
def main(): y = json.dumps(top_headlines) x = json.loads(y) source_name = x['articles'][0]['source']['name'] source_string = "Source: " + source_name epd = epd2in13_V2.EPD() while True: try: print("Clearing EPD") epd.init(epd.FULL_UPDATE) epd.Clear(0xFF) HBlackimage = Image.new( '1', (epd2in13_V2.EPD_HEIGHT, epd2in13_V2.EPD_WIDTH), 255) print("Drawing information to EPD") drawblack = ImageDraw.Draw(HBlackimage) font20 = ImageFont.truetype('fonts/arial.ttf', 20) font10 = ImageFont.truetype('fonts/arial.ttf', 10) n_image = Image.new('1', (epd.height, epd.width), 255) n_image_draw = ImageDraw.Draw(image) epd.init(epd.FULL_UPDATE) epd.displayPartBaseImage(epd.getbuffer(n_image)) epd.init(epd.PART_UPDATE) n_image_draw.text((0, 10), source_string, font=font10, fill=0) #Begin displaying top 5 headlines articles = top_headlines['articles'] results = [] for ar in articles: results.append(ar['title']) for i in range(0, 5): n_image_draw.text((0, (35 + (i * 15))), (str(i + 1) + "." + results[i]), font=font10, fill=0) #Displays current time while (True): n_image_draw.rectangle((180, 0, 250, 30), fill=255) n_image_draw.text((180, 0), time.strftime('%H:%M'), font=font20, fill=0) epd.displayPartial(epd.getbuffer(n_image)) except IOError as e: print('traceback.format_exec():\n%s', traceback.format_exc()) epdconfig.module_init() epdconfig.module_exit() exit() time.sleep(60)
def init_eink(): logging.info("eink_syslog init") epd = epd2in13_V2.EPD() epd.init(epd.FULL_UPDATE) epd.Clear(0xFF) image = Image.new('1', (epd.height, epd.width), 255) draw = ImageDraw.Draw(image) epd.init(epd.FULL_UPDATE) epd.displayPartBaseImage(epd.getbuffer(image)) epd.init(epd.PART_UPDATE) return (epd, image, draw)
import sys sys.path.append(r'lib') import epd2in13_V2 import time from PIL import Image, ImageDraw, ImageFont import traceback try: epd = epd2in13_V2.EPD() epd.init(epd.FULL_UPDATE) print("Clear...") epd.Clear(0xFF) epd.sleep() except: print('traceback.format_exc():\n%s', traceback.format_exc()) exit()
def main(): try: while True: print ("Update " + str(datetime.datetime.now())) #URL de página datos url_c = "https://corona.help/country/senegal" page_c = requests.get(url_c) soup_c = BeautifulSoup(page_c.text, 'html.parser') # Ajustar: Coge los activity timeline, texto en ingles explicando la evolución (quiero poner max. 2 ) #for litag in soup_c.find_all('ul', {'class': 'activity-timeline timeline-left list-unstyled'}): #for ultag in soup_c.find_all('ul', {'class': 'activity-timeline timeline-left list-unstyled'}): #for litag in ultag.find_all('li'): #print(litag.text[2]) history = re.findall('^\s+data: \[([0-9,]+)\],$',str(soup_c),re.MULTILINE) history_cases = history[0].split(',') history_deaths = history[1].split(',') history_cured = history[2].split(',') # Print current_day_all_infected = infections_c = soup_c.select('h2')[1].text.strip() current_day_0_infected_today = soup_c.select('h2')[2].text.strip() current_day_all_death = soup_c.select('h2')[3].text.strip() current_day_0_death_today = soup_c.select('h2')[4].text.strip() all_recoveries_total = soup_c.select('h2')[5].text.strip() current_day_0_recoveries = soup_c.select('h2')[6].text.strip() total_tests = soup_c.select('h2')[11].text.strip() today_current_tests = soup_c.select('h2')[12].text.strip() activity_timeline = soup_c.select('h4')[1].text.strip() #Casos confirmados totales current_day_all_infected = current_day_all_infected.encode('ascii', 'ignore') infected_h = current_day_all_infected infected_value_all= "Total casos confirmados: " + str(current_day_all_infected) print (infected_value_all) #Casos confirmados hoy current_day_0_infected_today = current_day_0_infected_today.encode('ascii', 'ignore') infeccion_diaria_h = current_day_0_infected_today infeccion_diaria_value= "Casos confirmados de hoy: " + str(current_day_0_infected_today) print (infeccion_diaria_value) quita_coma_calculo_incidencia_confirmados_diarios = infeccion_diaria_value.replace("," , "") #Muertes totales current_day_all_death = current_day_all_death.encode('ascii', 'ignore') muertes_totales = current_day_all_death muerte_tota_value= "Total muertes: " + str(current_day_all_death) print (muerte_tota_value) #Muertes Diarias current_day_0_death_today = current_day_0_death_today.encode('ascii', 'ignore') muertes_hoy = current_day_0_death_today muerte_hoy_value= "Muertes hoy: " + str(current_day_0_death_today) print (muerte_hoy_value) #Tests diarios today_current_tests = today_current_tests.encode('ascii', 'ignore') test_hoy = today_current_tests test_hoy = "Tests realizados: " + str(today_current_tests) quita_coma_calulo_incidencia_test = test_hoy.replace(",'" , "") #Calulo positividad diaria #print(quita_coma_calculo_incidencia_confirmados_diarios) #porcentaje_diario_contagio = (quita_coma_calulo_incidencia_test) * (quita_coma_calculo_incidencia_confirmados_diarios) / 100 #intentamos conectar con la pantalla: try: epd = epd2in13_V2.EPD() # get the display epd.init(epd.FULL_UPDATE) # initialize the display print("Clear...") # prints to console, not the display, for debugging epd.Clear(0xFF) #Mostramos en pantalla resultados title = ImageFont.truetype("pic/Font.ttc", 25) font = ImageFont.truetype("pic/Font.ttc", 15) fontlittle = ImageFont.truetype("pic/Font.ttc", 12) logging.info("1.Drawing on the image...") image = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(image) draw.text((55, 5), "SPEEDTEST", font = title, fill = 0) draw.text((75, 30), str(now.strftime("%d-%m %H:%M")), font = fontlittle, fill = 0) draw.text((20, 71), str(ping), font = font, fill = 0) draw.text((20, 90), "ping", font = fontlittle, fill = 0) draw.text((103, 71), str(download), font = font, fill=0) draw.text((103, 90), "download", font = fontlittle, fill=0) draw.text((180,71), str(upload), font = font, fill=0) draw.text((180, 90), "upload", font = fontlittle, fill=0) epd.display(epd.getbuffer(image)) finally: print("none")
def main(): y = json.dumps(top_headlines) x = json.loads(y) yy = json.dumps(top_headlines_2) xx = json.loads(yy) source_name = x['articles'][0]['source']['name'] source_name_2 = xx['articles'][0]['source']['name'] source_string = "Sources: " + source_name source_string_2 = "Sources: " + source_name_2 epd = epd2in13_V2.EPD() while True: try: print("Clear...") epd.init( epd.FULL_UPDATE ) #Initiates the E-Paper Display; Also wakes up from deep sleep epd.Clear(0xFF) #Sets the screen to white HBlackimage = Image.new( '1', (epd2in13_V2.EPD_HEIGHT, epd2in13_V2.EPD_WIDTH), 255) print("Drawing...") drawblack = ImageDraw.Draw(HBlackimage) font20 = ImageFont.truetype('fonts/arial.ttf', 20) font12 = ImageFont.truetype( 'fonts/arial.ttf', 10) #Note changed to 10 just for testing purposes! ######Test for updating time, but static headlines time_image = Image.new('1', (epd.height, epd.width), 255) time_draw = ImageDraw.Draw(time_image) epd.init(epd.FULL_UPDATE) epd.displayPartBaseImage(epd.getbuffer(time_image)) epd.init(epd.PART_UPDATE) time_draw.text((0, 10), source_string, font=font12, fill=0) time_draw.text((0, 25), source_string_2, font=font12, fill=0) #Begin displaying the top 3 headlines from each language articles_de = top_headlines['articles'] results_de = [] for ar in articles_de: results_de.append(ar['title']) for i_d in range(0, 3): time_draw.text((0, (35 + (i_d * 15))), (str(i_d + 1) + "." + results_de[i_d]), font=font12, fill=0) articles = top_headlines_2['articles'] results = [] for art in articles: results.append(art['title']) for i in range(0, 3): time_draw.text((0, (80 + (i * 15))), str(i + 3) + "." + results[i], font=font12, fill=0) while (True): time_draw.rectangle((180, 0, 250, 30), fill=255) time_draw.text((180, 0), time.strftime('%H:%M'), font=font20, fill=0) epd.displayPartial(epd.getbuffer(time_image)) except IOError as e: print('traceback.format_exec():\n%s', traceback.format_exc()) epdconfig.module_init() epdconfig.module_exit() exit() time.sleep(60)
def get_epd2in13_V2(): return epd2in13_V2.EPD()
sys.path.insert(1, "./lib") import epd2in13_V2 as epdscreen from PIL import Image, ImageDraw, ImageFont import time import datetime import bluetooth._bluetooth as bluez import blescan import tiltclass import threading import uploadclass import apikey epd = epdscreen.EPD() DEBUG_MODE = True global_UpdateImage = Image.new('1', (epdscreen.EPD_HEIGHT, epdscreen.EPD_WIDTH), 255) temp_gravRead = 1.000 # # Initialise Tilt bluetooth uuids and associated classes # TILTS = { 'a495bb10c5b14b44b5121370f02d74de': 'Red',