diff --git a/csv/crypto.csv b/csv/crypto.csv index 73e0c12..30b1be5 100644 --- a/csv/crypto.csv +++ b/csv/crypto.csv @@ -1,4 +1,4 @@ symbol,name,base,current,24hr change -BTC,bitcoin,usd,41608,7.5637268829287105 -ETH,ethereum,gbp,1767.07,4.946057229445047 -DOGE,dogecoin,usd,0.209425,3.0856074912371008 +BTC,bitcoin,usd,38562,-3.1527074759072398 +ETH,ethereum,gbp,1804.79,-5.029820064487153 +DOGE,dogecoin,usd,0.198365,-3.4809067470776904 diff --git a/csv/currency.json b/csv/currency.json index d939540..ff21f94 100644 --- a/csv/currency.json +++ b/csv/currency.json @@ -1 +1 @@ -["USD", {"AUD": [1.362, 1.3572], "CAD": [1.2569, 1.2565], "CHF": [0.91488, 0.91499], "EUR": [0.84696, 0.84674], "GBP": [0.72072, 0.72399], "JPY": [110.08, 110.06], "NZD": [1.4409, 1.4357]}] \ No newline at end of file +["USD", {"AUD": [1.3535, 1.358], "CAD": [1.2515, 1.2465], "CHF": [0.90324, 0.90535], "EUR": [0.8414, 0.84133], "GBP": [0.71817, 0.71991], "JPY": [109.13, 109.52], "NZD": [1.4264, 1.4337]}] \ No newline at end of file diff --git a/csv/current_weather.json b/csv/current_weather.json index 4ede625..c008f51 100644 --- a/csv/current_weather.json +++ b/csv/current_weather.json @@ -1 +1 @@ -[{"main_weather": "Clouds", "description": "overcast clouds", "temp": 29.14, "min_temp": 28.1, "max_temp": 29.92, "feels_like": 36.14, "humidity": 90, "clouds": 96, "wind_speed": 0.45, "wind_direction": 90, "visibility": 10000, "uv": 0, "rain_chance": 0}, {"main_weather": "Clouds", "description": "scattered clouds", "temp": 21.34, "min_temp": 12.35, "max_temp": 21.56, "feels_like": 20.91, "humidity": 53, "clouds": 28, "wind_speed": 6.69, "wind_direction": 260, "visibility": 10000, "uv": 2.93, "rain_chance": 0}] \ No newline at end of file +[{"main_weather": "Clouds", "description": "broken clouds", "temp": 27.33, "min_temp": 26.86, "max_temp": 29.57, "feels_like": 31.44, "humidity": 88, "clouds": 70, "wind_speed": 4.92, "wind_direction": 40, "visibility": 10000, "uv": 0, "rain_chance": 0.82}, {"main_weather": "Clouds", "description": "overcast clouds", "temp": 19.25, "min_temp": 13.89, "max_temp": 20.27, "feels_like": 19.01, "humidity": 68, "clouds": 94, "wind_speed": 4.63, "wind_direction": 130, "visibility": 10000, "uv": 1.06, "rain_chance": 0.56}] \ No newline at end of file diff --git a/csv/daily_weather.json b/csv/daily_weather.json index b25c449..68aec29 100644 --- a/csv/daily_weather.json +++ b/csv/daily_weather.json @@ -1 +1 @@ -[[{"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.1, "max_temp": 29.92}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.42, "max_temp": 29.19}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.53, "max_temp": 30.07}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.35, "max_temp": 29.88}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.43, "max_temp": 28.64}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.31, "max_temp": 29.18}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.32, "max_temp": 31.55}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.18, "max_temp": 32.05}], [{"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 12.35, "max_temp": 21.56}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.31, "max_temp": 18.5}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.38, "max_temp": 20.87}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.75, "max_temp": 20.42}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.39, "max_temp": 20.32}, {"main_weather": "Rain", "description": "light rain", "min_temp": 15.16, "max_temp": 21.32}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.99, "max_temp": 21.43}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.34, "max_temp": 21.38}]] \ No newline at end of file +[[{"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.86, "max_temp": 29.57}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.72, "max_temp": 28.32}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.03, "max_temp": 27.98}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.2, "max_temp": 28.08}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.91, "max_temp": 28.84}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.18, "max_temp": 29.87}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.09, "max_temp": 29.25}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.23, "max_temp": 29.96}], [{"main_weather": "Rain", "description": "light rain", "min_temp": 13.89, "max_temp": 20.27}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.12, "max_temp": 22.97}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 13.54, "max_temp": 21.04}, {"main_weather": "Rain", "description": "light rain", "min_temp": 15, "max_temp": 19.8}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 13.95, "max_temp": 19.15}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.39, "max_temp": 19.7}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.31, "max_temp": 22.84}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 15.14, "max_temp": 23.12}]] \ No newline at end of file diff --git a/csv/last_updates.json b/csv/last_updates.json index 47af5b2..8cb7894 100644 --- a/csv/last_updates.json +++ b/csv/last_updates.json @@ -1 +1 @@ -{"stocks": "31/07/2021 05:57:19", "crypto": "31/07/2021 05:57:20", "news": "31/07/2021 05:57:21", "weather": "31/07/2021 05:57:20", "forex": "31/07/2021 11:57:24", "sports": "31/07/2021 05:57:21"} \ No newline at end of file +{"stocks": "03/08/2021 13:14:11", "crypto": "03/08/2021 13:14:13", "news": "03/08/2021 13:14:15", "weather": "03/08/2021 13:14:14", "forex": "03/08/2021 19:14:18", "sports": "03/08/2021 13:14:16"} \ No newline at end of file diff --git a/csv/news.csv b/csv/news.csv index 4a51c19..0c1e1fd 100644 --- a/csv/news.csv +++ b/csv/news.csv @@ -1,21 +1,21 @@ headline,source,date,time -Coronavirus live: UK businesses warned over ‘no jab no job’ policies^ Germany anti-lockdown protests banned - The Guardian,The Guardian,2021-07-31,08:39:03Z -Live: Tokyo Olympics^ day eight: Great Britain and Fiji fight for bronze ahead of Black Ferns' gold medal bid - Stuff.co.nz,Stuff.co.nz,2021-07-31,08:29:00Z -Basketball-Nigeria's Metu blasts government for lack of support at Games - Reuters,Reuters,2021-07-31,08:24:00Z -Image: Hubble spots squabbling galactic siblings - Phys.org,Phys.Org,2021-07-31,08:17:09Z -Mi 12 Tipped to Integrate Newly Announced LPDDR5X RAM^ Could Come With Snapdragon 898 SoC - Gadgets 360,NDTV News,2021-07-31,08:08:21Z -Tokyo 2020 Day 8: Regrets for Mark English in 800m; golf hots up as McIlroy hunts a medal - The Irish Times,The Irish Times,2021-07-31,08:03:45Z -JUST IN: Nollywood actress Racheal Oniga is dead - P.M. News,P.M. News,2021-07-31,08:03:45Z -DOH lists 8^147 new COVID-19 cases^ 167 more deaths - CNN Philippines,CNN Philippines,2021-07-31,08:01:47Z -Team GB smash world record to win Tokyo 4x100m mixed medley relay gold - The Guardian,The Guardian,2021-07-31,08:00:00Z -Bright reflections observed at Mars’ south pole may be clay^ not water - Tech Explorist,Tech Explorist,2021-07-31,07:58:33Z -Huge Chunk Of Road Caves In Under Flyover In South Delhi^ Stops Traffic - NDTV,NDTV News,2021-07-31,07:57:33Z -Business groups seek clarity on regulations as emergency ordinances in limbo - Malaysiakini,Malaysiakini,2021-07-31,07:54:00Z -Tokyo Olympics live: OlyWhites captain Winston Reid recovers from injury to face Japan - Stuff.co.nz,Stuff.co.nz,2021-07-31,07:53:00Z -Sailing: Kimberly Lim and Cecilia Low finish 10th overall^ first Singaporeans to qualify for medal race at Olympics - CNA,CNA,2021-07-31,07:48:46Z -Google will stop account sign-in for users running these old Android versions - Times of India,The Times of India,2021-07-31,07:48:00Z -UPDATED: Blessing Okagbare suspended from athletics hours to Olympics 100m semi-final race - Premium Times,Premium Times,2021-07-31,07:42:56Z -India records 41^649 new Covid cases; active cases rise for 4th day - The Indian Express,The Indian Express,2021-07-31,07:39:37Z -Home Office set up fake website to deter asylum seekers from crossing Channel with ‘misleading’ claims - The Independent,Independent,2021-07-31,07:35:09Z -Assam-Mizoram border dispute LIVE Updates: Tensions rise as Mizoram names CM Himanta Biswa Sarma in violence FIR - The Indian Express,The Indian Express,2021-07-31,07:29:22Z -PV Sindhu Semi-Final LIVE: Sindhu can create history today by becoming 1st Indian sportsperson to play two Olympic Finals in individual sports - InsideSport,InsideSport,2021-07-31,07:26:11Z +Pentagon on lockdown after gunshots fired near Metro station - Daily Mail,Daily Mail,2021-08-03,16:26:56Z +Andrew Cuomo: New York Governor sexually harassed women^ report finds - BBC News,BBC News,2021-08-03,16:14:54Z +New York Gov. Andrew Cuomo sexually harassed multiple women^ state attorney general report says - CNN,CNN,2021-08-03,16:13:00Z +Vaccinated people are much more protected from COVID-19 than unvaccinated individuals; the benefits of the COVID-19 vaccines outweigh their risks - Health Feedback,Health Feedback,2021-08-03,16:08:36Z +Coronavirus live updates: Quebec reports 175 new cases^ no deaths - Montreal Gazette,Montreal Gazette,2021-08-03,16:06:05Z +Index surges anew ahead of Q2 earnings - Philstar.com,Philippine Star,2021-08-03,16:00:00Z +Matt Damon’s New Statement Saying He Doesn’t “Use Slurs Of Any Kind” After “Retiring The F-Slur” Has Sparked A Huge Debate In Light Of Him Playing Gay Characters In The Past - BuzzFeed News,BuzzFeed News,2021-08-03,15:55:00Z +Pentagon reopens after brief lockdown due to shooting near Metro station - Hindustan Times,Hindustan Times,2021-08-03,15:51:14Z +Massive Balloon the Size of a Soccer Stadium to Launch Telescope to Edge of Space to Study How Stars Form - Good News Network,Good News Network,2021-08-03,15:51:01Z +Today’s coronavirus news: Ontario reporting 164 cases Tuesday^ 168 cases Monday; NYC to require vaccination proof for indoor dining^ gyms - Toronto Star,Toronto Star,2021-08-03,15:45:00Z +NBA free agency Day 1 winners and losers: Heat make power moves; Lakers defense takes hit; Knicks go sideways - CBS Sports,CBS Sports,2021-08-03,15:45:00Z +Covid 19 coronavirus: China orders mass testing in Wuhan as outbreak spreads - New Zealand Herald,New Zealand Herald,2021-08-03,15:35:31Z +Celtic sign goalkeeper Joe Hart and midfielder James McCarthy - Sky Sports,Sky Sports,2021-08-03,15:33:55Z +At least 3 injured in workplace shooting at SmileDirectClub in Antioch^ Tennessee - NBC News,NBC News,2021-08-03,15:32:02Z +#UnrestSA: State wants to adds treason charges to lawyer Ike Khumalo's incitement case - News24,News24,2021-08-03,15:27:28Z +Boeing delays key uncrewed test flight of Starliner capsule to space station - The Straits Times,The Straits Times,2021-08-03,15:21:41Z +Florida's Broward County school district reverses its mask mandate after funding threat from the governor - CNN,CNN,2021-08-03,15:21:00Z +U.S. Gov. Cuomo sexually harassed multiple women^ probe finds - CTV News,Ctvnews.ca,2021-08-03,15:18:39Z +COVID-19: UK records another 138 coronavirus deaths - the highest daily total since 17 March - Sky News,Sky.com,2021-08-03,15:17:28Z +Tokyo Olympics: PV Sindhu^ India's Double Olympic Medallist^ Felicitated After Returning From Tokyo | Olympics News - NDTVSports.com,NDTV News,2021-08-03,15:17:00Z diff --git a/csv/tickers.csv b/csv/tickers.csv index 8a91305..593e69c 100644 --- a/csv/tickers.csv +++ b/csv/tickers.csv @@ -1,4 +1,4 @@ name,current,opening -MSFT,288.51,286.19 -NFLX,520.495,521.015 -GOOG,2732.56,2728.535 +MSFT,286.9,285.605 +NFLX,510.84,514.24 +GOOG,2720.7,2721.21 diff --git a/display_images/crypto.ppm b/display_images/crypto.ppm index 55a9d69..748596d 100755 Binary files a/display_images/crypto.ppm and b/display_images/crypto.ppm differ diff --git a/display_images/display_gif.gif b/display_images/display_gif.gif index ed092d9..4d5d30e 100755 Binary files a/display_images/display_gif.gif and b/display_images/display_gif.gif differ diff --git a/display_images/forex.ppm b/display_images/forex.ppm index 80dd1a3..246f27f 100755 Binary files a/display_images/forex.ppm and b/display_images/forex.ppm differ diff --git a/display_images/league.ppm b/display_images/league.ppm index 48aa112..0794ec9 100755 Binary files a/display_images/league.ppm and b/display_images/league.ppm differ diff --git a/display_images/stocks.ppm b/display_images/stocks.ppm index 088c855..dfe6f2f 100755 Binary files a/display_images/stocks.ppm and b/display_images/stocks.ppm differ diff --git a/display_images/teams.ppm b/display_images/teams.ppm index 7325795..b15b7bd 100755 Binary files a/display_images/teams.ppm and b/display_images/teams.ppm differ diff --git a/display_images/user_gif.gif b/display_images/user_gif.gif index c78d7a0..1eadae4 100755 Binary files a/display_images/user_gif.gif and b/display_images/user_gif.gif differ diff --git a/stockTicker.py b/stockTicker.py index d3ee4a7..810b6c3 100644 --- a/stockTicker.py +++ b/stockTicker.py @@ -9,7 +9,7 @@ import sys, select import os import threading -from PIL import Image, ImageDraw, ImageFont +from PIL import Image, ImageDraw, ImageFont, ImageSequence Image.init() @@ -57,13 +57,16 @@ class StockTicker(): options.gpio_slowdown = 4 self.matrix = RGBMatrix(options = options) self.points = True # display crypto change in points or percent + self.functions = {'stocks': self.getStockImage, 'crypto': self.getCryptoImage, 'forex': self.getForexImage, 'daily_weather':self.getDailyWeatherImage, 'today_weather': self.getTodayWeatherImage, - 'league_table': self.getLeagueTableImage, 'league_games': self.getLeagueImage, 'news':self.getNewsImage, - 'text': self.getUserText, 'display_image': self.getUserImage, 'display_gif':self.getUserGIF, + 'league_table':lambda : self.getLeagueTableImage('premier_league'), 'past_games': lambda:self.getLeagueImage('NBA', 'past'), + 'future_games': lambda : self.getLeagueImage('NHL', 'future'), 'live_games': lambda: self.getLeagueImage('NBA', 'live'), + 'news':self.getNewsImage, 'text': self.getUserText, 'display_image': self.getUserImage, 'display_gif':self.getUserGIF, + 'stocks_prof': self.getStockProfessional, 'crypto_prof': self.getCryptoProfessional, 'forex_prof': self.getForexProfessional, - 'today_weather_prof': self.getTodayWeatherProfessional, 'news_prof':self.getNewsProfessional} #put this somewhere else + 'today_weather_prof': self.getTodayWeatherProfessional, 'news_prof':self.getNewsProfessional} def openImage(self, image_file): @@ -271,9 +274,9 @@ class StockTicker(): def updateMultiple(self, options): for option in options: - + img = self.functions[option]() + if option not in ['display_gif']: # aving the gif like this kills the animation - img = self.functions[option]() img.save('./display_images/'+ option+ '.ppm') def incrementGIF(self, image): @@ -319,7 +322,7 @@ class StockTicker(): image = self.openImage('./display_images/' + options[i % len(options)] +'.ppm') image = image.convert('RGB') else: - image = self.openImage('./display_images/user_gif.gif') + image = self.openImage('./display_images/display_gif.gif') img_width, img_height = image.size @@ -1081,6 +1084,8 @@ class StockTicker(): f = open( "csv/league.txt", 'r' ) league = f.read().replace('\n', '') f.close() + + title_img = self.openImage('feature_titles/sports_'+ time + '.png') img = Image.new('RGB', (10000, 32)) league_info = json.load(open('csv/sports/{}/{}_games.json'.format(league, time), 'r')) @@ -1204,8 +1209,8 @@ class StockTicker(): x_offset += buff_size img = img.crop((0,0,x_offset ,32)) - font = ImageFont.load("./fonts/texgyre-27.pil") - title_img = self.textImage(time.upper() + ' GAMES', font, matrix_height = True) + + return self.stitchImage([title_img, img]) @@ -1216,6 +1221,10 @@ class StockTicker(): f = open( "csv/table_league.txt", 'r' ) league = f.read().replace('\n', '') f.close() + + title_img = self.openImage('feature_titles/sports_team_stats.png') + + img = Image.new('RGB', (10000, 32)) team_info = json.load(open('csv/sports/{}/team_stats.json'.format(league), 'r')) @@ -1266,9 +1275,6 @@ class StockTicker(): img = img.crop((0,0,x_offset ,32)) - font = ImageFont.load("./fonts/texgyre-27.pil") - title_img = self.textImage('LEAGUE TABLE', font, matrix_height = True) - return self.stitchImage([title_img, img]) def getTodayWeatherImage(self): @@ -1887,9 +1893,20 @@ class StockTicker(): return self.stitchImage([title_img, image]) def getUserGIF(self): - + title_img = self.openImage('feature_titles/gifs.png') gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/user_gif.gif')) - return gif + + frames = [] + + for i, frame in enumerate(ImageSequence.Iterator(gif)): + f = self.stitchImage([title_img, frame]) + frames.append(f) + + + frames[0].save('./display_images/display_gif.gif', save_all=True, append_images=frames[1:], loop=0, optimize = False) + + + return None def displayStocks(self): @@ -1959,8 +1976,7 @@ class StockTicker(): self.scrollFunctionsAnimated(['display_image', 'display_image'], animation = 'traditional') elif msg == 'G': # gif - image = self.openImage('./display_images/user_gif.gif') - #self.displayGIF(image) + self.scrollFunctionsAnimated(['display_gif', 'display_gif'], animation = 'traditional') elif msg == 'W': # weather @@ -1970,28 +1986,16 @@ class StockTicker(): self.scrollFunctionsAnimated(['daily_weather', 'daily_weather'],animation = 'traditional') elif msg == 'P': # past league - img = self.getLeagueImage('NBA', 'past') - img.save('display_images/league.ppm') - - stock_ticker.scrollImageTransition(['display_images/league.ppm', 'display_images/league.ppm'], stocks = False) + self.scrollFunctionsAnimated(['past_games', 'past_games'],animation = 'traditional') elif msg == 'l': # future league - img = self.getLeagueImage('NHL', 'future') - img.save('display_images/league.ppm') - - stock_ticker.scrollImageTransition(['display_images/league.ppm', 'display_images/league.ppm'], stocks = False) + self.scrollFunctionsAnimated(['future_games', 'future_games'],animation = 'traditional') elif msg == 'L': # live game - img = self.getLeagueImage('NBA', 'live') - img.save('display_images/league.ppm') - - stock_ticker.scrollImageTransition(['display_images/league.ppm', 'display_images/league.ppm'], stocks = False) + self.scrollFunctionsAnimated(['live_games', 'live_games'],animation = 'traditional') elif msg == 't': #legue tble - img = self.getLeagueTableImage('premier_league') - img.save('display_images/teams.ppm') - - stock_ticker.scrollImageTransition(['display_images/teams.ppm', 'display_images/teams.ppm'], stocks = False) + self.scrollFunctionsAnimated(['league_table', 'league_table'],animation = 'traditional') elif msg == 'A': #everything @@ -2027,7 +2031,7 @@ if __name__ == '__main__': # - #stock_ticker.process_msg('b') + #stock_ticker.process_msg('G') #stock_ticker.process_msg('G') #stock_ticker.process_msg('f') #stock_ticker.process_msg('W')