multiprocessing used to update images in background
This commit is contained in:
parent
5c0fb44766
commit
3e59b011e1
BIN
final1.ppm
BIN
final1.ppm
Binary file not shown.
@ -16,7 +16,7 @@ import requests
|
|||||||
import pexpect
|
import pexpect
|
||||||
from rgbmatrix import RGBMatrix, RGBMatrixOptions
|
from rgbmatrix import RGBMatrix, RGBMatrixOptions
|
||||||
from rgbmatrix.graphics import *
|
from rgbmatrix.graphics import *
|
||||||
|
from multiprocessing import Process
|
||||||
|
|
||||||
def getInput(Block=False):
|
def getInput(Block=False):
|
||||||
if Block or select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []):
|
if Block or select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []):
|
||||||
@ -91,7 +91,7 @@ class StockTicker():
|
|||||||
image = self.openImage(image_file)
|
image = self.openImage(image_file)
|
||||||
img_width, img_height = image.size
|
img_width, img_height = image.size
|
||||||
|
|
||||||
print(offset_x, offset_y)
|
|
||||||
|
|
||||||
while offset_x > -img_width:
|
while offset_x > -img_width:
|
||||||
offset_x -= 1
|
offset_x -= 1
|
||||||
@ -107,11 +107,19 @@ class StockTicker():
|
|||||||
while True:
|
while True:
|
||||||
|
|
||||||
if current_img == 1:
|
if current_img == 1:
|
||||||
if stocks: self.getFullStockImage(1)
|
|
||||||
|
if stocks:
|
||||||
|
update_process = Process(target = self.getFullStockImage, args = (1,))
|
||||||
|
update_process.start()
|
||||||
image1 = self.openImage(image_files[0])
|
image1 = self.openImage(image_files[0])
|
||||||
image2 = self.openImage(image_files[1])
|
image2 = self.openImage(image_files[1])
|
||||||
|
|
||||||
elif current_img == 2:
|
elif current_img == 2:
|
||||||
if stocks: self.getFullStockImage(2)
|
|
||||||
|
if stocks:
|
||||||
|
update_process = Process(target = self.getFullStockImage, args = (2,))
|
||||||
|
update_process.start()
|
||||||
|
|
||||||
image1 = self.openImage(image_files[1])
|
image1 = self.openImage(image_files[1])
|
||||||
image2 = self.openImage(image_files[0])
|
image2 = self.openImage(image_files[0])
|
||||||
|
|
||||||
@ -143,7 +151,8 @@ class StockTicker():
|
|||||||
|
|
||||||
if kill: break
|
if kill: break
|
||||||
|
|
||||||
|
if stocks:
|
||||||
|
update_process.join()
|
||||||
if current_img == 1:
|
if current_img == 1:
|
||||||
current_img = 2
|
current_img = 2
|
||||||
elif current_img == 2:
|
elif current_img == 2:
|
||||||
@ -262,8 +271,6 @@ class StockTicker():
|
|||||||
ticker = symbol #TEXT
|
ticker = symbol #TEXT
|
||||||
current = '%.2f' % float(info[0]) #TEXT
|
current = '%.2f' % float(info[0]) #TEXT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
arrow, change = self.getArrow(change)
|
arrow, change = self.getArrow(change)
|
||||||
change = '%.2f' % change
|
change = '%.2f' % change
|
||||||
midFrame = self.textToImage(ticker, current, change, arrow) #IMAGE THE TEXT
|
midFrame = self.textToImage(ticker, current, change, arrow) #IMAGE THE TEXT
|
||||||
@ -332,7 +339,7 @@ class StockTicker():
|
|||||||
CSV = csv.reader(f)
|
CSV = csv.reader(f)
|
||||||
next(CSV)
|
next(CSV)
|
||||||
for row in CSV:
|
for row in CSV:
|
||||||
print(row)
|
|
||||||
try:
|
try:
|
||||||
symbol, current_price, opening_price = row
|
symbol, current_price, opening_price = row
|
||||||
self.symbols.append(symbol)
|
self.symbols.append(symbol)
|
||||||
@ -350,7 +357,7 @@ class StockTicker():
|
|||||||
CSV = csv.reader(f)
|
CSV = csv.reader(f)
|
||||||
next(CSV)
|
next(CSV)
|
||||||
for row in CSV:
|
for row in CSV:
|
||||||
print(row)
|
|
||||||
try:
|
try:
|
||||||
coin, current_price, day_change = row
|
coin, current_price, day_change = row
|
||||||
self.coins.append(coin)
|
self.coins.append(coin)
|
||||||
@ -432,7 +439,8 @@ if __name__ == '__main__':
|
|||||||
#stock_ticker.getFullStockImage(1)
|
#stock_ticker.getFullStockImage(1)
|
||||||
#stock_ticker.displayStocks()
|
#stock_ticker.displayStocks()
|
||||||
|
|
||||||
|
stock_ticker.delay = 0.001
|
||||||
|
stock_ticker.scrollImageTransition(['final.ppm', 'final.ppm'], offset_x = 0, offset_y = 0)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
msg = getInput()
|
msg = getInput()
|
||||||
|
Loading…
Reference in New Issue
Block a user