added all settings for messages, gifs, images and professional

This commit is contained in:
Neythen 2021-10-12 20:52:52 +01:00
parent 5beb927bf0
commit 1326007787
8 changed files with 246 additions and 191 deletions

View File

@ -1 +1 @@
{"feature": "Stocks", "speed": "medium", "animation": "continuous", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 43.42, "24hr_change": -3.963839231643678}, "BTC,USD": {"current": 49343, "24hr_change": 0.902025932223419}, "ETH,BTC": {"current": 0.06930671, "24hr_change": -1.7367682270496585}, "ADA,GBP": {"current": 1.62, "24hr_change": -3.549646457710461}}}
{"feature": "Stocks", "speed": "medium", "animation": "traditional", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 43.42, "24hr_change": -3.963839231643678}, "BTC,USD": {"current": 49343, "24hr_change": 0.902025932223419}, "ETH,BTC": {"current": 0.06930671, "24hr_change": -1.7367682270496585}, "ADA,GBP": {"current": 1.62, "24hr_change": -3.549646457710461}}}

View File

@ -1 +1 @@
["Custom Messages"]
["Stocks", "Crypto", "Forex"]

View File

@ -1 +1 @@
{"feature": "Stocks", "speed": "medium", "animation": "continuous", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NZD,GBP": {"current": 1.9471, "24hr_change": 0.0029000000000001247}, "CAD,USD": {"current": 1.271, "24hr_change": 0.0033999999999998476}}}
{"feature": "Stocks", "speed": "fast", "animation": "down", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NZD,GBP": {"current": 1.9471, "24hr_change": 0.0029000000000001247}, "CAD,USD": {"current": 1.271, "24hr_change": 0.0033999999999998476}}}

View File

@ -1 +1 @@
{"speed": "medium", "animation": "continuous", "title": true, "pause": "", "images": ["XOM.png", "ZBRA.png"]}
{"speed": "medium", "animation": "traditional", "title": true, "pause": "3", "images": ["XOM.png", "ZBRA.png"]}

View File

@ -1 +1 @@
{"feature": "Stocks", "speed": "medium", "animation": "continuous", "percent": true, "point": false, "logos": true, "chart": false, "title": true, "symbols": {"MSFT": {"current": 282.63, "opening": 287.28}, "GOOG": {"current": 2665.2, "opening": 2713.99}}}
{"feature": "Stocks", "speed": "slow", "animation": "down", "percent": true, "point": false, "logos": true, "chart": false, "title": true, "symbols": {"MSFT": {"current": 282.63, "opening": 287.28}, "GOOG": {"current": 2665.2, "opening": 2713.99}}}

View File

@ -77,6 +77,7 @@ def index():
team_stats = json.load(open('csv/league_tables.json', 'r'))
image_settings = json.load(open('csv/image_settings.json', 'r'))
GIF_settings = json.load(open('csv/GIF_settings.json', 'r'))
message_settings = json.load(open('csv/message_settings.json', 'r'))
templateData = {
@ -93,7 +94,8 @@ def index():
'live_games': live_games,
'team_stats': team_stats,
'image_settings':image_settings,
'GIF_settings':GIF_settings
'GIF_settings':GIF_settings,
'message_settings':message_settings
}
return render_template('index.html', **templateData)

View File

@ -39,7 +39,7 @@ class StockTicker():
def __init__(self):
#Define global resources
self.symbols = []
self.delay = 0.02
self.greenORred = (255, 255, 255)
#self.blank = Image.open('logos/blank.png')
self.blank = Image.new('RGB', (10, 32))
@ -68,8 +68,13 @@ class StockTicker():
'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional,
'Current Weather Prof': self.getTodayWeatherProfessional, 'News Prof':self.getNewsProfessional}
self.JSONs = {'Stocks': 'csv/stocks_settings.json', 'Crypto': 'csv/crypto_settings.json', 'Forex': 'csv/forex_settings.json',
'Daily Forecast':'csv/daily_weather.json', 'Current Weather': 'csv/current_weather.json',
'Sports (Team Stats)': 'csv/league_tables.json', 'Sports (Past Games)': 'csv/past_games.json',
'Sports (Upcoming Games)': 'csv/upcoming_games.json', 'Sports (Live Games)': 'csv/live_games.json',
'News':'csv/news_settings.json', 'Custom Images': 'csv/image_settings.json', 'Custom GIFs': 'csv/GIF_settings.json', 'Custom Messages': 'csv/message_settings.json',
'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json',
'Current Weather Prof': 'csv/current_weather.json', 'News Prof':'csv/news_settings.json'}
def openImage(self, image_file):
@ -303,13 +308,23 @@ class StockTicker():
sys.stdout.flush()
pass
return kill
def set_delay(self,speed):
if speed.lower() == 'slow':
self.delay = 0.04
elif speed.lower() == 'medium':
self.delay = 0.02
elif speed.lower() == 'fast':
self.delay = 0.01
return self.delay
def scrollFunctionsAnimated(self, options, animation = 'down'):
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
self.updateMultiple([options[0]])
kill = False
i = 0 # keep track of which image we are displaying
@ -319,7 +334,11 @@ class StockTicker():
update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],))
update_process.start()
self.delay = 0.02
settings = json.load(open(self.JSONs[options[(i) % len(options)]]))
self.set_delay(settings['speed'])
animation = settings['animation'].lower()
if options[i % len(options)] == 'Custom Images':
images = self.getUserImages()
@ -392,14 +411,165 @@ class StockTicker():
if kill: break
kill = self.scrollImage(image, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'Custom GIFs')
try:
pause = float(settings['pause'])
except:
pause = 0
pause_frames = int(float(pause)/self.delay)
kill = self.scrollImage(image, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'Custom GIFs', pause_frames = pause_frames)
if kill: break
if kill:break
update_process.join()
i+=1
def scrollProfessionalAnimated(self, options, animation = 'on'):
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
self.updateMultiple(options[0:2])
kill = False
i1 = 0 # keep track of which image we are displaying
i2 = 1 # keep track of which image we are displaying
self.double_buffer = self.matrix.CreateFrameCanvas()
update_process = Process(target = self.updateMultiple, args = ([options[(max(i1,i2)+1) % len(options)]],))
update_process.start()
image1 = self.openImage('./display_images/' + options[i1 % len(options)] +'.ppm')
image1 = image1.convert('RGB')
print(options[i2 % len(options)])
image2 = self.openImage('./display_images/' + options[i2 % len(options)] +'.ppm')
image2 = image2.convert('RGB')
settings1 = json.load(open(self.JSONs[options[0]]))
delay_t1 = self.set_delay(settings1['speed'])
animation1 = settings1['animation'].lower()
settings2 = json.load(open(self.JSONs[options[1]]))
delay_t2 = self.set_delay(settings2['speed'])
animation2 = settings2['animation'].lower()
if animation1 == 'traditional':
offset_y1 = 0
offset_x1 = 128
else:
offset_y1 = -16
offset_x1 = 0
if animation2 == 'traditional':
offset_y2 = 16
offset_x2 = 128
else:
offset_y2 = 32
offset_x2 = 0
frame_skip = int((1/15)/self.delay) #controls how fast gifs run
self.frame = 0
img_width1, img_height1 = image1.size
img_width2, img_height2 = image2.size
kill = False
delay_t1 = 0.02
delay_t2 = 0.025
update_t1 = time.time()
update_t2 = time.time()
while True:
if offset_x1 < -(img_width1+1):
i1 = max(i1, i2) + 1
settings1 = json.load(open(self.JSONs[options[i1 % len(options)]]))
delay_t1 = self.set_delay(settings1['speed'])
animation1 = settings1['animation'].lower()
if animation1 == 'traditional':
offset_y1 = 0
offset_x1 = 128
else:
offset_y1 = -16
offset_x1 = 0
update_process.join()
update_process = Process(target = self.updateMultiple, args = ([options[i1 % len(options)]],))
update_process.start()
image1 = self.openImage('./display_images/' + options[i1 % len(options)] +'.ppm')
image1 = image1.convert('RGB')
img_width1, img_height1 = image1.size
if offset_x2 < -(img_width2+1):
i2 = max(i1, i2) + 1
settings2 = json.load(open(self.JSONs[options[(i2) % len(options)]]))
delay_t2 = self.set_delay(settings2['speed'])
animation2 = settings2['animation'].lower()
if animation2 == 'traditional':
offset_y2 = 16
offset_x2 = 128
else:
offset_y2 = 32
offset_x2 = 0
update_process.join()
update_process = Process(target = self.updateMultiple, args = ([options[i2 % len(options)]],))
update_process.start()
image2 = self.openImage('./display_images/' + options[i2 % len(options)] +'.ppm')
image2 = image2.convert('RGB')
img_width2, img_height2 = image2.size
if time.time() - update_t1 > delay_t1:
update_t1 = time.time()
if offset_y1 < 0:
offset_y1+=1
else:
offset_x1 -= 1
if time.time() - update_t2 > delay_t2:
update_t2 = time.time()
if offset_y2 > 16:
offset_y2-=1
else:
offset_x2 -= 1
if kill: break
#image = image.convert('RGB')
self.double_buffer.SetImage(image1, offset_x1, offset_y1)
self.double_buffer.SetImage(image2, offset_x2, offset_y2)
buff = 0
# remove the ppixels behind the image, to stop trailing
self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer)
for y in range(16):
self.matrix.SetPixel(offset_x1 + img_width1 +1 , y , 0,0,0)
self.matrix.SetPixel(offset_x1 + img_width1 , y , 0,0,0)
for y in range(16,32):
self.matrix.SetPixel(offset_x2 + img_width2 +1 , y , 0,0,0)
self.matrix.SetPixel(offset_x2 + img_width2 , y , 0,0,0)
kill = self.checkKilled()
if kill: break
if kill: break
def scrollMultiple(self, animation = 'down'):
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
@ -2060,118 +2230,7 @@ class StockTicker():
if kill:
break
def scrollProfessionalAnimated(self, options, animation = 'on'):
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
print(options[0:2])
self.updateMultiple(options[0:2])
kill = False
i1 = 0 # keep track of which image we are displaying
i2 = 1 # keep track of which image we are displaying
self.double_buffer = self.matrix.CreateFrameCanvas()
update_process = Process(target = self.updateMultiple, args = ([options[(max(i1,i2)+1) % len(options)]],))
update_process.start()
image1 = self.openImage('./display_images/' + options[i1 % len(options)] +'.ppm')
image1 = image1.convert('RGB')
print(options[i2 % len(options)])
image2 = self.openImage('./display_images/' + options[i2 % len(options)] +'.ppm')
image2 = image2.convert('RGB')
offset_x1 = 0
offset_x2 = 0
offset_y1 = -16
offset_y2 = 32
frame_skip = int((1/15)/self.delay) #controls how fast gifs run
self.frame = 0
img_width1, img_height1 = image1.size
img_width2, img_height2 = image2.size
kill = False
delay_t1 = 0.02
delay_t2 = 0.025
update_t1 = time.time()
update_t2 = time.time()
while True:
if offset_x1 < -(img_width1+1):
i1 = max(i1, i2) + 1
offset_x1 = 0
offset_y1 = -16
update_process.join()
update_process = Process(target = self.updateMultiple, args = ([options[(max(i1,i2)+1) % len(options)]],))
update_process.start()
image1 = self.openImage('./display_images/' + options[i1 % len(options)] +'.ppm')
image1 = image1.convert('RGB')
img_width1, img_height1 = image1.size
if offset_x2 < -(img_width2+1):
i2 = max(i1, i2) + 1
offset_x2 = 0
offset_y2 = 32
update_process.join()
update_process = Process(target = self.updateMultiple, args = ([options[(max(i1,i2)+1) % len(options)]],))
update_process.start()
image2 = self.openImage('./display_images/' + options[i2 % len(options)] +'.ppm')
image2 = image2.convert('RGB')
img_width2, img_height2 = image2.size
if time.time() - update_t1 > delay_t1:
update_t1 = time.time()
if offset_y1 < 0:
offset_y1+=1
else:
offset_x1 -= 1
if time.time() - update_t2 > delay_t2:
update_t2 = time.time()
if offset_y2 > 16:
offset_y2-=1
else:
offset_x2 -= 1
if kill: break
#image = image.convert('RGB')
self.double_buffer.SetImage(image1, offset_x1, offset_y1)
self.double_buffer.SetImage(image2, offset_x2, offset_y2)
buff = 0
# remove the ppixels behind the image, to stop trailing
self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer)
for y in range(16):
self.matrix.SetPixel(offset_x1 + img_width1 +1 , y , 0,0,0)
self.matrix.SetPixel(offset_x1 + img_width1 , y , 0,0,0)
for y in range(16,32):
self.matrix.SetPixel(offset_x2 + img_width2 +1 , y , 0,0,0)
self.matrix.SetPixel(offset_x2 + img_width2 , y , 0,0,0)
kill = self.checkKilled()
if kill: break
if kill: break
def process_msg(self, msg):

View File

@ -280,11 +280,12 @@
</div>
<div class="col-auto">
<select id="inputTransition" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -483,11 +484,10 @@
</div>
<div class="col-auto">
<select id="inputTransition2" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -684,11 +684,9 @@
</div>
<div class="col-auto">
<select id="inputTransition3" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -887,11 +885,10 @@
</div>
<div class="col-auto">
<select id="inputTransition4" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -1073,11 +1070,10 @@
</div>
<div class="col-auto">
<select id="inputTransition5" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -1277,11 +1273,10 @@
</div>
<div class="col-auto">
<select id="inputTransition6" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -1450,11 +1445,10 @@
</div>
<div class="col-auto">
<select id="inputTransition7" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -1577,11 +1571,10 @@
</div>
<div class="col-auto">
<select id="inputTransition8" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -1704,11 +1697,10 @@
</div>
<div class="col-auto">
<select id="inputTransition9" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -1830,11 +1822,10 @@
</div>
<div class="col-auto">
<select id="inputTransition10" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -1977,11 +1968,10 @@
</div>
<div class="col-auto">
<select id="inputTransition11" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -2130,11 +2120,10 @@
</div>
<div class="col-auto">
<select id="inputTransition12" class="form-select animation-select">
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
</select>
</div>
</div>
@ -2282,11 +2271,10 @@
</div>
<div class="col-auto">
<select id="inputTransition13" class="form-select animation-select">
<option>Down</option>
<option>Up</option>
<option>Traditional</option>
<option>Continuous</option>
<option>None</option>
<option>Top to bottom</option>
<option>Bottom to Top</option>
<option>Pause</option>
</select>
</div>
</div>
@ -2442,7 +2430,9 @@
type="checkbox"
value=""
id="flexCheckChecked29"
checked
{% if message_settings.title%}
checked
{%endif%}
/>
</div>
</div>
@ -2454,6 +2444,10 @@
id="messages-features"
class="display-features-list text-dark message-list"
>
{% for f in message_settings.messages %}
<li>{{f.name}}</li>
{% endfor%}
</ul>