From 7a0056abc4546cf84112030553205042032ebfcc Mon Sep 17 00:00:00 2001 From: Neythen Date: Thu, 3 Jun 2021 21:56:25 +0100 Subject: [PATCH] basic weather added --- api_caller.py | 2 +- csv/crypto.csv | 4 +- csv/current_weather.json | 2 +- csv/daily_weather.json | 2 +- csv/last_update.csv | 2 +- csv/news.csv | 40 +++++++-------- csv/tickers.csv | 6 +-- display_gif | Bin 747 -> 821 bytes final.ppm | Bin 113391 -> 113391 bytes stockTicker.py | 108 ++++++++++++++++++++++++++++++++++++--- 10 files changed, 130 insertions(+), 36 deletions(-) diff --git a/api_caller.py b/api_caller.py index 5ff52ad..e0aab0e 100644 --- a/api_caller.py +++ b/api_caller.py @@ -224,7 +224,7 @@ def updateWeather(location, api_key): url = "https://api.openweathermap.org/data/2.5/weather?q={}&units=metric&appid={}".format(location, api_key) r = requests.get(url) weather = r.json() - + print(weather) current_weather = {} coords = weather['coord'] diff --git a/csv/crypto.csv b/csv/crypto.csv index db78d18..16884db 100644 --- a/csv/crypto.csv +++ b/csv/crypto.csv @@ -1,3 +1,3 @@ symbol,name,base,current,24hr change -BTC,bitcoin,usd,37943,5.398882470458167 -ETH,ethereum,gbp,1950.25,8.111712194442813 +BTC,bitcoin,usd,38625,2.2471171345902663 +ETH,ethereum,gbp,1985.53,2.296467164133747 diff --git a/csv/current_weather.json b/csv/current_weather.json index 8a39dc6..79020bf 100644 --- a/csv/current_weather.json +++ b/csv/current_weather.json @@ -1 +1 @@ -{"main_weather": "Clouds", "description": "overcast clouds", "temp": 19.95, "min_temp": 17.32, "max_temp": 21.2, "feels_like": 19.54, "humidity": 59, "clouds": 96, "wind_speed": 1.31, "wind_direction": 113, "visibility": 10000, "uv": 0} \ No newline at end of file +{"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} \ No newline at end of file diff --git a/csv/daily_weather.json b/csv/daily_weather.json index 813c4d5..c69e1d1 100644 --- a/csv/daily_weather.json +++ b/csv/daily_weather.json @@ -1 +1 @@ -[{"main_weather": "Rain", "description": "light rain", "min_temp": 27.04}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 24.89}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 16.33}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 22.03}, {"main_weather": "Rain", "description": "light rain", "min_temp": 21.89}, {"main_weather": "Rain", "description": "light rain", "min_temp": 24.13}, {"main_weather": "Rain", "description": "light rain", "min_temp": 25.2}, {"main_weather": "Rain", "description": "light rain", "min_temp": 25.55}] \ No newline at end of file +[{"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}] \ No newline at end of file diff --git a/csv/last_update.csv b/csv/last_update.csv index 6bae4df..d644919 100644 --- a/csv/last_update.csv +++ b/csv/last_update.csv @@ -1 +1 @@ -02/06/2021 16:08:56 +03/06/2021 16:44:14 diff --git a/csv/news.csv b/csv/news.csv index cd8cd2c..4299499 100644 --- a/csv/news.csv +++ b/csv/news.csv @@ -1,21 +1,21 @@ headline,source,date,time -LKL finalo serijos starte – užtikrinta „Žalgirio“ pergalė - Lrytas.lt,Lrytas.lt,2021-06-02,18:41:12Z -Israeli Opposition Races Against Deadline to Oust Netanyahu: Live Updates - The New York Times,New York Times,2021-06-02,18:36:55Z -Help with roads^ rivers and rubble a priority as farmers take stock of flood devastation - Stuff.co.nz,Stuff.co.nz,2021-06-02,18:23:00Z -ICFO: Spain overtakes China in one of the biggest quantum communication problems | Science - Sunday Vision,Sundayvision.co.ug,2021-06-02,18:15:04Z -Joel Embiid (knee) will not play in Game 5 - NBA.com,Heat.com,2021-06-02,18:00:00Z -Elephant herd razes 500-kilometer path of destruction after escape from China nature reserve - CNN ,CNN,2021-06-02,17:58:00Z -President Biden News: Live Updates - The New York Times,New York Times,2021-06-02,17:57:48Z -Lack of papal apology for Canada indigenous schools abuses 'shameful' - minister - GMA News,GMA News,2021-06-02,17:45:42Z -No Time To Die Singer Billie Eilish Rocks Blonde Locks In Lost Cause Video - CinemaBlend,CinemaBlend,2021-06-02,17:45:39Z -Jaguar F-Type available only with V8 engine for 2022 - Driving,Driving,2021-06-02,17:42:02Z -Premier Doug Ford announces no in-class learning until September - Toronto Star,Toronto Star,2021-06-02,17:37:30Z -Cricket: Devon Conway shines on debut as Black Caps dominate day one of first test against England at Lord's - New Zealand Herald,New Zealand Herald,2021-06-02,17:35:00Z -Atmospheric metal layers appear with surprising regularity - Science Daily,Science Daily,2021-06-02,17:31:46Z -Kevin Lunney attackers broke his leg and scored chest with blade^ court hears - The Irish Times,The Irish Times,2021-06-02,17:30:53Z -US wields $2bn tariff threat against 6 nations over digital taxes - Financial Times,Financial Times,2021-06-02,17:25:24Z -Duke Blue Devils basketball coach Mike Krzyzewski plans to retire after season^ sources say - ESPN,ESPN,2021-06-02,17:24:40Z -Do not politick with land^ Malema warns Ramaphosa as he cranks up pressure on ANC over amendment - News24,News24,2021-06-02,17:24:10Z -AMC frenzy triggers trading halts as stock surges 100 percent - NBC News,NBC News,2021-06-02,17:23:00Z -Facebook doubles down on business tools with WhatsApp API updates^ Login Connect for Messenger and more - TechCrunch,TechCrunch,2021-06-02,17:21:52Z -BJP leader Rakesh Pandit shot dead by terrorists outside his home in Kashmir - Moneycontrol.com,Moneycontrol,2021-06-02,17:19:38Z +FBI investigating Postmaster General Louis DeJoy in connection with past political fundraising - The Washington Post,The Washington Post,2021-06-03,18:38:00Z +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 +SpaceX launches tiny critters^ solar panels to space station - Phys.org,Phys.Org,2021-06-03,18:21:00Z +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 +Trent Alexander-Arnold: England right-back ruled out of Euro 2020 - BBC Sport,BBC News,2021-06-03,18:14:46Z +Washington to bar US investors from 59 Chinese companies - Financial Times,Financial Times,2021-06-03,18:00:50Z +Massive Die-Off Discovered by Accident: A Shark Mystery Millions of Years in the Making - SciTechDaily,SciTechDaily,2021-06-03,18:00:02Z +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 AirTag privacy improvements^ Android app coming this year - 9to5Mac,9to5Mac,2021-06-03,17:58:00Z +SpaceX launches Dragon cargo spacecraft to the Space Station with new Falcon 9 - Yahoo Singapore News,Yahoo Entertainment,2021-06-03,17:55:39Z +How to Photograph an Annular 'Ring of Fire' Solar Eclipse - PetaPixel,PetaPixel,2021-06-03,17:55:37Z +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 +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 +Morden schools move to remote learning as Manitoba reports 360 new cases^ 5 deaths - CBC.ca,CBC News,2021-06-03,17:51:51Z +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 live updates: Quebec publishes timeline for advancing second-dose appointments - Montreal Gazette,Montreal Gazette,2021-06-03,17:48:45Z +SpaceX launches Dragon cargo spacecraft to the Space Station with new Falcon 9 - Yahoo Movies Canada,Yahoo Entertainment,2021-06-03,17:47:22Z +Sinn Féin receives another £800^000 from the will of deceased English man - TheJournal.ie,TheJournal.ie,2021-06-03,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 +Vanessa Bryant^ Kobe’s widow^ alleges Nike leaked unauthorized Mambacita shoes - CNBC,CNBC,2021-06-03,17:43:14Z diff --git a/csv/tickers.csv b/csv/tickers.csv index fe635d3..344b9ce 100644 --- a/csv/tickers.csv +++ b/csv/tickers.csv @@ -1,4 +1,4 @@ name,current,opening -MSFT,247.3,248.125 -NFLX,499.24,499.82 -GOOG,2421.28,2435.31 +MSFT,245.71,245.22 +NFLX,489.43,495.19 +GOOG,2404.61,2395.02 diff --git a/display_gif b/display_gif index c78d7a0507f9d38881ba68a8edba24ddeadae454..1eadae40c4dc16d28234c6cb4e150b88c535af93 100755 GIT binary patch literal 821 zcmZ?wbhEHb3}R4V_{abTcCTk}KVj&5t@x9L(+DV{_@CR)H6+;CF~HSG&w!Z`BIKEy zn4apJn4X!O&6}Q>o118Bpl4!gVrt5u12P3<9s|?=mVQp9SNx0TOp)~7d~f#FqpgoB zYG*uBz30A7sC#a<@$z?X4}4Di`sUN&*04Py8zYz$n+~0OchbbL(Rbq6<-r%1g`{qs zv{#|qUF1D?+^Wf*vv<@wIj8J5F!d`x{XFrO1>1_P)7iE>-Rdl6{vxDe>yjN6%tys` za@-7^`Ljac!psYj4GdOXTCXytvK)5(+F8~0N!Vb*Da+HE))Q7+duw~I&f?y)`}Zx& zIlrYJ{+8r<@cPys9jUijcTS)7QjD#h`$pz2&zrRy_R1#xyX(t0FXrDVUi+pvIX$`h z{&{uvdETe?t;>sYXuPv2^R;=7!oI36dv;oX^NZXc_AK-LEBetm3q47Mo9TO1`%LHAR>f_&~F6B!e`n449));p8W^Mgx~OwI?))=2^quDWyHc3Y%SjX?cLqOpVJ$-)!oaQYD_z9a`M}Hxk?-R zC)I{E#2WYXb~Ri26in`#v#2RBwXdXQ{)z=_*G(}gubeY+@$~lXb$x~TTUJe5xbr}L zZhv{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lEnP947_QspP)X?D@;4MVnlGJ0z%<3+M!7+-_=QE z)&GdW87^%Dgl(`F9XjVaXuCI2fXtw?pKCv)?}VnHP)@`5(f~Ze0jVN>KSDW-iLo(h zEH+mz(gYVjLUF6^r}*2uEbe-fP74|%qScHu(g;QwTCZ{OBF&fw0s6vIZE$M%z!RH4 znMZh(C$DfgnG`W_KfyXB%>rf>>e=PLi>xBDL`pA`QDP){hz~< zmw!SJz0B+vxzPs#qCH`TzZulKibJFN0y1&=hEP?5tE^H&$$;d8hB||Xng2o>G`Lp} z(pgX*Hzef6cA^nFKOr089(an`8tO94`~b6 zj$$1XLS9TZPc9gecoc@x@I#cxeGI1+LyRGUVd(^HLCwVLP+GebL3o{4%Y+?xy7_OR zT=04VyU&v46^GNSCx1p3@%p=n;5v&_GT%x;GJ(T=42!59{<5ZYFaW>IQ}4o6?D?iB z5ir%}xbhB7n~kL<1Vx7wp&$lNMYH%O?R*rJ#^CrzVuVibGKOLR642ueBaLZua1@EG zgSJlY5${sp0STJLzgWVif~!djWKPTTS1bRFR0A}8^Dw&W1VBPQIHy<%kZ3Jg5PgcP z@0(`dj$G#7IoJ6EN8YFBWx&9@b0ch~Ux7^WVh;8cJ2M5k&Qad?VE~ayg>LwXX&`V> zhG2t!u6-Gw0;XJN1V9$N&cE+A)T`bA&T6lAJ$Z<`&bUBQVEeEnMnDCh#WHbkmh29( zD@gIp$raSPmJk>r*lV>7wPCbLM=5s_biDn#5d$s$!M6h)yul)rhmb|VUQ#J3c|7Af z|3rfC=JGvQtn%zdsc-)05qw*y1a)b{M(}Ck0&iL&yq&}n;I9PHj}%%c@g3lEh6Ohd z3vL(`x)*`2QWmeYr};1U=_UPg dBDbUF4Q*H{DcKSzOxY_`HY;E(7~e&c{{ekk8Gir( diff --git a/stockTicker.py b/stockTicker.py index 98181e2..5f5c72b 100644 --- a/stockTicker.py +++ b/stockTicker.py @@ -18,6 +18,8 @@ from rgbmatrix import RGBMatrix, RGBMatrixOptions from rgbmatrix.graphics import * from multiprocessing import Process import traceback +import json +from datetime import datetime def getInput(Block=False): @@ -216,7 +218,7 @@ class StockTicker(): current_img = 1 offset_x = 0 - def textImage(self, text, font, r = 255, g = 255, b = 255, matrix_height = False): + 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 ''' @@ -227,7 +229,7 @@ class StockTicker(): height = 32 print(text) print('dims:', width, height) - img = Image.new('RGB', (width + 50, height)) + img = Image.new('RGB', (width + buff + 3, height+3)) d = ImageDraw.Draw(img) d.text((0, 0), text, fill=(r, g, b), font=font) @@ -249,7 +251,7 @@ class StockTicker(): font = ImageFont.load("./fonts/texgyre-27.pil") - img = self.textImage(text, font, int(r), int(g), int(b), True) + img = self.textImage(text, font, int(r), int(g), int(b), True, buff = 50) img.save('scroll_text.ppm') self.scrollImageTransition(['scroll_text.ppm', 'scroll_text.ppm'], offset_x = 128, offset_y = 0, stocks = False) @@ -386,9 +388,7 @@ class StockTicker(): sys.stdout.flush() pass return False - - - + #Using change between min and day price give appropriate arrow #and set the overall change colour def getArrow(self, CHANGE): @@ -537,6 +537,98 @@ class StockTicker(): elif updated_img == 2: finalDisplayImage.save('final1.ppm') + def getWeatherImage(self): + img = Image.new('RGB', (128, 32)) + + location = 'London' + + + current_weather = json.load(open('csv/current_weather.json', 'r')) + + small_font = ImageFont.load("./fonts/4x6.pil") + large_font = ImageFont.load("./fonts/6x12.pil") + + + location_img = self.textImage(location, small_font) + + img.paste(location_img, (0,0)) + + main = current_weather['main_weather'] + if main == 'Clouds': + main = current_weather['description'] + weather_ids = {'Clear': '01', 'few clouds': '02', 'scattered clouds': '03', 'broken clouds':'04', 'overcast clouds':'04', 'Drizzle':'09', + 'Rain':'10', 'Thunderstorm':'11', 'Snow':'13', 'Mist': '50', 'Smoke': '50', 'Haze': '50', 'Dust': '50', 'Fog': '50', + 'Sand': '50', 'Ash': '50', 'Squall': '50', 'Tornado': '50'} + + weather_dir = './logos/weather_icons' + 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) + img.paste(temp_img, (32,13)) + + deg_img = self.textImage('o', small_font) + print(temp_img.size) + img.paste(deg_img, (31 + temp_img.size[0], 11)) + + main = current_weather['main_weather'] + main_img = self.textImage(main, small_font) + img.paste(main_img, (32, 25)) + + feels_img = self.textImage('Feels: ' + str(current_weather['feels_like']), small_font) + img.paste(feels_img, (location_img.size[0]+2, 0)) + + min_img = self.textImage( "{0:.1f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255) + img.paste(min_img, (location_img.size[0]+2, 7)) + + max_img = self.textImage( "{0:.1f}".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)) + + hum_img = Image.open(weather_dir + '/humidity.png') + img.paste(hum_img, ( 64, 8)) + + htext_img = self.textImage(str(current_weather['humidity']) + '%', small_font) + img.paste(htext_img, (73, 10)) + + uv_img = Image.open(weather_dir + '/uv.png') + img.paste(uv_img, ( 64, 20)) + + utext_img = self.textImage(str(current_weather['uv']) , small_font) + img.paste(utext_img, (75, 23)) + + 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()] + + print(month, date, weekday) + + date_img = self.textImage(month + ' ' + date + ', ' + weekday, small_font) + img.paste(date_img, (80, 0)) + + rain_img = Image.open(weather_dir + '/rain-chance.png') + img.paste(rain_img, (86,8)) + + rtext_img = self.textImage(str(current_weather['clouds']) + '%', small_font) + img.paste(rtext_img, (99, 10)) + + cloud_img = Image.open(weather_dir + '/clouds.png') + img.paste(cloud_img, (86,20)) + + ctext_img = self.textImage(str(current_weather['clouds']) + '%', small_font) + img.paste(ctext_img, (99, 22)) + + wind_img = Image.open(weather_dir + '/wind.png') + img.paste(wind_img, (115,8)) + + vis_img = Image.open(weather_dir + '/visibility.png') + img.paste(vis_img, (115,20)) + + self.setImage(img) #Send the final stitched image to the display for set amount of time @@ -676,6 +768,7 @@ if __name__ == '__main__': with open('log.txt', "w") as log: try: stock_ticker = StockTicker() + stock_ticker.getWeatherImage() #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.readCSV() @@ -705,6 +798,7 @@ if __name__ == '__main__': msg = getInput() stock_ticker.process_msg(msg) except Exception as e: + exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] log.write(str(e)) @@ -712,6 +806,6 @@ if __name__ == '__main__': log.write('. line: ' + str(exc_tb.tb_lineno)) log.write('. type: ' + str(exc_type)) log.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))) - + raise(e)