diff --git a/Calendar/E-Paper.py b/Calendar/E-Paper.py index 8b77836..69ff432 100644 --- a/Calendar/E-Paper.py +++ b/Calendar/E-Paper.py @@ -41,26 +41,28 @@ EPD_WIDTH = 640 EPD_HEIGHT = 384 if language in ['ja','zh','zh_tw','ko']: - default = ImageFont.truetype(fpath+'NotoSansCJK/NotoSansCJKsc-Light.otf', 18) - semi = ImageFont.truetype(fpath+'NotoSansCJK/NotoSansCJKsc-DemiLight.otf', 18) - bold = ImageFont.truetype(fpath+'NotoSansCJK/NotoSansCJKsc-Regular.otf', 18) - month_font = ImageFont.truetype(fpath+'NotoSansCJK/NotoSansCJKsc-DemiLight.otf', 40) + default = ImageFont.truetype(fpath+NotoSansCJK+'Light.otf', 18) + semi = ImageFont.truetype(fpath+NotoSansCJK+'DemiLight.otf', 18) + bold = ImageFont.truetype(fpath+NotoSansCJK+'Regular.otf', 18) + month_font = ImageFont.truetype(fpath+NotoSansCJK+'DemiLight.otf', 40) else: - default = ImageFont.truetype(fpath+'NotoSans/NotoSans-SemiCondensedLight.ttf', 18) - semi = ImageFont.truetype(fpath+'NotoSans/NotoSans-SemiCondensed.ttf', 18) - bold = ImageFont.truetype(fpath+'NotoSans/NotoSans-SemiCondensedMedium.ttf', 18) - month_font = ImageFont.truetype(fpath+'NotoSans/NotoSans-SemiCondensedLight.ttf', 40) + default = ImageFont.truetype(fpath+NotoSans+'Light.ttf', 18) + semi = ImageFont.truetype(fpath+NotoSans+'.ttf', 18) + bold = ImageFont.truetype(fpath+NotoSans+'Medium.ttf', 18) + month_font = ImageFont.truetype(fpath+NotoSans+'Light.ttf', 40) + +w_font_l = ImageFont.truetype(fpath+weather_font, 60) +w_font_s = ImageFont.truetype(fpath+weather_font, 22) im_open = Image.open '''Get system timezone and set timezone accordingly''' -file = open('/etc/timezone','r') -lines = file.readlines() -system_tz = lines[0].rstrip() -local_tz = timezone(system_tz) +with open('/etc/timezone','r') as file: + lines = file.readlines() + system_tz = lines[0].rstrip() + local_tz = timezone(system_tz) - -owm = pyowm.OWM(api_key) +owm = pyowm.OWM(api_key, language=language) """Main loop starts from here""" def main(): @@ -72,7 +74,7 @@ def main(): year = int(time.now().strftime('%Y')) mins = int(time.strftime("%M")) seconds = int(time.strftime("%S")) - now = arrow.now() + now = arrow.now(tz=system_tz) for i in range(1): print('_________Starting new loop___________'+'\n') @@ -127,7 +129,7 @@ def main(): weathericon = weather.get_weather_icon_name() Humidity = str(weather.get_humidity()) cloudstatus = str(weather.get_clouds()) - weather_description = (str(weather.get_status())) + weather_description = (str(weather.get_detailed_status())) if units is "metric": Temperature = str(int(weather.get_temperature(unit='celsius')['temp'])) @@ -141,54 +143,57 @@ def main(): write_text(50, 35, Temperature + " °F", (334, 0)) write_text(100, 35, windspeed+" mph", (114, 0)) - if hours is "24": - sunrisetime = str(datetime.fromtimestamp(int(weather.get_sunrise_time(timeformat='unix'))).strftime('%-H:%M')) - sunsettime = str(datetime.fromtimestamp(int(weather.get_sunset_time(timeformat='unix'))).strftime('%-H:%M')) - - if hours is "12": - sunrisetime = str(datetime.fromtimestamp(int(weather.get_sunrise_time(timeformat='unix'))).strftime('%-I:%M')) - sunsettime = str(datetime.fromtimestamp(int(weather.get_sunset_time(timeformat='unix'))).strftime('%-I:%M')) + sunrisetime = arrow.get(weather.get_sunrise_time()).to(system_tz) + sunsettime = arrow.get(weather.get_sunset_time()).to(system_tz) """Show the fetched weather data""" - print('Temperature: '+ Temperature+' °C') - print('Humidity: '+ Humidity+'%') - print('weather-icon name: '+weathericons[weathericon]) - print('Wind speed: '+ windspeed+'km/h') - print('Sunrise-time: '+ sunrisetime) - print('Sunset time: '+ sunsettime) - print('Cloudiness: ' + cloudstatus+'%') - print('Weather description: '+ weather_description+'\n') + print('Temperature:',Temperature, '°C') + print('Humidity:', Humidity, '%') + print('Wind speed:', windspeed, 'km/h') + print('Sunrise-time:', sunrisetime.format('HH:mm')) + print('Sunset time:', sunsettime.format('HH:mm')) + print('Cloudiness:', cloudstatus, '%') + print('Weather description:', weather_description, '\n') """Add the weather icon at the top left corner""" - image.paste(im_open(wpath + weathericons[weathericon] +'.jpeg'), wiconplace) + write_text(70,70, weathericons[weathericon], wiconplace, font = w_font_l) """Add the temperature icon at it's position""" - image.paste(tempicon, tempplace) + write_text(35,35, '\uf055', tempplace, font = w_font_s) """Add the humidity icon and display the humidity""" - image.paste(humicon, humplace) + write_text(35,35, '\uf07a', humplace, font = w_font_s) write_text(50, 35, Humidity + " %", (334, 35)) - """Add the sunrise icon and display the sunrise time""" - image.paste(sunriseicon, sunriseplace) - write_text(50, 35, sunrisetime, (249, 0)) + """Add the sunrise/sunset icon and display the time""" + if (now <= sunrisetime and now <= sunsettime) or (now >= sunrisetime and now >= sunsettime): + write_text(35,35, '\uf051', sunriseplace, font = w_font_s) + print('sunrise coming next') + if hours is "24": + write_text(50, 35, sunrisetime.format('H:mm'), (249, 0)) + if hours is "12": + write_text(50, 35, sunrisetime.format('h:mm'), (249, 0)) - """Add the sunset icon and display the sunrise time""" - image.paste(sunseticon, sunsetplace) - write_text(50, 35, sunsettime, (249, 35)) + if now >= sunrisetime and now <= sunsettime: + write_text(35,35, '\uf052', sunriseplace, font = w_font_s) + print('sunset coming next') + if hours is "24": + write_text(50, 35, sunsettime.format('H:mm'), (249, 0)) + if hours is "12": + write_text(50, 35, sunsettime.format('h:mm'), (249, 0)) """Add the wind icon at it's position""" - image.paste(windicon, windiconspace) + write_text(35,35, '\uf050', windiconspace, font = w_font_s) """Add a short weather description""" - write_text(144, 35, weather_description, (70, 35)) + write_text(229, 35, weather_description, (70, 35)) except Exception as e: """If no response was received from the openweathermap api server, add the cloud with question mark""" print('__________OWM-ERROR!__________'+'\n') print('Reason: ',e,'\n') - image.paste(no_response, wiconplace) + write_text(70,70, '\uf07b', wiconplace, font = w_font_l) pass """Set the Calendar to start on the day specified by the settings file """ @@ -218,7 +223,7 @@ def main(): if week_starts_on is "Sunday": prev_weekstart = now.replace(days = - now.isoweekday()) image.paste(weekday, weekday_pos['pos'+str(now.isoweekday())], weekday) - + weekday_names_list = [] for i in range(7): weekday_name = prev_weekstart.replace(days=+i) @@ -328,7 +333,7 @@ def main(): """Create a time span using the events_max_range value (in days) to filter events in that range""" - + time_span_calendar = time + timedelta(days=int(events_max_range)) time_span_agenda = time + timedelta(days=22) @@ -393,7 +398,7 @@ def main(): agenda_list.append({'value':events.begin.to(system_tz).format('hh:mm a')+ ' '+ str(events.name), 'type':'timed_event'}) else: agenda_list.append({'value':events.name, 'type':'full_day_event'}) - + if bottom_section is not "": del agenda_list[16:] image.paste(seperator2, agenda_view_lines['line17']) @@ -453,12 +458,12 @@ def main(): buffer = np.array(image) r,g,b = buffer[:,:,0], buffer[:,:,1], buffer[:,:,2] if display_colours is "bwr": - buffer[np.logical_and(r > 240, g > 240)] = [255,255,255] #white - buffer[np.logical_and(r > 240, g < 240)] = [255,0,0] #red + buffer[np.logical_and(r > 245, g > 245)] = [255,255,255] #white + buffer[np.logical_and(r > 245, g < 245)] = [255,0,0] #red buffer[np.logical_and(r != 255, r == g )] = [0,0,0] #black if display_colours is "bw": - buffer[np.logical_and(r > 240, g > 240)] = [255,255,255] #white + buffer[np.logical_and(r > 245, g > 245)] = [255,255,255] #white buffer[g < 255] = [0,0,0] #black improved_image = Image.fromarray(buffer).rotate(270, expand=True) diff --git a/Calendar/fonts/WeatherFont/weathericons-regular-webfont.ttf b/Calendar/fonts/WeatherFont/weathericons-regular-webfont.ttf new file mode 100644 index 0000000..948f0a5 Binary files /dev/null and b/Calendar/fonts/WeatherFont/weathericons-regular-webfont.ttf differ diff --git a/Calendar/image_data.py b/Calendar/image_data.py index 56bc876..cf69abd 100644 --- a/Calendar/image_data.py +++ b/Calendar/image_data.py @@ -18,17 +18,15 @@ dpath = path+'days/' opath = path+'other/' fpath = path+'fonts/' +NotoSansCJK = 'NotoSansCJK/NotoSansCJKsc-' +NotoSans = 'NotoSans/NotoSans-SemiCondensed' +weather_font = 'WeatherFont/weathericons-regular-webfont.ttf' + weekday = im_open(opath+'weekday.png') eventicon = im_open(opath+'event.png') dateicon = im_open(opath+'today.png') seperator = im_open(opath+'seperator.jpeg') seperator2 = im_open(opath+'seperator2.jpeg') -tempicon = im_open(opath+'temperature.jpeg') -humicon = im_open(opath+'humidity.jpeg') -no_response = im_open(opath+'cloud-no-response.jpeg') -sunriseicon = im_open(opath+'wi-sunrise.jpeg') -sunseticon = im_open(opath+'wi-sunset.jpeg') -windicon = im_open(opath+'wi-strong-wind.jpeg') black = im_open(opath+'black.jpeg') white = im_open(opath+'white.jpeg') red = im_open(opath+'red.jpeg') @@ -129,12 +127,10 @@ weekday_pos = { } weathericons = { - '01d': 'wi-day-sunny', '02d':'wi-day-cloudy', '03d': 'wi-cloudy', - '04d': 'wi-cloudy-windy', '09d': 'wi-showers', '10d':'wi-rain', - '11d':'wi-thunderstorm', '13d':'wi-snow', '50d': 'wi-fog', - '01n': 'wi-night-clear', '02n':'wi-night-cloudy', - '03n': 'wi-night-cloudy', '04n': 'wi-night-cloudy', - '09n': 'wi-night-showers', '10n':'wi-night-rain', - '11n':'wi-night-thunderstorm', '13n':'wi-night-snow', - '50n': 'wi-night-alt-cloudy-windy' + '01d': '\uf00d', '02d': '\uf002', '03d': '\uf013', + '04d': '\uf012', '09d': '\uf01a', '10d': '\uf019', + '11d': '\uf01e', '13d': '\uf01b', '50d': '\uf014', + '01n': '\uf02e', '02n': '\uf013', '03n': '\uf013', + '04n': '\uf013', '09n': '\uf037', '10n': '\uf036', + '11n': '\uf03b', '13n': '\uf038', '50n': '\uf023' } diff --git a/Calendar/other/cloud-no-response.jpeg b/Calendar/other/cloud-no-response.jpeg deleted file mode 100644 index 9e14426..0000000 Binary files a/Calendar/other/cloud-no-response.jpeg and /dev/null differ diff --git a/Calendar/other/humidity.jpeg b/Calendar/other/humidity.jpeg deleted file mode 100644 index 09497d8..0000000 Binary files a/Calendar/other/humidity.jpeg and /dev/null differ diff --git a/Calendar/other/temperature.jpeg b/Calendar/other/temperature.jpeg deleted file mode 100644 index 679e04a..0000000 Binary files a/Calendar/other/temperature.jpeg and /dev/null differ diff --git a/Calendar/other/wi-strong-wind.jpeg b/Calendar/other/wi-strong-wind.jpeg deleted file mode 100644 index 319dfa4..0000000 Binary files a/Calendar/other/wi-strong-wind.jpeg and /dev/null differ diff --git a/Calendar/other/wi-sunrise.jpeg b/Calendar/other/wi-sunrise.jpeg deleted file mode 100644 index ad096bd..0000000 Binary files a/Calendar/other/wi-sunrise.jpeg and /dev/null differ diff --git a/Calendar/other/wi-sunset.jpeg b/Calendar/other/wi-sunset.jpeg deleted file mode 100644 index 1619f44..0000000 Binary files a/Calendar/other/wi-sunset.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-cloudy-windy.jpeg b/Calendar/weather-icons/wi-cloudy-windy.jpeg deleted file mode 100644 index e53e59d..0000000 Binary files a/Calendar/weather-icons/wi-cloudy-windy.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-cloudy.jpeg b/Calendar/weather-icons/wi-cloudy.jpeg deleted file mode 100644 index bce588a..0000000 Binary files a/Calendar/weather-icons/wi-cloudy.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-day-cloudy.jpeg b/Calendar/weather-icons/wi-day-cloudy.jpeg deleted file mode 100644 index 63dead6..0000000 Binary files a/Calendar/weather-icons/wi-day-cloudy.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-day-sunny.jpeg b/Calendar/weather-icons/wi-day-sunny.jpeg deleted file mode 100644 index 87a88aa..0000000 Binary files a/Calendar/weather-icons/wi-day-sunny.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-fog.jpeg b/Calendar/weather-icons/wi-fog.jpeg deleted file mode 100644 index 02a6382..0000000 Binary files a/Calendar/weather-icons/wi-fog.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-night-alt-cloudy-windy.jpeg b/Calendar/weather-icons/wi-night-alt-cloudy-windy.jpeg deleted file mode 100644 index 6c4539f..0000000 Binary files a/Calendar/weather-icons/wi-night-alt-cloudy-windy.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-night-clear.jpeg b/Calendar/weather-icons/wi-night-clear.jpeg deleted file mode 100644 index 083c6a0..0000000 Binary files a/Calendar/weather-icons/wi-night-clear.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-night-cloudy.jpeg b/Calendar/weather-icons/wi-night-cloudy.jpeg deleted file mode 100644 index 3760a4c..0000000 Binary files a/Calendar/weather-icons/wi-night-cloudy.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-night-rain.jpeg b/Calendar/weather-icons/wi-night-rain.jpeg deleted file mode 100644 index 4d41166..0000000 Binary files a/Calendar/weather-icons/wi-night-rain.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-night-showers.jpeg b/Calendar/weather-icons/wi-night-showers.jpeg deleted file mode 100644 index 1f543b3..0000000 Binary files a/Calendar/weather-icons/wi-night-showers.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-night-snow.jpeg b/Calendar/weather-icons/wi-night-snow.jpeg deleted file mode 100644 index 5a61252..0000000 Binary files a/Calendar/weather-icons/wi-night-snow.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-night-thunderstorm.jpeg b/Calendar/weather-icons/wi-night-thunderstorm.jpeg deleted file mode 100644 index 938c482..0000000 Binary files a/Calendar/weather-icons/wi-night-thunderstorm.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-rain.jpeg b/Calendar/weather-icons/wi-rain.jpeg deleted file mode 100644 index b60255a..0000000 Binary files a/Calendar/weather-icons/wi-rain.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-showers.jpeg b/Calendar/weather-icons/wi-showers.jpeg deleted file mode 100644 index bec0534..0000000 Binary files a/Calendar/weather-icons/wi-showers.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-snow.jpeg b/Calendar/weather-icons/wi-snow.jpeg deleted file mode 100644 index 8c73914..0000000 Binary files a/Calendar/weather-icons/wi-snow.jpeg and /dev/null differ diff --git a/Calendar/weather-icons/wi-thunderstorm.jpeg b/Calendar/weather-icons/wi-thunderstorm.jpeg deleted file mode 100644 index 121de06..0000000 Binary files a/Calendar/weather-icons/wi-thunderstorm.jpeg and /dev/null differ