professional image creation updated
This commit is contained in:
parent
65dfcdc321
commit
3fb1ee197a
@ -1 +1 @@
|
|||||||
["Stocks", "Crypto", "Forex", "Current Weather"]
|
["Custom Images"]
|
@ -1 +1 @@
|
|||||||
{"speed": "medium", "animation": "continuous", "title": true, "pause": "", "images": ["image.png"]}
|
{"speed": "medium", "animation": "continuous", "title": true, "pause": "", "images": ["ZM.png", "WORK.png"]}
|
Binary file not shown.
BIN
display_images/forex_prof.ppm → display_images/Current Weather Prof.ppm
Executable file → Normal file
BIN
display_images/forex_prof.ppm → display_images/Current Weather Prof.ppm
Executable file → Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
display_images/News Prof.ppm
Normal file
BIN
display_images/News Prof.ppm
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20
log.txt
20
log.txt
@ -1,9 +1,17 @@
|
|||||||
'StockTicker' object has no attribute 'readStocksCSV'. file: stockTicker.py. line: 2186. type: <class 'AttributeError'>
|
[Errno 2] No such file or directory: '/home/pi/Desktop/stock_ticker/ZM.png'. file: stockTicker.py. line: 2230. type: <class 'FileNotFoundError'>
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File "stockTicker.py", line 2186, in <module>
|
File "stockTicker.py", line 2230, in <module>
|
||||||
stock_ticker.updateMultiple(['Stocks Prof'])
|
stock_ticker.process_msg(msg)
|
||||||
|
File "stockTicker.py", line 2194, in process_msg
|
||||||
|
self.scrollFunctionsAnimated(userSettings, animation = 'down')
|
||||||
|
File "stockTicker.py", line 309, in scrollFunctionsAnimated
|
||||||
|
self.updateMultiple([options[0]])
|
||||||
File "stockTicker.py", line 276, in updateMultiple
|
File "stockTicker.py", line 276, in updateMultiple
|
||||||
img = self.functions[option]()
|
img = self.functions[option]()
|
||||||
File "stockTicker.py", line 927, in getStockProfessional
|
File "stockTicker.py", line 1953, in getUserImage
|
||||||
self.readStocksCSV()
|
image = self.openImage(os.path.join(os.path.dirname(os.path.abspath(__file__)), image))
|
||||||
AttributeError: 'StockTicker' object has no attribute 'readStocksCSV'
|
File "stockTicker.py", line 76, in openImage
|
||||||
|
image = Image.open(image_file)
|
||||||
|
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2634, in open
|
||||||
|
fp = builtins.open(filename, "rb")
|
||||||
|
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/Desktop/stock_ticker/ZM.png'
|
||||||
|
@ -491,6 +491,7 @@ allFeaturesFileAddBtn.map((value, index) => {
|
|||||||
value.addEventListener("click", () => {
|
value.addEventListener("click", () => {
|
||||||
var tag = document.createElement("li");
|
var tag = document.createElement("li");
|
||||||
tag.innerHTML = allFeaturesFile[index].files[0].name;
|
tag.innerHTML = allFeaturesFile[index].files[0].name;
|
||||||
|
|
||||||
allFeatures[index].appendChild(tag);
|
allFeatures[index].appendChild(tag);
|
||||||
changeVarValue();
|
changeVarValue();
|
||||||
addEventOnFeaturesList();
|
addEventOnFeaturesList();
|
||||||
|
134
stockTicker.py
134
stockTicker.py
@ -702,23 +702,35 @@ class StockTicker():
|
|||||||
|
|
||||||
def getCryptoProfessional(self):
|
def getCryptoProfessional(self):
|
||||||
|
|
||||||
title_img = self.openImage('feature_titles/small_feature_titles/crypto.png')
|
|
||||||
self.blank = Image.new('RGB', (0, 16))
|
self.blank = Image.new('RGB', (0, 16))
|
||||||
image_list = [title_img, Image.new('RGB', (5, 16))]
|
|
||||||
|
|
||||||
start = time.time()
|
f = open('csv/crypto_settings.json', 'r')
|
||||||
self.readCryptoCSV()
|
all_crypto_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
for i, coin in enumerate(self.coins):
|
if all_crypto_settings['title']:
|
||||||
|
title_img = self.openImage('feature_titles/small_feature_titles/crypto.png')
|
||||||
|
image_list = [title_img]
|
||||||
|
image_list.append(self.blank)
|
||||||
|
else:
|
||||||
|
image_list = []
|
||||||
|
|
||||||
info = self.coin_info[coin]
|
|
||||||
|
|
||||||
change = float(info[3]) #TEXT
|
|
||||||
ticker = info[0] #TEXT
|
|
||||||
current = float(info[2]) #TEXT
|
|
||||||
base = info[1].upper()
|
|
||||||
|
|
||||||
if self.points:
|
coin_info = all_crypto_settings['symbols']
|
||||||
|
coin_bases = list(coin_info.keys())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for i, cb in enumerate(coin_bases):
|
||||||
|
|
||||||
|
ticker, base = cb.split(',')
|
||||||
|
current = coin_info[cb]["current"]
|
||||||
|
change = coin_info[cb]["24hr_change"]
|
||||||
|
|
||||||
|
if all_crypto_settings["point"]:
|
||||||
# convert percent to points
|
# convert percent to points
|
||||||
change = change/100 * current
|
change = change/100 * current
|
||||||
|
|
||||||
@ -802,41 +814,42 @@ class StockTicker():
|
|||||||
|
|
||||||
def getForexProfessional(self):
|
def getForexProfessional(self):
|
||||||
|
|
||||||
|
self.blank = Image.new('RGB', (0, 16))
|
||||||
f = open('csv/forex_settings.json', 'r')
|
f = open('csv/forex_settings.json', 'r')
|
||||||
all_forex_settings = json.load(f)
|
all_forex_settings = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
if all_forex_settings['title']:
|
if all_forex_settings['title']:
|
||||||
title_img = self.openImage('feature_titles/small_feature_titles/forex.png')
|
title_img = self.openImage('feature_titles/small_feature_titles/forex.png')
|
||||||
self.blank = Image.new('RGB', (0, 16))
|
image_list = [title_img]
|
||||||
image_list = [title_img, Image.new('RGB', (5, 16))]
|
image_list.append(self.blank)
|
||||||
else:
|
else:
|
||||||
image_list = []
|
image_list = []
|
||||||
|
|
||||||
|
forex_settings = all_forex_settings['symbols']
|
||||||
base, currency_info = json.load(open('csv/currency.json', 'r'))
|
|
||||||
currencies = ['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD']
|
|
||||||
|
|
||||||
|
|
||||||
for i, currency in enumerate(currencies):
|
symbol_bases = list(forex_settings.keys())
|
||||||
|
|
||||||
current, yesterday = currency_info[currency]
|
|
||||||
|
|
||||||
change = 1/current - 1/yesterday
|
for i, sb in enumerate(symbol_bases):
|
||||||
|
symbol, base = sb.split(',')
|
||||||
|
|
||||||
|
current = forex_settings[sb]['current']
|
||||||
|
change = forex_settings[sb]['24hr_change']
|
||||||
|
|
||||||
current = 1/current
|
|
||||||
current = '%.3f' % current
|
current = '%.3f' % current
|
||||||
|
|
||||||
|
|
||||||
arrow, change = self.getArrow(change, professional = True)
|
arrow, change = self.getArrow(change, professional = True)
|
||||||
change = '%.6f' % change
|
change = '%.6f' % change
|
||||||
midFrame = self.textToImageProf(currency + '(' + base + ')', current, change, arrow, font = ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
|
midFrame = self.textToImageProf(symbol + '(' + 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'), 'currencies')
|
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'currencies')
|
||||||
|
|
||||||
logo = Image.open(os.path.join(logos_path, currency.lower() + '.png'))
|
logo = Image.open(os.path.join(logos_path, symbol.lower() + '.png'))
|
||||||
bse = Image.open(os.path.join(logos_path, base.lower() + '.png'))
|
bse = Image.open(os.path.join(logos_path, base.lower() + '.png'))
|
||||||
|
|
||||||
new_im = Image.new('RGB', (32, 32))
|
new_im = Image.new('RGB', (32, 32))
|
||||||
@ -878,8 +891,7 @@ class StockTicker():
|
|||||||
image_list = []
|
image_list = []
|
||||||
|
|
||||||
|
|
||||||
symbols = []
|
|
||||||
stock_info = {}
|
|
||||||
|
|
||||||
stock_info = all_stocks_settings['symbols']
|
stock_info = all_stocks_settings['symbols']
|
||||||
symbols = list(stock_info.keys())
|
symbols = list(stock_info.keys())
|
||||||
@ -920,6 +932,7 @@ class StockTicker():
|
|||||||
return finalDisplayImage
|
return finalDisplayImage
|
||||||
|
|
||||||
def getStockProfessional(self):
|
def getStockProfessional(self):
|
||||||
|
self.blank = Image.new('RGB', (0, 16))
|
||||||
|
|
||||||
f = open('csv/stocks_settings.json', 'r')
|
f = open('csv/stocks_settings.json', 'r')
|
||||||
all_stocks_settings = json.load(f)
|
all_stocks_settings = json.load(f)
|
||||||
@ -932,10 +945,11 @@ class StockTicker():
|
|||||||
else:
|
else:
|
||||||
image_list = []
|
image_list = []
|
||||||
|
|
||||||
self.readStocksCSV()
|
|
||||||
|
|
||||||
self.blank = Image.new('RGB', (0, 16))
|
stock_info = all_stocks_settings['symbols']
|
||||||
for i, symbol in enumerate(self.symbols):
|
symbols = list(stock_info.keys())
|
||||||
|
|
||||||
|
for i, symbol in enumerate(symbols):
|
||||||
|
|
||||||
|
|
||||||
info = stock_info[symbol]
|
info = stock_info[symbol]
|
||||||
@ -1052,28 +1066,30 @@ class StockTicker():
|
|||||||
|
|
||||||
def getNewsProfessional(self):
|
def getNewsProfessional(self):
|
||||||
|
|
||||||
headline_font = ImageFont.load("./fonts/6x10.pil")
|
all_settings = json.load(open('csv/news_settings.json', 'r'))
|
||||||
source_font = ImageFont.load("./fonts/6x10.pil")
|
|
||||||
|
|
||||||
|
if all_settings['title']:
|
||||||
title_img = self.openImage('feature_titles/small_feature_titles/news.png')
|
title_img = self.openImage('feature_titles/small_feature_titles/news.png')
|
||||||
image_list = [title_img, Image.new('RGB', (5, 16))]
|
image_list = [title_img]
|
||||||
|
|
||||||
|
headline_font = ImageFont.load("./fonts/6x13.pil")
|
||||||
|
source_font = ImageFont.load("./fonts/6x13.pil")
|
||||||
|
|
||||||
|
headline_info = all_settings['headlines']
|
||||||
|
|
||||||
headlines = []
|
headlines = []
|
||||||
|
source_date_times = []
|
||||||
sources = []
|
sources = []
|
||||||
|
|
||||||
f = open('csv/news.csv', 'r')
|
|
||||||
CSV = csv.reader(f)
|
|
||||||
next(CSV)
|
|
||||||
for row in CSV:
|
|
||||||
headline, source, date, time = row
|
|
||||||
headlines.append(headline)
|
|
||||||
sources.append(source)
|
|
||||||
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
|
|
||||||
blank = Image.new('RGB', (0, 16))
|
blank = Image.new('RGB', (0, 16))
|
||||||
for i, headline in enumerate(headlines):
|
|
||||||
|
for i, hi in enumerate(headline_info):
|
||||||
|
headline, source, date_time = hi
|
||||||
|
date, time = date_time.split('T')
|
||||||
|
time = time[:-1]
|
||||||
|
source_date_time = source + ': ' + date + ' ' + time
|
||||||
|
|
||||||
headline = headline.replace("^", ",")
|
headline = headline.replace("^", ",")
|
||||||
headline = headline.replace("’", "'")
|
headline = headline.replace("’", "'")
|
||||||
headline = headline.replace("‘", "'")
|
headline = headline.replace("‘", "'")
|
||||||
@ -1088,7 +1104,7 @@ class StockTicker():
|
|||||||
headline = lst[0]
|
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(source_date_time+ ':', source_font, r=255, g=255, b=0, matrix_height = True)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1453,15 +1469,19 @@ class StockTicker():
|
|||||||
return self.stitchImage(imgs)
|
return self.stitchImage(imgs)
|
||||||
|
|
||||||
def getTodayWeatherProfessional(self):
|
def getTodayWeatherProfessional(self):
|
||||||
f = open( "csv/weather_location.txt", 'r' )
|
all_settings = json.load(open('csv/current_weather.json', 'r'))
|
||||||
line = next(f)
|
|
||||||
locations = line.split(',')
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
|
if all_settings['title']:
|
||||||
title_img = self.openImage('feature_titles/small_feature_titles/weather.png')
|
title_img = self.openImage('feature_titles/small_feature_titles/weather.png')
|
||||||
image_list = [title_img, Image.new('RGB', (3, 16))]
|
image_list = [title_img, Image.new('RGB', (3, 16))]
|
||||||
|
else:
|
||||||
|
image_list = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
current_weathers = all_settings['locations']
|
||||||
|
locations = list(current_weathers.keys())
|
||||||
|
|
||||||
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']
|
||||||
month = months[int(datetime.now().strftime('%m'))-1]
|
month = months[int(datetime.now().strftime('%m'))-1]
|
||||||
@ -1470,10 +1490,11 @@ class StockTicker():
|
|||||||
weekday = weekdays[datetime.today().weekday()]
|
weekday = weekdays[datetime.today().weekday()]
|
||||||
|
|
||||||
for i, location in enumerate(locations):
|
for i, location in enumerate(locations):
|
||||||
|
|
||||||
img = Image.new('RGB', (1000, 32))
|
img = Image.new('RGB', (1000, 32))
|
||||||
|
|
||||||
|
|
||||||
current_weather = current_weathers[i]
|
current_weather = current_weathers[location]
|
||||||
small_font = ImageFont.load("./fonts/4x6.pil")
|
small_font = ImageFont.load("./fonts/4x6.pil")
|
||||||
font = ImageFont.load("./fonts/6x10.pil")
|
font = ImageFont.load("./fonts/6x10.pil")
|
||||||
large_font = ImageFont.load("./fonts/10x20.pil")
|
large_font = ImageFont.load("./fonts/10x20.pil")
|
||||||
@ -1923,21 +1944,22 @@ class StockTicker():
|
|||||||
f = open('csv/image_settings.json', 'r')
|
f = open('csv/image_settings.json', 'r')
|
||||||
all_settings = json.load(f)
|
all_settings = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
image = self.openImage(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/user_image.ppm'))
|
|
||||||
|
|
||||||
if all_settings['title']:
|
if all_settings['title']:
|
||||||
imgs = [title_img, image]
|
imgs = [title_img]
|
||||||
else:
|
else:
|
||||||
imgs = [image]
|
imgs = []
|
||||||
|
|
||||||
|
for image in all_settings['images']:
|
||||||
|
image = self.openImage(os.path.join(os.path.dirname(os.path.abspath(__file__)), image))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return self.stitchImage(imgs)
|
return self.stitchImage(imgs)
|
||||||
|
|
||||||
def getUserGIF(self):
|
def getUserGIF(self):
|
||||||
title_img = self.openImage('feature_titles/gifs.png')
|
title_img = self.openImage('feature_titles/gifs.png')
|
||||||
|
|
||||||
gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/user_gif.gif'))
|
gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), all_settings['images'][0]))
|
||||||
|
|
||||||
f = open('csv/GIF_settings.json', 'r')
|
f = open('csv/GIF_settings.json', 'r')
|
||||||
all_settings = json.load(f)
|
all_settings = json.load(f)
|
||||||
@ -2191,7 +2213,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
start_image = Image.open('./logos/startup_logo.png')
|
start_image = Image.open('./logos/startup_logo.png')
|
||||||
|
|
||||||
stock_ticker.updateMultiple(['Stocks Prof', 'Crypto Prof', 'Forex Prof'])
|
|
||||||
stock_ticker.setImage(start_image)
|
stock_ticker.setImage(start_image)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
stock_ticker.resetMatrix()
|
stock_ticker.resetMatrix()
|
||||||
|
Loading…
Reference in New Issue
Block a user