news lag fixes and professional demo added to server

This commit is contained in:
Neythen 2021-07-14 18:02:54 +01:00
parent bf61c43a65
commit c490a5390c
28 changed files with 196 additions and 262 deletions

View File

@ -1,4 +1,4 @@
symbol,name,base,current,24hr change symbol,name,base,current,24hr change
BTC,bitcoin,usd,32537,-2.3240271926474465 BTC,bitcoin,usd,32927,0.1348056422318777
ETH,ethereum,gbp,1416.58,-4.239934826025793 ETH,ethereum,gbp,1447.6,0.44060897841839514
DOGE,dogecoin,usd,0.198075,-3.4900700142218035 DOGE,dogecoin,usd,0.202152,0.7090173677844843

1 symbol name base current 24hr change
2 BTC bitcoin usd 32537 32927 -2.3240271926474465 0.1348056422318777
3 ETH ethereum gbp 1416.58 1447.6 -4.239934826025793 0.44060897841839514
4 DOGE dogecoin usd 0.198075 0.202152 -3.4900700142218035 0.7090173677844843

View File

@ -1 +1 @@
["USD", {"AUD": [1.3374, 1.3405], "CAD": [1.2481, 1.2498], "CHF": [0.91667, 0.91563], "EUR": [0.84431, 0.84374], "GBP": [0.72204, 0.72199], "JPY": [110.22, 110.15], "NZD": [1.4337, 1.436]}] ["USD", {"AUD": [1.3391, 1.3374], "CAD": [1.2472, 1.2481], "CHF": [0.91771, 0.91667], "EUR": [0.8466, 0.84431], "GBP": [0.72094, 0.72204], "JPY": [110.31, 110.22], "NZD": [1.4239, 1.4337]}]

View File

@ -1 +1 @@
[{"main_weather": "Clouds", "description": "overcast clouds", "temp": 29.14, "min_temp": 29.07, "max_temp": 30.95, "feels_like": 35.13, "humidity": 80, "clouds": 89, "wind_speed": 0.89, "wind_direction": 135, "visibility": 10000, "uv": 0, "rain_chance": 0}, {"main_weather": "Clouds", "description": "scattered clouds", "temp": 20.47, "min_temp": 14.03, "max_temp": 22.37, "feels_like": 20.48, "humidity": 73, "clouds": 40, "wind_speed": 4.12, "wind_direction": 350, "visibility": 10000, "uv": 0.18, "rain_chance": 0.62}] [{"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}]

View File

@ -1 +1 @@
[[{"main_weather": "Clouds", "description": "few clouds", "min_temp": 29.07, "max_temp": 30.95}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.62, "max_temp": 30.79}, {"main_weather": "Rain", "description": "light rain", "min_temp": 29.02, "max_temp": 30.91}, {"main_weather": "Rain", "description": "light rain", "min_temp": 29.06, "max_temp": 30.42}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 27, "max_temp": 28.33}, {"main_weather": "Rain", "description": "light rain", "min_temp": 27.13, "max_temp": 29.29}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.39, "max_temp": 29.93}, {"main_weather": "Rain", "description": "light rain", "min_temp": 28.89, "max_temp": 31.24}], [{"main_weather": "Rain", "description": "light rain", "min_temp": 14.03, "max_temp": 22.37}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 14.6, "max_temp": 22.64}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 14.84, "max_temp": 22.03}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 12.38, "max_temp": 24.02}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 14.95, "max_temp": 26.2}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 15.51, "max_temp": 27.33}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 16.25, "max_temp": 25.9}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 14.61, "max_temp": 23.59}]] [[{"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}]]

View File

@ -1,21 +1,21 @@
headline,source,date,time headline,source,date,time
BREAKING: Senate okays 20-year jail for candidates snatching ballot materials - The Punch,The Punch,2021-07-13,16:35:23Z Amazon rainforest now emitting more CO2 than it absorbs - The Guardian,The Guardian,2021-07-14,16:40:00Z
The rat's whiskers: Multidisciplinary research reveals how we sense texture: Mathematicians and neuroscientists achieve breakthrough in understanding how whiskers 'amplify' texture - Science Daily,Science Daily,2021-07-13,16:30:30Z MI5 investigated rightwing terror suspect who was 13 years old - The Guardian,The Guardian,2021-07-14,16:26:00Z
2 officers injured and homicide suspect dead in shooting near Baltimore mall^ police say - CNN ,CNN,2021-07-13,16:25: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
Elon Musk Returns to Court to Defend Teslas SolarCity Purchase - The Wall Street Journal,The Wall Street Journal,2021-07-13,16:25:00Z Award-winning Classic Adventure Games Syberia I & II Are FREE For Keeps On GOG - Geek Culture,Geek Culture,2021-07-14,16:18:59Z
INEC: Fayose^ others commend Senate on Onochies rejection - Punch Newspapers,The Punch,2021-07-13,16:22:09Z Solar radio signals could be used to monitor melting ice sheets - Phys.org,Phys.Org,2021-07-14,16:11:48Z
Emmy Nominations: The Crown^ The Mandalorian Top List; HBO/HBO Max Edges Netflix For Top Spot Full List Of Nominees - Deadline,Deadline,2021-07-13,16:22:00Z Baltimore officer charged with murder after stepson is found hidden in crawlspace - NBC News,NBC News,2021-07-14,16:03:41Z
Foreign aid: Boris Johnson sees off Tory rebellion over cut to overseas aid budget - Sky News,Sky.com,2021-07-13,16:18:45Z Today at Apple tutorial videos being added to YouTube - htxt.africa,Htxt.co.za,2021-07-14,16:00:49Z
Emmys 2021: The Crown and The Mandalorian lead Emmy nominations - BBC News,BBC News,2021-07-13,16:08:37Z CRISPR stops coronavirus replication in human cells - Livescience.com,Live Science,2021-07-14,15:54:39Z
Windows 11 is full of delightful detail - The Verge,The Verge,2021-07-13,16:06:34Z 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
The best pre-workout foods - Diet - IOL,IOL,2021-07-13,16:00:54Z Catt Sadler gets COVID despite being fully vaccinated: 'Delta is relentless' - Page Six,Page Six,2021-07-14,15:51:00Z
The hunt for wormholes: How scientists look for space-time tunnels - Space.com,Space.com,2021-07-13,16:00:50Z 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
Is a third dose of Covid-19 vaccines really needed to boost the immune response? - Scroll.in,Scroll.in,2021-07-13,16:00:00Z 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
OFW remittances post 2-digit growth in May - Philstar.com,Philippine Star,2021-07-13,16:00:00Z EU unveils ambitious climate package as it cools on fossil fuels - CNN ,CNN,2021-07-14,15:45:00Z
COVID Cases In Parts Of Missouri And Arkansas Surge To Levels Not Seen Since Winter - NPR,NPR,2021-07-13,15:58:50Z COVID-19: UNILAG shuts hostels indefinitely^ reverts to virtual classes - Guardian,Guardian Nigeria,2021-07-14,15:43:00Z
Rapper shot as many as 64 times as he walked out of Chicago jail - NBC News,NBC News,2021-07-13,15:51:12Z 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
Gene editing 'blocks virus transmission' in human cells - Guardian,Guardian Nigeria,2021-07-13,15:47:19Z Bolsonaro in hospital as hiccups persist for more than 10 days - The Guardian,The Guardian,2021-07-14,15:39:00Z
How Canada's athletes are training for what could be the hottest Olympics - CBC.ca,CBC News,2021-07-13,15:45:17Z EIA Inventory Report Sends Oil Prices Higher - OilPrice.com,OilPrice.com,2021-07-14,15:33:00Z
Biafra: Nnamdi Kanu in need of quick^ advanced medical attention Lawyer - Daily Post Nigeria,Daily Post Nigeria,2021-07-13,15:45: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
COVID-19: UK reports 36^660 new coronavirus cases and 50 more deaths - Sky News,Sky.com,2021-07-13,15:45:00Z 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
Euro 2020: Uefa opens disciplinary proceedings against England after Italy final - The Independent,Independent,2021-07-13,15:43:15Z Investment in space companies hit record $4.5 billion in the second quarter^ report says - CNBC,CNBC,2021-07-14,15:27:33Z

1 headline source date time
2 BREAKING: Senate okays 20-year jail for candidates snatching ballot materials - The Punch Amazon rainforest now emitting more CO2 than it absorbs - The Guardian The Punch The Guardian 2021-07-13 2021-07-14 16:35:23Z 16:40:00Z
3 The rat's whiskers: Multidisciplinary research reveals how we sense texture: Mathematicians and neuroscientists achieve breakthrough in understanding how whiskers 'amplify' texture - Science Daily MI5 investigated rightwing terror suspect who was 13 years old - The Guardian Science Daily The Guardian 2021-07-13 2021-07-14 16:30:30Z 16:26:00Z
4 2 officers injured and homicide suspect dead in shooting near Baltimore mall^ police say - CNN Ottawa Public Health adds zero new COVID-19 cases for second day this week - CTV Edmonton CNN Ctvnews.ca 2021-07-13 2021-07-14 16:25:00Z 16:25:24Z
5 Elon Musk Returns to Court to Defend Tesla’s SolarCity Purchase - The Wall Street Journal Award-winning Classic Adventure Games Syberia I & II Are FREE For Keeps On GOG - Geek Culture The Wall Street Journal Geek Culture 2021-07-13 2021-07-14 16:25:00Z 16:18:59Z
6 INEC: Fayose^ others commend Senate on Onochie’s rejection - Punch Newspapers Solar radio signals could be used to monitor melting ice sheets - Phys.org The Punch Phys.Org 2021-07-13 2021-07-14 16:22:09Z 16:11:48Z
7 Emmy Nominations: ‘The Crown’^ ‘The Mandalorian’ Top List; HBO/HBO Max Edges Netflix For Top Spot – Full List Of Nominees - Deadline Baltimore officer charged with murder after stepson is found hidden in crawlspace - NBC News Deadline NBC News 2021-07-13 2021-07-14 16:22:00Z 16:03:41Z
8 Foreign aid: Boris Johnson sees off Tory rebellion over cut to overseas aid budget - Sky News Today at Apple tutorial videos being added to YouTube - htxt.africa Sky.com Htxt.co.za 2021-07-13 2021-07-14 16:18:45Z 16:00:49Z
9 Emmys 2021: The Crown and The Mandalorian lead Emmy nominations - BBC News CRISPR stops coronavirus replication in human cells - Livescience.com BBC News Live Science 2021-07-13 2021-07-14 16:08:37Z 15:54:39Z
10 Windows 11 is full of delightful detail - The Verge Tour de France 2021 Stage 17^ as it happened: Tadej Pogacar tightens GC grip after Carapaz bluff - Eurosport UK The Verge Eurosport.co.uk 2021-07-13 2021-07-14 16:06:34Z 15:52:00Z
11 The best pre-workout foods - Diet - IOL Catt Sadler gets COVID despite being fully vaccinated: 'Delta is relentless' - Page Six IOL Page Six 2021-07-13 2021-07-14 16:00:54Z 15:51:00Z
12 The hunt for wormholes: How scientists look for space-time tunnels - Space.com COVID-19 in B.C.: Another update on cases^ deaths^ outbreaks coming from health ministry - CTV News Vancouver Space.com Ctvnews.ca 2021-07-13 2021-07-14 16:00:50Z 15:50:48Z
13 Is a third dose of Covid-19 vaccines really needed to boost the immune response? - Scroll.in UK records 42^000 Covid cases in worst day for six months - with 49 more deaths - The Mirror Scroll.in Mirror Online 2021-07-13 2021-07-14 16:00:00Z 15:46:49Z
14 OFW remittances post 2-digit growth in May - Philstar.com EU unveils ambitious climate package as it cools on fossil fuels - CNN Philippine Star CNN 2021-07-13 2021-07-14 16:00:00Z 15:45:00Z
15 COVID Cases In Parts Of Missouri And Arkansas Surge To Levels Not Seen Since Winter - NPR COVID-19: UNILAG shuts hostels indefinitely^ reverts to virtual classes - Guardian NPR Guardian Nigeria 2021-07-13 2021-07-14 15:58:50Z 15:43:00Z
16 Rapper shot as many as 64 times as he walked out of Chicago jail - NBC News Worten tem stock da Xbox Series X e oferece 3 meses de Xbox Game Pass - Eurogamer.pt NBC News Eurogamer.pt 2021-07-13 2021-07-14 15:51:12Z 15:41:00Z
17 Gene editing 'blocks virus transmission' in human cells - Guardian Bolsonaro in hospital as hiccups persist for more than 10 days - The Guardian Guardian Nigeria The Guardian 2021-07-13 2021-07-14 15:47:19Z 15:39:00Z
18 How Canada's athletes are training for what could be the hottest Olympics - CBC.ca EIA Inventory Report Sends Oil Prices Higher - OilPrice.com CBC News OilPrice.com 2021-07-13 2021-07-14 15:45:17Z 15:33:00Z
19 Biafra: Nnamdi Kanu in need of quick^ advanced medical attention – Lawyer - Daily Post Nigeria Dani Dyer's boyfriend Sammy Kimmence jailed for scamming pensioners out of almost £34^000 - Sky News Daily Post Nigeria Sky.com 2021-07-13 2021-07-14 15:45:00Z 15:31:18Z
20 COVID-19: UK reports 36^660 new coronavirus cases and 50 more deaths - Sky News Aussie comedian claims his ‘simple maths’ accurately calculates daily NSW Covid-19 cases - NEWS.com.au Sky.com News.com.au 2021-07-13 2021-07-14 15:45:00Z 15:29:31Z
21 Euro 2020: Uefa opens disciplinary proceedings against England after Italy final - The Independent Investment in space companies hit record $4.5 billion in the second quarter^ report says - CNBC Independent CNBC 2021-07-13 2021-07-14 15:43:15Z 15:27:33Z

View File

@ -1,2 +1,2 @@
speed,brightness speed,brightness
f,9 s,0
1 speed brightness
2 f s 9 0

View File

@ -1,4 +1,4 @@
name,current,opening name,current,opening
MSFT,280.75,277.5 MSFT,282.56,282.41
NFLX,540.99,535.53 NFLX,551.69,541.99
GOOG,2628.34,2617.28 GOOG,2646.92,2637.49

1 name current opening
2 MSFT 280.75 282.56 277.5 282.41
3 NFLX 540.99 551.69 535.53 541.99
4 GOOG 2628.34 2646.92 2617.28 2637.49

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

0
display_images/display_gif.ppm Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 747 B

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
display_images/user_gif.ppm Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

View File

@ -185,27 +185,6 @@ def SetWeather():
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 and allowed_file(fle.filename):
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("/DisplayGIF", methods=['POST']) @app.route("/DisplayGIF", methods=['POST'])
def DisplayGIF(): def DisplayGIF():
@ -312,6 +291,11 @@ def matrix():
ticker.sendline('K') ticker.sendline('K')
ticker.sendline('t') ticker.sendline('t')
elif "Professional" in request.form:
ticker.sendline('K')
ticker.sendline('b')
elif "All" in request.form: elif "All" in request.form:
ticker.sendline('K') ticker.sendline('K')

View File

@ -23,3 +23,4 @@ pip3 install pytz
pip3 install matplotlib pip3 install matplotlib
sudo apt-get remove bluez bluez-firmware pi-bluetooth triggerhappy pigpio sudo apt-get remove bluez bluez-firmware pi-bluetooth triggerhappy pigpio
sudo apt autoremove

View File

@ -75,9 +75,7 @@ class StockTicker():
dirs = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'] dirs = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']
return dirs[int((deg+22.5)//45)%8] return dirs[int((deg+22.5)//45)%8]
def setImage(self, image, offset_x = 0, offset_y = 0, unsafe=True, min_x = 0, max_x = 128, min_y = 0, max_y = 32): def setImage(self, image, offset_x = 0, offset_y = 0, unsafe=True, min_x = 0, max_x = 128, min_y = 0, max_y = 32):
@ -101,9 +99,7 @@ class StockTicker():
for y in range(max(0, -offset_y), min(img_height, self.matrix.height - offset_y)): for y in range(max(0, -offset_y), min(img_height, self.matrix.height - offset_y)):
for x in range(max(0, -offset_x), min(img_width, self.matrix.width - offset_x)): for x in range(max(0, -offset_x), min(img_width, self.matrix.width - offset_x)):
if min_x <= x + offset_x <= max_x and min_y <= y + offset_y <= max_y: if min_x <= x + offset_x <= max_x and min_y <= y + offset_y <= max_y:
(r, g, b) = pixels[x, y] (r, g, b) = pixels[x, y]
self.matrix.SetPixel(x + offset_x, y + offset_y, r*self.brightness, g*self.brightness, b*self.brightness) self.matrix.SetPixel(x + offset_x, y + offset_y, r*self.brightness, g*self.brightness, b*self.brightness)
@ -112,12 +108,13 @@ class StockTicker():
img_width, img_height = image.size img_width, img_height = image.size
double_buffer = self.matrix.CreateFrameCanvas()
image = image.convert('RGB')
while offset_x > -img_width: while offset_x > -img_width:
offset_x -= 1 offset_x -= 1
self.setImage(image, offset_x = offset_x, offset_y = offset_y) double_buffer.SetImage(image, offset_x, offset_y)
double_buffer = self.matrix.SwapOnVSync(double_buffer)
# remove the ppixels behind the image, to stop trailing # remove the ppixels behind the image, to stop trailing
for x in range(offset_x + img_width, 128): for x in range(offset_x + img_width, 128):
for y in range(self.matrix.height): for y in range(self.matrix.height):
@ -242,14 +239,15 @@ class StockTicker():
update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],)) update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],))
update_process.start() update_process.start()
image = self.openImage('./display_images/' + options[i % len(options)] +'.ppm') image = self.openImage('./display_images/' + options[i % len(options)] +'.ppm')
if options[i % len(options)] != 'display_gif':
image = image.convert('RGB')
if animation == 'continuous':
image2 = self.openImage('./display_images/' + options[(i + 1) % len(options)] +'.ppm')
img_width, img_height = image.size img_width, img_height = image.size
double_buffer = self.matrix.CreateFrameCanvas() double_buffer = self.matrix.CreateFrameCanvas()
offset_x = 0 offset_x = 0
if animation == 'traditional': if animation == 'traditional':
offset_x = 128 offset_x = 128
@ -287,8 +285,12 @@ class StockTicker():
offset_y -= 1 offset_y -= 1
double_buffer.SetImage(image.convert('RGB'), offset_x, 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)
double_buffer = self.matrix.SwapOnVSync(double_buffer) double_buffer = self.matrix.SwapOnVSync(double_buffer)
time.sleep(self.delay) time.sleep(self.delay)
@ -309,7 +311,10 @@ class StockTicker():
frame +=1 frame +=1
pause_frames -=1 pause_frames -=1
double_buffer.SetImage(image.convert('RGB'), offset_x) 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)
double_buffer = self.matrix.SwapOnVSync(double_buffer) double_buffer = self.matrix.SwapOnVSync(double_buffer)
@ -335,7 +340,10 @@ class StockTicker():
frame +=1 frame +=1
offset_y += 1 offset_y += 1
double_buffer.SetImage(image.convert('RGB'), offset_x, 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)
double_buffer = self.matrix.SwapOnVSync(double_buffer) double_buffer = self.matrix.SwapOnVSync(double_buffer)
@ -359,7 +367,10 @@ class StockTicker():
frame +=1 frame +=1
pause_frames -=1 pause_frames -=1
double_buffer.SetImage(image.convert('RGB'), offset_x) 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)
double_buffer = self.matrix.SwapOnVSync(double_buffer) double_buffer = self.matrix.SwapOnVSync(double_buffer)
@ -389,22 +400,23 @@ class StockTicker():
#self.setImage(image.convert('RGB'), offset_x = offset_x, offset_y = offset_y) #self.setImage(image.convert('RGB'), offset_x = offset_x, offset_y = offset_y)
double_buffer.SetImage(image.convert('RGB'), offset_x) 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)
buff = 0 buff = 0
if offset_x + img_width + buff< self.matrix.width and animation == 'continuous': # if the image is ending
double_buffer.SetImage(image.convert('RGB'), offset_x + img_width + buff)
double_buffer = self.matrix.SwapOnVSync(double_buffer)
else:
# remove the ppixels behind the image, to stop trailing # remove the ppixels behind the image, to stop trailing
double_buffer = self.matrix.SwapOnVSync(double_buffer) double_buffer = self.matrix.SwapOnVSync(double_buffer)
for y in range(self.matrix.height): 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 , y , 0,0,0)
self.matrix.SetPixel(offset_x + img_width +1 , 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 +2 , y , 0,0,0)
time.sleep(self.delay) time.sleep(self.delay)
kill = self.checkKilled() kill = self.checkKilled()
@ -580,8 +592,6 @@ class StockTicker():
d.text((4, 0), TICKER, fill=(255, 255, 255), font=font) d.text((4, 0), TICKER, fill=(255, 255, 255), font=font)
d.text((4, 8), CURRENT, fill=self.greenORred, font=font) d.text((4, 8), CURRENT, fill=self.greenORred, font=font)
img.paste(ARROW, ((text_width_current + 7),10)) img.paste(ARROW, ((text_width_current + 7),10))
d.text(((text_width_current+18), 8), CHANGE, fill=self.greenORred, font=font) d.text(((text_width_current+18), 8), CHANGE, fill=self.greenORred, font=font)
@ -603,14 +613,11 @@ class StockTicker():
new_im.paste(im, (x_offset,0)) new_im.paste(im, (x_offset,0))
x_offset += im.size[0] x_offset += im.size[0]
return new_im return new_im
def resetMatrix(self): def resetMatrix(self):
for x in range(self.matrix.width): for x in range(self.matrix.width):
for y in range(self.matrix.height): for y in range(self.matrix.height):
self.matrix.SetPixel(x , y , 0,0,0) self.matrix.SetPixel(x , y , 0,0,0)
@ -637,12 +644,10 @@ class StockTicker():
change = change/100 * current change = change/100 * current
current = '%.2f' % current current = '%.2f' % current
arrow, change = self.getArrow(change) arrow, change = self.getArrow(change)
change = '%.2f' % change change = '%.2f' % change
midFrame = self.textToImage(ticker + '(' + base + ')', current, change, arrow) #IMAGE THE TEXT midFrame = self.textToImage(ticker + '(' + base + ')', current, change, arrow) #IMAGE THE TEXT
try: try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto')
@ -652,23 +657,18 @@ class StockTicker():
except: except:
stitchedStock = midFrame stitchedStock = midFrame
image_list.append(stitchedStock) image_list.append(stitchedStock)
image_list.append(self.blank) image_list.append(self.blank)
finalDisplayImage = self.stitchImage(image_list) finalDisplayImage = self.stitchImage(image_list)
return finalDisplayImage return finalDisplayImage
def getCryptoProfessional(self): def getCryptoProfessional(self):
image_list = [] title_img = self.openImage('feature_titles/small_feature_titles/crypto.png')
image_list = [title_img]
start = time.time() start = time.time()
self.readCryptoCSV() self.readCryptoCSV()
@ -687,16 +687,13 @@ class StockTicker():
change = change/100 * current change = change/100 * current
current = '%.2f' % current current = '%.2f' % current
arrow, change = self.getArrow(change, professional=True) arrow, change = self.getArrow(change, professional=True)
change = '%.2f' % change change = '%.2f' % change
midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
try: try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto')
logo = Image.open(os.path.join(logos_path, ticker + '.png')) logo = Image.open(os.path.join(logos_path, ticker + '.png'))
w,h = logo.size w,h = logo.size
@ -705,15 +702,10 @@ class StockTicker():
except: except:
stitchedStock = midFrame stitchedStock = midFrame
image_list.append(stitchedStock) image_list.append(stitchedStock)
image_list.append(self.blank) image_list.append(self.blank)
finalDisplayImage = self.stitchImage(image_list) finalDisplayImage = self.stitchImage(image_list)
self.blank = Image.new('RGB', (10, 32)) self.blank = Image.new('RGB', (10, 32))
return finalDisplayImage return finalDisplayImage
@ -728,20 +720,16 @@ class StockTicker():
currencies = ['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD'] currencies = ['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD']
for i, currency in enumerate(currencies): for i, currency in enumerate(currencies):
current, yesterday = currency_info[currency] current, yesterday = currency_info[currency]
change = 1/current - 1/yesterday change = 1/current - 1/yesterday
current = 1/current current = 1/current
current = '%.3f' % current current = '%.3f' % current
arrow, change = self.getArrow(change) arrow, change = self.getArrow(change)
change = '%.6f' % change change = '%.6f' % change
midFrame = self.textToImage(currency + '(' + base + ')', current, change, arrow) #IMAGE THE TEXT midFrame = self.textToImage(currency + '(' + base + ')', current, change, arrow) #IMAGE THE TEXT
try: try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'currencies') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'currencies')
@ -756,31 +744,20 @@ class StockTicker():
stitchedStock = self.stitchImage([new_im, midFrame]) stitchedStock = self.stitchImage([new_im, midFrame])
image_list.append(new_im) image_list.append(new_im)
except Exception as e: except Exception as e:
print(e) print(e)
image_list.append(midFrame) image_list.append(midFrame)
image_list.append(self.blank) image_list.append(self.blank)
finalDisplayImage = self.stitchImage(image_list) finalDisplayImage = self.stitchImage(image_list)
return finalDisplayImage return finalDisplayImage
def getForexProfessional(self): def getForexProfessional(self):
image_list = [] title_img = self.openImage('feature_titles/small_feature_titles/forex.png')
image_list = [title_img]
base, currency_info = json.load(open('csv/currency.json', 'r')) base, currency_info = json.load(open('csv/currency.json', 'r'))
currencies = ['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD'] currencies = ['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD']
@ -875,7 +852,8 @@ class StockTicker():
return finalDisplayImage return finalDisplayImage
def getStockProfessional(self): def getStockProfessional(self):
image_list = [] title_img = self.openImage('feature_titles/small_feature_titles/stocks.png')
image_list = [title_img]
self.readStocksCSV() self.readStocksCSV()
@ -929,11 +907,8 @@ class StockTicker():
def getNewsImage(self): def getNewsImage(self):
title_img = self.openImage('feature_titles/news.png') title_img = self.openImage('feature_titles/news.png')
headline_font = ImageFont.load("./fonts/6x13.pil")
source_font = ImageFont.load("./fonts/6x13.pil")
headline_font = ImageFont.load("./fonts/10x20.pil")
source_font = ImageFont.load("./fonts/10x20.pil")
image_list = [title_img] image_list = [title_img]
@ -949,10 +924,9 @@ class StockTicker():
source_date_times.append(source + ': ' + date + ' ' + time) source_date_times.append(source + ': ' + date + ' ' + time)
f.close() f.close()
for i, headline in enumerate(headlines): for i, headline in enumerate(headlines):
headline = headline.replace("^", ",") headline = headline.replace("^", ",")
headline = headline.replace("", "'") headline = headline.replace("", "'")
headline = headline.replace("", "'") headline = headline.replace("", "'")
@ -962,17 +936,19 @@ class StockTicker():
headline = headline.replace('', '-') headline = headline.replace('', '-')
headline = ''.join([h for h in headline if ord(h) < 256]) headline = ''.join([h for h in headline if ord(h) < 256])
lst = headline.rsplit('-', 1) #remove source name at end of headline
headline = lst[0]
headline_img = self.textImage(headline, headline_font, matrix_height = True) headline_img = self.textImage(headline, headline_font, matrix_height = True)
source_img = self.textImage(source_date_times[i], source_font, r=255, g=255, b=0, matrix_height = True) source_img = self.textImage(source_date_times[i], source_font, r=255, g=255, b=0, matrix_height = True)
try: try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'news_logos') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'news_logos')
logo = Image.open(os.path.join(logos_path, 'techcrunch' + '.png')) logo = Image.open(os.path.join(logos_path, 'techcrunch' + '.png'))
img = Image.new('RGB', (headline_img.size[0], 32)) img = Image.new('RGB', (headline_img.size[0], 32))
img.paste(headline_img, (2, -3)) img.paste(headline_img, (2, 0))
img.paste(source_img, (2,16)) img.paste(source_img, (2,16))
img= self.stitchImage([logo,img]) img= self.stitchImage([logo,img])
@ -984,6 +960,7 @@ class StockTicker():
img.paste(source_img, (0,16)) img.paste(source_img, (0,16))
image_list.append(img) image_list.append(img)
image_list.append(self.blank)
news_image = self.stitchImage(image_list) news_image = self.stitchImage(image_list)
@ -994,7 +971,8 @@ class StockTicker():
headline_font = ImageFont.load("./fonts/6x10.pil") headline_font = ImageFont.load("./fonts/6x10.pil")
source_font = ImageFont.load("./fonts/6x10.pil") source_font = ImageFont.load("./fonts/6x10.pil")
image_list = [] title_img = self.openImage('feature_titles/small_feature_titles/news.png')
image_list = [title_img]
headlines = [] headlines = []
sources = [] sources = []
@ -1010,7 +988,7 @@ class StockTicker():
f.close() f.close()
blank = Image.new('RGB', (0, 16))
for i, headline in enumerate(headlines): for i, headline in enumerate(headlines):
headline = headline.replace("^", ",") headline = headline.replace("^", ",")
headline = headline.replace("", "'") headline = headline.replace("", "'")
@ -1022,6 +1000,9 @@ class StockTicker():
headline = ''.join([h for h in headline if ord(h) < 256]) headline = ''.join([h for h in headline if ord(h) < 256])
lst = headline.rsplit('-', 1) #remove source name at end of headline
headline = lst[0]
headline_img = self.textImage(headline, headline_font, matrix_height = True) headline_img = self.textImage(headline, headline_font, matrix_height = True)
source_img = self.textImage(sources[i], source_font, r=255, g=255, b=0, matrix_height = True) source_img = self.textImage(sources[i], source_font, r=255, g=255, b=0, matrix_height = True)
@ -1035,7 +1016,7 @@ class StockTicker():
logo = logo.resize((int(width/2), int(height/2))) logo = logo.resize((int(width/2), int(height/2)))
img = Image.new('RGB', (headline_img.size[0]+ source_img.size[0], 32)) img = Image.new('RGB', (headline_img.size[0]+ source_img.size[0] + logo.size[0], 32))
img.paste(headline_img, (source_img.size[0]+ 5, 3)) img.paste(headline_img, (source_img.size[0]+ 5, 3))
img.paste(source_img, (2,3)) img.paste(source_img, (2,3))
@ -1043,12 +1024,12 @@ class StockTicker():
except Exception as e: except Exception as e:
img = Image.new('RGB', (headline_img.size[0], 32)) img = Image.new('RGB', (headline_img.size[0] + source_img.size[0], 32))
img.paste(headline_img, (0,0)) img.paste(headline_img, (0,0))
img.paste(source_img, (0,16)) img.paste(source_img, (0,16))
image_list.append(img) image_list.append(img)
image_list.append(blank)
news_image = self.stitchImage(image_list) news_image = self.stitchImage(image_list)
return news_image return news_image
@ -1341,7 +1322,7 @@ class StockTicker():
wind_img = Image.open(weather_dir + '/wind.png') wind_img = Image.open(weather_dir + '/wind.png')
img.paste(wind_img, (154,8)) img.paste(wind_img, (154,8))
wtext_img = self.textImage("{0:.0f}".format(current_weather['wind_speed']) + 'm/s', small_font) wtext_img = self.textImage("{0:.0f}".format(current_weather['wind_speed']) + 'm/s'.upper(), small_font)
img.paste(wtext_img, (168, 10)) img.paste(wtext_img, (168, 10))
wdir_img = self.textImage(self.degreesToCompass(current_weather['wind_direction']).upper(), small_font) wdir_img = self.textImage(self.degreesToCompass(current_weather['wind_direction']).upper(), small_font)
@ -1350,7 +1331,7 @@ class StockTicker():
vis_img = Image.open(weather_dir + '/visibility.png') vis_img = Image.open(weather_dir + '/visibility.png')
img.paste(vis_img, (154,20)) img.paste(vis_img, (154,20))
vtext_img = self.textImage(str(current_weather['visibility']/1000) + 'km', small_font) vtext_img = self.textImage(str(current_weather['visibility']/1000) + 'km'.upper(), small_font)
img.paste(vtext_img, (168, 22)) img.paste(vtext_img, (168, 22))
imgs.append(img) imgs.append(img)
@ -1365,7 +1346,9 @@ class StockTicker():
locations = line.split(',') locations = line.split(',')
f.close() f.close()
title_img = self.openImage('feature_titles/small_feature_titles/weather.png')
image_list = [title_img]
current_weathers = json.load(open('csv/current_weather.json', 'r')) current_weathers = json.load(open('csv/current_weather.json', 'r'))
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
months =['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] months =['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
@ -1424,15 +1407,15 @@ class StockTicker():
deg_img = self.textImage('o', small_font) deg_img = self.textImage('o', small_font)
img.paste(deg_img, (x_offset, 1)) img.paste(deg_img, (x_offset+1, 1))
x_offset += deg_img.size[0] -2 x_offset += deg_img.size[0] -2
min_img = self.textImage( "{0:.0f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255) min_img = self.textImage( "{0:.0f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255)
img.paste(min_img, (x_offset, 2)) img.paste(min_img, (x_offset+2, 2))
max_img = self.textImage( "{0:.0f}".format(current_weather['max_temp']), small_font, r=255, g=0, b=0) max_img = self.textImage( "{0:.0f}".format(current_weather['max_temp']), small_font, r=255, g=0, b=0)
img.paste(max_img, (x_offset, 8)) img.paste(max_img, (x_offset+2, 8))
x_offset += max_img.size[0] + 2 x_offset += max_img.size[0] + 2
@ -1461,7 +1444,9 @@ class StockTicker():
img = img.crop((0,0,x_offset +image.size[0] ,16)) img = img.crop((0,0,x_offset +image.size[0] ,16))
return img
image_list.append(img)
return self.stitchImage(image_list)
def getDailyWeatherImageAlt(self): def getDailyWeatherImageAlt(self):
@ -1645,126 +1630,91 @@ class StockTicker():
weather_dir = './logos/weather_icons' weather_dir = './logos/weather_icons'
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png') weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
temp_img = self.textImage(str("{0:.0f}".format(current_weather['temp'])), large_font) temp_img = self.textImage(str("{0:.0f}".format(current_weather['temp'])), large_font)
deg_img = self.textImage('o', small_font) deg_img = self.textImage('o', small_font)
min_img = self.textImage( "{0:.0f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255) min_img = self.textImage( "{0:.0f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255)
max_img = self.textImage( "{0:.0f}".format(current_weather['max_temp']), small_font, r=255, g=0, b=0) max_img = self.textImage( "{0:.0f}".format(current_weather['max_temp']), small_font, r=255, g=0, b=0)
main = current_weather['main_weather'] main = current_weather['main_weather']
main_img = self.textImage(main.upper(), small_font) main_img = self.textImage(main.upper(), small_font)
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
months =['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] months =['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
month = months[int(datetime.now().strftime('%m'))] month = months[int(datetime.now().strftime('%m'))]
date = str(int(datetime.now().strftime('%d'))) date = str(int(datetime.now().strftime('%d')))
weekday = weekdays[datetime.today().weekday()] weekday = weekdays[datetime.today().weekday()]
date_img = self.textImage((month + ' ' + date + ',' + weekday).upper(), extra_small_font) date_img = self.textImage((month + ' ' + date + ',' + weekday).upper(), extra_small_font)
rain_img = Image.open(weather_dir + '/rain-chance.png') rain_img = Image.open(weather_dir + '/rain-chance.png')
rtext_img = self.textImage(str(int(current_weather['rain_chance']*100)) + '%', extra_small_font) rtext_img = self.textImage(str(int(current_weather['rain_chance']*100)) + '%', extra_small_font)
hum_img = Image.open(weather_dir + '/humidity.png')
hum_img = Image.open(weather_dir + '/humidity.png')
htext_img = self.textImage(str(current_weather['humidity']) + '%', extra_small_font) htext_img = self.textImage(str(current_weather['humidity']) + '%', extra_small_font)
uv_img = Image.open(weather_dir + '/uv.png') uv_img = Image.open(weather_dir + '/uv.png')
utext_img = self.textImage(str(current_weather['uv']) , extra_small_font) utext_img = self.textImage(str(current_weather['uv']) , extra_small_font)
wind_img = Image.open(weather_dir + '/wind.png') wind_img = Image.open(weather_dir + '/wind.png')
wtext_img = self.textImage(str(current_weather['wind_speed']) + 'm/s'.upper(), extra_small_font)
wtext_img = self.textImage(str(current_weather['wind_speed']) + 'm/s', extra_small_font)
uv_img = Image.open(weather_dir + '/uv.png') uv_img = Image.open(weather_dir + '/uv.png')
utext_img = self.textImage(str(current_weather['uv']) , small_font) utext_img = self.textImage(str(current_weather['uv']) , small_font)
cloud_img = Image.open(weather_dir + '/clouds.png') cloud_img = Image.open(weather_dir + '/clouds.png')
ctext_img = self.textImage(str(current_weather['clouds']) + '%', small_font) ctext_img = self.textImage(str(current_weather['clouds']) + '%', small_font)
wind_img = Image.open(weather_dir + '/wind.png') wind_img = Image.open(weather_dir + '/wind.png')
wtext_img = self.textImage("{0:.0f}".format(current_weather['wind_speed']) + 'm/s'.upper(), small_font)
wtext_img = self.textImage("{0:.0f}".format(current_weather['wind_speed']) + 'm/s', small_font)
wdir_img = self.textImage(self.degreesToCompass(current_weather['wind_direction']), small_font) wdir_img = self.textImage(self.degreesToCompass(current_weather['wind_direction']), small_font)
vis_img = Image.open(weather_dir + '/visibility.png') vis_img = Image.open(weather_dir + '/visibility.png')
vtext_img = self.textImage(str(current_weather['visibility']/1000) + 'km'.upper(), small_font)
vtext_img = self.textImage(str(current_weather['visibility']/1000) + 'km', small_font)
img.paste(location_img, (0,0)) img.paste(location_img, (0,0))
x_offset = location_img.size[0]+2
img.paste(weather_img, (0,12)) img.paste(weather_img, (0,12))
img.paste(temp_img, (30,9)) img.paste(temp_img, (34,9))
img.paste(deg_img, (50, 8)) img.paste(deg_img, (55, 8))
img.paste(min_img, (55, 10)) img.paste(min_img, (61, 10))
img.paste(main_img, (30, 26)) img.paste(main_img, (31, 26))
img.paste(max_img, (55, 19)) img.paste(max_img, (61, 18))
img.paste(date_img, (location_img.size[0], 1)) img.paste(date_img, (x_offset, 1))
x_offset += date_img.size[0]+2
img.paste(rain_img, (x_offset,0))
x_offset += rain_img.size[0]+2
img.paste(rtext_img, (x_offset, 1))
x_offset += rtext_img.size[0]+2
img.paste(rain_img, (90,0)) img.paste(hum_img, (x_offset, 0))
img.paste(rtext_img, (103, 1)) x_offset += hum_img.size[0]+2
img.paste(htext_img, (x_offset, 1))
x_offset+= htext_img.size[0]+2
img.paste(hum_img, (117, 0)) img.paste(uv_img, ( x_offset, 0))
img.paste(htext_img, (128, 1)) x_offset += uv_img.size[0]+2
img.paste(utext_img, (x_offset, 1))
x_offset += utext_img.size[0]+2
img.paste(uv_img, ( 143, 0)) img.paste(cloud_img, (x_offset,0))
img.paste(utext_img, (156, 1)) x_offset += cloud_img.size[0]+2
img.paste(ctext_img, (x_offset, 1))
x_offset += ctext_img.size[0]+2
img.paste(cloud_img, (169,0)) img.paste(wind_img, (x_offset,0))
img.paste(ctext_img, (182, 1)) x_offset += wind_img.size[0]+2
img.paste(wtext_img, (x_offset, 1))
x_offset += wtext_img.size[0]+2
img.paste(wdir_img, (x_offset, 1))
x_offset+= wdir_img.size[0]+2
img.paste(wind_img, (205,0)) img.paste(vis_img, (x_offset,0))
img.paste(wtext_img, (218, 1)) x_offset+= vis_img.size[0]+2
img.paste(wdir_img, (231, 1)) img.paste(vtext_img, (x_offset, 1))
x_offset += vtext_img.size[0] +2
img.paste(vis_img, (243,0))
img.paste(vtext_img, (256, 1))
#img.paste(uv_img, ( 96, 0)) #img.paste(uv_img, ( 96, 0))
#img.paste(utext_img, (109, 0)) #img.paste(utext_img, (109, 0))
#img.paste(wind_img, (96,0)) #img.paste(wind_img, (96,0))
#img.paste(wtext_img, (109,0)) #img.paste(wtext_img, (109,0))
#img.paste(date_img, (70, 0)) #img.paste(date_img, (70, 0))
x_offset = 70 x_offset = 70
for i in range(1,len(daily_weather)-1): for i in range(1,len(daily_weather)-1):
weekday = weekdays[(datetime.today().weekday() + i)%7] weekday = weekdays[(datetime.today().weekday() + i)%7]
day_img = self.textImage( weekday.upper(), small_font) day_img = self.textImage( weekday.upper(), small_font)
@ -1784,7 +1734,7 @@ class StockTicker():
img.paste(day_img, (x_offset +5, 9)) img.paste(day_img, (x_offset +5, 9))
img.paste(weather_img, (x_offset +5, 16)) img.paste(weather_img, (x_offset +5, 16))
img.paste(min_img, (x_offset + 25, 10)) img.paste(min_img, (x_offset + 25, 10))
img.paste(max_img, (x_offset + 25, 20)) img.paste(max_img, (x_offset + 25, 18))
x_offset += 40 x_offset += 40
@ -1897,12 +1847,36 @@ class StockTicker():
return self.stitchImage([title_img, image]) return self.stitchImage([title_img, image])
def getUserGIF(self): def getUserGIF(self):
gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/display_gif.ppm'))
gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/user_gif.ppm'))
return gif return gif
def displayStocks(self): def displayStocks(self):
self.scrollImageTransition(['final.ppm', 'final.ppm'], offset_x = 0, offset_y = 0) self.scrollImageTransition(['final.ppm', 'final.ppm'], offset_x = 0, offset_y = 0)
def displayProfessional(self):
forex = self.getForexProfessional()
crypto = self.getCryptoProfessional()
news = self.getNewsProfessional()
stock = self.getStockProfessional()
weather = self.getTodayWeatherProfessional()
x_offset = 0
news.paste(weather, (x_offset, 16))
x_offset += weather.size[0]
news.paste(crypto, (x_offset, 16))
x_offset += crypto.size[0]
news.paste(stock, (x_offset, 16))
x_offset += stock.size[0]
news.paste(forex, (x_offset, 16))
x_offset += forex.size[0]
while True:
kill = stock_ticker.scrollImage(news, offset_x = 128)
if kill:
break
def process_msg(self, msg): def process_msg(self, msg):
@ -1936,20 +1910,20 @@ class StockTicker():
elif msg == 'T':# text elif msg == 'T':# text
self.scrollFunctionsAnimated(['text', 'text'], animation = 'continuous') self.scrollFunctionsAnimated(['text', 'text'], animation = 'traditional')
elif msg == 'I': # image elif msg == 'I': # image
self.scrollFunctionsAnimated(['display_image', 'display_image'], animation = 'continuous') self.scrollFunctionsAnimated(['display_image', 'display_image'], animation = 'traditional')
elif msg == 'G': # gif elif msg == 'G': # gif
self.scrollFunctionsAnimated(['display_gif', 'display_gif'], animation = 'continuous') self.scrollFunctionsAnimated(['display_gif', 'display_gif'], animation = 'traditional')
elif msg == 'W': # weather elif msg == 'W': # weather
self.scrollFunctionsAnimated(['today_weather', 'today_weather'], animation = 'continuous') self.scrollFunctionsAnimated(['today_weather', 'today_weather'], animation = 'traditional')
elif msg == 'D': # daily weather elif msg == 'D': # daily weather
self.scrollFunctionsAnimated(['daily_weather', 'daily_weather'], animation = 'continuous') self.scrollFunctionsAnimated(['daily_weather', 'daily_weather'],animation = 'traditional')
elif msg == 'P': # past league elif msg == 'P': # past league
img = self.getLeagueImage('NBA', 'past') img = self.getLeagueImage('NBA', 'past')
@ -1986,6 +1960,9 @@ class StockTicker():
self.scrollFunctionsAnimated(userSettings, animation = 'down') self.scrollFunctionsAnimated(userSettings, animation = 'down')
elif msg == 'b':
self.displayProfessional()
elif msg == 'K': # kill elif msg == 'K': # kill
self.resetMatrix() self.resetMatrix()
@ -1996,35 +1973,6 @@ if __name__ == '__main__':
stock_ticker = StockTicker() stock_ticker = StockTicker()
'''
forex = stock_ticker.getForexProfessional()
crypto = stock_ticker.getCryptoProfessional()
news = stock_ticker.getNewsProfessional()
stock = stock_ticker.getStockProfessional()
weather = stock_ticker.getTodayWeatherProfessional()
x_offset = 0
news.paste(weather, (x_offset, 16))
x_offset += weather.size[0]
news.paste(crypto, (x_offset, 16))
x_offset += crypto.size[0]
news.paste(stock, (x_offset, 16))
x_offset += stock.size[0]
news.paste(forex, (x_offset, 16))
x_offset += forex.size[0]
while True:
kill = stock_ticker.scrollImage(news, offset_x = 128)
if kill:
break
'''
# #
#stock_ticker.process_msg('A') #stock_ticker.process_msg('A')
#stock_ticker.process_msg('G') #stock_ticker.process_msg('G')

View File

@ -20,6 +20,7 @@
<input type="submit" name="Future NHL" value="Future NHL" style="height:50px" > <input type="submit" name="Future NHL" value="Future NHL" style="height:50px" >
<input type="submit" name="Live NHL" value="Live NHL" style="height:50px" > <input type="submit" name="Live NHL" value="Live NHL" style="height:50px" >
<input type="submit" name="Premier league table" value="Premier league table" style="height:50px" > <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="All" value="All" style="height:50px" >
<input type="submit" name="Stop Display" value="Stop Display"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"> <input type="submit" name="Shutdown the pi" value="Shutdown the pi"style="height:50px">