transition animations added and sports tidied up

This commit is contained in:
Neythen
2021-06-22 20:05:56 +01:00
parent eb3d52a071
commit 2bee635511
32 changed files with 369 additions and 243 deletions
+3 -1
View File
@@ -451,12 +451,14 @@ if __name__ == '__main__':
finnhubAPIkey = "c24qddqad3ickpckgg80" #Finnhub
finnhubsandboxAPIkey = "sandbox_c24qddqad3ickpckgg8g" #Finnhub
stock_time = 2 #minutes
crypto_time = 10 #minutes
news_time = 30 #minutes
weather_time = 10 #minutes
# TODO: different update times for stocks, weather and news
finnhubClient = finnhub.Client(api_key=finnhubAPIkey)
max_stocks = 200
max_crypto = 100
iexAPIkey = 'pk_68ef6a15902c41f887f0b544a0ca17cf' #IEX
iexSandboxAPIkey = 'Tpk_0078dff413ef4f979137f7111452dc4b'
@@ -478,7 +480,7 @@ if __name__ == '__main__':
symbols, stock_info = readCSV('csv/tickers.csv', max_stocks)
updateStockPrices(symbols)
updateUpdate(NY_time)
coins, coin_info, unique_bases = readCryptoCSV('csv/crypto.csv', max_stocks)
coins, coin_info, unique_bases = readCryptoCSV('csv/crypto.csv', max_crypto)
weather_key = 'bd5d5096a5ba30bbcfb57ead42ab3fee'
+2 -2
View File
@@ -1,3 +1,3 @@
symbol,name,base,current,24hr change
BTC,bitcoin,usd,32709,-5.776193166295658
ETH,ethereum,gbp,1419.48,-7.468105883111548
BTC,bitcoin,usd,32955,0.18795236810340699
ETH,ethereum,gbp,1388.1,-1.2416916112022245
1 symbol name base current 24hr change
2 BTC bitcoin usd 32709 32955 -5.776193166295658 0.18795236810340699
3 ETH ethereum gbp 1419.48 1388.1 -7.468105883111548 -1.2416916112022245
+1 -1
View File
@@ -1 +1 @@
["USD", {"AUD": [1.2965, 1.3001], "CAD": [1.2177, 1.2189], "CHF": [0.89871, 0.90015], "EUR": [0.82481, 0.8259], "GBP": [0.70793, 0.71151], "JPY": [109.86, 110.08], "NZD": [1.3981, 1.403]}]
["USD", {"AUD": [1.3299, 1.3305], "CAD": [1.2381, 1.2411], "CHF": [0.92004, 0.9212], "EUR": [0.84076, 0.84097], "GBP": [0.71935, 0.72046], "JPY": [110.56, 110.09], "NZD": [1.4302, 1.4344]}]
+1 -1
View File
@@ -1 +1 @@
{"main_weather": "Clouds", "description": "overcast clouds", "temp": 29.78, "min_temp": 27.98, "max_temp": 30.21, "feels_like": 36.78, "humidity": 88, "clouds": 100, "wind_speed": 0.89, "wind_direction": 278, "visibility": 10000, "uv": 0, "rain_chance": 0.74}
{"main_weather": "Clouds", "description": "overcast clouds", "temp": 26.64, "min_temp": 25.58, "max_temp": 27.4, "feels_like": 26.64, "humidity": 90, "clouds": 100, "wind_speed": 0.45, "wind_direction": 135, "visibility": 10000, "uv": 0, "rain_chance": 1}
+1 -1
View File
@@ -1 +1 @@
[{"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.51, "max_temp": 29.9}, {"main_weather": "Rain", "description": "very heavy rain", "min_temp": 25.39, "max_temp": 28.65}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.23, "max_temp": 27.86}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.08, "max_temp": 29.59}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.28, "max_temp": 30.13}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.33, "max_temp": 29.98}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.18, "max_temp": 28.89}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.62, "max_temp": 27.71}]
[{"main_weather": "Rain", "description": "heavy intensity rain", "min_temp": 24.83, "max_temp": 27.8}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 25.07, "max_temp": 26.83}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.55, "max_temp": 29}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.75, "max_temp": 29.78}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.93, "max_temp": 29.4}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.61, "max_temp": 28.14}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.57, "max_temp": 28.14}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.69, "max_temp": 28.13}]
+1 -1
View File
@@ -1 +1 @@
21/06/2021 12:41:07
22/06/2021 15:05:29
1 21/06/2021 12:41:07 22/06/2021 15:05:29
+20 -20
View File
@@ -1,21 +1,21 @@
headline,source,date,time
Live Updates: Tornado Hits Chicago Suburbs^ Causing Massive Damage - NBC Chicago,NBC Chicago,2021-06-21,14:36:30Z
Manchester City make Harry Kane bid worth at least £100m to Tottenham - The Guardian,The Guardian,2021-06-21,14:23:00Z
Released but unspent: P18 billion for tests^ health workers expiring June 30 - Rappler,Rappler,2021-06-21,14:22:00Z
Israeli health experts share best practices on vaccine rollout - ABS-CBN News,Abs-cbn.com,2021-06-21,14:21:00Z
LIVE Southampton Weather Updates^ June 21^ Monday^ India vs New Zealand Day 4^ WTC 2021 Final: Play Called Of - India.com,India.com,2021-06-21,14:14:47Z
Handel im Wandel: Hybride Konsumenten? - APA OTS,Www.ots.at,2021-06-21,14:11:54Z
Canada lifting restrictions for fully vaccinated travellers starting July 5 - CTV News,Ctvnews.ca,2021-06-21,14:11:53Z
Philippines^ Saudi Arabia reaffirm vow to protect OFWs - ABS-CBN News,Abs-cbn.com,2021-06-21,14:11:00Z
Geochemical study confirms cause of end-Permian mass extinction event - Phys.org,Phys.Org,2021-06-21,14:05:26Z
The laptops and tablets worth your money on Prime Day - Yahoo Tech,Engadget,2021-06-21,14:05:13Z
Gracie Spinks death: Derbyshire Police referred to watchdog - BBC News,BBC News,2021-06-21,14:03:22Z
Paul Walker's Toyota Supra from The Fast and the Furious fetches over half a million - CNET,CNET,2021-06-21,14:02:17Z
Stock market news live updates: Stocks^ Treasury yields rise as Dow recovers after worst weekly loss since October - Yahoo Finance,Yahoo Entertainment,2021-06-21,14:00:10Z
Millions of new smart TVs^ laptops and other items in Amazon warehouse marked 'destroy' - TheJournal.ie,TheJournal.ie,2021-06-21,13:57:00Z
Target Deal Days rival Amazon Prime Day with massive discounts — here are the best deals to shop - Yahoo Finance Australia,Intheknow.com,2021-06-21,13:56:09Z
PNB Housing Finance vs SEBI: SAT gives nod for EGM on June 22; Voting results to not be declared till... - Moneycontrol,Moneycontrol,2021-06-21,13:53:59Z
Sporadic Covid-19 cases still widespread in Klang Valley - Malaysiakini,Malaysiakini,2021-06-21,13:48:00Z
Samsung Odyssey G3^ Odyssey G5^ Odyssey G7 Gaming Monitors With 178 Degrees Viewing Angle Launched - Gadgets 360,NDTV News,2021-06-21,13:47:31Z
New possibilities for detecting Hawking radiation emitted by primordial black holes - Phys.org,Phys.Org,2021-06-21,13:40:03Z
Global Lip Fillers Market 2021 Industry Trends^ Growth^ Analysis^ Opportunities And Overview || DBMR The Courier - The Courier,Mccourier.com,2021-06-21,13:39:38Z
I am not a vector: Oireachtas committee hears from children affected by the pandemic - TheJournal.ie,TheJournal.ie,2021-06-22,18:30:00Z
Liability conceded in case of couple wrongly advised to terminate pregnancy - The Irish Times,The Irish Times,2021-06-22,18:15:58Z
Delta COVID-19 variant greatest threat to US pandemic response - Fauci - GMA News Online,GMA News,2021-06-22,18:10:22Z
LIVE WTC Final IND vs NZ Live Cricket Score^ Today Match DAY 5 Updates: Kohli-Pujara in; India Lead New Zeala - India.com,India.com,2021-06-22,18:08:55Z
Prime Day headphone deals you shouldn't miss on AirPods^ Bose^ Beats^ Sony^ Samsung and more - CNET,CNET,2021-06-22,18:03:00Z
Jack Grealish^ Bukayo Saka and Harry Maguire start for England against Czech Republic - Sky Sports,Sky Sports,2021-06-22,18:01:14Z
Mother's gestational diabetes is an independent risk factor for fetal hypoxia during labor - News-Medical.Net,News-Medical.Net,2021-06-22,18:01:00Z
Amazon sees Prime Day sales boost amid supply chain snags - CNA,CNA,2021-06-22,18:00:37Z
Twitter opens applications for Ticketed Spaces and Super Follows test - The Verge,The Verge,2021-06-22,18:00:00Z
Mastercard Foundation Appoints Robin Washington to Board of Directors - Guardian,Guardian Nigeria,2021-06-22,18:00:00Z
Trudeau says border restrictions will be further relaxed 'in the coming weeks' if all goes well - CBC.ca,CBC News,2021-06-22,17:58:29Z
Euro 2020 LIVE: Grealish and Maguire start for England^ Mount and Chilwell out of Czech Republic clash^... - talkSPORT.com,TalkSport,2021-06-22,17:47:23Z
Quarter of a million children in England missed school last week due to Covid - The Guardian,The Guardian,2021-06-22,17:46:00Z
'I am appalled': Billie Eilish apologizes for mouthing racial slur in resurfaced video - CBC.ca,CBC News,2021-06-22,17:45:46Z
U.S. to narrowly miss Bidens July 4 vaccination goal^ White House says - The Washington Post,The Washington Post,2021-06-22,17:45:00Z
Vin Diesel explains feud with Dwayne Johnson: 'A lot of tough love' - Fox News,Fox News,2021-06-22,17:41:14Z
Todays coronavirus news: Two-thirds of Canadians say governments shouldnt lift all restrictions; Construction complete on new vaccine-manufacturing plant in Montreal; Ontario reporting 296 cases - Toronto Star,Toronto Star,2021-06-22,17:37:30Z
Tembisa 10: Piet Rampedi pens apology to Independent Media staff for baby saga - News24,News24,2021-06-22,17:33:26Z
Stinging secret: research reveals how venom from Australian caterpillars could be used in medicines - The Guardian,The Guardian,2021-06-22,17:31:00Z
Doc Rivers not giving up on Ben Simmons^ says 76ers have a plan in place to improve his shooting struggles - CBS Sports,CBS Sports,2021-06-22,17:28:00Z
1 headline source date time
2 Live Updates: Tornado Hits Chicago Suburbs^ Causing Massive Damage - NBC Chicago ‘I am not a vector’: Oireachtas committee hears from children affected by the pandemic - TheJournal.ie NBC Chicago TheJournal.ie 2021-06-21 2021-06-22 14:36:30Z 18:30:00Z
3 Manchester City make Harry Kane bid worth at least £100m to Tottenham - The Guardian Liability conceded in case of couple ‘wrongly advised’ to terminate pregnancy - The Irish Times The Guardian The Irish Times 2021-06-21 2021-06-22 14:23:00Z 18:15:58Z
4 Released but unspent: P18 billion for tests^ health workers expiring June 30 - Rappler Delta COVID-19 variant greatest threat to US pandemic response - Fauci - GMA News Online Rappler GMA News 2021-06-21 2021-06-22 14:22:00Z 18:10:22Z
5 Israeli health experts share best practices on vaccine rollout - ABS-CBN News LIVE WTC Final IND vs NZ Live Cricket Score^ Today Match DAY 5 Updates: Kohli-Pujara in; India Lead New Zeala - India.com Abs-cbn.com India.com 2021-06-21 2021-06-22 14:21:00Z 18:08:55Z
6 LIVE Southampton Weather Updates^ June 21^ Monday^ India vs New Zealand Day 4^ WTC 2021 Final: Play Called Of - India.com Prime Day headphone deals you shouldn't miss on AirPods^ Bose^ Beats^ Sony^ Samsung and more - CNET India.com CNET 2021-06-21 2021-06-22 14:14:47Z 18:03:00Z
7 Handel im Wandel: Hybride Konsumenten? - APA OTS Jack Grealish^ Bukayo Saka and Harry Maguire start for England against Czech Republic - Sky Sports Www.ots.at Sky Sports 2021-06-21 2021-06-22 14:11:54Z 18:01:14Z
8 Canada lifting restrictions for fully vaccinated travellers starting July 5 - CTV News Mother's gestational diabetes is an independent risk factor for fetal hypoxia during labor - News-Medical.Net Ctvnews.ca News-Medical.Net 2021-06-21 2021-06-22 14:11:53Z 18:01:00Z
9 Philippines^ Saudi Arabia reaffirm vow to protect OFWs - ABS-CBN News Amazon sees Prime Day sales boost amid supply chain snags - CNA Abs-cbn.com CNA 2021-06-21 2021-06-22 14:11:00Z 18:00:37Z
10 Geochemical study confirms cause of end-Permian mass extinction event - Phys.org Twitter opens applications for Ticketed Spaces and Super Follows test - The Verge Phys.Org The Verge 2021-06-21 2021-06-22 14:05:26Z 18:00:00Z
11 The laptops and tablets worth your money on Prime Day - Yahoo Tech Mastercard Foundation Appoints Robin Washington to Board of Directors - Guardian Engadget Guardian Nigeria 2021-06-21 2021-06-22 14:05:13Z 18:00:00Z
12 Gracie Spinks death: Derbyshire Police referred to watchdog - BBC News Trudeau says border restrictions will be further relaxed 'in the coming weeks' if all goes well - CBC.ca BBC News CBC News 2021-06-21 2021-06-22 14:03:22Z 17:58:29Z
13 Paul Walker's Toyota Supra from The Fast and the Furious fetches over half a million - CNET Euro 2020 LIVE: Grealish and Maguire start for England^ Mount and Chilwell out of Czech Republic clash^... - talkSPORT.com CNET TalkSport 2021-06-21 2021-06-22 14:02:17Z 17:47:23Z
14 Stock market news live updates: Stocks^ Treasury yields rise as Dow recovers after worst weekly loss since October - Yahoo Finance Quarter of a million children in England missed school last week due to Covid - The Guardian Yahoo Entertainment The Guardian 2021-06-21 2021-06-22 14:00:10Z 17:46:00Z
15 Millions of new smart TVs^ laptops and other items in Amazon warehouse marked 'destroy' - TheJournal.ie 'I am appalled': Billie Eilish apologizes for mouthing racial slur in resurfaced video - CBC.ca TheJournal.ie CBC News 2021-06-21 2021-06-22 13:57:00Z 17:45:46Z
16 Target Deal Days rival Amazon Prime Day with massive discounts — here are the best deals to shop - Yahoo Finance Australia U.S. to narrowly miss Biden’s July 4 vaccination goal^ White House says - The Washington Post Intheknow.com The Washington Post 2021-06-21 2021-06-22 13:56:09Z 17:45:00Z
17 PNB Housing Finance vs SEBI: SAT gives nod for EGM on June 22; Voting results to not be declared till... - Moneycontrol Vin Diesel explains feud with Dwayne Johnson: 'A lot of tough love' - Fox News Moneycontrol Fox News 2021-06-21 2021-06-22 13:53:59Z 17:41:14Z
18 Sporadic Covid-19 cases still widespread in Klang Valley - Malaysiakini Today’s coronavirus news: Two-thirds of Canadians say governments shouldn’t lift all restrictions; Construction complete on new vaccine-manufacturing plant in Montreal; Ontario reporting 296 cases - Toronto Star Malaysiakini Toronto Star 2021-06-21 2021-06-22 13:48:00Z 17:37:30Z
19 Samsung Odyssey G3^ Odyssey G5^ Odyssey G7 Gaming Monitors With 178 Degrees Viewing Angle Launched - Gadgets 360 ‘Tembisa 10’: Piet Rampedi pens apology to Independent Media staff for baby saga - News24 NDTV News News24 2021-06-21 2021-06-22 13:47:31Z 17:33:26Z
20 New possibilities for detecting Hawking radiation emitted by primordial black holes - Phys.org Stinging secret: research reveals how venom from Australian caterpillars could be used in medicines - The Guardian Phys.Org The Guardian 2021-06-21 2021-06-22 13:40:03Z 17:31:00Z
21 Global Lip Fillers Market 2021 Industry Trends^ Growth^ Analysis^ Opportunities And Overview || DBMR – The Courier - The Courier Doc Rivers not giving up on Ben Simmons^ says 76ers have a plan in place to improve his shooting struggles - CBS Sports Mccourier.com CBS Sports 2021-06-21 2021-06-22 13:39:38Z 17:28:00Z
+1 -1
View File
@@ -1 +1 @@
[{"date": "2021-06-21", "time": "00:00:00", "round": "0", "home_team": "Philadelphia 76ers", "home_score": "96", "away_team": "Atlanta Hawks", "away_score": "103"}, {"date": "2021-06-23", "time": "01:00:00", "round": "0", "home_team": "Phoenix Suns", "home_score": null, "away_team": "Los Angeles Clippers", "away_score": null}, {"date": "2021-06-24", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": null, "away_team": "Atlanta Hawks", "away_score": null}, {"date": "2021-06-25", "time": "01:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": null, "away_team": "Phoenix Suns", "away_score": null}, {"date": "2021-06-26", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": null, "away_team": "Atlanta Hawks", "away_score": null}, {"date": "2021-06-27", "time": "01:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": null, "away_team": "Phoenix Suns", "away_score": null}, {"date": "2021-06-28", "time": "00:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": null, "away_team": "Milwaukee Bucks", "away_score": null}, {"date": "2021-06-30", "time": "00:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": null, "away_team": "Milwaukee Bucks", "away_score": null}]
[{"date": "2021-06-23", "time": "01:00:00", "round": "0", "home_team": "Phoenix Suns", "home_score": null, "away_team": "Los Angeles Clippers", "away_score": null}, {"date": "2021-06-24", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": null, "away_team": "Atlanta Hawks", "away_score": null}, {"date": "2021-06-25", "time": "01:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": null, "away_team": "Phoenix Suns", "away_score": null}, {"date": "2021-06-26", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": null, "away_team": "Atlanta Hawks", "away_score": null}, {"date": "2021-06-27", "time": "01:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": null, "away_team": "Phoenix Suns", "away_score": null}, {"date": "2021-06-28", "time": "00:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": null, "away_team": "Milwaukee Bucks", "away_score": null}, {"date": "2021-06-30", "time": "00:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": null, "away_team": "Milwaukee Bucks", "away_score": null}]
+1 -1
View File
@@ -1 +1 @@
[{"date": "2021-06-21", "time": "00:00", "progess": "", "status": "FT", "home_team": "Philadelphia 76ers", "home_score": "96", "away_team": "Atlanta Hawks", "away_score": "103"}]
[]
+1 -1
View File
@@ -1 +1 @@
[{"date": "2021-06-20", "time": "19:30:00", "round": "0", "home_team": "Phoenix Suns", "home_score": "120", "away_team": "Los Angeles Clippers", "away_score": "114"}, {"date": "2021-06-20", "time": "00:30:00", "round": "0", "home_team": "Brooklyn Nets", "home_score": "111", "away_team": "Milwaukee Bucks", "away_score": "115"}, {"date": "2021-06-19", "time": "02:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "131", "away_team": "Utah Jazz", "away_score": "119"}, {"date": "2021-06-18", "time": "23:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": "99", "away_team": "Philadelphia 76ers", "away_score": "104"}, {"date": "2021-06-18", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": "104", "away_team": "Brooklyn Nets", "away_score": "89"}, {"date": "2021-06-17", "time": "02:00:00", "round": "0", "home_team": "Utah Jazz", "home_score": "111", "away_team": "Los Angeles Clippers", "away_score": "119"}, {"date": "2021-06-16", "time": "00:30:00", "round": "0", "home_team": "Brooklyn Nets", "home_score": "114", "away_team": "Milwaukee Bucks", "away_score": "108"}, {"date": "2021-06-16", "time": "23:30:00", "round": "0", "home_team": "Philadelphia 76ers", "home_score": "106", "away_team": "Atlanta Hawks", "away_score": "109"}, {"date": "2021-06-15", "time": "02:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "118", "away_team": "Utah Jazz", "away_score": "104"}, {"date": "2021-06-14", "time": "23:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": "103", "away_team": "Philadelphia 76ers", "away_score": "100"}, {"date": "2021-06-14", "time": "00:00:00", "round": "0", "home_team": "Denver Nuggets", "home_score": "118", "away_team": "Phoenix Suns", "away_score": "125"}, {"date": "2021-06-13", "time": "00:30:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "132", "away_team": "Utah Jazz", "away_score": "106"}, {"date": "2021-06-13", "time": "19:00:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": "107", "away_team": "Brooklyn Nets", "away_score": "96"}, {"date": "2021-06-12", "time": "02:00:00", "round": "0", "home_team": "Denver Nuggets", "home_score": "102", "away_team": "Phoenix Suns", "away_score": "116"}, {"date": "2021-06-11", "time": "02:00:00", "round": "0", "home_team": "Utah Jazz", "home_score": "117", "away_team": "Los Angeles Clippers", "away_score": "111"}]
[{"date": "2021-06-21", "time": "00:00:00", "round": "0", "home_team": "Philadelphia 76ers", "home_score": "96", "away_team": "Atlanta Hawks", "away_score": "103"}, {"date": "2021-06-20", "time": "19:30:00", "round": "0", "home_team": "Phoenix Suns", "home_score": "120", "away_team": "Los Angeles Clippers", "away_score": "114"}, {"date": "2021-06-20", "time": "00:30:00", "round": "0", "home_team": "Brooklyn Nets", "home_score": "111", "away_team": "Milwaukee Bucks", "away_score": "115"}, {"date": "2021-06-19", "time": "02:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "131", "away_team": "Utah Jazz", "away_score": "119"}, {"date": "2021-06-18", "time": "23:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": "99", "away_team": "Philadelphia 76ers", "away_score": "104"}, {"date": "2021-06-18", "time": "00:30:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": "104", "away_team": "Brooklyn Nets", "away_score": "89"}, {"date": "2021-06-17", "time": "02:00:00", "round": "0", "home_team": "Utah Jazz", "home_score": "111", "away_team": "Los Angeles Clippers", "away_score": "119"}, {"date": "2021-06-16", "time": "00:30:00", "round": "0", "home_team": "Brooklyn Nets", "home_score": "114", "away_team": "Milwaukee Bucks", "away_score": "108"}, {"date": "2021-06-16", "time": "23:30:00", "round": "0", "home_team": "Philadelphia 76ers", "home_score": "106", "away_team": "Atlanta Hawks", "away_score": "109"}, {"date": "2021-06-15", "time": "02:00:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "118", "away_team": "Utah Jazz", "away_score": "104"}, {"date": "2021-06-14", "time": "23:30:00", "round": "0", "home_team": "Atlanta Hawks", "home_score": "103", "away_team": "Philadelphia 76ers", "away_score": "100"}, {"date": "2021-06-14", "time": "00:00:00", "round": "0", "home_team": "Denver Nuggets", "home_score": "118", "away_team": "Phoenix Suns", "away_score": "125"}, {"date": "2021-06-13", "time": "00:30:00", "round": "0", "home_team": "Los Angeles Clippers", "home_score": "132", "away_team": "Utah Jazz", "away_score": "106"}, {"date": "2021-06-13", "time": "19:00:00", "round": "0", "home_team": "Milwaukee Bucks", "home_score": "107", "away_team": "Brooklyn Nets", "away_score": "96"}, {"date": "2021-06-12", "time": "02:00:00", "round": "0", "home_team": "Denver Nuggets", "home_score": "102", "away_team": "Phoenix Suns", "away_score": "116"}]
+1 -1
View File
@@ -1 +1 @@
[{"date": "2021-06-21", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "1", "away_team": "Vegas Golden Knights", "away_score": "2"}, {"date": "2021-06-22", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": null, "away_team": "New York Islanders", "away_score": null}, {"date": "2021-06-23", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": null, "away_team": "Montreal Canadiens", "away_score": null}, {"date": "2021-06-24", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": null, "away_team": "Tampa Bay Lightning", "away_score": null}, {"date": "2021-06-25", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": null, "away_team": "Vegas Golden Knights", "away_score": null}]
[{"date": "2021-06-22", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "8", "away_team": "New York Islanders", "away_score": "0"}, {"date": "2021-06-23", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": null, "away_team": "Montreal Canadiens", "away_score": null}, {"date": "2021-06-24", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": null, "away_team": "Tampa Bay Lightning", "away_score": null}, {"date": "2021-06-25", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": null, "away_team": "Vegas Golden Knights", "away_score": null}]
+1 -1
View File
@@ -1 +1 @@
[{"date": "2021-06-21", "time": "00:00", "progess": "", "status": "AOT", "home_team": "Montreal Canadiens", "home_score": "1", "away_team": "Vegas Golden Knights", "away_score": "2"}]
[{"date": "2021-06-22", "time": "00:00", "progess": "", "status": "FT", "home_team": "Tampa Bay Lightning", "home_score": "8", "away_team": "New York Islanders", "away_score": "0"}]
+1 -1
View File
@@ -1 +1 @@
[{"date": "2021-06-20", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": "3", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-19", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "3", "away_team": "Vegas Golden Knights", "away_score": "2"}, {"date": "2021-06-18", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": "1", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-17", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "2", "away_team": "Montreal Canadiens", "away_score": "3"}, {"date": "2021-06-16", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "4", "away_team": "New York Islanders", "away_score": "2"}, {"date": "2021-06-15", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "4", "away_team": "Montreal Canadiens", "away_score": "1"}, {"date": "2021-06-13", "time": "19:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "1", "away_team": "New York Islanders", "away_score": "2"}, {"date": "2021-06-11", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "6", "away_team": "Colorado Avalanche", "away_score": "3"}, {"date": "2021-06-09", "time": "23:30:00", "round": "0", "home_team": "New York Islanders", "home_score": "6", "away_team": "Boston Bruins", "away_score": "2"}, {"date": "2021-06-09", "time": "01:00:00", "round": "0", "home_team": "Colorado Avalanche", "home_score": "2", "away_team": "Vegas Golden Knights", "away_score": "3"}, {"date": "2021-06-08", "time": "22:30:00", "round": "0", "home_team": "Carolina Hurricanes", "home_score": "0", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-08", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "3", "away_team": "Winnipeg Jets", "away_score": "2"}, {"date": "2021-06-07", "time": "22:30:00", "round": "0", "home_team": "Boston Bruins", "home_score": "4", "away_team": "New York Islanders", "away_score": "5"}, {"date": "2021-06-07", "time": "00:30:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "5", "away_team": "Colorado Avalanche", "away_score": "1"}, {"date": "2021-06-06", "time": "22:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "5", "away_team": "Winnipeg Jets", "away_score": "1"}]
[{"date": "2021-06-21", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "1", "away_team": "Vegas Golden Knights", "away_score": "2"}, {"date": "2021-06-20", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": "3", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-19", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "3", "away_team": "Vegas Golden Knights", "away_score": "2"}, {"date": "2021-06-18", "time": "00:00:00", "round": "0", "home_team": "New York Islanders", "home_score": "1", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-17", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "2", "away_team": "Montreal Canadiens", "away_score": "3"}, {"date": "2021-06-16", "time": "00:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "4", "away_team": "New York Islanders", "away_score": "2"}, {"date": "2021-06-15", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "4", "away_team": "Montreal Canadiens", "away_score": "1"}, {"date": "2021-06-13", "time": "19:00:00", "round": "0", "home_team": "Tampa Bay Lightning", "home_score": "1", "away_team": "New York Islanders", "away_score": "2"}, {"date": "2021-06-11", "time": "01:00:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "6", "away_team": "Colorado Avalanche", "away_score": "3"}, {"date": "2021-06-09", "time": "23:30:00", "round": "0", "home_team": "New York Islanders", "home_score": "6", "away_team": "Boston Bruins", "away_score": "2"}, {"date": "2021-06-09", "time": "01:00:00", "round": "0", "home_team": "Colorado Avalanche", "home_score": "2", "away_team": "Vegas Golden Knights", "away_score": "3"}, {"date": "2021-06-08", "time": "22:30:00", "round": "0", "home_team": "Carolina Hurricanes", "home_score": "0", "away_team": "Tampa Bay Lightning", "away_score": "2"}, {"date": "2021-06-08", "time": "00:00:00", "round": "0", "home_team": "Montreal Canadiens", "home_score": "3", "away_team": "Winnipeg Jets", "away_score": "2"}, {"date": "2021-06-07", "time": "22:30:00", "round": "0", "home_team": "Boston Bruins", "home_score": "4", "away_team": "New York Islanders", "away_score": "5"}, {"date": "2021-06-07", "time": "00:30:00", "round": "0", "home_team": "Vegas Golden Knights", "home_score": "5", "away_team": "Colorado Avalanche", "away_score": "1"}]
+3 -3
View File
@@ -1,4 +1,4 @@
name,current,opening
MSFT,262.3,259.82
NFLX,495.166,501.64
GOOG,2529.965,2514.8
MSFT,265.24,262.72
NFLX,511.198,498.54
GOOG,2536.73,2529
1 name current opening
2 MSFT 262.3 265.24 259.82 262.72
3 NFLX 495.166 511.198 501.64 498.54
4 GOOG 2529.965 2536.73 2514.8 2529
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 821 B

After

Width:  |  Height:  |  Size: 821 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+2 -10
View File
@@ -7,16 +7,7 @@ pip3 install pexpect
sudo apt-get install libopenjp2-7
sudo apt-get install libtiff5
chmod ugo+rwx final.ppm
chmod ugo+rwx final1.ppm
chmod ugo+rwx scroll_text.ppm
chmod ugo+rwx display_gif
chmod ugo+rwx display_image.ppm
chmod ugo+rwx weather.ppm
chmod ugo+rwx teams.ppm
chmod ugo+rwx league.ppm
chmod ugo+rwx full.ppm
chmod ugo+rwx display_images/*
cd rpi-rgb-led-matrix
sudo apt-get update && sudo apt-get install python3-dev python3-pillow -y
make build-python PYTHON=$(which python3)
@@ -27,5 +18,6 @@ sudo apt-get install libatlas-base-dev
pip3 install pycoingecko
pip3 install newsapi-python
pip3 install pytz
pip3 install matplotlib
sudo apt-get remove bluez bluez-firmware pi-bluetooth triggerhappy pigpio
+329 -197
View File
@@ -39,7 +39,7 @@ class StockTicker():
self.greenORred = (255, 255, 255)
#self.blank = Image.open('logos/blank.png')
self.blank = Image.new('RGB', (15, 32))
self.blank = Image.new('RGB', (10, 32))
self.running = True
self.brightness = 1.0
self.delay = 0.02
@@ -110,9 +110,7 @@ class StockTicker():
self.setImage(image, offset_x = offset_x, offset_y = offset_y)
# remove the ppixels behind the image, to stop trailing
# remove the ppixels behind the image, to stop trailing
for x in range(offset_x + img_width, 128):
for y in range(self.matrix.height):
@@ -120,17 +118,7 @@ class StockTicker():
self.matrix.SetPixel(x , y , 0,0,0)
try:
msg = getInput()
if msg == 'K':
self.resetMatrix()
return True
self.process_msg(msg)
except KeyboardInterrupt:
sys.stdout.flush()
pass
kill = self.checkKilled()
time.sleep(self.delay)
return False
@@ -146,20 +134,10 @@ class StockTicker():
self.setImage(image, offset_x = offset_x+128, offset_y = offset_y)
self.setImage(image, offset_x = offset_x, offset_y = offset_y+20)
try:
msg = getInput()
if msg == 'K':
self.resetMatrix()
return True
self.process_msg(msg)
except KeyboardInterrupt:
sys.stdout.flush()
pass
kill = self.checkKilled()
time.sleep(self.delay)
return False
return kill
def scrollImageTransition(self, image_files, offset_x = 0, offset_y = 0, stocks = True):
# use two image files and switch between them with a seemless transition
@@ -199,20 +177,9 @@ class StockTicker():
time.sleep(self.delay)
try:
msg = getInput()
if msg == 'K':
self.resetMatrix()
kill = True
image1.close()
image2.close()
break
kill = self.checkKilled()
if kill: break
self.process_msg(msg)
except KeyboardInterrupt:
sys.stdout.flush()
pass
if stocks:
image1.close()
image2.close()
@@ -226,7 +193,115 @@ class StockTicker():
elif current_img == 2:
current_img = 1
offset_x = 0
def updateMultiple(self, options):
for option in options:
print(option)
img = self.functions[option]()
img.save('display_images/' + option + '.ppm')
def checkKilled(self):
kill = False
try:
msg = getInput()
if msg == 'K':
self.resetMatrix()
kill = True
self.process_msg(msg)
except KeyboardInterrupt:
sys.stdout.flush()
pass
return kill
def scrollFunctionsAnimated(self, options, animation = 'continuous'):
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
self.updateMultiple(options)
print('done update')
kill = False
i = 0 # keep track of which image we are displaying
while True:
update_process = Process(target = self.updateMultiple, args = (options,))
update_process.start()
print('display_images/' + options[i % len(options)] +'.ppm')
image = self.openImage('display_images/' + options[i % len(options)] +'.ppm')
if animation == 'continuous':
image2 = self.openImage('display_images/' + options[(i + 1) % len(options)] +'.ppm')
img_width, img_height = image.size
offset_x = 0
if animation == 'traditional':
offset_x = 128
offset_y = 0
#first scroll image in from bottom
if animation == 'up':
offset_y = 32
while offset_y > 0:
self.setImage(image, offset_x = offset_x, offset_y = offset_y)
offset_y -= 1
time.sleep(self.delay)
kill = self.checkKilled()
if kill: break
elif animation == 'down':
offset_y = -32
while offset_y < 0:
self.setImage(image, offset_x = offset_x, offset_y = offset_y)
offset_y += 1
time.sleep(self.delay)
kill = self.checkKilled()
if kill: break
while offset_x > -img_width:
offset_x -= 1
# remove the ppixels behind the image, to stop trailing
for x in range(0,offset_x ):
for y in range(self.matrix.height):
self.matrix.SetPixel(x , y , 0,0,0)
self.setImage(image, offset_x = offset_x, offset_y = offset_y)
if animation == 'continuous':
if offset_x + img_width < self.matrix.width: # if the image is ending
self.setImage(image2, offset_x = offset_x + img_width, offset_y = offset_y)
else:
# remove the ppixels behind the image, to stop trailing
for x in range(offset_x + img_width, 128):
for y in range(self.matrix.height):
self.matrix.SetPixel(x , y , 0,0,0)
time.sleep(self.delay)
kill = self.checkKilled()
if kill: break
if kill: break
update_process.join()
i+=1
def textImage(self, text, font, r = 255, g = 255, b = 255, matrix_height = False, buff = 0):
'''
creates and returns a ppm image containing the text in the supplied font and colour
@@ -236,14 +311,14 @@ class StockTicker():
if matrix_height:
height = 32
img = Image.new('RGB', (width + buff + 3, height+5))
img = Image.new('RGB', (width + buff + 3, height+3))
d = ImageDraw.Draw(img)
d.text((0, 0), text, fill=(r, g, b), font=font)
return img
def displayUserText(self):
def getUserText(self):
'''
displays the text entered in the webpage by the user.
'''
@@ -259,73 +334,66 @@ class StockTicker():
font = ImageFont.load("./fonts/texgyre-27.pil")
img = self.textImage(text, font, int(r), int(g), int(b), True, buff = 50)
return img
img.save('scroll_text.ppm')
self.scrollImageTransition(['scroll_text.ppm', 'scroll_text.ppm'], offset_x = 128, offset_y = 0, stocks = False)
def displayNews(self):
def getNewsImage(self):
headline_font = ImageFont.load("./fonts/10x20.pil")
source_font = ImageFont.load("./fonts/10x20.pil")
while True:
headlines = []
source_date_times = []
image_list = []
headlines = []
source_date_times = []
f = open('csv/news.csv', 'r')
CSV = csv.reader(f)
next(CSV)
for row in CSV:
headline, source, date, time = row
headlines.append(headline)
source_date_times.append(source + ': ' + date + ' ' + time)
f = open('csv/news.csv', 'r')
CSV = csv.reader(f)
next(CSV)
for row in CSV:
headline, source, date, time = row
headlines.append(headline)
source_date_times.append(source + ': ' + date + ' ' + time)
f.close()
if len(headlines) > 0:
for i, headline in enumerate(headlines):
headline = headline.replace("^", ",")
headline = headline.replace("", "'")
headline = headline.replace("", "'")
headline = headline.replace('', '"')
headline = headline.replace('', '"')
headline_img = self.textImage(headline, headline_font, matrix_height = True)
source_img = self.textImage(source_date_times[i], source_font, r=255, g=255, b=0, matrix_height = True)
try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'news_logos')
logo = Image.open(os.path.join(logos_path, 'techcrunch' + '.png'))
img = Image.new('RGB', (headline_img.size[0], 32))
img.paste(headline_img, (2, -3))
img.paste(source_img, (2,16))
img= self.stitchImage([logo,img])
except Exception as e:
print(e)
img = Image.new('RGB', (headline_img.size[0], 32))
img.paste(headline_img, (0,0))
img.paste(source_img, (0,16))
img.save('image.ppm')
killed = self.scrollImage(img, offset_x = 128, offset_y = 0)
#killed = self.scrollImageStacked(img, offset_x = 128, offset_y = 0)
if killed: break
else:
print('new failed')
if killed: break
f.close()
for i, headline in enumerate(headlines):
headline = headline.replace("^", ",")
headline = headline.replace("", "'")
headline = headline.replace("", "'")
headline = headline.replace('', '"')
headline = headline.replace('', '"')
headline_img = self.textImage(headline, headline_font, matrix_height = True)
source_img = self.textImage(source_date_times[i], source_font, r=255, g=255, b=0, matrix_height = True)
try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'news_logos')
logo = Image.open(os.path.join(logos_path, 'techcrunch' + '.png'))
img = Image.new('RGB', (headline_img.size[0], 32))
img.paste(headline_img, (2, -3))
img.paste(source_img, (2,16))
img= self.stitchImage([logo,img])
except Exception as e:
print(e)
img = Image.new('RGB', (headline_img.size[0], 32))
img.paste(headline_img, (0,0))
img.paste(source_img, (0,16))
image_list.append(img)
news_image = self.stitchImage(image_list)
return news_image
def displayGIF(self, gif):
# To iterate through the entire gif
i = 0
@@ -429,7 +497,8 @@ class StockTicker():
def textToImage(self, TICKER, CURRENT, CHANGE, ARROW):
font = ImageFont.load("./fonts/10x20.pil")
text_width_current, text_height = self.get_text_dimensions(CURRENT, font)
img = Image.new('RGB', (text_width_current + 100, 32))
img = Image.new('RGB', (text_width_current +100 , 32))
d = ImageDraw.Draw(img)
d.text((4, 0), TICKER, fill=(255, 255, 255), font=font)
@@ -442,9 +511,9 @@ class StockTicker():
text_width_change, text_height = self.get_text_dimensions(CHANGE, font)
newWidth = (text_width_current+29) + (text_width_change)
newWidth = text_width_current + text_width_change +30
img.crop((0,0,newWidth,32))
img = img.crop((0,0,newWidth,32))
return img
#Stitch the logo & prices picture into one image
@@ -467,43 +536,19 @@ class StockTicker():
self.matrix.SetPixel(x , y , 0,0,0)
#Connect all the pieces togeather creating 1 long final stock image
def getFullStockImage(self, updated_img):
image_list = []
def getCryptoImage(self):
font = ImageFont.load("./fonts/texgyre-27.pil")
title_img = self.textImage('CRYPTO', font, matrix_height = True)
image_list = [title_img]
image_list.append(self.blank)
start = time.time()
self.readCSV()
for i, symbol in enumerate(self.symbols):
info = self.stock_info[symbol]
change = float(info[0])-float(info[1]) #TEXT
ticker = symbol #TEXT
current = '%.2f' % float(info[0]) #TEXT
arrow, change = self.getArrow(change)
change = '%.2f' % change
midFrame = self.textToImage(ticker, current, change, arrow) #IMAGE THE TEXT
try:
logos_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos')
logo = Image.open(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame])
except:
stitchedStock = midFrame
image_list.append(self.blank)
image_list.append(stitchedStock)
self.readCryptoCSV()
for i, coin in enumerate(self.coins):
info = self.coin_info[coin]
change = float(info[3]) #TEXT
@@ -532,13 +577,29 @@ class StockTicker():
stitchedStock = midFrame
image_list.append(self.blank)
image_list.append(stitchedStock)
image_list.append(self.blank)
finalDisplayImage = self.stitchImage(image_list)
return finalDisplayImage
def getForexImage(self):
font = ImageFont.load("./fonts/texgyre-27.pil")
title_img = self.textImage('FOREX', font, matrix_height = True)
image_list = [title_img]
image_list.append(self.blank)
start = time.time()
base, currency_info = json.load(open('csv/currency.json', 'r'))
currencies = ['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD']
for i, currency in enumerate(['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD']):
for i, currency in enumerate(currencies):
current, yesterday = currency_info[currency]
@@ -561,28 +622,76 @@ class StockTicker():
new_im = Image.new('RGB', (32, 32))
for im in image_list:
new_im.paste(bse, (0,10), bse.convert('RGBA'))
new_im.paste(logo, (10,0), logo.convert('RGBA'))
new_im.paste(bse, (0,10), bse.convert('RGBA'))
new_im.paste(logo, (10,0), logo.convert('RGBA'))
stitchedStock = self.stitchImage([new_im, midFrame])
image_list.append(new_im)
except Exception as e:
print(e)
image_list.append(midFrame)
image_list.append(self.blank)
print('image', len(image_list))
finalDisplayImage = self.stitchImage(image_list)
return finalDisplayImage
#Connect all the pieces togeather creating 1 long final stock image
def getStockImage(self):
font = ImageFont.load("./fonts/texgyre-27.pil")
title_img = self.textImage('STOCKS', font, matrix_height = True)
image_list = [title_img]
image_list.append(self.blank)
start = time.time()
self.readStocksCSV()
for i, symbol in enumerate(self.symbols):
info = self.stock_info[symbol]
change = float(info[0])-float(info[1]) #TEXT
ticker = symbol #TEXT
current = '%.2f' % float(info[0]) #TEXT
arrow, change = self.getArrow(change)
change = '%.2f' % change
midFrame = self.textToImage(ticker, current, change, arrow) #IMAGE THE TEXT
try:
logos_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos')
logo = Image.open(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame])
except:
stitchedStock = midFrame
image_list.append(self.blank)
image_list.append(stitchedStock)
image_list.append(self.blank)
finalDisplayImage = self.stitchImage(image_list)
if updated_img == 1:
finalDisplayImage.save('final.ppm')
elif updated_img == 2:
finalDisplayImage.save('final1.ppm')
return finalDisplayImage
@@ -657,41 +766,50 @@ class StockTicker():
#img.paste(vs_timage, (x_offset, 12))
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
hc_timage = self.textImage(sports_info[home_team]['code'], med_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
ac_timage = self.textImage(sports_info[away_team]['code'], med_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
hc_timage = self.textImage(sports_info[home_team]['code'], med_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
ac_timage = self.textImage(sports_info[away_team]['code'], med_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
vs_timage = self.textImage('vs', med_font, r = 255, g = 255, b = 255)
img.paste(hc_timage, (x_offset, 9))
img.paste(vs_timage, (x_offset + hc_timage.size[0], 9))
img.paste(ac_timage, (x_offset + hc_timage.size[0] + vs_timage.size[0], 9))
x_offset += max( date_timage.size[0], hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0])
else:
img.paste(date_timage, (x_offset+10, 0))
score_image = self.textImage(home_score + '-' + away_score, large_font, r = 255, g = 255, b = 255)
#vs_timage = self.textImage(sports_info[home_team]['code'] + 'vs' + sports_info[away_team]['code'], small_font, r = 255, g = 255, b = 255)
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
hc_timage = self.textImage(sports_info[home_team]['code'], small_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
hc_timage = self.textImage(sports_info[home_team]['code'], small_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
ac_timage = self.textImage(sports_info[away_team]['code'], small_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
vs_timage = self.textImage('vs', small_font, r = 255, g = 255, b = 255)
img.paste(hc_timage, (x_offset+14, 9))
img.paste(vs_timage, (x_offset+13 + hc_timage.size[0], 9))
img.paste(ac_timage, (x_offset+14 + hc_timage.size[0] + vs_timage.size[0], 9))
if date_timage.size[0] > score_image.size[0]:
img.paste(date_timage, (x_offset+2, 0))
img.paste(hc_timage, (x_offset+6, 9))
img.paste(vs_timage, (x_offset+5 + hc_timage.size[0], 9))
img.paste(ac_timage, (x_offset+6 + hc_timage.size[0] + vs_timage.size[0], 9))
img.paste(score_image, (x_offset + 2 + int((date_timage.size[0] - score_image.size[0])/2), 15))
else:
img.paste(date_timage, (x_offset+1+int((score_image.size[0] - date_timage.size[0] )/2), 0))
vs_size = hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]
img.paste(hc_timage, (x_offset + 1 + int((score_image.size[0] - vs_size)/2), 9))
img.paste(vs_timage, (x_offset + int((score_image.size[0] - vs_size)/2) + hc_timage.size[0], 9))
img.paste(ac_timage, (x_offset+1 + int((score_image.size[0] - vs_size)/2) + hc_timage.size[0] + vs_timage.size[0], 9))
img.paste(score_image, (x_offset+1, 15))
img.paste(score_image, (x_offset + 35 - int(score_image.size[0]/2), 15))
x_offset += max( date_timage.size[0]+4, hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]+4, 2 + int(score_image.size[0]))
#img.paste(vs_timage, (x_offset+4, 9))
@@ -704,13 +822,11 @@ class StockTicker():
#x_offset += max(home_timage.size[0], away_timage.size[0], date_timage.size[0], round_timage.size[0], score_image.size[0])
if time == 'future':
x_offset += max( date_timage.size[0], hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0])
else:
x_offset += max( date_timage.size[0]+10, hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]+14, 35 + int(score_image.size[0]/2))
img.paste(away_logo, (x_offset+2,0))
img.paste(away_logo, (x_offset,0))
x_offset += away_logo.size[0]
x_offset += buff_size
@@ -1018,7 +1134,7 @@ class StockTicker():
img1 = img.crop((64,0,x_offset ,32))
img1.save('weather.ppm')
img1.save('display_images/weather.ppm')
return img0, img1
@@ -1203,7 +1319,7 @@ class StockTicker():
#Retrieve symbols and stock info from the csv file
def readCSV(self):
def readStocksCSV(self):
self.symbols = []
self.stock_info = {}
@@ -1221,6 +1337,7 @@ class StockTicker():
f.close()
def readCryptoCSV(self):
self.coins = []
self.coin_info = {}
f = open('csv/crypto.csv', 'r')
@@ -1300,11 +1417,19 @@ class StockTicker():
def process_msg(self, msg):
if msg == 'S': # stocks
self.getFullStockImage(1)
self.displayStocks()
img = self.getStockImage()
img.save('display_images/stocks.ppm')
self.scrollImageTransition(['display_images/stocks.ppm', 'display_images/stocks.ppm'], stocks = False)
elif msg == 'N': #news
self.displayNews()
img = self.getNewsImage()
img.save('display_images/news.ppm')
self.scrollImageTransition(['display_images/news.ppm', 'display_images/news.ppm'], stocks = False)
# speed settings
elif msg == 's':
self.delay = 0.03
@@ -1323,11 +1448,14 @@ class StockTicker():
elif msg == 'T':# text
self.displayUserText()
img = self.getUserText()
img.save('display_images/scroll_text.ppm')
self.scrollImageTransition(['display_images/scroll_text.ppm', 'display_images/scroll_text.ppm'], offset_x = 128, offset_y = 0, stocks = False)
elif msg == 'I': # image
image = self.openImage(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_image'))
image = self.openImage(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/display_image'))
#self.setImage( image)
while True:
@@ -1337,7 +1465,7 @@ class StockTicker():
break
elif msg == 'G': # gif
gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_gif'))
gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/display_gif'))
#self.displayGIF(gif)
while True:
kill = self.scrollGIF(gif, offset_x = 128)
@@ -1346,50 +1474,51 @@ class StockTicker():
elif msg == 'W': # weather
img = self.getTodayWeatherImage()
img.save('weather.ppm')
self.scrollImageTransition(['weather.ppm', 'weather.ppm'], stocks = False)
img.save('display_images/weather.ppm')
self.scrollImageTransition(['display_images/weather.ppm', 'display_images/weather.ppm'], stocks = False)
elif msg == 'D': # daily weather
#self.displayDailyWeatherAlt()
img = self.getDailyWeatherImage()
img.save('weather.ppm')
img.save('display_images/weather.ppm')
#self.setImage( image)
self.scrollImageTransition(['weather.ppm', 'weather.ppm'], stocks = False)
self.scrollImageTransition(['display_images/weather.ppm', 'display_images/weather.ppm'], stocks = False)
elif msg == 'P': # past league
img = self.getLeagueImage('premier_league', 'past')
img.save('league.ppm')
img = self.getLeagueImage('NBA', 'past')
img.save('display_images/league.ppm')
stock_ticker.scrollImageTransition(['league.ppm', 'league.ppm'], stocks = False)
stock_ticker.scrollImageTransition(['display_images/league.ppm', 'display_images/league.ppm'], stocks = False)
elif msg == 'F': # future league
img = self.getLeagueImage('NBA', 'future')
img.save('league.ppm')
img = self.getLeagueImage('NHL', 'future')
img.save('display_images/league.ppm')
stock_ticker.scrollImageTransition(['league.ppm', 'league.ppm'], stocks = False)
stock_ticker.scrollImageTransition(['display_images/league.ppm', 'display_images/league.ppm'], stocks = False)
elif msg == 'L': # live game
img = self.getLeagueImage('NBA', 'live')
img.save('league.ppm')
img.save('display_images/league.ppm')
stock_ticker.scrollImageTransition(['league.ppm', 'league.ppm'], stocks = False)
stock_ticker.scrollImageTransition(['display_images/league.ppm', 'display_images/league.ppm'], stocks = False)
elif msg == 't': #teams
img = self.getTeamsImage('premier_league')
img.save('teams.ppm')
img.save('display_images/teams.ppm')
stock_ticker.scrollImageTransition(['teams.ppm', 'teams.ppm'], stocks = False)
stock_ticker.scrollImageTransition(['display_images/teams.ppm', 'display_images/teams.ppm'], stocks = False)
elif msg == 'A': #everything
stock_img = self.getFullStockImage(1)
weather_img = self.getTodayWeatherImage()
past_img = self.getLeagueImage('NBA', 'past')
future_img = img = self.getLeagueImage('NBA', 'future')
overall_img = self.stitchImage([stock_img, weather_img, past_img, future_img])
overall_img.save('full.ppm')
self.scrollImageTransition(['full.ppm', 'full.ppm'], stocks = False)
self.functions = {'stocks': self.getStockImage, 'crypto': self.getCryptoImage, 'forex': self.getForexImage,
'weather':self.getDailyWeatherImage} #put this somewhere else
userSettings = ['stocks', 'crypto', 'forex'] # these wil be read from csv, just for demo
#userSettings = ['stocks', 'crypto'] # these wil be read from csv, just for demo
#userSettings = [ 'forex', 'weather'] # these wil be read from csv, just for demo
self.scrollFunctionsAnimated(userSettings, animation = 'down')
elif msg == 'K': # kill
self.resetMatrix()
@@ -1399,7 +1528,10 @@ if __name__ == '__main__':
with open('log.txt', "w") as log:
try:
stock_ticker = StockTicker()
#stock_ticker.process_msg('P')
#stock_ticker.process_msg('A')
BIN
View File
Binary file not shown.