Merge remote-tracking branch 'upstream/master'
This commit is contained in:
		| @@ -4,11 +4,12 @@ from PIL import Image, ImageDraw, ImageFont | ||||
| EPD_WIDTH = 640 | ||||
| EPD_HEIGHT = 384 | ||||
|  | ||||
| epd = epd7in5b.EPD() | ||||
|  | ||||
| def calibration(): | ||||
|     for i in range(2): | ||||
|         epd = epd7in5b.EPD() | ||||
|         epd.init() | ||||
|         black = Image.new('L', (EPD_WIDTH, EPD_HEIGHT), 0) | ||||
|         black = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 0) | ||||
|         print('calibrating black...') | ||||
|         ImageDraw.Draw(black) | ||||
|         epd.display_frame(epd.get_frame_buffer(black)) | ||||
| @@ -17,17 +18,14 @@ def calibration(): | ||||
|         ImageDraw.Draw(red) | ||||
|         print('calibrating red...') | ||||
|         epd.display_frame(epd.get_frame_buffer(red)) | ||||
|         white = Image.new('L', (EPD_WIDTH, EPD_HEIGHT), 255) | ||||
|         white = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 255) | ||||
|         ImageDraw.Draw(white) | ||||
|         print('calibrating white...') | ||||
|         epd.display_frame(epd.get_frame_buffer(white)) | ||||
|  | ||||
|         epd.sleep() | ||||
|     print('Cycle complete!') | ||||
|  | ||||
| def main(): | ||||
|     epd = epd7in5b.EPD() | ||||
|     epd.init() | ||||
|  | ||||
|     for i in range(1): | ||||
|         calibration() | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,32 @@ | ||||
| """ | ||||
| E-Paper Software (main script) adapted for the 3-colour E-Paper display | ||||
| A full and detailed breakdown for this code can be found in the wiki. | ||||
| If you have any questions, feel free to open an issue at Github. | ||||
|  | ||||
| Copyright by Ace-Laboratory | ||||
| """ | ||||
|  | ||||
| # url refers to the iCal url. It's the link you can copy when you click on | ||||
| # 'export' Calendar in Google or Yahoo (and many more online) Calendars | ||||
|  | ||||
| # api-key refers to your openweathermap api key. It can be generated for free | ||||
| # when you sign up for an account and consists of a bunch of numbers and letters | ||||
|  | ||||
| # location refers to the city you live in. You api key will be used to grab live | ||||
| # weather data for this city. Use the format below (city-name, country code) | ||||
|  | ||||
| # week_starts_on refers to the day on which the week starts on in your country. | ||||
| # Choose between Monday and Sunday. | ||||
|  | ||||
| """ To quickly get started, fill in the following details:""" | ||||
|  | ||||
| url = "https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics" | ||||
| api_key = "" | ||||
| location = "California, US" | ||||
| week_starts_on = "Monday" | ||||
|  | ||||
| """That's all. The software will do the rest. You don't need to modify anything below this.""" | ||||
|  | ||||
| import epd7in5b #epd-control | ||||
| from PIL import Image, ImageDraw, ImageFont, ImageOps #image operations | ||||
| import calendar,  pyowm #calendar and openweathermap wrapper | ||||
| @@ -12,11 +38,12 @@ import arrow #icalendar parser compatible dates | ||||
| from calibration import calibration | ||||
|  | ||||
| epd = epd7in5b.EPD() #required | ||||
| epd.init() #required | ||||
|  | ||||
| url = "please past a valid calendar url here" # or use this one for testing:  | ||||
| #url = "https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics" | ||||
| calendar.setfirstweekday(calendar.MONDAY) #mon or sun | ||||
| if (week_starts_on == "Monday"): | ||||
|     calendar.setfirstweekday(calendar.MONDAY) | ||||
|      | ||||
| if (week_starts_on == "Sunday"): | ||||
|     calendar.setfirstweekday(calendar.Sunday) | ||||
|  | ||||
| c = Calendar(urlopen(url).read().decode('UTF-8')) | ||||
| e = Event() | ||||
| @@ -76,9 +103,9 @@ def main(): | ||||
|                 calibration() | ||||
|             if hour is 12: | ||||
|                 calibration() | ||||
|             if hour is 18: #change to 18 | ||||
|             if hour is 18: | ||||
|                 calibration() | ||||
|  | ||||
|             epd.init() | ||||
|             image = Image.new('L', (EPD_WIDTH, EPD_HEIGHT), 255) | ||||
|             draw = (ImageDraw.Draw(image)).bitmap | ||||
|              | ||||
| @@ -86,9 +113,11 @@ def main(): | ||||
|             draw(monthplace, Image.open(mpath+str(time.strftime("%B"))+'.bmp')) | ||||
|  | ||||
|             if calendar.firstweekday() == 0: | ||||
|                 #print('Your week starts on Monday') #->debug | ||||
|                 draw(weekplace, weekmon) | ||||
|                  | ||||
|             if calendar.firstweekday() == 6: | ||||
|                 #print('Your week starts on Sunday') #->debug | ||||
|                 draw(weekplace, weeksun) | ||||
|              | ||||
|             draw(barplace, bar)  | ||||
| @@ -112,12 +141,15 @@ def main(): | ||||
|                 pass | ||||
|              | ||||
|             # openweathermap api | ||||
|             owm = pyowm.OWM('Your Openweathermap API') | ||||
|             observation = owm.weather_at_place('Your City, Your Country Name') # like (New York, US) | ||||
|             owm = pyowm.OWM(api_key) | ||||
|             observation = owm.weather_at_place(location) | ||||
|             weather = observation.get_weather() | ||||
|             weathericon = weather.get_weather_icon_name() | ||||
|             Temperature = str(int(weather.get_temperature(unit='celsius')['temp'])) | ||||
|             Humidity = str(weather.get_humidity()) | ||||
|             #print('temp: '+Temperature +'°C') #->debug | ||||
|             #print('humidity: '+Humidity+'%') #->debug | ||||
|             #print(weathericon)              #->debug | ||||
|              | ||||
|             #weather icon handler | ||||
|             draw(wiconplace, open(wpath+weathericons[weathericon]+'.bmp')) | ||||
| @@ -204,6 +236,7 @@ def main(): | ||||
|  | ||||
|             # delete the list so deleted events can be removed from the list | ||||
|             del elist[:] | ||||
|             epd.sleep() | ||||
|              | ||||
|             for i in range(1): | ||||
|                 nexthour = ((60 - int(time.strftime("%-M")))*60) - (int(time.strftime("%-S"))) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user