diff --git a/__pycache__/stockTicker.cpython-37.pyc b/__pycache__/stockTicker.cpython-37.pyc index a90e8ab..dd972e0 100644 Binary files a/__pycache__/stockTicker.cpython-37.pyc and b/__pycache__/stockTicker.cpython-37.pyc differ diff --git a/api_caller.py b/api_caller.py index c941a0e..4941d13 100644 --- a/api_caller.py +++ b/api_caller.py @@ -192,13 +192,15 @@ if __name__ == '__main__': NY_time = datetime.now(NY_zone) print(NY_time) - + symbols, stock_info = readCSV('csv/tickers.csv', max_stocks) + updateStockPrices(symbols) + updateUpdate(NY_time) while True: coins, coin_info = readCSV('csv/crypto.csv', max_stocks) updateCrypto(coins) - #updateNews() + updateNews() NY_time = datetime.now(NY_zone) symbols, stock_info = readCSV('csv/tickers.csv', max_stocks) diff --git a/csv/crypto.csv b/csv/crypto.csv index 1a752af..d6b5f11 100644 --- a/csv/crypto.csv +++ b/csv/crypto.csv @@ -1,3 +1,3 @@ name,current,24hr change -bitcoin,41158,-3.112342608605254 -ethereum,2691.26,-8.560574933024819 +bitcoin,34484,-6.042010140586837 +ethereum,2038.77,-12.44588779457297 diff --git a/csv/last_update.csv b/csv/last_update.csv index 9a20847..ce65959 100644 --- a/csv/last_update.csv +++ b/csv/last_update.csv @@ -1 +1 @@ -21/05/2021 09:21:44 +23/05/2021 05:14:57 diff --git a/csv/news.csv b/csv/news.csv index 8aa2bb9..39563d7 100644 --- a/csv/news.csv +++ b/csv/news.csv @@ -1,21 +1,21 @@ -headline, ' doesnt display, sort out comma -Total of 43 Changi Airport workers test positive for Covid-19; source likely worker who helped infected family from South Asia - The Straits Times -Covid-19 (May 21) - 6493 new cases, nationwide uptrend; 50 deaths - Malaysiakini -Lady Gaga says rape as teenager left her pregnant and caused psychotic break - The Guardian -Coronavirus: Spain to lift restrictions for UK and Japanese travellers - BBC News -Walsh wonderful as Warriors win thriller over Tigers - NRL.COM -Diana interview: Whistleblower wants apology from BBC bosses - BBC News -Latest Gombak death-in-custody due to heart attack, says S'gor CPO - Malaysiakini -Prince Harry tells Oprah that Diana's death led him to drink and drugs, accuses royals of 'total neglect' - NBC News -Manchester United passed on signing Man City star Ruben Dias - Manchester Evening News -Prince Harry: pain of Diana's death pushed me to drink and drugs - The Star Online -Kim Kardashian Accused Kourtney Kardashian Of Constantly "Degrading" Her Staff After A Brutal Confrontation With Her Nanny - BuzzFeed News -Overwatch 2 PvP is 5v5, Bastion reworked "from the ground up" - Eurogamer.net -Hospital staff 'should have checked for blood clots', say SA family - 9News -Cloudy skies to continue in Southern Luzon, Visayas and Mindanao due to ITCZ - INQUIRER.net -16-year-old Pune boy merges 50,000 images of Moon to create detailed picture - The Tribune -UK to offer Australia tariff-free trade deal despite farmers' fears - BBC News -Disha Patani does backflip to new BTS song Butter and Tiger Shroff is impressed, watch - Hindustan Times -Mop-up operations begin in Cape Town after flooding caused by heavy rain - News24 -New type of coronavirus originating in dogs found — study - The Edge Markets MY -House panel OKs bill for creation of PH virology institute, CDC - ABS-CBN News +headline +CBSE 12th Board Exams, JEE Main, NEET 2021 LIVE Updates: Meeting Concludes, Decision to be Out Shortly - News18 +Full Flower Moon and lunar eclipse coming May 26 - Barriere Star Journal +BBC reporter ‘never wanted to harm’ Diana - Herald Sun +Mad man to bad man: Jared Harris on his winning TV streak - The Guardian +India battles fatal black fungus threat as coronavirus deaths approach 300,000 - Irish Examiner +‘I wasn’t going to embarrass him’: Wayne’s blunt answer to Benji question - Fox Sports +China's Mars rover starts roaming the Red Planet - Jakarta Post +YouTube Confirms BTS's “Butter” MV Has Officially Broken All-Time Record For Most Views In 24 Hours - soompi +Ireland weather forecast as Met Eireann predicts rollercoaster Sunday but big midweek change ahead - Irish Mirror +Covid: Pfizer and AstraZeneca jabs effective against Indian variant - study - BBC News +Delhi Lockdown Extended Again, Arvind Kejriwal Says "May Unlock If..." - NDTV +Rapper AKA gives his version of events leading up to death of fiancé Anele Tembe - News24 +China says Martian rover takes first drive on surface of Red Planet - TimesLIVE +300 unvaccinated COVID-19 cases in current outbreak vs 78 vaccinated: Ong Ye Kung - CNA +‘Can’t allow that’: Sneaky AFL star getting away with murder - NEWS.com.au +Millions of Brits ‘unwittingly tracked’ by phone after Covid jab to see if movements changed... - The Sun +India struggles with black fungus infection as Covid deaths surge to 300,000 - The Irish Times +PM Modi holds meeting on Cyclone Yaas, landfall expected on May 26 - Hindustan Times +Australia Talks, one of the nation's biggest social surveys, is back for 2021. Here's how it works - ABC News +Bangladesh vs Sri Lanka, 1st ODI in Dhaka: Live Cricket Score and Updates - India Today diff --git a/csv/scroll_text.csv b/csv/scroll_text.csv index 3313a6f..300099b 100644 --- a/csv/scroll_text.csv +++ b/csv/scroll_text.csv @@ -1 +1 @@ -ARUSHI IS CUTE,0,0,255 \ No newline at end of file +hello world!,255,255,0 \ No newline at end of file diff --git a/csv/tickers.csv b/csv/tickers.csv index f9cd618..0311acc 100644 --- a/csv/tickers.csv +++ b/csv/tickers.csv @@ -1,22 +1,22 @@ name,current,opening -MSFT,246.48,243.96 -NFLX,501.67,489.55 -GOOG,2356.09,2328.04 -TSLA,586.78,575 -AAPL,127.31,125.23 -INTC,55.95,55.57 -TXN,185.3,182.28 -HPQ,32.04,31.98 -HOG,48.28,48.99 -LUV,59.92,60.92 -WMT,142.42,141.5 -BJ,46.16,48.26 -ETSY,172.36,166.28 -G,44.26,43.83 -GDDY,81.4,81.18 -GNRC,308.53,304.56 -PEP,147.23,145.25 -STM,36.18,35.79 -YELP,38.38,37.84 -XRAY,67.95,67.72 -ZTS,175.8,171.52 +MSFT,245.17,247.565 +NFLX,497.89,503.12 +GOOG,2345.1,2365.99 +TSLA,580.88,596.11 +AAPL,125.43,127.82 +INTC,56.08,56.42 +TXN,185.01,186.69 +HPQ,31.66,32.26 +HOG,48.06,48.68 +LUV,60.09,60.26 +WMT,141.75,142.52 +BJ,45.67,46.26 +ETSY,167.56,173 +G,44.12,44.3 +GDDY,79.08,81.3 +GNRC,308.68,311.12 +PEP,147.1,147.8734 +STM,36.21,36.41 +YELP,37.92,38.3 +XRAY,67.48,68.01 +ZTS,176.02,176.55 diff --git a/display_gif b/display_gif old mode 100644 new mode 100755 index 1eadae4..c78d7a0 Binary files a/display_gif and b/display_gif differ diff --git a/display_image b/display_image old mode 100644 new mode 100755 index 7538ced..dda00e7 Binary files a/display_image and b/display_image differ diff --git a/final.ppm b/final.ppm index 009e314..6251b2f 100755 Binary files a/final.ppm and b/final.ppm differ diff --git a/scroll_text.ppm b/scroll_text.ppm index f4d2363..cadb84d 100755 Binary files a/scroll_text.ppm and b/scroll_text.ppm differ diff --git a/stockTicker.py b/stockTicker.py index 190970b..77c5934 100644 --- a/stockTicker.py +++ b/stockTicker.py @@ -87,8 +87,7 @@ class StockTicker(): self.matrix.SetPixel(x + offset_x, y + offset_y, r*self.brightness, g*self.brightness, b*self.brightness) - def scrollImage(self, image_file, offset_x = 0, offset_y = 0): - image = self.openImage(image_file) + def scrollImage(self, image, offset_x = 0, offset_y = 0): img_width, img_height = image.size @@ -112,6 +111,32 @@ class StockTicker(): time.sleep(self.delay) return False + + def scrollImageStacked(self, image, offset_x = 0, offset_y = 0): + img_width, img_height = image.size + + + + while offset_x > -img_width - 128: + offset_x -= 1 + + self.setImage(image, offset_x = offset_x+128, offset_y = offset_y) + self.setImage(image, offset_x = offset_x, offset_y = offset_y+16) + + try: + msg = getInput() + if msg == 'K': + self.resetMatrix() + + return True + + self.process_msg(msg) + except KeyboardInterrupt: + sys.stdout.flush() + pass + + time.sleep(self.delay) + return False 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 @@ -177,9 +202,26 @@ class StockTicker(): elif current_img == 2: current_img = 1 offset_x = 0 - - def displayTextRepeating(self): + + def textImage(self, text, font, r = 255, g = 255, b = 255): + ''' + creates and returns a ppm image containing the text in the supplied font and colour + ''' + width, height = self.get_text_dimensions(text, font) + print(text) + print('dims:', width, height) + img = Image.new('RGB', (width + 50, height)) + d = ImageDraw.Draw(img) + + d.text((4, 0), text, fill=(r, g, b), font=font) + return img + + + def displayUserText(self): + ''' + displays the text entered in the webpage by the user. + ''' f = open('csv/scroll_text.csv', 'r') @@ -191,32 +233,16 @@ class StockTicker(): font = ImageFont.load("./fonts/texgyre-27.pil") - width, height = self.get_text_dimensions(text, font) - print(text) - print('dims:', width, height) - img = Image.new('RGB', (width + 50, 32)) - d = ImageDraw.Draw(img) - - d.text((4, 0), text, fill=(int(r), int(g), int(b)), font=font) + img = self.textImage(text, font, int(r), int(g), int(b)) img.save('scroll_text.ppm') self.scrollImageTransition(['scroll_text.ppm', 'scroll_text.ppm'], offset_x = 128, offset_y = 0, stocks = False) - def displayText(self, text, font): - - - - - width, height = self.get_text_dimensions(text, font) - print(text) - print('dims:', width, height) - img = Image.new('RGB', (width + 50, 32)) - d = ImageDraw.Draw(img) - d.text((4, 0), text, fill=(255, 255, 255), font=font) + - img.save('scroll_text.ppm') - return self.scrollImage('scroll_text.ppm', offset_x = 128, offset_y = 0) + + def displayNews(self): font = ImageFont.load("./fonts/8x13.pil") @@ -230,12 +256,16 @@ class StockTicker(): f.close() for headline in headlines: - killed = self.displayText(headline, font) + img = self.textImage(headline, font) - if killed: - kill = True - if kill: break - if kill: break + #killed = self.scrollImage(img, offset_x = 128, offset_y = 0) + killed = self.scrollImageStacked(img, offset_x = 128, offset_y = 0) + + + + + if killed: break + if killed: break @@ -527,7 +557,7 @@ class StockTicker(): elif msg == 'T':# text - self.displayTextRepeating() + self.displayUserText() elif msg == 'I': # image @@ -547,8 +577,10 @@ if __name__ == '__main__': #print(sys.stdin.readlines()) stock_ticker = StockTicker() + #stock_ticker.displayTextRepeating() #stock_ticker.process_msg('f') - #stock_ticker.displayNews() + + stock_ticker.displayNews() #stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/open.gif') #stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/close.gif')