wcurrent and daily weather added

This commit is contained in:
Neythen 2021-06-07 21:03:03 +01:00
parent 7a0056abc4
commit 34b204347a
29 changed files with 174 additions and 68 deletions

View File

@ -257,7 +257,7 @@ def updateWeather(location, api_key):
dct['main_weather'] = day['weather'][0]['main'] dct['main_weather'] = day['weather'][0]['main']
dct['description'] = day['weather'][0]['description'] dct['description'] = day['weather'][0]['description']
dct['min_temp'] = day['temp']['min'] dct['min_temp'] = day['temp']['min']
dct['min_temp'] = day['temp']['max'] dct['max_temp'] = day['temp']['max']
daily_weather.append(dct) daily_weather.append(dct)

View File

@ -1,3 +1,3 @@
symbol,name,base,current,24hr change symbol,name,base,current,24hr change
BTC,bitcoin,usd,38625,2.2471171345902663 BTC,bitcoin,usd,35686,-0.19855074369701814
ETH,ethereum,gbp,1985.53,2.296467164133747 ETH,ethereum,gbp,1923.88,1.8532746746620032

1 symbol name base current 24hr change
2 BTC bitcoin usd 38625 35686 2.2471171345902663 -0.19855074369701814
3 ETH ethereum gbp 1985.53 1923.88 2.296467164133747 1.8532746746620032

View File

@ -1 +1 @@
{"main_weather": "Clouds", "description": "broken clouds", "temp": 18.31, "min_temp": 14.07, "max_temp": 19.86, "feels_like": 18.05, "humidity": 71, "clouds": 69, "wind_speed": 1.84, "wind_direction": 283, "visibility": 10000, "uv": 0} {"main_weather": "Clouds", "description": "overcast clouds", "temp": 18.72, "min_temp": 15.77, "max_temp": 20.06, "feels_like": 18.42, "humidity": 68, "clouds": 100, "wind_speed": 2.44, "wind_direction": 228, "visibility": 10000, "uv": 0}

View File

@ -1 +1 @@
[{"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 24.1}, {"main_weather": "Rain", "description": "light rain", "min_temp": 17.29}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 22.66}, {"main_weather": "Rain", "description": "light rain", "min_temp": 22.87}, {"main_weather": "Rain", "description": "light rain", "min_temp": 21.16}, {"main_weather": "Rain", "description": "light rain", "min_temp": 21.82}, {"main_weather": "Rain", "description": "light rain", "min_temp": 23.41}, {"main_weather": "Rain", "description": "light rain", "min_temp": 22.89}] [{"main_weather": "Clouds", "description": "few clouds", "min_temp": 12.92, "max_temp": 22.22}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 12.68, "max_temp": 22.5}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 13.04, "max_temp": 23.87}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 14.72, "max_temp": 24.47}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 15.51, "max_temp": 25.8}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 16.6, "max_temp": 28.11}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 16.35, "max_temp": 27.24}, {"main_weather": "Rain", "description": "light rain", "min_temp": 17.54, "max_temp": 28.74}]

View File

@ -1 +1 @@
03/06/2021 16:44:14 07/06/2021 16:02:07

1 03/06/2021 16:44:14 07/06/2021 16:02:07

View File

@ -1,21 +1,21 @@
headline,source,date,time headline,source,date,time
FBI investigating Postmaster General Louis DeJoy in connection with past political fundraising - The Washington Post,The Washington Post,2021-06-03,18:38:00Z macOS 12 Monterey announced - here's what's coming to MacBooks later in 2021 - TechRadar,TechRadar,2021-06-07,18:30:46Z
FIFA World Cup Qualifiers Live Score: 10-men India 0-1 Qatar in second half - The Indian Express,The Indian Express,2021-06-03,18:30:08Z COVID vaccine: Period changes could be a short-term side effect - Times of India,The Times of India,2021-06-07,18:30:00Z
SpaceX launches tiny critters^ solar panels to space station - Phys.org,Phys.Org,2021-06-03,18:21: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
Covid travel rules: Portugal removed from UK green list as seven others join red list - BBC News,BBC News,2021-06-03,18:16:25Z Arctic micro-animal survives 24000 years in Siberian permafrost - eNCA,eNCA,2021-06-07,18:20:10Z
Trent Alexander-Arnold: England right-back ruled out of Euro 2020 - BBC Sport,BBC News,2021-06-03,18:14:46Z 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
Washington to bar US investors from 59 Chinese companies - Financial Times,Financial Times,2021-06-03,18:00:50Z Leveraging past flu pandemics helps build universal flu vaccine - The Science Board,Scienceboard.net,2021-06-07,18:16:01Z
Massive Die-Off Discovered by Accident: A Shark Mystery Millions of Years in the Making - SciTechDaily,SciTechDaily,2021-06-03,18:00:02Z iPadOS 15 announced at WWDC^ features improved multitasking and surprising Swift Playgrounds features - Yahoo Singapore News,Yahoo Entertainment,2021-06-07,18:12:11Z
SpaceX launches Dragon cargo spacecraft to the Space Station with new Falcon 9 - Yahoo Philippines News,Yahoo Entertainment,2021-06-03,18:00:00Z Apple announces watchOS 8 with new health features - The Verge,The Verge,2021-06-07,18:11:38Z
Apple announces AirTag privacy improvements^ Android app coming this year - 9to5Mac,9to5Mac,2021-06-03,17:58:00Z 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
SpaceX launches Dragon cargo spacecraft to the Space Station with new Falcon 9 - Yahoo Singapore News,Yahoo Entertainment,2021-06-03,17:55:39Z Apples Siri will finally work without an internet connection thanks to on-device processing - The Verge,The Verge,2021-06-07,18:07:17Z
How to Photograph an Annular 'Ring of Fire' Solar Eclipse - PetaPixel,PetaPixel,2021-06-03,17:55:37Z tvOS is getting spatial audio support for AirPods Pro and Max - Yahoo Singapore News,Yahoo Entertainment,2021-06-07,18:07:02Z
Cricket: Devon Conway hits stunning 200 but England fight back against Black Caps on day two of first test at Lord's - New Zealand Herald,New Zealand Herald,2021-06-03,17:53:09Z 2nd dose vaccine eligibility expands^ 2 new deaths linked to Alpha COVID-19 variant - Global News,Global News,2021-06-07,18:04:33Z
UK records 5^274 new Covid cases in 24 hours in highest number of daily infections since March as well as... - The Sun,The Sun,2021-06-03,17:52:00Z iPadOS 15 announced at WWDC^ features improved multitasking and surprising Swift Playgrounds features - Yahoo Movies Canada,Yahoo Entertainment,2021-06-07,18:04:33Z
Morden schools move to remote learning as Manitoba reports 360 new cases^ 5 deaths - CBC.ca,CBC News,2021-06-03,17:51:51Z 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
Andorra 1 Ireland 4: Stephen Kenny finally gets a win as Troy Parrott brace inspires comeback victory - Independent.ie,Independent.ie,2021-06-03,17:49:00Z Covid 19 coronavirus: Fiji crisis - 147 cases in two days^ patient dies - New Zealand Herald,New Zealand Herald,2021-06-07,18:00:00Z
COVID-19 live updates: Quebec publishes timeline for advancing second-dose appointments - Montreal Gazette,Montreal Gazette,2021-06-03,17:48:45Z FDA approves Alzheimer's drug from Biogen^ against experts' advice - NBC News,NBC News,2021-06-07,17:59:36Z
SpaceX launches Dragon cargo spacecraft to the Space Station with new Falcon 9 - Yahoo Movies Canada,Yahoo Entertainment,2021-06-03,17:47:22Z Covid: Euro 2020 fan zone in Glasgow an 'absolute slap' for hospitality - BBC News,BBC News,2021-06-07,17:47:18Z
Sinn Féin receives another £800^000 from the will of deceased English man - TheJournal.ie,TheJournal.ie,2021-06-03,17:47:00Z 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
England vs New Zealand: Devon Conway scores double ton in first Test but Joe Root's men fight back at Lord's - Sky Sports,Sky Sports,2021-06-03,17:44:58Z Stream of stars extends thousands of light-years across the Milky Way - Phys.org,Phys.Org,2021-06-07,17:46:34Z
Vanessa Bryant^ Kobes widow^ alleges Nike leaked unauthorized Mambacita shoes - CNBC,CNBC,2021-06-03,17:43:14Z New Brunswick fails to meet vaccination target^ delays first phase of reopening plan - HalifaxToday.ca,HalifaxToday.ca,2021-06-07,17:45:58Z

1 headline source date time
2 FBI investigating Postmaster General Louis DeJoy in connection with past political fundraising - The Washington Post macOS 12 Monterey announced - here's what's coming to MacBooks later in 2021 - TechRadar The Washington Post TechRadar 2021-06-03 2021-06-07 18:38:00Z 18:30:46Z
3 FIFA World Cup Qualifiers Live Score: 10-men India 0-1 Qatar in second half - The Indian Express COVID vaccine: Period changes could be a short-term side effect - Times of India The Indian Express The Times of India 2021-06-03 2021-06-07 18:30:08Z 18:30:00Z
4 SpaceX launches tiny critters^ solar panels to space station - Phys.org 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 Phys.Org Toronto Star 2021-06-03 2021-06-07 18:21:00Z 18:20:11Z
5 Covid travel rules: Portugal removed from UK green list as seven others join red list - BBC News Arctic micro-animal survives 24000 years in Siberian permafrost - eNCA BBC News eNCA 2021-06-03 2021-06-07 18:16:25Z 18:20:10Z
6 Trent Alexander-Arnold: England right-back ruled out of Euro 2020 - BBC Sport Live updates: Harris warns Guatemalans they will be turned back if they come to the U.S. border illegally - The Washington Post BBC News The Washington Post 2021-06-03 2021-06-07 18:14:46Z 18:18:00Z
7 Washington to bar US investors from 59 Chinese companies - Financial Times Leveraging past flu pandemics helps build universal flu vaccine - The Science Board Financial Times Scienceboard.net 2021-06-03 2021-06-07 18:00:50Z 18:16:01Z
8 Massive Die-Off Discovered by Accident: A Shark Mystery Millions of Years in the Making - SciTechDaily iPadOS 15 announced at WWDC^ features improved multitasking and surprising Swift Playgrounds features - Yahoo Singapore News SciTechDaily Yahoo Entertainment 2021-06-03 2021-06-07 18:00:02Z 18:12:11Z
9 SpaceX launches Dragon cargo spacecraft to the Space Station with new Falcon 9 - Yahoo Philippines News Apple announces watchOS 8 with new health features - The Verge Yahoo Entertainment The Verge 2021-06-03 2021-06-07 18:00:00Z 18:11:38Z
10 Apple announces AirTag privacy improvements^ Android app coming this year - 9to5Mac 17 areas now COVID hotspots in UK cases as surge 53% in a week - Yahoo Philippines News 9to5Mac Yahoo Entertainment 2021-06-03 2021-06-07 17:58:00Z 18:11:15Z
11 SpaceX launches Dragon cargo spacecraft to the Space Station with new Falcon 9 - Yahoo Singapore News Apple’s Siri will finally work without an internet connection thanks to on-device processing - The Verge Yahoo Entertainment The Verge 2021-06-03 2021-06-07 17:55:39Z 18:07:17Z
12 How to Photograph an Annular 'Ring of Fire' Solar Eclipse - PetaPixel tvOS is getting spatial audio support for AirPods Pro and Max - Yahoo Singapore News PetaPixel Yahoo Entertainment 2021-06-03 2021-06-07 17:55:37Z 18:07:02Z
13 Cricket: Devon Conway hits stunning 200 but England fight back against Black Caps on day two of first test at Lord's - New Zealand Herald 2nd dose vaccine eligibility expands^ 2 new deaths linked to Alpha COVID-19 variant - Global News New Zealand Herald Global News 2021-06-03 2021-06-07 17:53:09Z 18:04:33Z
14 UK records 5^274 new Covid cases in 24 hours in highest number of daily infections since March as well as... - The Sun iPadOS 15 announced at WWDC^ features improved multitasking and surprising Swift Playgrounds features - Yahoo Movies Canada The Sun Yahoo Entertainment 2021-06-03 2021-06-07 17:52:00Z 18:04:33Z
15 Morden schools move to remote learning as Manitoba reports 360 new cases^ 5 deaths - CBC.ca Skin in the game: Video chat apps tout 'inclusive' AI features | Global Banking & Finance Review - Global Banking And Finance Review CBC News Global Banking And Finance Review 2021-06-03 2021-06-07 17:51:51Z 18:00:27Z
16 Andorra 1 Ireland 4: Stephen Kenny finally gets a win as Troy Parrott brace inspires comeback victory - Independent.ie Covid 19 coronavirus: Fiji crisis - 147 cases in two days^ patient dies - New Zealand Herald Independent.ie New Zealand Herald 2021-06-03 2021-06-07 17:49:00Z 18:00:00Z
17 COVID-19 live updates: Quebec publishes timeline for advancing second-dose appointments - Montreal Gazette FDA approves Alzheimer's drug from Biogen^ against experts' advice - NBC News Montreal Gazette NBC News 2021-06-03 2021-06-07 17:48:45Z 17:59:36Z
18 SpaceX launches Dragon cargo spacecraft to the Space Station with new Falcon 9 - Yahoo Movies Canada Covid: Euro 2020 fan zone in Glasgow an 'absolute slap' for hospitality - BBC News Yahoo Entertainment BBC News 2021-06-03 2021-06-07 17:47:22Z 17:47:18Z
19 Sinn Féin receives another £800^000 from the will of deceased English man - TheJournal.ie As AMC Entertainment stock surges 20%^ SEC says it's watching memes for 'disruptions of the market^ manipulative trading^ or other misconduct' - MarketWatch TheJournal.ie MarketWatch 2021-06-03 2021-06-07 17:47:00Z
20 England vs New Zealand: Devon Conway scores double ton in first Test but Joe Root's men fight back at Lord's - Sky Sports Stream of stars extends thousands of light-years across the Milky Way - Phys.org Sky Sports Phys.Org 2021-06-03 2021-06-07 17:44:58Z 17:46:34Z
21 Vanessa Bryant^ Kobe’s widow^ alleges Nike leaked unauthorized Mambacita shoes - CNBC New Brunswick fails to meet vaccination target^ delays first phase of reopening plan - HalifaxToday.ca CNBC HalifaxToday.ca 2021-06-03 2021-06-07 17:43:14Z 17:45:58Z

View File

@ -1,4 +1,4 @@
name,current,opening name,current,opening
MSFT,245.71,245.22 MSFT,253.81,249.98
NFLX,489.43,495.19 NFLX,494.66,492.917
GOOG,2404.61,2395.02 GOOG,2466.09,2451.32

1 name current opening
2 MSFT 245.71 253.81 245.22 249.98
3 NFLX 489.43 494.66 495.19 492.917
4 GOOG 2404.61 2466.09 2395.02 2451.32

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: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

BIN
logos/weather_icons/uv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

View File

@ -278,8 +278,8 @@ def matrix():
LastCommand = 'Run display' LastCommand = 'Run display'
if "Run News" in request.form: elif "Run News" in request.form:
pass
print('run display') print('run display')
ticker.sendline('K') ticker.sendline('K')
ticker.sendline('N') ticker.sendline('N')
@ -288,8 +288,27 @@ def matrix():
LastCommand = 'Run display' LastCommand = 'Run display'
elif "Stop Display (at next refresh)" in request.form: elif "Run Weather" in request.form:
pass
ticker.sendline('K')
ticker.sendline('W')
print('back in flask')
LastCommand = 'Run display'
elif "Run Daily Weather" in request.form:
ticker.sendline('K')
ticker.sendline('D')
print('back in flask')
LastCommand = 'Run display'
elif "Stop Display" in request.form:
print('run display') print('run display')
#ticker.kill() #ticker.kill()
try: try:
@ -299,7 +318,7 @@ def matrix():
except: except:
print("none running") print("none running")
elif "Shutdown the pi" in request.form: elif "Shutdown the pi" in request.form:
pass
try: try:
LastCommand = 'shutdown' LastCommand = 'shutdown'
os.system("sudo shutdown now") os.system("sudo shutdown now")

View File

@ -537,21 +537,21 @@ class StockTicker():
elif updated_img == 2: elif updated_img == 2:
finalDisplayImage.save('final1.ppm') finalDisplayImage.save('final1.ppm')
def getWeatherImage(self): def getTodayWeatherImage(self):
img = Image.new('RGB', (128, 32)) img = Image.new('RGB', (225, 32))
location = 'London' location = 'London'
current_weather = json.load(open('csv/current_weather.json', 'r')) current_weather = json.load(open('csv/current_weather.json', 'r'))
small_font = ImageFont.load("./fonts/4x6.pil") small_font = ImageFont.load("./fonts/5x7.pil")
large_font = ImageFont.load("./fonts/6x12.pil") large_font = ImageFont.load("./fonts/10x20.pil")
location_img = self.textImage(location, small_font) location_img = self.textImage(location, small_font)
img.paste(location_img, (0,0)) img.paste(location_img, (5,0))
main = current_weather['main_weather'] main = current_weather['main_weather']
if main == 'Clouds': if main == 'Clouds':
@ -561,41 +561,41 @@ class StockTicker():
'Sand': '50', 'Ash': '50', 'Squall': '50', 'Tornado': '50'} 'Sand': '50', 'Ash': '50', 'Squall': '50', 'Tornado': '50'}
weather_dir = './logos/weather_icons' weather_dir = './logos/weather_icons'
print(current_weather)
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
img.paste(weather_img, (0,12))
temp_img = self.textImage(str(current_weather['temp']), large_font) weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
img.paste(temp_img, (32,13)) img.paste(weather_img, (5,12))
temp_img = self.textImage(str("{0:.0f}".format(current_weather['temp'])), large_font)
img.paste(temp_img, (50,9))
deg_img = self.textImage('o', small_font) deg_img = self.textImage('o', small_font)
print(temp_img.size) print(temp_img.size)
img.paste(deg_img, (31 + temp_img.size[0], 11)) img.paste(deg_img, (70, 8))
main = current_weather['main_weather'] main = current_weather['main_weather']
main_img = self.textImage(main, small_font) main_img = self.textImage(main, small_font)
img.paste(main_img, (32, 25)) img.paste(main_img, (45, 26))
feels_img = self.textImage('Feels: ' + str(current_weather['feels_like']), small_font) feels_img = self.textImage('Feels like:' + str("{0:.0f}".format(current_weather['feels_like'])), small_font)
img.paste(feels_img, (location_img.size[0]+2, 0)) img.paste(feels_img, (41, 0))
min_img = self.textImage( "{0:.1f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255) min_img = self.textImage( "{0:.0f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255)
img.paste(min_img, (location_img.size[0]+2, 7)) img.paste(min_img, (75, 15))
max_img = self.textImage( "{0:.1f}".format(current_weather['max_temp']), small_font, r=255, g=0, b=0) max_img = self.textImage( "{0:.0f}".format(current_weather['max_temp']), small_font, r=255, g=0, b=0)
img.paste(max_img, (location_img.size[0] + min_img.size[0]+2, 7)) img.paste(max_img, (90, 15))
hum_img = Image.open(weather_dir + '/humidity.png') hum_img = Image.open(weather_dir + '/humidity.png')
img.paste(hum_img, ( 64, 8)) img.paste(hum_img, ( 107, 8))
htext_img = self.textImage(str(current_weather['humidity']) + '%', small_font) htext_img = self.textImage(str(current_weather['humidity']) + '%', small_font)
img.paste(htext_img, (73, 10)) img.paste(htext_img, (120, 10))
uv_img = Image.open(weather_dir + '/uv.png') uv_img = Image.open(weather_dir + '/uv.png')
img.paste(uv_img, ( 64, 20)) img.paste(uv_img, ( 109, 20))
utext_img = self.textImage(str(current_weather['uv']) , small_font) utext_img = self.textImage(str(current_weather['uv']) , small_font)
img.paste(utext_img, (75, 23)) img.paste(utext_img, (120, 23))
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
months =['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] months =['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
@ -605,31 +605,99 @@ class StockTicker():
weekday = weekdays[datetime.today().weekday()] weekday = weekdays[datetime.today().weekday()]
print(month, date, weekday)
date_img = self.textImage(month + ' ' + date + ', ' + weekday, small_font) date_img = self.textImage(month + ' ' + date + ', ' + weekday, small_font)
img.paste(date_img, (80, 0)) img.paste(date_img, (132, 0))
rain_img = Image.open(weather_dir + '/rain-chance.png') rain_img = Image.open(weather_dir + '/rain-chance.png')
img.paste(rain_img, (86,8)) img.paste(rain_img, (143,8))
rtext_img = self.textImage(str(current_weather['clouds']) + '%', small_font) rtext_img = self.textImage(str(current_weather['clouds']) + '%', small_font)
img.paste(rtext_img, (99, 10)) img.paste(rtext_img, (156, 10))
cloud_img = Image.open(weather_dir + '/clouds.png') cloud_img = Image.open(weather_dir + '/clouds.png')
img.paste(cloud_img, (86,20)) img.paste(cloud_img, (143,20))
ctext_img = self.textImage(str(current_weather['clouds']) + '%', small_font) ctext_img = self.textImage(str(current_weather['clouds']) + '%', small_font)
img.paste(ctext_img, (99, 22)) img.paste(ctext_img, (156, 22))
wind_img = Image.open(weather_dir + '/wind.png') wind_img = Image.open(weather_dir + '/wind.png')
img.paste(wind_img, (115,8)) img.paste(wind_img, (177,8))
wtext_img = self.textImage(str(current_weather['wind_speed']) + 'm/s', small_font)
img.paste(wtext_img, (190, 10))
vis_img = Image.open(weather_dir + '/visibility.png') vis_img = Image.open(weather_dir + '/visibility.png')
img.paste(vis_img, (115,20)) img.paste(vis_img, (177,20))
self.setImage(img) vtext_img = self.textImage(str(current_weather['visibility']/1000) + 'km', small_font)
img.paste(vtext_img, (190, 22))
return img
def getDailyWeatherImage(self):
location = 'London'
img = Image.new('RGB', (1000, 32))
daily_weather = json.load(open('csv/daily_weather.json', 'r'))
small_font = ImageFont.load("./fonts/5x7.pil")
large_font = ImageFont.load("./fonts/10x20.pil")
location_img = self.textImage(location, small_font)
#img.paste(location_img, (20,0))
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, small_font)
#img.paste(date_img, (70, 0))
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)):
weather = daily_weather[i]
main = weather['main_weather']
if main == 'Clouds':
main = weather['description']
weather_img = Image.open(weather_dir + '/weather_type_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))
x_offset += weather_img.size[0] + 5
img = img.crop((0,0,x_offset,32))
return img
#Send the final stitched image to the display for set amount of time #Send the final stitched image to the display for set amount of time
def displayStocks(self): def displayStocks(self):
@ -756,8 +824,16 @@ class StockTicker():
kill = self.scrollGIF(gif, offset_x = 128) kill = self.scrollGIF(gif, offset_x = 128)
if kill: if kill:
break break
elif msg == 'W': # weather
img = stock_ticker.getTodayWeatherImage()
img.save('weather.ppm')
self.scrollImageTransition(['weather.ppm', 'weather.ppm'])
elif msg == 'D': # daily weather
img = stock_ticker.getDailyWeatherImage()
img.save('weather.ppm')
self.scrollImageTransition(['weather.ppm', 'weather.ppm'])
elif msg == 'K': # kill elif msg == 'K': # kill
self.resetMatrix() self.resetMatrix()
@ -768,7 +844,16 @@ if __name__ == '__main__':
with open('log.txt', "w") as log: with open('log.txt', "w") as log:
try: try:
stock_ticker = StockTicker() stock_ticker = StockTicker()
stock_ticker.getWeatherImage()
#img = stock_ticker.getDailyWeatherImage()
#img = stock_ticker.getTodayWeatherImage()
#img.save('weather.ppm')
#stock_ticker.scrollImageTransition(['weather.ppm', 'weather.ppm'])
#stock_ticker.process_msg('G') #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) #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)
#stock_ticker.readCSV() #stock_ticker.readCSV()

View File

@ -12,7 +12,9 @@
<form action="/matrix" method="POST"> <form action="/matrix" method="POST">
<input type="submit" name="Run Stocks" value="Run Stocks" style="height:50px" > <input type="submit" name="Run Stocks" value="Run Stocks" style="height:50px" >
<input type="submit" name="Run News" value="Run News" style="height:50px" > <input type="submit" name="Run News" value="Run News" style="height:50px" >
<input type="submit" name="Stop Display (at next refresh)" value="Stop Display"style="height:50px"> <input type="submit" name="Run Weather" value="Run Weather" style="height:50px" >
<input type="submit" name="Run Daily Weather" value="Run Daily Weather" style="height:50px" >
<input type="submit" name="Stop Display" value="Stop Display"style="height:50px">
<input type="submit" name="Shutdown the pi" value="Shutdown the pi"style="height:50px"> <input type="submit" name="Shutdown the pi" value="Shutdown the pi"style="height:50px">
</form> </form>
<br><br> <br><br>

BIN
weather.ppm Executable file

Binary file not shown.