weather updates

This commit is contained in:
Neythen 2021-06-08 21:16:08 +01:00
parent 7ab6a0a24b
commit 02274e9d0e
22 changed files with 219 additions and 77 deletions

View File

@ -245,6 +245,8 @@ def updateWeather(location, api_key):
current_weather['wind_direction'] = weather['wind']['deg']
current_weather['visibility'] = weather['visibility']
current_weather['uv'] = r.json()['current']['uvi']
current_weather['rain_chance'] = r.json()['hourly'][0]['pop']
json.dump( current_weather, open( "csv/current_weather.json", 'w+' ))
@ -259,8 +261,7 @@ def updateWeather(location, api_key):
dct['min_temp'] = day['temp']['min']
dct['max_temp'] = day['temp']['max']
daily_weather.append(dct)
json.dump( daily_weather, open( "csv/daily_weather.json", 'w+' ))
if __name__ == '__main__':

View File

@ -1,3 +1,3 @@
symbol,name,base,current,24hr change
BTC,bitcoin,usd,35668,-0.37786061371520613
ETH,ethereum,gbp,1923.94,1.8341326495198176
BTC,bitcoin,usd,32887,-7.6081007271389165
ETH,ethereum,gbp,1768.04,-8.205044425803774

1 symbol name base current 24hr change
2 BTC bitcoin usd 35668 32887 -0.37786061371520613 -7.6081007271389165
3 ETH ethereum gbp 1923.94 1768.04 1.8341326495198176 -8.205044425803774

View File

@ -1 +1 @@
{"main_weather": "Clouds", "description": "overcast clouds", "temp": 18.69, "min_temp": 15.77, "max_temp": 20.06, "feels_like": 18.44, "humidity": 70, "clouds": 100, "wind_speed": 2.44, "wind_direction": 228, "visibility": 10000, "uv": 0}
{"main_weather": "Clouds", "description": "overcast clouds", "temp": 19.73, "min_temp": 15.55, "max_temp": 21.01, "feels_like": 19.27, "humidity": 58, "clouds": 100, "wind_speed": 1.84, "wind_direction": 249, "visibility": 10000, "uv": 0, "rain_chance": 0}

View File

@ -1 +1 @@
[{"main_weather": "Clouds", "description": "few clouds", "min_temp": 12.92, "max_temp": 22.21}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 12.67, "max_temp": 22.49}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 13.03, "max_temp": 23.86}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 14.72, "max_temp": 24.46}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 15.5, "max_temp": 25.79}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 16.59, "max_temp": 28.09}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 16.34, "max_temp": 27.22}, {"main_weather": "Rain", "description": "light rain", "min_temp": 17.53, "max_temp": 28.72}]
[{"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 13.24, "max_temp": 23.67}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 12.23, "max_temp": 23.89}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.69, "max_temp": 22.98}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.9, "max_temp": 24.55}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 15.43, "max_temp": 25.91}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 16.26, "max_temp": 27.68}, {"main_weather": "Rain", "description": "light rain", "min_temp": 17.66, "max_temp": 29.24}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 16.08, "max_temp": 23.33}]

View File

@ -1 +1 @@
07/06/2021 16:09:41
08/06/2021 16:13:48

1 07/06/2021 16:09:41 08/06/2021 16:13:48

View File

@ -1,21 +1,21 @@
headline,source,date,time
macOS 12 Monterey announced - here's what's coming to MacBooks later in 2021 - TechRadar,TechRadar,2021-06-07,18:30:46Z
COVID vaccine: Period changes could be a short-term side effect - Times of India,The Times of India,2021-06-07,18:30:00Z
Todays coronavirus news: Ontario reporting 525 COVID-19 cases; Ontario to begin reopening Friday; Toronto announces new outdoor fitness programs starting this weekend - Toronto Star,Toronto Star,2021-06-07,18:20:11Z
Arctic micro-animal survives 24000 years in Siberian permafrost - eNCA,eNCA,2021-06-07,18:20:10Z
Live updates: Harris warns Guatemalans they will be turned back if they come to the U.S. border illegally - The Washington Post,The Washington Post,2021-06-07,18:18:00Z
Leveraging past flu pandemics helps build universal flu vaccine - The Science Board,Scienceboard.net,2021-06-07,18:16:01Z
iPadOS 15 announced at WWDC^ features improved multitasking and surprising Swift Playgrounds features - Yahoo Singapore News,Yahoo Entertainment,2021-06-07,18:12:11Z
Apple announces watchOS 8 with new health features - The Verge,The Verge,2021-06-07,18:11:38Z
17 areas now COVID hotspots in UK cases as surge 53% in a week - Yahoo Philippines News,Yahoo Entertainment,2021-06-07,18:11:15Z
Apples Siri will finally work without an internet connection thanks to on-device processing - The Verge,The Verge,2021-06-07,18:07:17Z
tvOS is getting spatial audio support for AirPods Pro and Max - Yahoo Singapore News,Yahoo Entertainment,2021-06-07,18:07:02Z
2nd dose vaccine eligibility expands^ 2 new deaths linked to Alpha COVID-19 variant - Global News,Global News,2021-06-07,18:04:33Z
iPadOS 15 announced at WWDC^ features improved multitasking and surprising Swift Playgrounds features - Yahoo Movies Canada,Yahoo Entertainment,2021-06-07,18:04:33Z
Skin in the game: Video chat apps tout 'inclusive' AI features | Global Banking & Finance Review - Global Banking And Finance Review,Global Banking And Finance Review,2021-06-07,18:00:27Z
Covid 19 coronavirus: Fiji crisis - 147 cases in two days^ patient dies - New Zealand Herald,New Zealand Herald,2021-06-07,18:00:00Z
FDA approves Alzheimer's drug from Biogen^ against experts' advice - NBC News,NBC News,2021-06-07,17:59:36Z
Covid: Euro 2020 fan zone in Glasgow an 'absolute slap' for hospitality - BBC News,BBC News,2021-06-07,17:47:18Z
As AMC Entertainment stock surges 20%^ SEC says it's watching memes for 'disruptions of the market^ manipulative trading^ or other misconduct' - MarketWatch,MarketWatch,2021-06-07,17:47:00Z
Stream of stars extends thousands of light-years across the Milky Way - Phys.org,Phys.Org,2021-06-07,17:46:34Z
New Brunswick fails to meet vaccination target^ delays first phase of reopening plan - HalifaxToday.ca,HalifaxToday.ca,2021-06-07,17:45:58Z
Reduce your salt intake to boost your immunity - Times of India,The Times of India,2021-06-08,18:30:00Z
Geostationary Earth Orbit Hyperspectral Infrared Radiation Data Improves Local Severe Storm Forecasts - Space Bollyinside - BollyInside,Bollyinside.com,2021-06-08,18:27:29Z
Carbon dioxide levels hit 50 percent higher than preindustrial time - NBC News,NBC News,2021-06-08,18:23:31Z
Annual Solar Eclipse Tomorrow^ People of THESE Places in India Will be Able to Watch - India.com,India.com,2021-06-08,18:23:07Z
National Indigenous leaders plan Vatican visit to call for long-awaited papal apology - CBC.ca,CBC News,2021-06-08,18:15:57Z
N.B. says another 29000 people need to get vaccine before health orders are relaxed - NiagaraFallsReview.ca,Toronto Star,2021-06-08,18:11:50Z
Coroner determines Upper Hutt toddler's playground death was the result of 'tragic accident' - Stuff.co.nz,Stuff.co.nz,2021-06-08,18:06:00Z
Controversial scheme to collect and share patient data delayed - The Independent,Independent,2021-06-08,18:05:12Z
Minecraft updates with Cliffs and Caves Part 1^ adds goats and copper - Polygon,Polygon,2021-06-08,18:04:21Z
Utah Jazz rule PG Mike Conley out for Game 1 vs. LA Clippers with hamstring strain - ESPN,ESPN,2021-06-08,17:57:46Z
'This was a terrorist attack': Trudeau condemns London hit-and-run that left four Muslim family members dead - CBC.ca,CBC News,2021-06-08,17:56:14Z
Zidansek and Pavlyuchenkova reach French Open semis after epic battles - The Guardian,The Guardian,2021-06-08,17:51:00Z
New dinosaur species found in Australia was as long as a basketball court - NBC News,NBC News,2021-06-08,17:36:11Z
Julio Jones declines to take No. 11 from Tennessee Titans' A.J. Brown - ESPN,ESPN,2021-06-08,17:35:03Z
EXCLUSIVE: Listen to the full 40-minute Rudy Giuliani phone call with a Ukrainian presidential aide - CNN ,CNN,2021-06-08,17:35:00Z
Waterford dog attack: Dog that attacked and killed three-month-old baby girl is put down as post mortem carried out on child - Independent.ie,Independent.ie,2021-06-08,17:31:00Z
Missing bundles of joy: Govt can't find woman who gave birth to 10 babies - Eyewitness News,EWN,2021-06-08,17:25:17Z
UK housing market is on fire^ warns Bank of England chief economist - The Guardian,The Guardian,2021-06-08,17:22:00Z
Chris Harrison: The Bachelor host leaves for good over racism row - BBC News,BBC News,2021-06-08,17:19:39Z
COVID-19 Update: Three-day vaccination blitz at Telus Convention Centre | Delta variant outbreaks confirmed at Foothills | Alberta urges Ottawa to drop hotel quarantines - Calgary Herald,Calgary Herald,2021-06-08,17:15:00Z

1 headline source date time
2 macOS 12 Monterey announced - here's what's coming to MacBooks later in 2021 - TechRadar Reduce your salt intake to boost your immunity - Times of India TechRadar The Times of India 2021-06-07 2021-06-08 18:30:46Z 18:30:00Z
3 COVID vaccine: Period changes could be a short-term side effect - Times of India Geostationary Earth Orbit Hyperspectral Infrared Radiation Data Improves Local Severe Storm Forecasts - Space Bollyinside - BollyInside The Times of India Bollyinside.com 2021-06-07 2021-06-08 18:30:00Z 18:27:29Z
4 Today’s coronavirus news: Ontario reporting 525 COVID-19 cases; Ontario to begin reopening Friday; Toronto announces new outdoor fitness programs starting this weekend - Toronto Star Carbon dioxide levels hit 50 percent higher than preindustrial time - NBC News Toronto Star NBC News 2021-06-07 2021-06-08 18:20:11Z 18:23:31Z
5 Arctic micro-animal survives 24000 years in Siberian permafrost - eNCA Annual Solar Eclipse Tomorrow^ People of THESE Places in India Will be Able to Watch - India.com eNCA India.com 2021-06-07 2021-06-08 18:20:10Z 18:23:07Z
6 Live updates: Harris warns Guatemalans they will be turned back if they come to the U.S. border illegally - The Washington Post National Indigenous leaders plan Vatican visit to call for long-awaited papal apology - CBC.ca The Washington Post CBC News 2021-06-07 2021-06-08 18:18:00Z 18:15:57Z
7 Leveraging past flu pandemics helps build universal flu vaccine - The Science Board N.B. says another 29000 people need to get vaccine before health orders are relaxed - NiagaraFallsReview.ca Scienceboard.net Toronto Star 2021-06-07 2021-06-08 18:16:01Z 18:11:50Z
8 iPadOS 15 announced at WWDC^ features improved multitasking and surprising Swift Playgrounds features - Yahoo Singapore News Coroner determines Upper Hutt toddler's playground death was the result of 'tragic accident' - Stuff.co.nz Yahoo Entertainment Stuff.co.nz 2021-06-07 2021-06-08 18:12:11Z 18:06:00Z
9 Apple announces watchOS 8 with new health features - The Verge Controversial scheme to collect and share patient data delayed - The Independent The Verge Independent 2021-06-07 2021-06-08 18:11:38Z 18:05:12Z
10 17 areas now COVID hotspots in UK cases as surge 53% in a week - Yahoo Philippines News Minecraft updates with Cliffs and Caves Part 1^ adds goats and copper - Polygon Yahoo Entertainment Polygon 2021-06-07 2021-06-08 18:11:15Z 18:04:21Z
11 Apple’s Siri will finally work without an internet connection thanks to on-device processing - The Verge Utah Jazz rule PG Mike Conley out for Game 1 vs. LA Clippers with hamstring strain - ESPN The Verge ESPN 2021-06-07 2021-06-08 18:07:17Z 17:57:46Z
12 tvOS is getting spatial audio support for AirPods Pro and Max - Yahoo Singapore News 'This was a terrorist attack': Trudeau condemns London hit-and-run that left four Muslim family members dead - CBC.ca Yahoo Entertainment CBC News 2021-06-07 2021-06-08 18:07:02Z 17:56:14Z
13 2nd dose vaccine eligibility expands^ 2 new deaths linked to Alpha COVID-19 variant - Global News Zidansek and Pavlyuchenkova reach French Open semis after epic battles - The Guardian Global News The Guardian 2021-06-07 2021-06-08 18:04:33Z 17:51:00Z
14 iPadOS 15 announced at WWDC^ features improved multitasking and surprising Swift Playgrounds features - Yahoo Movies Canada New dinosaur species found in Australia was as long as a basketball court - NBC News Yahoo Entertainment NBC News 2021-06-07 2021-06-08 18:04:33Z 17:36:11Z
15 Skin in the game: Video chat apps tout 'inclusive' AI features | Global Banking & Finance Review - Global Banking And Finance Review Julio Jones declines to take No. 11 from Tennessee Titans' A.J. Brown - ESPN Global Banking And Finance Review ESPN 2021-06-07 2021-06-08 18:00:27Z 17:35:03Z
16 Covid 19 coronavirus: Fiji crisis - 147 cases in two days^ patient dies - New Zealand Herald EXCLUSIVE: Listen to the full 40-minute Rudy Giuliani phone call with a Ukrainian presidential aide - CNN New Zealand Herald CNN 2021-06-07 2021-06-08 18:00:00Z 17:35:00Z
17 FDA approves Alzheimer's drug from Biogen^ against experts' advice - NBC News Waterford dog attack: Dog that attacked and killed three-month-old baby girl is put down as post mortem carried out on child - Independent.ie NBC News Independent.ie 2021-06-07 2021-06-08 17:59:36Z 17:31:00Z
18 Covid: Euro 2020 fan zone in Glasgow an 'absolute slap' for hospitality - BBC News Missing bundles of joy: Govt can't find woman who gave birth to 10 babies - Eyewitness News BBC News EWN 2021-06-07 2021-06-08 17:47:18Z 17:25:17Z
19 As AMC Entertainment stock surges 20%^ SEC says it's watching memes for 'disruptions of the market^ manipulative trading^ or other misconduct' - MarketWatch UK housing market is on fire^ warns Bank of England chief economist - The Guardian MarketWatch The Guardian 2021-06-07 2021-06-08 17:47:00Z 17:22:00Z
20 Stream of stars extends thousands of light-years across the Milky Way - Phys.org Chris Harrison: The Bachelor host leaves for good over racism row - BBC News Phys.Org BBC News 2021-06-07 2021-06-08 17:46:34Z 17:19:39Z
21 New Brunswick fails to meet vaccination target^ delays first phase of reopening plan - HalifaxToday.ca COVID-19 Update: Three-day vaccination blitz at Telus Convention Centre | Delta variant outbreaks confirmed at Foothills | Alberta urges Ottawa to drop hotel quarantines - Calgary Herald HalifaxToday.ca Calgary Herald 2021-06-07 2021-06-08 17:45:58Z 17:15:00Z

View File

@ -1,4 +1,4 @@
name,current,opening
MSFT,253.81,249.98
NFLX,494.66,492.9169
GOOG,2466.09,2451.32
MSFT,252.57,255.16
NFLX,492.39,497
GOOG,2482.85,2479.9

1 name current opening
2 MSFT 253.81 252.57 249.98 255.16
3 NFLX 494.66 492.39 492.9169 497
4 GOOG 2466.09 2482.85 2451.32 2479.9

BIN
display_image Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
display_image.ppm Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
final.ppm

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

View File

@ -63,9 +63,16 @@ class StockTicker():
image = image.convert('RGB')
return image
def degreesToCompass(self, deg):
dirs = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']
return dirs[int((deg+22.5)//45)%8]
def setImage(self, image, offset_x = 0, offset_y = 0, unsafe=False):
def setImage(self, image, offset_x = 0, offset_y = 0, unsafe=False, min_x = 0, max_x = 128, min_y = 0, max_y = 32):
if (image.mode != "RGB"):
@ -86,11 +93,12 @@ class StockTicker():
# C functions can certainly be faster.
img_width, img_height = image.size
pixels = image.load()
for x in range(max(0, -offset_x), min(img_width, self.matrix.width - offset_x)):
for x in range(max(0,-offset_x), min(img_width, self.matrix.width - offset_x)):
for y in range(max(0, -offset_y), min(img_height, self.matrix.height - offset_y)):
(r, g, b) = pixels[x, y]
self.matrix.SetPixel(x + offset_x, y + offset_y, r*self.brightness, g*self.brightness, b*self.brightness)
if min_x <= x + offset_x <= max_x and min_y <= y + offset_y <= max_y:
self.matrix.SetPixel(x + offset_x, y + offset_y, r*self.brightness, g*self.brightness, b*self.brightness)
def scrollImage(self, image, offset_x = 0, offset_y = 0):
img_width, img_height = image.size
@ -550,7 +558,8 @@ class StockTicker():
large_font = ImageFont.load("./fonts/10x20.pil")
location_img = self.textImage(location, small_font)
location_img = self.textImage(location, small_font, r = 255, g = 255, b = 0)
img.paste(location_img, (5,0))
@ -566,10 +575,10 @@ class StockTicker():
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
img.paste(weather_img, (5,12))
temp_img = self.textImage(str("{0:.0f}".format(current_weather['temp'])), large_font)
temp_img = self.textImage(str("{0:.0f}".format(current_weather['temp'])), large_font, r = 200, g = 0, b = 255)
img.paste(temp_img, (50,9))
deg_img = self.textImage('o', small_font)
deg_img = self.textImage('o', small_font, r = 200, g = 0, b = 255)
print(temp_img.size)
img.paste(deg_img, (70, 8))
@ -577,7 +586,7 @@ class StockTicker():
main_img = self.textImage(main, small_font)
img.paste(main_img, (45, 26))
feels_img = self.textImage('Feels like:' + str("{0:.0f}".format(current_weather['feels_like'])), small_font)
feels_img = self.textImage('Feels like:' + str("{0:.0f}".format(current_weather['feels_like'])), small_font, r = 200, g = 0, b = 255)
img.paste(feels_img, (41, 0))
min_img = self.textImage( "{0:.0f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255)
@ -593,10 +602,10 @@ class StockTicker():
img.paste(htext_img, (120, 10))
uv_img = Image.open(weather_dir + '/uv.png')
img.paste(uv_img, ( 109, 20))
img.paste(uv_img, ( 107, 20))
utext_img = self.textImage(str(current_weather['uv']) , small_font)
img.paste(utext_img, (120, 23))
img.paste(utext_img, (118, 23))
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
months =['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
@ -608,14 +617,14 @@ class StockTicker():
date_img = self.textImage(month + ' ' + date + ', ' + weekday, small_font)
date_img = self.textImage(month + ' ' + date + ',' + weekday, small_font)
img.paste(date_img, (132, 0))
rain_img = Image.open(weather_dir + '/rain-chance.png')
img.paste(rain_img, (143,8))
rtext_img = self.textImage(str(current_weather['clouds']) + '%', small_font)
rtext_img = self.textImage(str(current_weather['rain_chance']) + '%', small_font)
img.paste(rtext_img, (156, 10))
cloud_img = Image.open(weather_dir + '/clouds.png')
@ -625,58 +634,141 @@ class StockTicker():
img.paste(ctext_img, (156, 22))
wind_img = Image.open(weather_dir + '/wind.png')
img.paste(wind_img, (177,8))
img.paste(wind_img, (179,8))
wtext_img = self.textImage(str(current_weather['wind_speed']) + 'm/s', small_font)
img.paste(wtext_img, (190, 10))
wtext_img = self.textImage("{0:.0f}".format(current_weather['wind_speed']) + 'm/s', small_font)
img.paste(wtext_img, (192, 10))
wdir_img = self.textImage(self.degreesToCompass(current_weather['wind_direction']), small_font)
img.paste(wdir_img, (212, 10))
vis_img = Image.open(weather_dir + '/visibility.png')
img.paste(vis_img, (177,20))
img.paste(vis_img, (179,20))
vtext_img = self.textImage(str(current_weather['visibility']/1000) + 'km', small_font)
img.paste(vtext_img, (190, 22))
img.paste(vtext_img, (192, 22))
return img
def getDailyWeatherImage(self):
location = 'London'
img = Image.new('RGB', (1000, 32))
img = Image.new('RGB', (128, 32))
daily_weather = json.load(open('csv/daily_weather.json', 'r'))
current_weather = json.load(open('csv/current_weather.json', 'r'))
small_font = ImageFont.load("./fonts/5x7.pil")
extra_small_font = ImageFont.load("./fonts/4x6.pil")
large_font = ImageFont.load("./fonts/10x20.pil")
location_img = self.textImage(location, small_font)
location_img = self.textImage(location, small_font, r = 255, g = 255, b = 0)
#img.paste(location_img, (20,0))
main = current_weather['main_weather']
if main == 'Clouds':
main = current_weather['description']
weather_ids = {'Clear': '01', 'few clouds': '02', 'scattered clouds': '03', 'broken clouds':'04', 'overcast clouds':'04', 'Drizzle':'09',
'Rain':'10', 'Thunderstorm':'11', 'Snow':'13', 'Mist': '50', 'Smoke': '50', 'Haze': '50', 'Dust': '50', 'Fog': '50',
'Sand': '50', 'Ash': '50', 'Squall': '50', 'Tornado': '50'}
weather_dir = './logos/weather_icons'
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
temp_img = self.textImage(str("{0:.0f}".format(current_weather['temp'])), large_font)
deg_img = self.textImage('o', small_font)
min_img = self.textImage( "{0:.0f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255)
max_img = self.textImage( "{0:.0f}".format(current_weather['max_temp']), small_font, r=255, g=0, b=0)
main = current_weather['main_weather']
main_img = self.textImage(main, small_font)
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
months =['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
month = months[int(datetime.now().strftime('%m'))]
date = str(int(datetime.now().strftime('%d')))
weekday = weekdays[datetime.today().weekday()]
date_img = self.textImage(month + ' ' + date + ',' + weekday, extra_small_font)
rain_img = Image.open(weather_dir + '/rain-chance.png')
date_img = self.textImage(month + ' ' + date + ', ' + weekday, small_font)
rtext_img = self.textImage(str(current_weather['rain_chance']) + '%', extra_small_font)
hum_img = Image.open(weather_dir + '/humidity.png')
htext_img = self.textImage(str(current_weather['humidity']) + '%', extra_small_font)
uv_img = Image.open(weather_dir + '/uv.png')
utext_img = self.textImage(str(current_weather['uv']) , extra_small_font)
wind_img = Image.open(weather_dir + '/wind.png')
wtext_img = self.textImage(str(current_weather['wind_speed']) + 'm/s', extra_small_font)
print(temp_img.size)
img.paste(location_img, (0,0))
img.paste(weather_img, (0,12))
img.paste(temp_img, (30,9))
img.paste(deg_img, (50, 8))
img.paste(min_img, (56, 10))
img.paste(main_img, (30, 26))
img.paste(max_img, (56, 20))
img.paste(date_img, (location_img.size[0], 1))
img.paste(rain_img, (75,0))
img.paste(rtext_img, (88, 1))
img.paste(hum_img, (102, 0))
img.paste(htext_img, (113, 1))
#img.paste(uv_img, ( 96, 0))
#img.paste(utext_img, (109, 0))
#img.paste(wind_img, (96,0))
#img.paste(wtext_img, (109,0))
img0 = img
img = Image.new('RGB', (1000, 32))
daily_weather = json.load(open('csv/daily_weather.json', 'r'))
#img.paste(date_img, (70, 0))
x_offset = 64
for i in range(0,len(daily_weather)-1):
print(len(daily_weather))
weather_dir = './logos/weather_icons'
weather_ids = {'Clear': '01', 'few clouds': '02', 'scattered clouds': '03', 'broken clouds':'04', 'overcast clouds':'04', 'Drizzle':'09',
'Rain':'10', 'Thunderstorm':'11', 'Snow':'13', 'Mist': '50', 'Smoke': '50', 'Haze': '50', 'Dust': '50', 'Fog': '50',
'Sand': '50', 'Ash': '50', 'Squall': '50', 'Tornado': '50'}
x_offset = 4
for i in range(len(daily_weather)):
weekday = weekdays[(datetime.today().weekday() + i)%7]
day_img = self.textImage( weekday, small_font)
weather = daily_weather[i]
main = weather['main_weather']
@ -684,21 +776,24 @@ class StockTicker():
if main == 'Clouds':
main = weather['description']
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
weather_img = Image.open(weather_dir + '/small_icons/' + weather_ids[main] + '.png')
min_img = self.textImage( "{0:.0f}".format(weather['min_temp']), small_font, r=0, g=0, b=255)
max_img = self.textImage( "{0:.0f}".format(weather['max_temp']), small_font, r=255, g=0, b=0)
img.paste(weather_img, (x_offset, 0))
img.paste(min_img, (x_offset, 26))
img.paste(max_img, (x_offset + 12, 26))
img.paste(day_img, (x_offset +5, 9))
img.paste(weather_img, (x_offset +5, 16))
img.paste(min_img, (x_offset + 25, 10))
img.paste(max_img, (x_offset + 25, 21))
x_offset += weather_img.size[0] + 5
x_offset += 35
img = img.crop((0,0,x_offset,32))
img1 = img.crop((64,0,x_offset ,32))
return img
img1.save('weather.ppm')
return img0, img1
#Send the final stitched image to the display for set amount of time
def displayStocks(self):
@ -779,6 +874,48 @@ class StockTicker():
self.running = False
print('MATRIX DISPLAY STOP CALLED')
def displayDailyWeather(self):
img0, img1 = self.getDailyWeatherImage()
#img = stock_ticker.getTodayWeatherImage()
while True:
self.setImage(img0, offset_x = 0, offset_y = 0)
image = img1
img_width, img_height = image.size
offset_x = 64
offset_y = 0
while offset_x > 64-img_width:
offset_x -= 1
self.setImage(image, offset_x = offset_x, offset_y = offset_y, min_x = 64, min_y = 9)
if offset_x + img_width < self.matrix.width: # if the image is ending
self.setImage(image, offset_x = offset_x + img_width, offset_y = offset_y, min_x = 64, min_y = 9)
try:
msg = getInput()
if msg == 'K':
self.resetMatrix()
return True
self.process_msg(msg)
except KeyboardInterrupt:
sys.stdout.flush()
pass
time.sleep(self.delay)
def process_msg(self, msg):
if msg == 'S': # stocks
@ -829,12 +966,10 @@ class StockTicker():
elif msg == 'W': # weather
img = stock_ticker.getTodayWeatherImage()
img.save('weather.ppm')
self.scrollImageTransition(['weather.ppm', 'weather.ppm'])
self.scrollImageTransition(['weather.ppm', 'weather.ppm'], stocks = False)
elif msg == 'D': # daily weather
img = stock_ticker.getDailyWeatherImage()
img.save('weather.ppm')
self.scrollImageTransition(['weather.ppm', 'weather.ppm'])
self.displayDailyWeather()
elif msg == 'K': # kill
self.resetMatrix()
@ -848,12 +983,18 @@ if __name__ == '__main__':
#img = stock_ticker.getDailyWeatherImage()
#img0, img1 = stock_ticker.getDailyWeatherImage()
#img = stock_ticker.getTodayWeatherImage()
#img.save('weather.ppm')
#stock_ticker.scrollImageTransition(['weather.ppm', 'weather.ppm'])
#stock_ticker.process_msg('S')
#stock_ticker.process_msg('W')
#stock_ticker.displayDailyWeather()
#stock_ticker.delay = 10
#stock_ticker.scrollImageTransition(['weather.ppm', 'weather.ppm'], stocks = False)
#stock_ticker.process_msg('G')
#stock_ticker.scrollImageTransition([os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_image'), os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_image')], stocks = False)

Binary file not shown.