diff --git a/csv/crypto.csv b/csv/crypto.csv index 433aab3..e60505b 100644 --- a/csv/crypto.csv +++ b/csv/crypto.csv @@ -1,4 +1,4 @@ symbol,name,base,current,24hr change -BTC,bitcoin,usd,32927,0.1348056422318777 -ETH,ethereum,gbp,1447.6,0.44060897841839514 -DOGE,dogecoin,usd,0.202152,0.7090173677844843 +BTC,bitcoin,usd,31554,-4.613357050355953 +ETH,ethereum,gbp,1389.61,-4.851321076226648 +DOGE,dogecoin,usd,0.184145,-8.017861229371038 diff --git a/csv/current_weather.json b/csv/current_weather.json index 29b156f..e1582e5 100644 --- a/csv/current_weather.json +++ b/csv/current_weather.json @@ -1 +1 @@ -[{"main_weather": "Clouds", "description": "few clouds", "temp": 29.76, "min_temp": 28.24, "max_temp": 30.39, "feels_like": 36.76, "humidity": 80, "clouds": 14, "wind_speed": 0.45, "wind_direction": 255, "visibility": 10000, "uv": 0, "rain_chance": 0}, {"main_weather": "Clouds", "description": "few clouds", "temp": 23.92, "min_temp": 14.67, "max_temp": 23.92, "feels_like": 24.04, "humidity": 64, "clouds": 20, "wind_speed": 0.89, "wind_direction": 284, "visibility": 10000, "uv": 0.8, "rain_chance": 0}] \ No newline at end of file +[{"main_weather": "Clouds", "description": "scattered clouds", "temp": 29.76, "min_temp": 28.5, "max_temp": 30.61, "feels_like": 36.76, "humidity": 81, "clouds": 31, "wind_speed": 0.45, "wind_direction": 275, "visibility": 10000, "uv": 0, "rain_chance": 0}, {"main_weather": "Clouds", "description": "overcast clouds", "temp": 19.71, "min_temp": 14.35, "max_temp": 21.63, "feels_like": 19.62, "humidity": 72, "clouds": 90, "wind_speed": 5.14, "wind_direction": 360, "visibility": 10000, "uv": 0.36, "rain_chance": 0}] \ No newline at end of file diff --git a/csv/daily_weather.json b/csv/daily_weather.json index 854fee4..28cf74b 100644 --- a/csv/daily_weather.json +++ b/csv/daily_weather.json @@ -1 +1 @@ -[[{"main_weather": "Rain", "description": "light rain", "min_temp": 28.24, "max_temp": 30.39}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.95, "max_temp": 30.09}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.4, "max_temp": 29.06}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.65, "max_temp": 29.11}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.62, "max_temp": 28.55}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.71, "max_temp": 29.87}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.26, "max_temp": 31.54}, {"main_weather": "Rain", "description": "light rain", "min_temp": 29.41, "max_temp": 31.81}], [{"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 14.67, "max_temp": 23.92}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 14.59, "max_temp": 22.45}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 12.66, "max_temp": 25.26}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 14.87, "max_temp": 26.39}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 16.48, "max_temp": 28.14}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 18.46, "max_temp": 29.05}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 15.76, "max_temp": 21.21}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 12.81, "max_temp": 22.64}]] \ No newline at end of file +[[{"main_weather": "Rain", "description": "light rain", "min_temp": 28.5, "max_temp": 30.61}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.04, "max_temp": 29.77}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.64, "max_temp": 29.24}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.7, "max_temp": 28.62}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.62, "max_temp": 29.4}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.97, "max_temp": 30.11}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.69, "max_temp": 31.64}, {"main_weather": "Rain", "description": "light rain", "min_temp": 30.01, "max_temp": 32.67}], [{"main_weather": "Clouds", "description": "broken clouds", "min_temp": 14.35, "max_temp": 21.63}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 12.58, "max_temp": 26.02}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 16.35, "max_temp": 27.43}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 17.91, "max_temp": 27.84}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 17.11, "max_temp": 21.74}, {"main_weather": "Rain", "description": "light rain", "min_temp": 15.75, "max_temp": 21.98}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 12.8, "max_temp": 21.13}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.45, "max_temp": 15.92}]] \ No newline at end of file diff --git a/csv/last_updates.json b/csv/last_updates.json index e69de29..96ff93b 100644 --- a/csv/last_updates.json +++ b/csv/last_updates.json @@ -0,0 +1 @@ +{"stocks": "15/07/2021 14:46:31", "crypto": "15/07/2021 14:46:34", "news": "15/07/2021 14:09:38", "weather": "15/07/2021 14:09:35", "forex": "14/07/2021 18:58:56", "sports": "15/07/2021 14:09:39"} \ No newline at end of file diff --git a/csv/news.csv b/csv/news.csv index 3afcfea..edc4efc 100644 --- a/csv/news.csv +++ b/csv/news.csv @@ -1,21 +1,21 @@ headline,source,date,time -Amazon rainforest now emitting more CO2 than it absorbs - The Guardian,The Guardian,2021-07-14,16:40:00Z -MI5 investigated rightwing terror suspect who was 13 years old - The Guardian,The Guardian,2021-07-14,16:26:00Z -Ottawa Public Health adds zero new COVID-19 cases for second day this week - CTV Edmonton,Ctvnews.ca,2021-07-14,16:25:24Z -Award-winning Classic Adventure Games Syberia I & II Are FREE For Keeps On GOG - Geek Culture,Geek Culture,2021-07-14,16:18:59Z -Solar radio signals could be used to monitor melting ice sheets - Phys.org,Phys.Org,2021-07-14,16:11:48Z -Baltimore officer charged with murder after stepson is found hidden in crawlspace - NBC News,NBC News,2021-07-14,16:03:41Z -Today at Apple tutorial videos being added to YouTube - htxt.africa,Htxt.co.za,2021-07-14,16:00:49Z -CRISPR stops coronavirus replication in human cells - Livescience.com,Live Science,2021-07-14,15:54:39Z -Tour de France 2021 Stage 17^ as it happened: Tadej Pogacar tightens GC grip after Carapaz bluff - Eurosport UK,Eurosport.co.uk,2021-07-14,15:52:00Z -Catt Sadler gets COVID despite being fully vaccinated: 'Delta is relentless' - Page Six,Page Six,2021-07-14,15:51:00Z -COVID-19 in B.C.: Another update on cases^ deaths^ outbreaks coming from health ministry - CTV News Vancouver,Ctvnews.ca,2021-07-14,15:50:48Z -UK records 42^000 Covid cases in worst day for six months - with 49 more deaths - The Mirror,Mirror Online,2021-07-14,15:46:49Z -EU unveils ambitious climate package as it cools on fossil fuels - CNN ,CNN,2021-07-14,15:45:00Z -COVID-19: UNILAG shuts hostels indefinitely^ reverts to virtual classes - Guardian,Guardian Nigeria,2021-07-14,15:43:00Z -Worten tem stock da Xbox Series X e oferece 3 meses de Xbox Game Pass - Eurogamer.pt,Eurogamer.pt,2021-07-14,15:41:00Z -Bolsonaro in hospital as hiccups persist for more than 10 days - The Guardian,The Guardian,2021-07-14,15:39:00Z -EIA Inventory Report Sends Oil Prices Higher - OilPrice.com,OilPrice.com,2021-07-14,15:33:00Z -Dani Dyer's boyfriend Sammy Kimmence jailed for scamming pensioners out of almost £34^000 - Sky News,Sky.com,2021-07-14,15:31:18Z -Aussie comedian claims his ‘simple maths’ accurately calculates daily NSW Covid-19 cases - NEWS.com.au,News.com.au,2021-07-14,15:29:31Z -Investment in space companies hit record $4.5 billion in the second quarter^ report says - CNBC,CNBC,2021-07-14,15:27:33Z +Asus ROG Zephyrus S17 (2021) Review - PCMag,PCMag.com,2021-07-15,16:21:43Z +Covid-19: 994 cases reported in State with HSE on higher alert due to rising numbers of infections - The Irish Times,The Irish Times,2021-07-15,16:18:45Z +'We have never seen such a disaster': Dozens dead after heavy flooding in Europe - Stuff.co.nz,Stuff.co.nz,2021-07-15,16:18:00Z +China Criticized the Afghan War. Now It Worries About the Withdrawal. - The New York Times,New York Times,2021-07-15,16:16:00Z +Bukayo Saka: England winger won't allow negativity to break him after Euro 2020 final disappointment - Sky Sports,Sky Sports,2021-07-15,16:14:04Z +Isolation facilities ready for Delta variant – DoH - The Manila Times,The Manila Times,2021-07-15,16:12:18Z +Plant-based diet rich in soy reduces troubling menopause symptoms by 84% - News-Medical.Net,News-Medical.Net,2021-07-15,16:07:00Z +UK plan for Troubles amnesty breaches international obligations – Irish minister - The Guardian,The Guardian,2021-07-15,16:00:00Z +Calamba local exec survives ambush try - GMA News Online,GMA News,2021-07-15,15:59:04Z +Darts icon and former world champion Andy Fordham dies^ aged 59 - Daily Mail,Daily Mail,2021-07-15,15:57:53Z +Britney Spears' former attorney says change in conservatorship case is imminent: 'We're going to see lawsuits' - Fox News,Fox News,2021-07-15,15:43:58Z +Young YOU | What's happening with the Hubble telescope | You - News24,News24,2021-07-15,15:42:51Z +Engineers find imaging technique could become treatment for deep vein thrombosis - EurekAlert,EurekAlert,2021-07-15,15:41:04Z +Top 10 Covid updates: Third wave likely by end of August^ but numbers may not be high^ says ICMR - Scroll.in,Scroll.in,2021-07-15,15:41:00Z +Brookfield revises hostile bid for Inter Pipeline after losing court challenge^ raises cash price - The Globe and Mail,The Globe And Mail,2021-07-15,15:36:47Z +Britain records 63 Covid deaths in highest daily toll since MARCH - Daily Mail,Daily Mail,2021-07-15,15:32:17Z +Hailey Bieber Shut Down The “Beyond False” Accusations That Justin Bieber “Aggressively Yelled” At Her In A Viral TikTok - BuzzFeed News,BuzzFeed News,2021-07-15,15:31:00Z +‘Leaked’ Kremlin documents suggest Vladimir Putin personally authorised operation to help Donald Trump win in 2016 - NEWS.com.au,News.com.au,2021-07-15,15:27:48Z +Dutch crime reporter Peter de Vries dies after being shot in the head - Telegraph.co.uk,Telegraph.co.uk,2021-07-15,15:25:00Z +GTA Online update reveals "gigantic" shared social space to show off your cars - Eurogamer.net,Eurogamer.net,2021-07-15,15:25:00Z diff --git a/csv/tickers.csv b/csv/tickers.csv index c4aac3c..cfe82d9 100644 --- a/csv/tickers.csv +++ b/csv/tickers.csv @@ -1,4 +1,4 @@ name,current,opening -MSFT,282.56,282.41 -NFLX,551.69,541.99 -GOOG,2646.92,2637.49 +MSFT,280.31,282.16 +NFLX,540.37,554.86 +GOOG,2620.4,2647.615 diff --git a/display_images/crypto.ppm b/display_images/crypto.ppm index aa9c3f4..f5e8d64 100755 Binary files a/display_images/crypto.ppm and b/display_images/crypto.ppm differ diff --git a/display_images/daily_weather.ppm b/display_images/daily_weather.ppm index cf71759..6e2fd8d 100755 Binary files a/display_images/daily_weather.ppm and b/display_images/daily_weather.ppm differ diff --git a/display_images/display_gif.gif b/display_images/display_gif.gif old mode 100644 new mode 100755 index 2819c90..ed092d9 Binary files a/display_images/display_gif.gif and b/display_images/display_gif.gif differ diff --git a/display_images/display_gif.ppm b/display_images/display_gif.ppm old mode 100644 new mode 100755 index c78d7a0..e69de29 Binary files a/display_images/display_gif.ppm and b/display_images/display_gif.ppm differ diff --git a/display_images/league.ppm b/display_images/league.ppm index 48aa112..b7383fb 100755 Binary files a/display_images/league.ppm and b/display_images/league.ppm differ diff --git a/display_images/news.ppm b/display_images/news.ppm index fd35888..b926b71 100755 Binary files a/display_images/news.ppm and b/display_images/news.ppm differ diff --git a/display_images/stocks.ppm b/display_images/stocks.ppm index 0ec7767..e3fb1de 100755 Binary files a/display_images/stocks.ppm and b/display_images/stocks.ppm differ diff --git a/display_images/today_weather.ppm b/display_images/today_weather.ppm index 61ed1c5..2e66be5 100755 Binary files a/display_images/today_weather.ppm and b/display_images/today_weather.ppm differ diff --git a/display_images/user_gif.gif b/display_images/user_gif.gif new file mode 100755 index 0000000..c78d7a0 Binary files /dev/null and b/display_images/user_gif.gif differ diff --git a/display_images/user_gif.ppm b/display_images/user_gif.ppm index c78d7a0..1eadae4 100644 Binary files a/display_images/user_gif.ppm and b/display_images/user_gif.ppm differ diff --git a/server.py b/server.py index 44c42ce..85b5915 100644 --- a/server.py +++ b/server.py @@ -198,7 +198,7 @@ def DisplayGIF(): return hello() if fle: - filename = 'user_gif.ppm' + filename = 'user_gif.gif' fle.save(os.path.join(os.path.dirname(os.path.abspath(__file__)),os.path.join('display_images', filename))) global LastCommand LastCommand = 'Add a new logo file' @@ -207,6 +207,28 @@ def DisplayGIF(): return hello() return hello() +@app.route("/DisplayImage", methods=['POST']) +def DisplayImage(): + + if request.method == 'POST': + if 'file' not in request.files: + print('No file attached in request') + return hello() + fle = request.files['file'] + if fle.filename == '': + print('No file selected') + return hello() + if fle: + + filename = 'user_image.ppm' + fle.save(os.path.join(os.path.dirname(os.path.abspath(__file__)),os.path.join('display_images', filename))) + global LastCommand + LastCommand = 'Add a new logo file' + ticker.sendline('K') + ticker.sendline('I') + return hello() + return hello() + @app.route("/Ticker", methods=['POST']) def Ticker(): diff --git a/stockTicker.py b/stockTicker.py index 784af64..127da5c 100644 --- a/stockTicker.py +++ b/stockTicker.py @@ -149,8 +149,10 @@ class StockTicker(): 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 current_img = 1 - image1 = self.openImage(image_files[0]) - image2 = self.openImage(image_files[1]) + image1 = self.openImage(image_files[0]).convert('RGB') + image2 = self.openImage(image_files[1]).convert('RGB') + + double_buffer = self.matrix.CreateFrameCanvas() kill = False while True: @@ -159,8 +161,8 @@ class StockTicker(): if stocks: update_process = Process(target = self.getFullStockImage, args = (1,)) update_process.start() - image1 = self.openImage(image_files[0]) - image2 = self.openImage(image_files[1]) + image1 = self.openImage(image_files[0]).convert('RGB') + image2 = self.openImage(image_files[1]).convert('RGB') elif current_img == 2: @@ -168,8 +170,8 @@ class StockTicker(): update_process = Process(target = self.getFullStockImage, args = (2,)) update_process.start() - image1 = self.openImage(image_files[1]) - image2 = self.openImage(image_files[0]) + image1 = self.openImage(image_files[1]).convert('RGB') + image2 = self.openImage(image_files[0]).convert('RGB') img_width, img_height = image1.size @@ -177,11 +179,13 @@ class StockTicker(): while offset_x > -img_width: offset_x -= 1 - self.setImage(image1, offset_x = offset_x, offset_y = offset_y) + double_buffer.SetImage(image1, offset_x, offset_y) + 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) - + double_buffer.SetImage(image2, offset_x, offset_y) + + double_buffer = self.matrix.SwapOnVSync(double_buffer) time.sleep(self.delay) kill = self.checkKilled() @@ -206,9 +210,10 @@ class StockTicker(): for option in options: - if option not in ['display_gif']: + 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 checkKilled(self): @@ -239,9 +244,12 @@ class StockTicker(): update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],)) update_process.start() - image = self.openImage('./display_images/' + options[i % len(options)] +'.ppm') + if options[i % len(options)] != 'display_gif': + image = self.openImage('./display_images/' + options[i % len(options)] +'.ppm') image = image.convert('RGB') + else: + image = self.openImage('./display_images/user_gif.gif') img_width, img_height = image.size @@ -352,7 +360,7 @@ class StockTicker(): if kill: break - + if kill: break while pause_frames > 0: if pause_frames%frames == 0: @@ -378,31 +386,34 @@ class StockTicker(): kill = self.checkKilled() if kill: break - + if kill: break while offset_x > -img_width: # for animation in gifs if offset_x%frames == 0: + + try: - + print(frame) image.seek(frame) except EOFError: - + frame = 0 + image.seek(frame) frame +=1 + #image = image.convert('RGB') offset_x -= 1 - - - + #self.setImage(image.convert('RGB'), offset_x = offset_x, offset_y = offset_y) if options[i % len(options)] != 'display_gif': double_buffer.SetImage(image, offset_x, offset_y) else: + double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y) @@ -1238,7 +1249,7 @@ class StockTicker(): title_img = self.openImage('feature_titles/weather.png') - imgs = [title_img] + imgs = [title_img, self.blank] current_weathers = json.load(open('csv/current_weather.json', 'r')) for i, location in enumerate(locations): img = Image.new('RGB', (200, 32)) @@ -1265,15 +1276,15 @@ class StockTicker(): img.paste(weather_img, (5,9)) temp_img = self.textImage(str("{0:.0f}".format(current_weather['temp'])), large_font) - img.paste(temp_img, (36,9)) + img.paste(temp_img, (39,9)) deg_img = self.textImage('o', small_font) - img.paste(deg_img, (56, 8)) + img.paste(deg_img, (59, 8)) main = current_weather['main_weather'] main_img = self.textImage(main.upper(), small_font) - img.paste(main_img, (34, 26)) + img.paste(main_img, (35, 26)) feels_img = self.textImage('Feels like:'.upper() + str("{0:.0f}".format(current_weather['feels_like'])), small_font) img.paste(feels_img, (location_img.size[0] + 10, 0)) @@ -1335,7 +1346,7 @@ class StockTicker(): img.paste(vtext_img, (168, 22)) imgs.append(img) - + imgs.append(self.blank) return self.stitchImage(imgs) @@ -1599,7 +1610,7 @@ class StockTicker(): f.close() title_img = self.openImage('feature_titles/weather.png') - imgs = [title_img] + imgs = [title_img, self.blank] current_weathers = json.load(open('csv/current_weather.json', 'r')) @@ -1740,6 +1751,7 @@ class StockTicker(): img1 = img.crop((0,0,x_offset ,32)) imgs.append(img1) + imgs.append(self.blank) # add the image text @@ -1848,7 +1860,7 @@ class StockTicker(): def getUserGIF(self): - gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/user_gif.ppm')) + gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/user_gif.gif')) return gif def displayStocks(self): @@ -1917,6 +1929,8 @@ 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 @@ -1974,7 +1988,7 @@ if __name__ == '__main__': # - #stock_ticker.process_msg('A') + #stock_ticker.process_msg('G') #stock_ticker.process_msg('G') #stock_ticker.process_msg('f') #stock_ticker.process_msg('W') diff --git a/templates/index.html b/templates/index.html index 33848a8..e092e92 100644 --- a/templates/index.html +++ b/templates/index.html @@ -58,12 +58,19 @@ -

Display a image or gif

+

Display a gif

+

Display an image

+
+

+ +

+ +

Tickers to display

To change the tickers displayed please upload a CSV (comma separated value) file with 11 tickers on each row e.g