multiple images and gifs

This commit is contained in:
Neythen 2021-07-27 18:33:02 +01:00
parent 23c4e2cd06
commit 3c0907baf6
11 changed files with 165 additions and 57 deletions

View File

@ -1,4 +1,4 @@
symbol,name,base,current,24hr change
BTC,bitcoin,usd,40270,16.560179943187396
ETH,ethereum,gbp,1750.78,11.871734531689802
DOGE,dogecoin,usd,0.22635,14.743047682205162
BTC,bitcoin,usd,37791,-3.5064161412834833
ETH,ethereum,gbp,1608.87,-5.529203500553435
DOGE,dogecoin,usd,0.199271,-10.734868356523817

1 symbol name base current 24hr change
2 BTC bitcoin usd 40270 37791 16.560179943187396 -3.5064161412834833
3 ETH ethereum gbp 1750.78 1608.87 11.871734531689802 -5.529203500553435
4 DOGE dogecoin usd 0.22635 0.199271 14.743047682205162 -10.734868356523817

View File

@ -1 +1 @@
["USD", {"AUD": [1.3553, 1.3667], "CAD": [1.2551, 1.2684], "CHF": [0.91966, 0.92151], "EUR": [0.84926, 0.84947], "GBP": [0.72665, 0.73363], "JPY": [110.26, 110.12], "NZD": [1.4358, 1.4444]}]
["USD", {"AUD": [1.3572, 1.3583], "CAD": [1.2565, 1.256], "CHF": [0.91499, 0.91847], "EUR": [0.84674, 0.84839], "GBP": [0.72399, 0.7251], "JPY": [110.06, 110.33], "NZD": [1.4357, 1.4328]}]

View File

@ -1 +1 @@
[{"main_weather": "Clouds", "description": "overcast clouds", "temp": 29.61, "min_temp": 29.36, "max_temp": 32.34, "feels_like": 36.61, "humidity": 90, "clouds": 100, "wind_speed": 0.45, "wind_direction": 200, "visibility": 10000, "uv": 0, "rain_chance": 0.73}, {"main_weather": "Clouds", "description": "broken clouds", "temp": 21.11, "min_temp": 14.98, "max_temp": 24.47, "feels_like": 21.23, "humidity": 75, "clouds": 80, "wind_speed": 4.12, "wind_direction": 210, "visibility": 10000, "uv": 0, "rain_chance": 0.12}]
[{"main_weather": "Clouds", "description": "broken clouds", "temp": 29.92, "min_temp": 29.34, "max_temp": 30.71, "feels_like": 36.92, "humidity": 88, "clouds": 78, "wind_speed": 0.45, "wind_direction": 299, "visibility": 10000, "uv": 0, "rain_chance": 0.72}, {"main_weather": "Clouds", "description": "few clouds", "temp": 20.29, "min_temp": 16.54, "max_temp": 20.41, "feels_like": 20.33, "humidity": 75, "clouds": 20, "wind_speed": 0.45, "wind_direction": 278, "visibility": 10000, "uv": 0.23, "rain_chance": 0.84}]

View File

@ -1 +1 @@
[[{"main_weather": "Rain", "description": "light rain", "min_temp": 29.36, "max_temp": 32.34}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 29.45, "max_temp": 31.59}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 29.04, "max_temp": 30.82}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.75, "max_temp": 29.42}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.77, "max_temp": 28.47}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.04, "max_temp": 28.25}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.27, "max_temp": 30.37}, {"main_weather": "Rain", "description": "light rain", "min_temp": 29.15, "max_temp": 31.87}], [{"main_weather": "Rain", "description": "light rain", "min_temp": 14.98, "max_temp": 24.47}, {"main_weather": "Rain", "description": "light rain", "min_temp": 15.59, "max_temp": 20.24}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.65, "max_temp": 20.3}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 12.01, "max_temp": 20.01}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 13.09, "max_temp": 20.15}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.43, "max_temp": 21.97}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 12.99, "max_temp": 22.6}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.44, "max_temp": 21.85}]]
[[{"main_weather": "Rain", "description": "light rain", "min_temp": 29.34, "max_temp": 30.71}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.88, "max_temp": 30.28}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 28.76, "max_temp": 30.43}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.46, "max_temp": 29.34}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 26.98, "max_temp": 28.05}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27.66, "max_temp": 30.29}, {"main_weather": "Rain", "description": "light rain", "min_temp": 29.07, "max_temp": 31.98}, {"main_weather": "Rain", "description": "light rain", "min_temp": 29.71, "max_temp": 31.97}], [{"main_weather": "Rain", "description": "light rain", "min_temp": 16.54, "max_temp": 20.41}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.1, "max_temp": 20.41}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 12.28, "max_temp": 20.13}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.47, "max_temp": 15}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.98, "max_temp": 19.48}, {"main_weather": "Rain", "description": "light rain", "min_temp": 12.63, "max_temp": 21.45}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 13.76, "max_temp": 21.62}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 15.08, "max_temp": 23.41}]]

View File

@ -1 +1 @@
{"stocks": "26/07/2021 15:54:43", "crypto": "26/07/2021 15:54:43", "news": "26/07/2021 15:54:43", "weather": "26/07/2021 15:54:43", "forex": "26/07/2021 21:54:43", "sports": "26/07/2021 15:54:43"}
{"stocks": "27/07/2021 13:30:45", "crypto": "27/07/2021 13:30:48", "news": "27/07/2021 13:30:50", "weather": "27/07/2021 13:30:49", "forex": "27/07/2021 19:30:53", "sports": "27/07/2021 13:30:50"}

4
csv/multiple.csv Normal file
View File

@ -0,0 +1,4 @@
type,content,pause(secs)
text,hello world!,0
image,/home/pi/Desktop/stock_ticker/logos/crypto/BTC.png,5
gif,/home/pi/Desktop/stock_ticker/gifs/close.gif,15
1 type content pause(secs)
2 text hello world! 0
3 image /home/pi/Desktop/stock_ticker/logos/crypto/BTC.png 5
4 gif /home/pi/Desktop/stock_ticker/gifs/close.gif 15

View File

@ -1,21 +1,21 @@
headline,source,date,time
Green Bay Packers GM Brian Gutekunst 'remains hopeful' for positive resolution with QB Aaron Rodgers - ESPN,ESPN,2021-07-26,18:32:46Z
Is 25C too hot? How we decide what qualifies as a heatwave - Stuff.co.nz,Stuff.co.nz,2021-07-26,18:29:00Z
COVID-19: More testing sites and self-isolation exemption list in England expanded in bid to ease 'pingdemic' - Sky News,Sky.com,2021-07-26,18:28:11Z
12 times iPhones beat Androids - The Nation Newspaper ,The Nation Newspaper ,2021-07-26,18:20:37Z
Large meteor lights up skies in Norway - CTV News,Ctvnews.ca,2021-07-26,18:14:16Z
Summer Olympics 2021: What to Watch for on Day 4 in Tokyo - Bleacher Report,Bleacher Report,2021-07-26,18:11:43Z
COVID-19 live updates: Savannah reinstates masks indoors^ Orlando in 'crisis mode' - ABC News,ABC News,2021-07-26,18:06:00Z
Tunisias Democracy Verges on Dissolution as President Moves to Take Control - The New York Times,New York Times,2021-07-26,18:04:29Z
Tokyo Olympics DAY 4 India Results: Bad day at office - InsideSport,InsideSport,2021-07-26,18:03:34Z
Kanye Wests New Album Donda Will Be Released August 6^ A Rep Confirms - Pitchfork,Pitchfork,2021-07-26,17:57:12Z
Psaki: Biden doesn't want to 'fight' Fox after Trump 'destroyed trust in media' - Business Insider,Business Insider,2021-07-26,17:56:13Z
Scientists including India astronomers spot unique Gamma-ray burst using NASAs space telescope - Times of India,The Times of India,2021-07-26,17:53:00Z
Manchester United in final negotiations to sign Raphaël Varane for around £40m - The Guardian,The Guardian,2021-07-26,17:49:00Z
#UnrestSA: West Rand politician Bruce Nimmerhoudt charged with terrorism - News24,News24,2021-07-26,17:47:52Z
SA women plan class action lawsuit over implant used to treat incontinence - News24,News24,2021-07-26,17:47:46Z
Coronavirus: 11 new COVID-19 cases in Manitoba^ Winnipeg's test positivity rate below two per cent - CTV News Winnipeg,Ctvnews.ca,2021-07-26,17:46:29Z
Tokyo 2020: Mona McSharrys achievement a paradigm shift for Irish swimming - The Irish Times,The Irish Times,2021-07-26,17:44:27Z
Mount Sinai researchers use cerebral organoids to study frontotemporal dementia - News-Medical.Net,News-Medical.Net,2021-07-26,17:44:00Z
Texas^ Oklahoma Indicate They'll Leave the Big 12 for the SEC - The New York Times,New York Times,2021-07-26,17:40:26Z
How Baba Ijesha defiled my foster daughter while watching cartoons — Princess - The Nation Newspaper ,The Nation Newspaper ,2021-07-26,17:38:26Z
Tokyo 2020 Olympics: Osaka story ended by Vondrousova^ and Bencic ousts Krejcikova - The Sport Review,The Sport Review,2021-07-27,16:34:00Z
1st alarm raised as Marikina River water level breaches 15 meters - ABS-CBN News,Abs-cbn.com,2021-07-27,16:23:00Z
Aaron Rodgers back to work as icy Packers relationship appears to thaw - Fox News,Fox News,2021-07-27,16:09:19Z
Lake Tahoe plane crash: Twin-engine jet accident kills all passengers^ FAA says - Fox News,Fox News,2021-07-27,16:08:40Z
Alex Telles: Manchester United left-back out until September with injury^ says Ole Gunnar Solskjaer - Sky Sports,Sky Sports,2021-07-27,16:07:30Z
Disney's Jungle Cruise Review - IGN,IGN,2021-07-27,16:00:34Z
BOP deficit widens to $312 million in June - Philstar.com,Philippine Star,2021-07-27,16:00:00Z
Vista Land optimistic on growth prospects - Philstar.com,Philippine Star,2021-07-27,16:00:00Z
Phoenix Petroleum settles P3 billion commercial papers - Philstar.com,Philippine Star,2021-07-27,16:00:00Z
Facebook assembles expert team to build 'metaverse' - Taipei Times,Taipei Times,2021-07-27,16:00:00Z
Emily Blunt and the Rock Drip With Charismatic Chemistry in Disney's Jungle Cruise - Gizmodo,Gizmodo.com,2021-07-27,16:00:00Z
Exclusive: Rakesh Asthana appointed Delhi Police Commissioner - Hindustan Times,Hindustan Times,2021-07-27,15:54:36Z
Simone Biles says mental health issues behind Tokyo Olympics withdrawal as she admits: 'I just didn't want to go on' - Sky News,Sky.com,2021-07-27,15:52:08Z
Mamata Banerjee meets PM Modi^ calls for all-party meeting to discuss Pegasus issue - The Indian Express,The Indian Express,2021-07-27,15:51:49Z
Trump could be forced to testify over Capitol riot^ says Liz Cheney: This is not a game - The Independent,Independent,2021-07-27,15:51:28Z
A First Look At The Fitbit Charge 5? - Forbes,Forbes,2021-07-27,15:47:38Z
Facebook upgrades Oculus Quest 2 storage and recalls foam face masks - The Verge,The Verge,2021-07-27,15:41:36Z
Boris Johnson says stop and search policy kind and loving way to get weapons off streets - The Independent,Independent,2021-07-27,15:41:05Z
Sinema meets with Biden as bipartisan talks teeter - POLITICO,Politico,2021-07-27,15:41:02Z
Nova Scotia man identified as Ottawa homicide victim - CBC.ca,CBC News,2021-07-27,15:40:40Z

1 headline source date time
2 Green Bay Packers GM Brian Gutekunst 'remains hopeful' for positive resolution with QB Aaron Rodgers - ESPN Tokyo 2020 Olympics: Osaka story ended by Vondrousova^ and Bencic ousts Krejcikova - The Sport Review ESPN The Sport Review 2021-07-26 2021-07-27 18:32:46Z 16:34:00Z
3 Is 25C too hot? How we decide what qualifies as a heatwave - Stuff.co.nz 1st alarm raised as Marikina River water level breaches 15 meters - ABS-CBN News Stuff.co.nz Abs-cbn.com 2021-07-26 2021-07-27 18:29:00Z 16:23:00Z
4 COVID-19: More testing sites and self-isolation exemption list in England expanded in bid to ease 'pingdemic' - Sky News Aaron Rodgers back to work as icy Packers relationship appears to thaw - Fox News Sky.com Fox News 2021-07-26 2021-07-27 18:28:11Z 16:09:19Z
5 12 times iPhones beat Androids - The Nation Newspaper Lake Tahoe plane crash: Twin-engine jet accident kills all passengers^ FAA says - Fox News The Nation Newspaper Fox News 2021-07-26 2021-07-27 18:20:37Z 16:08:40Z
6 Large meteor lights up skies in Norway - CTV News Alex Telles: Manchester United left-back out until September with injury^ says Ole Gunnar Solskjaer - Sky Sports Ctvnews.ca Sky Sports 2021-07-26 2021-07-27 18:14:16Z 16:07:30Z
7 Summer Olympics 2021: What to Watch for on Day 4 in Tokyo - Bleacher Report Disney's Jungle Cruise Review - IGN Bleacher Report IGN 2021-07-26 2021-07-27 18:11:43Z 16:00:34Z
8 COVID-19 live updates: Savannah reinstates masks indoors^ Orlando in 'crisis mode' - ABC News BOP deficit widens to $312 million in June - Philstar.com ABC News Philippine Star 2021-07-26 2021-07-27 18:06:00Z 16:00:00Z
9 Tunisia’s Democracy Verges on Dissolution as President Moves to Take Control - The New York Times Vista Land optimistic on growth prospects - Philstar.com New York Times Philippine Star 2021-07-26 2021-07-27 18:04:29Z 16:00:00Z
10 Tokyo Olympics DAY 4 India Results: Bad day at office - InsideSport Phoenix Petroleum settles P3 billion commercial papers - Philstar.com InsideSport Philippine Star 2021-07-26 2021-07-27 18:03:34Z 16:00:00Z
11 Kanye West’s New Album Donda Will Be Released August 6^ A Rep Confirms - Pitchfork Facebook assembles expert team to build 'metaverse' - Taipei Times Pitchfork Taipei Times 2021-07-26 2021-07-27 17:57:12Z 16:00:00Z
12 Psaki: Biden doesn't want to 'fight' Fox after Trump 'destroyed trust in media' - Business Insider Emily Blunt and the Rock Drip With Charismatic Chemistry in Disney's Jungle Cruise - Gizmodo Business Insider Gizmodo.com 2021-07-26 2021-07-27 17:56:13Z 16:00:00Z
13 Scientists including India astronomers spot unique Gamma-ray burst using NASA’s space telescope - Times of India Exclusive: Rakesh Asthana appointed Delhi Police Commissioner - Hindustan Times The Times of India Hindustan Times 2021-07-26 2021-07-27 17:53:00Z 15:54:36Z
14 Manchester United in final negotiations to sign Raphaël Varane for around £40m - The Guardian Simone Biles says mental health issues behind Tokyo Olympics withdrawal as she admits: 'I just didn't want to go on' - Sky News The Guardian Sky.com 2021-07-26 2021-07-27 17:49:00Z 15:52:08Z
15 #UnrestSA: West Rand politician Bruce Nimmerhoudt charged with terrorism - News24 Mamata Banerjee meets PM Modi^ calls for all-party meeting to discuss Pegasus issue - The Indian Express News24 The Indian Express 2021-07-26 2021-07-27 17:47:52Z 15:51:49Z
16 SA women plan class action lawsuit over implant used to treat incontinence - News24 Trump could be forced to testify over Capitol riot^ says Liz Cheney: ‘This is not a game’ - The Independent News24 Independent 2021-07-26 2021-07-27 17:47:46Z 15:51:28Z
17 Coronavirus: 11 new COVID-19 cases in Manitoba^ Winnipeg's test positivity rate below two per cent - CTV News Winnipeg A First Look At The Fitbit Charge 5? - Forbes Ctvnews.ca Forbes 2021-07-26 2021-07-27 17:46:29Z 15:47:38Z
18 Tokyo 2020: Mona McSharry’s achievement a paradigm shift for Irish swimming - The Irish Times Facebook upgrades Oculus Quest 2 storage and recalls foam face masks - The Verge The Irish Times The Verge 2021-07-26 2021-07-27 17:44:27Z 15:41:36Z
19 Mount Sinai researchers use cerebral organoids to study frontotemporal dementia - News-Medical.Net Boris Johnson says stop and search policy ‘kind and loving’ way to get weapons off streets - The Independent News-Medical.Net Independent 2021-07-26 2021-07-27 17:44:00Z 15:41:05Z
20 Texas^ Oklahoma Indicate They'll Leave the Big 12 for the SEC - The New York Times Sinema meets with Biden as bipartisan talks teeter - POLITICO New York Times Politico 2021-07-26 2021-07-27 17:40:26Z 15:41:02Z
21 How ‘Baba Ijesha’ defiled my foster daughter while watching cartoons — Princess - The Nation Newspaper Nova Scotia man identified as Ottawa homicide victim - CBC.ca The Nation Newspaper CBC News 2021-07-26 2021-07-27 17:38:26Z 15:40:40Z

View File

@ -1,4 +1,4 @@
name,current,opening
MSFT,289.33,289
NFLX,517.2,514.85
GOOG,2783.82,2764.03
MSFT,283.47,289.34
NFLX,515.31,518.95
GOOG,2706.565,2801.15

1 name current opening
2 MSFT 289.33 283.47 289 289.34
3 NFLX 517.2 515.31 514.85 518.95
4 GOOG 2783.82 2706.565 2764.03 2801.15

View File

@ -323,6 +323,11 @@ def matrix():
ticker.sendline('K')
ticker.sendline('A')
elif "Multiple" in request.form:
ticker.sendline('K')
ticker.sendline('+')
elif "Stop Display" in request.form:

View File

@ -108,10 +108,10 @@ class StockTicker():
(r, g, b) = pixels[x, y]
self.matrix.SetPixel(x + offset_x, y + offset_y, r*self.brightness, g*self.brightness, b*self.brightness)
def scrollImage(self, image, double_buffer, offset_x = 0, offset_y = 0, frame_skip = 10, gif = False):
def scrollImage(self, image, offset_x = 0, offset_y = 0, frame_skip = 10, gif = False, pause_frames = 0):
img_width, img_height = image.size
kill = False
while offset_x > -img_width:
while offset_x > -(img_width+1):
# for animation in gifs
if offset_x%frame_skip == 0:
@ -122,27 +122,52 @@ class StockTicker():
#self.setImage(image.convert('RGB'), offset_x = offset_x, offset_y = offset_y)
if gif:
double_buffer.SetImage(image, offset_x, offset_y)
else:
double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y)
self.double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y)
else:
self.double_buffer.SetImage(image, offset_x, offset_y)
buff = 0
# remove the ppixels behind the image, to stop trailing
double_buffer = self.matrix.SwapOnVSync(double_buffer)
self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer)
for y in range(self.matrix.height):
self.matrix.SetPixel(offset_x + img_width , y , 0,0,0)
self.matrix.SetPixel(offset_x + img_width +1 , y , 0,0,0)
self.matrix.SetPixel(offset_x + img_width +2 , y , 0,0,0)
self.matrix.SetPixel(offset_x + img_width , y , 0,0,0)
time.sleep(self.delay)
kill = self.checkKilled()
if offset_x == 0:
while pause_frames > 0:
if pause_frames%frame_skip == 0:
self.incrementGIF(image)
pause_frames -=1
if gif:
self.double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y)
else:
self.double_buffer.SetImage(image, offset_x, offset_y)
for y in range(self.matrix.height):
self.matrix.SetPixel(offset_x + img_width +1 , y , 0,0,0)
self.matrix.SetPixel(offset_x + img_width , y , 0,0,0)
self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer)
time.sleep(self.delay)
kill = self.checkKilled()
if kill: break
if kill: break
if kill: break
return kill
def scrollImageY(self, image, double_buffer, direction = 1, offset_x = 0, offset_y = 0, frame_skip = 10, gif = False):
def scrollImageY(self, image, direction = 1, offset_x = 0, offset_y = 0, frame_skip = 10, gif = False):
kill = False
while offset_y != 0:
@ -154,11 +179,12 @@ class StockTicker():
offset_y += direction
if gif:
double_buffer.SetImage(image, offset_x, offset_y)
else:
double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y)
self.double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y)
double_buffer = self.matrix.SwapOnVSync(double_buffer)
else:
self.double_buffer.SetImage(image, offset_x, offset_y)
self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer)
time.sleep(self.delay)
kill = self.checkKilled()
@ -213,7 +239,7 @@ class StockTicker():
pass
return kill
def scrollFunctionsAnimated(self, options, animation = 'continuous'):
def scrollFunctionsAnimated(self, options, animation = 'down'):
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
@ -222,6 +248,7 @@ class StockTicker():
kill = False
i = 0 # keep track of which image we are displaying
self.double_buffer = self.matrix.CreateFrameCanvas()
while True:
update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],))
@ -234,10 +261,7 @@ class StockTicker():
else:
image = self.openImage('./display_images/user_gif.gif')
img_width, img_height = image.size
double_buffer = self.matrix.CreateFrameCanvas()
offset_x = 0
if animation == 'traditional':
@ -247,11 +271,10 @@ class StockTicker():
elif animation in ['up', 'down']:
offset_x = max(0, 128-img_width)
offset_y = 0
#first scroll image in from bottom
frame_skip = 10 #controls how fast gifs run
frame_skip = int((1/15)/self.delay) #controls how fast gifs run
self.frame = 0
pause_frames = int(0.5/self.delay)
@ -262,7 +285,7 @@ class StockTicker():
direction = 1
offset_y = -33
self.scrollImageY(image, double_buffer, direction = direction, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] != 'display_gif')
self.scrollImageY(image, direction = direction, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'display_gif')
offset_y = 0
@ -273,11 +296,11 @@ class StockTicker():
pause_frames -=1
if options[i % len(options)] != 'display_gif':
double_buffer.SetImage(image, offset_x, offset_y)
self.double_buffer.SetImage(image, offset_x, offset_y)
else:
double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y)
self.double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y)
double_buffer = self.matrix.SwapOnVSync(double_buffer)
self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer)
time.sleep(self.delay)
kill = self.checkKilled()
@ -289,14 +312,86 @@ class StockTicker():
if kill: break
kill = self.scrollImage(image, double_buffer, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] != 'display_gif')
kill = self.scrollImage(image, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'display_gif')
if kill: break
update_process.join()
i+=1
def scrollMultiple(self, animation = 'down'):
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
# read lines from csv
images = []
delays = []
kinds = []
f = open('csv/multiple.csv', 'r')
CSV = csv.reader(f)
next(CSV)
font = ImageFont.load("./fonts/texgyre-27.pil")
for row in CSV:
kind, content, delay = row
delays.append(delay)
kinds.append(kind)
print(kind, content, delay)
if kind == 'text':
images.append(self.textImage(content, font, 255, 255, 0, True, w_buff = 50))
elif kind == 'image':
images.append(self.openImage(content).convert('RGB'))
elif kind == 'gif':
images.append(self.openImage(content))
f.close()
kill = False
i = 0 # keep track of which image we are displaying
self.double_buffer = self.matrix.CreateFrameCanvas()
while True:
image = images[i%len(images)]
delay = delays[i%len(images)]
kind = kinds[i%len(images)]
img_width, img_height = image.size
offset_x = 0
if animation == 'traditional':
offset_x = 128
elif animation == 'continuous':
offset_x = 0
elif animation in ['up', 'down']:
offset_x = max(0, 128-img_width)
offset_y = 0
#first scroll image in from bottom
frame_skip = int((1/15)/self.delay) #controls how fast gifs run
self.frame = 0
pause_frames = int(float(delay)/self.delay)
if animation == 'up':
offset_y = 33
direction = -1
elif animation == 'down':
direction = 1
offset_y = -33
self.scrollImageY(image, direction = direction, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = kind=='gif')
offset_y = 0
kill = self.scrollImage(image, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = kind=='gif', pause_frames = pause_frames)
if kill: break
i+=1
def textImage(self, text, font, r = 255, g = 255, b = 255, matrix_height = False, w_buff = 3, h_buff = 3):
'''
creates and returns a ppm image containing the text in the supplied font and colour
@ -1846,6 +1941,9 @@ class StockTicker():
userSettings = ['stocks_prof', 'crypto_prof', 'forex_prof', 'today_weather_prof']
self.scrollFunctionsAnimatedProf(userSettings)
elif msg == '+':
stock_ticker.scrollMultiple()
elif msg == 'K': # kill
self.resetMatrix()
@ -1855,7 +1953,7 @@ if __name__ == '__main__':
with open('log.txt', "w") as log:
try:
stock_ticker = StockTicker()
#
#stock_ticker.process_msg('b')

View File

@ -22,6 +22,7 @@
<input type="submit" name="Premier league table" value="Premier league table" style="height:50px" >
<input type="submit" name="Professional" value="Professional" style="height:50px" >
<input type="submit" name="All" value="All" style="height:50px" >
<input type="submit" name="Multiple" value="Multiple" style="height:50px" >
<input type="submit" name="Stop Display" value="Stop Display"style="height:50px">
<input type="submit" name="Shutdown the pi" value="Shutdown the pi"style="height:50px">
</form>