Merge pull request #21 from fin-tic/dev

update 1.3.8
This commit is contained in:
Justin 2023-09-22 19:45:23 +08:00 committed by GitHub
commit 4c1e196367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 7279 additions and 498 deletions

113
clock_screensaver.py Normal file
View File

@ -0,0 +1,113 @@
import time
from datetime import datetime
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
import json
import pytz
try:
with open('clock_screensaver.json', 'r') as f:
settings = json.load(f)['clock1']
except:
settings1 = {"clock1": {"time_color": "White", "weekday_color": "Cyan", "date_color": "Blue", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "clock2": {"time_color": "Orange", "date_color": "White", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "world_clock": {"city_color": "White", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}}
with open('clock_screensaver.json', 'w') as f:
json.dump(settings1, f)
settings = settings1['clock1']
# Configuration for the LED matrix
options = RGBMatrixOptions()
options.rows = 32
options.cols = 128
options.chain_length = 1
options.parallel = 1
options.hardware_mapping = 'adafruit-hat' # Change this if you have a different GPIO mapping
options.gpio_slowdown = 2
options.brightness = int(settings['brightness'])*10
# Create the RGBMatrix object
matrix = RGBMatrix(options=options)
# Create a canvas to draw on
canvas = matrix.CreateFrameCanvas()
# Set the font and text color
font = graphics.Font()
font.LoadFont("fonts/6x12.bdf") # Change this to the path of your desired font file
font2 = graphics.Font()
font2.LoadFont("fonts/8x13B.bdf")
color = graphics.Color(255, 255, 255) # White color
timezone = pytz.timezone(settings['timezone'])
time_colors = {
"White": graphics.Color(255,255,255),
"Red": graphics.Color(255, 0,0),
"Green": graphics.Color(0,255,0),
"Dark Green": graphics.Color(0, 100,0),
"Blue": graphics.Color(0,0,255),
"Purple": graphics.Color(145,0,255),
"Pink": graphics.Color(255,0,255),
"Yellow": graphics.Color(255,255,0),
"Orange": graphics.Color(255,130,0),
"Gold": graphics.Color(255,190,0),
"Gray": graphics.Color(100,100,100),
"Cyan": graphics.Color(0,255,255)
}
colon_visible = False
while True:
# Clear the canvas
canvas.Clear()
# Get the current time, weekday, and date
if settings['12hour']:
if settings['display_pm'] and settings['display_seconds']:
current_time = datetime.now(timezone).strftime("%I:%M:%S %p")
elif settings['display_pm'] and not settings['display_seconds']:
current_time = datetime.now(timezone).strftime("%I:%M %p")
elif not settings['display_pm'] and settings['display_seconds']:
current_time = datetime.now(timezone).strftime("%I:%M:%S")
else:
current_time = datetime.now(timezone).strftime("%I:%M")
else:
if settings['display_pm'] and settings['display_seconds']:
current_time = datetime.now(timezone).strftime("%H:%M:%S %p")
elif settings['display_pm'] and not settings['display_seconds']:
current_time = datetime.now(timezone).strftime("%H:%M %p")
elif not settings['display_pm'] and settings['display_seconds']:
current_time = datetime.now(timezone).strftime("%H:%M:%S")
else:
current_time = datetime.now(timezone).strftime("%H:%M")
if colon_visible:
current_time = current_time.replace(":", " ")
colon_visible = False
else:
colon_visible = True
current_weekday = datetime.now(timezone).strftime("%A")
current_date = datetime.now(timezone).strftime("%d %b %Y")
weekday_width = graphics.DrawText(canvas, font, 0, 0, color, current_weekday.upper())
time_width = graphics.DrawText(canvas, font2, 0, 0, time_colors[settings['time_color']], current_time)
date_width = graphics.DrawText(canvas, font, 0, 0, time_colors[settings['date_color']], current_date.upper())
canvas.Clear()
x_coordinate_weekday = int((options.cols - weekday_width) / 2)
x_coordinate_time = int((options.cols - time_width) / 2)
x_coordinate_date = int((options.cols - date_width) /2)
# Draw the time, weekday, and date on the canvas
graphics.DrawText(canvas, font2, x_coordinate_time, 12, time_colors[settings['time_color']], current_time)
graphics.DrawText(canvas, font, x_coordinate_weekday, 22, time_colors[settings['weekday_color']], current_weekday.upper())
graphics.DrawText(canvas, font, x_coordinate_date, 31, time_colors[settings['date_color']], current_date.upper())
# Swap the canvas onto the matrix
canvas = matrix.SwapOnVSync(canvas)
# Wait for 1 second before updating the clock
time.sleep(0.5)

88
clock_screensaver2.py Normal file
View File

@ -0,0 +1,88 @@
import time
from datetime import datetime
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
import json
import pytz
try:
with open('clock_screensaver.json', 'r') as f:
settings = json.load(f)['clock2']
except:
settings1 = {"clock1": {"time_color": "White", "weekday_color": "Cyan", "date_color": "Blue", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "clock2": {"time_color": "Orange", "date_color": "White", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "world_clock": {"city_color": "White", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}}
with open('clock_screensaver.json', 'w') as f:
json.dump(settings1, f)
settings = settings1['clock2']
# Configuration for the LED matrix
options = RGBMatrixOptions()
options.rows = 32
options.cols = 128
options.chain_length = 1
options.parallel = 1
options.hardware_mapping = 'adafruit-hat' # Change this if you have a different GPIO mapping
options.gpio_slowdown = 2
options.brightness = int(settings['brightness']) * 10
# Create the RGBMatrix object
matrix = RGBMatrix(options=options)
# Create a canvas to draw on
canvas = matrix.CreateFrameCanvas()
timezone = pytz.timezone(settings['timezone'])
# Set the font and text color
font = graphics.Font()
font.LoadFont("fonts/clR6x12.bdf")
#font.LoadFont("fonts/6x12.bdf") # Change this to the path of your desired font file
font2 = graphics.Font()
font2.LoadFont("fonts/texgyre-27.bdf")
time_colors = {
"White": graphics.Color(255,255,255),
"Red": graphics.Color(255, 0,0),
"Green": graphics.Color(0,255,0),
"Dark Green": graphics.Color(0, 100,0),
"Blue": graphics.Color(0,0,255),
"Purple": graphics.Color(145,0,255),
"Pink": graphics.Color(255,0,255),
"Yellow": graphics.Color(255,255,0),
"Orange": graphics.Color(255,130,0),
"Gold": graphics.Color(255,190,0),
"Gray": graphics.Color(100,100,100),
"Cyan": graphics.Color(0,255,255)
}
colon_visible = False
while True:
canvas.Clear()
if settings['12hour']:
if settings['display_pm']:
current_time = datetime.now(timezone).strftime("%I:%M %p")
else:
current_time = datetime.now(timezone).strftime("%I:%M")
else:
if settings['display_pm']:
current_time = datetime.now(timezone).strftime("%H:%M %p")
else:
current_time = datetime.now(timezone).strftime("%H:%M")
if colon_visible:
current_time = current_time.replace(":", " ")
colon_visible = False
else:
colon_visible = True
current_date = datetime.now(timezone).strftime("%a %d %b %Y")
date_width = graphics.DrawText(canvas, font, 0, 0, time_colors[settings['date_color']], current_date.upper())
time_width = graphics.DrawText(canvas, font2, 0, 0, time_colors[settings['time_color']], current_time)
canvas.Clear()
x_coordinate_time = int((options.cols - time_width) / 2)
x_coordinate_date = int((options.cols - date_width) /2)
graphics.DrawText(canvas, font2, x_coordinate_time, 21, time_colors[settings['time_color']], current_time)
graphics.DrawText(canvas, font, x_coordinate_date, 31, time_colors[settings['date_color']], current_date.upper())
canvas = matrix.SwapOnVSync(canvas)
time.sleep(0.5)

View File

@ -1 +1 @@
{"scheduler":{"force": false}, "stocks": {"time": "14/06/2022 06:42:06", "force": false}, "crypto": {"time": "14/06/2022 06:58:18", "force": false}, "news": {"time": "14/06/2022 05:29:08", "force": false}, "weather": {"time": "14/06/2022 05:29:08", "force": false}, "forex": {"time": "14/06/2022 05:29:14", "force": false}, "sports_l": {"time": "14/06/2022 04:42:37", "force": false}, "sports_p": {"time": "14/06/2022 06:27:34", "force": false}, "sports_u": {"time": "14/06/2022 06:28:34", "force": false}, "sports_t": {"time": "14/06/2022 06:26:23", "force": false}, "commodities": {"time": "14/06/2022 06:51:07", "force": false}, "indices": {"time": "05/10/2022 04:06:10", "force": false}, "movies": {"time": "05/10/2022 02:31:40", "force": false}, "ipo": {"time": "05/10/2022 02:31:40", "force": false}, "prepost": {"time": "05/10/2022 02:31:40", "force": false}, "economic": {"time": "05/10/2022 02:31:40", "force": false}, "jokes": {"time": "05/10/2022 02:31:40", "force": false}}
{"scheduler":{"force": false}, "stocks": {"time": "14/06/2022 06:42:06", "force": false}, "crypto": {"time": "14/06/2022 06:58:18", "force": false}, "news": {"time": "14/06/2022 05:29:08", "force": false}, "weather": {"time": "14/06/2022 05:29:08", "force": false}, "forex": {"time": "14/06/2022 05:29:14", "force": false}, "sports_l": {"time": "14/06/2022 04:42:37", "force": false}, "sports_p": {"time": "14/06/2022 06:27:34", "force": false}, "sports_u": {"time": "14/06/2022 06:28:34", "force": false}, "sports_t": {"time": "14/06/2022 06:26:23", "force": false}, "commodities": {"time": "14/06/2022 06:51:07", "force": false}, "indices": {"time": "05/10/2022 04:06:10", "force": false}, "movies": {"time": "05/10/2022 02:31:40", "force": false}, "ipo": {"time": "05/10/2022 02:31:40", "force": false}, "prepost": {"time": "05/10/2022 02:31:40", "force": false}, "economic": {"time": "05/10/2022 02:31:40", "force": false}, "jokes": {"time": "05/10/2022 02:31:40", "force": false}, "market": {"time": "05/10/2022 02:31:40", "force": false}, "sector": {"time": "05/10/2022 02:31:40", "force": false}}

View File

@ -32,6 +32,7 @@ try:
last_updates['stocks']['force'] = True
last_updates['prepost']['force'] = True
last_updates['sports_l']['force'] = True
last_updates['market']['force'] = True
f = open('csv/last_updates.json', 'w')
json.dump(last_updates, f)
f.close()
@ -145,7 +146,16 @@ def getCookiesnCrumb():
with open('crumb.txt', 'w') as f:
f.write(crumb)
def human_format(num):
num = float('{:.3g}'.format(num))
magnitude = 0
while abs(num) >= 1000:
magnitude += 1
num /= 1000.0
return '{}{}'.format('{:f}'.format(num).rstrip('0').rstrip('.'), ['', 'K', 'M', 'B', 'T'][magnitude])
def updateStocks(api_key, logf):
try:
@ -154,7 +164,7 @@ def updateStocks(api_key, logf):
all_stocks_settings = json.load(f)
f.close()
except:
all_stocks_settings = {"feature": "Stocks", "speed": "medium", "speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"AAPL": {"current": "164.02", "change": "-1.59", "percent_change": "-0.97"}, "MSFT": {"current": "288.29", "change": "-1.32", "percent_change": "-0.46"}, "GOOG": {"current": "2586.74", "change": "-34.01", "percent_change": "-1.31"}, "NFLX": {"current": "380.52", "change": "-7.59", "percent_change": "-1.99"}}, "prepost": False}
all_stocks_settings = {"feature": "Stocks", "speed": "medium", "speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"AAPL": {"current": "164.02", "change": "-1.59", "percent_change": "-0.97"}, "MSFT": {"current": "288.29", "change": "-1.32", "percent_change": "-0.46"}, "GOOG": {"current": "2586.74", "change": "-34.01", "percent_change": "-1.31"}, "NFLX": {"current": "380.52", "change": "-7.59", "percent_change": "-1.99"}}, "prepost": False, "lohivol": False, "display_name": False}
stock_info = all_stocks_settings['symbols']
symbols = list(stock_info.keys())
@ -163,7 +173,7 @@ def updateStocks(api_key, logf):
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'}
# url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/stocks?symbols='
url1 = 'https://query1.finance.yahoo.com/v7/finance/quote?fields=regularMarketPrice,regularMarketChangePercent,regularMarketChange&region=US&lang=en-US&symbols='
url1 = 'https://query1.finance.yahoo.com/v7/finance/quote?fields=longName,regularMarketPrice,regularMarketChangePercent,regularMarketChange,regularMarketDayHigh,regularMarketDayLow,regularMarketVolume&region=US&lang=en-US&symbols='
url2 = 'https://cloud.iexapis.com/v1/stock/market/batch?&types=quote&token=pk_aff870df1a984daa9dd43c71801c1936&symbols='
url = random.choice([url1, url2])
@ -177,7 +187,10 @@ def updateStocks(api_key, logf):
if len(data) > 0:
for symbol in symbols:
try:
stock_info[data[symbol]['quote']['symbol']] = {'current': data[symbol]['quote']['latestPrice'], 'change': data[symbol]['quote']['change'], 'percent_change':data[symbol]['quote']['changePercent'] * 100}
if 'name' in stock_info[data[symbol]['quote']['symbol']] and stock_info[data[symbol]['quote']['symbol']]['name'] != '':
stock_info[data[symbol]['quote']['symbol']] = {'current': str(data[symbol]['quote']['latestPrice']), 'change': str(data[symbol]['quote']['change']), 'percent_change': str(data[symbol]['quote']['changePercent'] * 100), 'day_low': str(data[symbol]['quote']['low']), 'day_high': str(data[symbol]['quote']['high']), 'volume': str(human_format(data[symbol]['quote']['latestVolume'])), 'name': stock_info[data[symbol]['quote']['symbol']]['name']}
else:
stock_info[data[symbol]['quote']['symbol']] = {'current': str(data[symbol]['quote']['latestPrice']), 'change': str(data[symbol]['quote']['change']), 'percent_change': str(data[symbol]['quote']['changePercent'] * 100), 'day_low': str(data[symbol]['quote']['low']), 'day_high': str(data[symbol]['quote']['high']), 'volume': str(human_format(data[symbol]['quote']['latestVolume'])), 'name': data[symbol]['quote']['companyName'].split(' - ')[0].replace('Corp.', 'Corp').replace('Corporation', 'Corp')}
except:
pass
all_stocks_settings['symbols'] = stock_info
@ -215,8 +228,10 @@ def updateStocks(api_key, logf):
for symbol in symbols:
try:
for stock in data['quoteResponse']['result']:
if stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B') == symbol:
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] = {'current': stock['regularMarketPrice'], 'change': stock['regularMarketChange'], 'percent_change':stock['regularMarketChangePercent']}
if stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B') == symbol and 'name' in stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] and stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['name'] != '':
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] = {'current': str(stock['regularMarketPrice']), 'change': str(stock['regularMarketChange']), 'percent_change': str(stock['regularMarketChangePercent']), 'day_low': str(stock['regularMarketDayLow']), 'day_high': str(stock['regularMarketDayHigh']), 'volume': str(human_format(stock['regularMarketVolume'])), 'name': stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['name']}
elif stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B') == symbol and 'name' not in stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]:
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] = {'current': str(stock['regularMarketPrice']), 'change': str(stock['regularMarketChange']), 'percent_change': str(stock['regularMarketChangePercent']), 'day_low': str(stock['regularMarketDayLow']), 'day_high': str(stock['regularMarketDayHigh']), 'volume': str(human_format(stock['regularMarketVolume'])), 'name': stock['longName'].replace(',','').replace('Inc.','Inc').replace('Corporation', 'Corp').replace('Ltd.', 'Ltd').replace('Limited','Ltd')}
except:
pass
all_stocks_settings['symbols'] = stock_info
@ -364,15 +379,6 @@ def updateCommodities(api_key, logf):
#logf.write('. type: ' + str(exc_type))
#logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
#logf.close()
def human_format(num):
num = float('{:.3g}'.format(num))
magnitude = 0
while abs(num) >= 1000:
magnitude += 1
num /= 1000.0
return '{}{}'.format('{:f}'.format(num).rstrip('0').rstrip('.'), ['', 'K', 'M', 'B', 'T'][magnitude])
def updateMovies(api_key, logf):
@ -613,7 +619,7 @@ def updateCrypto(api_key, logf):
all_crypto_settings = json.load(f)
f.close()
except:
all_crypto_settings = {"feature": "Stocks", "speed": "medium","speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"ETH,USD": {"current": "2629.32", "24hr_change": "-27.6432", "percent_change": "-1.04"}, "BTC,USD": {"current": "38161.00", "24hr_change": "-50.8386", "percent_change": "-0.13"}, "BNB,USD": {"current": "372.57", "24hr_change": "0.4140", "percent_change": "0.11"}, "ADA,BTC": {"current": "0.0000", "24hr_change": "-0.0000", "percent_change": "-3.74"}}}
all_crypto_settings = {"feature": "Stocks", "speed": "medium","speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "lohivol": False, "display_name": False, "symbols": {"ETH,USD": {"current": "2629.32", "24hr_change": "-27.6432", "percent_change": "-1.04"}, "BTC,USD": {"current": "38161.00", "24hr_change": "-50.8386", "percent_change": "-0.13"}, "BNB,USD": {"current": "372.57", "24hr_change": "0.4140", "percent_change": "0.11"}, "ADA,BTC": {"current": "0.0000", "24hr_change": "-0.0000", "percent_change": "-3.74"}}}
coin_info = all_crypto_settings['symbols']
symbol_base = list(coin_info.keys())
@ -642,7 +648,7 @@ def updateCrypto(api_key, logf):
if symbol.upper() + ',' + base.upper() == sb:
coin_info[symbol.upper() + ',' + base.upper()] = {'current': d['price'], '24hr_change': d['price_over_24hr'], 'percent_change': d['percent_over_24hr']}
coin_info[symbol.upper() + ',' + base.upper()] = {'current': d['price'], '24hr_change': d['price_over_24hr'], 'percent_change': d['percent_over_24hr'], 'volume': human_format(d['volume']), 'day_low': d['day_low'], 'day_high': d['day_high'], 'name': d['name']}
all_crypto_settings['symbols'] = coin_info
with open('csv/crypto_settings.json', 'w+') as f:
@ -851,6 +857,94 @@ def updateJokes(api_key, logf):
pass
def updateMarket(api_key, logf):
try:
try:
f = open('csv/market_settings.json', 'r')
all_market_settings = json.load(f)
f.close()
except:
all_market_settings = {"feature": "Gainers, Losers, Active", "speed": "medium", "speed2": "medium", "animation": "up", "percent": True, "point": True, "logos": True, "chart": False, "title": True, "lohivol": False, "display_name": False, "categories": ["Top Gainers", "Top Losers", "Most Active"], "gainers": {}, "losers": {}, "mostactive": {}}
try:
f = open('csv/sector_settings.json', 'r')
all_sector_settings = json.load(f)
f.close()
except:
all_sector_settings = {"feature": "Sector Performance", "speed": "medium", "speed2": "medium", "animation": "up", "logos": True, "title": True, "sectors": ["Energy", "Financials", "Real Estate", "Technology"], "data": {}}
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'}
url = 'https://cloud.iexapis.com/stable/stock/market/overview?token=pk_aff870df1a984daa9dd43c71801c1936&'
data = requests.get(url, headers=headers).json()
mostactive = data['mostactive']
gainers = data['gainers']
losers = data['losers']
sectors = data['sectorPerformance']
all_market_settings['losers'] = {}
all_market_settings['gainers'] = {}
all_market_settings['mostactive'] = {}
all_sector_settings['data'] = {}
try:
for item in losers:
all_market_settings['losers'][item['symbol']] = {
"current": str(item['latestPrice']),
"change": str(item['change']),
"percent_change": str(item['changePercent'] * 100),
"day_low": str(item['low']),
"day_high": str(item['high']),
"volume": human_format(item['latestVolume']),
"name": item['companyName'].split(' - ')[0].replace('Corp.', 'Corp').replace('Corporation', 'Corp')
}
except:
pass
try:
for item in gainers:
all_market_settings['gainers'][item['symbol']] = {
"current": str(item['latestPrice']),
"change": str(item['change']),
"percent_change": str(item['changePercent'] * 100),
"day_low": str(item['low']),
"day_high": str(item['high']),
"volume": human_format(item['latestVolume']),
"name": item['companyName'].split(' - ')[0].replace('Corp.', 'Corp').replace('Corporation', 'Corp')
}
except:
pass
try:
for item in mostactive:
all_market_settings['mostactive'][item['symbol']] = {
"current": str(item['latestPrice']),
"change": str(item['change']),
"percent_change": str(item['changePercent'] * 100),
"day_low": str(item['low']),
"day_high": str(item['high']),
"volume": human_format(item['latestVolume']),
"name": item['companyName'].split(' - ')[0].replace('Corp.', 'Corp').replace('Corporation', 'Corp')
}
except:
pass
try:
for item in sectors:
all_sector_settings['data'][item['name']] = {
"current": str(item['performance'] * 100),
"name": str(item['name']),
"symbol": str(item['symbol'])
}
except:
pass
with open('csv/market_settings.json', 'w+') as f:
json.dump(all_market_settings, f)
with open('csv/sector_settings.json', 'w+') as f:
json.dump(all_sector_settings, f)
except:
pass
def updateNews(api_key, logf):
try:
try:
@ -1534,7 +1628,7 @@ if __name__ == '__main__':
t = time.time()
update_frequencies = {'stocks':2, 'crypto':7, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440, 'commodities': 15, 'indices': 15, 'movies': 1440, 'ipo': 1440, 'prepost': 15, 'economic': 15, 'jokes': 15} #minutes
update_frequencies = {'stocks':2, 'crypto':7, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440, 'commodities': 15, 'indices': 15, 'movies': 1440, 'ipo': 1440, 'prepost': 15, 'economic': 15, 'jokes': 15, 'market': 5} #minutes
NY_zone = pytz.timezone('America/New_York')
CET_zone = pytz.timezone('EST')
@ -1612,7 +1706,7 @@ if __name__ == '__main__':
"forex": {"time": "06/03/2022 03:54:02", "force": True}, "sports_l": {"time": "06/03/2022 04:10:09", "force": True},
"sports_p": {"time": "06/03/2022 04:10:09", "force": True},
"sports_u": {"time": "06/03/2022 04:10:09", "force": True},"sports_t": {"time": "06/03/2022 04:10:09", "force": True}, "commodities": {"time": "06/03/2022 04:10:09", "force": True}, "indices": {"time": "06/03/2022 04:10:09", "force": True}, "movies": {"time": "06/03/2022 04:10:09", "force": True}, "ipo": {"time": "06/03/2022 04:10:09", "force": True},
"prepost": {"time": "06/03/2022 04:10:09", "force": True}, "economic": {"time": "06/03/2022 04:10:09", "force": True}, "jokes": {"time": "06/03/2022 04:10:09", "force": True}}
"prepost": {"time": "06/03/2022 04:10:09", "force": True}, "economic": {"time": "06/03/2022 04:10:09", "force": True}, "jokes": {"time": "06/03/2022 04:10:09", "force": True}, "market": {"time": "06/03/2022 04:10:09", "force": True}, "sector": {"time": "06/03/2022 04:10:09", "force": True}}
try:
if last_updates['scheduler']['force']:
@ -1755,7 +1849,29 @@ if __name__ == '__main__':
update_process.start()
update_processes.append(update_process)
# market
market_time = datetime.strptime(last_updates['market']['time'], "%d/%m/%Y %H:%M:%S")
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
diff = (NY_time - market_time).total_seconds()/60 #minutes
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
opening = NY_time.replace(hour=9, minute=30, second=0, microsecond=0).replace(tzinfo=None)
closing = NY_time.replace(hour=16, minute=20, second=0, microsecond=0).replace(tzinfo=None)
stock_open = opening < NY_time < closing and datetime.today().weekday() <= 4
if last_updates['market']['force'] or (diff >= update_frequencies['market'] and stock_open):# or msg == 'c':
market_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
last_updates['market']['time'] = market_time
last_updates['market']['force'] = False
last_updates['sector']['time'] = market_time
last_updates['sector']['force'] = False
update_process = Process(target = updateMarket, args = (api_key,logf))
update_process.start()
update_processes.append(update_process)
# jokes
jokes_time = datetime.strptime(last_updates['jokes']['time'], "%d/%m/%Y %H:%M:%S")

BIN
feature_titles/market.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

BIN
feature_titles/sector.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

BIN
logos/active.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

BIN
logos/active_prof.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

BIN
logos/gainers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

BIN
logos/gainers_prof.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

View File

@ -0,0 +1,8 @@
{\rtf1\ansi\ansicpg1252\cocoartf2513
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\f0\fs24 \cf0 add global stock logos here }

BIN
logos/losers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

BIN
logos/losers_prof.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

BIN
logos/sector/Energy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

BIN
logos/sector/Financials.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

BIN
logos/sector/Materials.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

BIN
logos/sector/Technology.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

BIN
logos/sector/Utilities.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

585
server.py
View File

@ -5,6 +5,7 @@
# stockTicker can not be copied and/or distributed without the express
# permission of Neythen Treloar
from PIL import Image
from flask import Flask, render_template, request
from stockTicker import StockTicker
from werkzeug.utils import secure_filename
@ -26,6 +27,7 @@ import urllib.request
import sys
#stock_ticker = StockTicker()
import traceback
import requests
#open('log.txt', 'w').close() #wipe logs
@ -145,7 +147,7 @@ def index():
global command
all_features = ['Current Weather','Daily Forecast','News', 'Sports (Upcoming Games)','Sports (Past Games)','Sports (Live Games)',
'Sports (Team Stats)','Custom Images', 'Custom GIFs', 'Custom Messages', 'Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Movies',
'IPO Calendar', 'Economic Calendar', 'Jokes']
'IPO Calendar', 'Economic Calendar', 'Jokes', 'Gainers, Losers, Active', 'Sector Performance', 'Place (Reddit)', 'Clock 1' , 'Clock 2', 'World Clock']
global professional
@ -207,7 +209,7 @@ def index():
stocks_settings = json.load(f)
f.close()
except:
stocks_settings = {"feature": "Stocks", "speed": "medium", "speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"AAPL": {"current": "164.02", "change": "-1.59", "percent_change": "-0.97"}, "MSFT": {"current": "288.29", "change": "-1.32", "percent_change": "-0.46"}, "GOOG": {"current": "2586.74", "change": "-34.01", "percent_change": "-1.31"}, "NFLX": {"current": "380.52", "change": "-7.59", "percent_change": "-1.99"}}, "prepost": False}
stocks_settings = {"feature": "Stocks", "speed": "medium", "speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"AAPL": {"current": "164.02", "change": "-1.59", "percent_change": "-0.97"}, "MSFT": {"current": "288.29", "change": "-1.32", "percent_change": "-0.46"}, "GOOG": {"current": "2586.74", "change": "-34.01", "percent_change": "-1.31"}, "NFLX": {"current": "380.52", "change": "-7.59", "percent_change": "-1.99"}}, "prepost": False, "lohivol": False, "display_name": False}
dict1 = {
"Aluminum": "ALU", "Brent Crude Oil": "BRENTOIL", "Coffee": "COFFEE", "Copper": "XCU", "Corn": "CORN", "Cotton": "COTTON", "Gold": "XAU",
@ -254,7 +256,7 @@ def index():
crypto_settings = json.load(f)
f.close()
except:
crypto_settings = {"feature": "Stocks", "speed": "medium","speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"ETH,USD": {"current": "2629.32", "24hr_change": "-27.6432", "percent_change": "-1.04"}, "BTC,USD": {"current": "38161.00", "24hr_change": "-50.8386", "percent_change": "-0.13"}, "BNB,USD": {"current": "372.57", "24hr_change": "0.4140", "percent_change": "0.11"}, "ADA,BTC": {"current": "0.0000", "24hr_change": "-0.0000", "percent_change": "-3.74"}}}
crypto_settings = {"feature": "Stocks", "speed": "medium","speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "lohivol": False, "display_name": False, "symbols": {"ETH,USD": {"current": "2629.32", "24hr_change": "-27.6432", "percent_change": "-1.04"}, "BTC,USD": {"current": "38161.00", "24hr_change": "-50.8386", "percent_change": "-0.13"}, "BNB,USD": {"current": "372.57", "24hr_change": "0.4140", "percent_change": "0.11"}, "ADA,BTC": {"current": "0.0000", "24hr_change": "-0.0000", "percent_change": "-3.74"}}}
try:
f= open('csv/movie_settings.json', 'r')
@ -269,7 +271,8 @@ def index():
f.close()
except:
ipo_settings = {"feature": "IPO", "speed": "medium", "speed2": "medium", "animation": "down", "title": True, "symbols": ["No Data"]}
with open('csv/ipo_settings.json', 'w') as f:
json.dump(ipo_settings, f)
try:
f = open('csv/forex_settings.json', 'r')
forex_settings = json.load(f)
@ -357,7 +360,8 @@ def index():
f.close()
except:
economic_settings = {"feature": "Economic Calendar", "speed": "medium", "speed2": "medium", "animation": "up", "importance": "Med - High", "title": True, "timezone": "US/Eastern", "countries": ["United States"], "events": []}
with open('csv/economic_settings.json', 'w') as f:
json.dump(economic_settings, f)
try:
f = open('csv/jokes_settings.json', 'r')
jokes_settings = json.load(f)
@ -366,14 +370,93 @@ def index():
jokes_settings['categories'] = ['Any']
except:
jokes_settings = {"feature": "Jokes", "speed": "medium", "speed2": "medium", "animation": "up", "title": True, "safe": True, "categories": ["Any"], "blacklist": [], "amount": "5", "jokes": []}
with open('csv/jokes_settings.json', 'w') as f:
json.dump(jokes_settings, f)
try:
f = open('csv/place_settings.json', 'r')
place_settings = json.load(f)
f.close()
except:
place_settings = {"feature": "Place", "speed": "medium", "speed2": "medium", "animation": "up", "title": True, "width": "128", "pause": "0", "places": ["r/place 2017", "r/place 2022"]}
with open('csv/place_settings.json', 'w') as f:
json.dump(place_settings, f)
try:
f = open('csv/market_settings.json', 'r')
market_settings = json.load(f)
f.close()
except:
market_settings = {"feature": "Gainers, Losers, Active", "speed": "medium", "speed2": "medium", "animation": "up", "percent": True, "point": True, "logos": True, "chart": False, "title": True, "lohivol": False, "display_name": False, "categories": ["Top Gainers", "Top Losers", "Most Active"], "gainers": {}, "losers": {}, "mostactive": {}}
with open('csv/market_settings.json', 'w') as f:
json.dump(market_settings, f)
try:
f = open('csv/sector_settings.json', 'r')
sector_settings = json.load(f)
f.close()
except:
sector_settings = {"feature": "Sector Performance", "speed": "medium", "speed2": "medium", "animation": "up", "logos": True, "title": True, "sectors": ["Energy", "Financials", "Real Estate", "Technology"], "data": {}}
with open('csv/sector_settings.json', 'w') as f:
json.dump(sector_settings, f)
try:
f = open('clock_screensaver.json', 'r')
clock_screensaver = json.load(f)
f.close()
except:
clock_screensaver = {"clock1": {"time_color": "White", "weekday_color": "Cyan", "date_color": "Blue", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "clock2": {"time_color": "Orange", "date_color": "White", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "world_clock": {"city_color": "White", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}}
with open('clock_screensaver.json', 'w') as f:
json.dump(clock_screensaver, f)
try:
f = open('csv/clock1_settings.json', 'r')
clock1_settings = json.load(f)
f.close()
except:
clock1_settings = {"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"}
with open('csv/clock1_settings.json', 'w') as f:
json.dump(clock1_settings, f)
try:
f = open('csv/clock2_settings.json', 'r')
clock2_settings = json.load(f)
f.close()
except:
clock2_settings = {"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"}
with open('csv/clock2_settings.json', 'w') as f:
json.dump(clock2_settings, f)
try:
f = open('csv/worldclock_settings.json', 'r')
worldclock_settings = json.load(f)
f.close()
except:
worldclock_settings = {"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"}
with open('csv/worldclock_settings.json', 'w') as f:
json.dump(worldclock_settings, f)
try:
f = open('csv/scheduler.json','r')
scheduler_settings = json.load(f)
if 'screensaver' not in str(scheduler_settings):
scheduler_settings['screensaver1'] = {}
scheduler_settings['screensaver1']['hour'] = '00'
scheduler_settings['screensaver1']['minute'] = '00'
scheduler_settings['screensaver1']['endhour'] = '00'
scheduler_settings['screensaver1']['endminute'] = '00'
scheduler_settings['screensaver1']['type'] = 'World Clock'
scheduler_settings['screensaver1']['enabled'] = False
scheduler_settings['screensaver2'] = {}
scheduler_settings['screensaver2']['hour'] = '00'
scheduler_settings['screensaver2']['minute'] = '00'
scheduler_settings['screensaver2']['endhour'] = '00'
scheduler_settings['screensaver2']['endminute'] = '00'
scheduler_settings['screensaver2']['type'] = 'Clock 2'
scheduler_settings['screensaver2']['enabled'] = False
scheduler_settings['screensaver3'] = {}
scheduler_settings['screensaver3']['hour'] = '00'
scheduler_settings['screensaver3']['minute'] = '00'
scheduler_settings['screensaver3']['endhour'] = '00'
scheduler_settings['screensaver3']['endminute'] = '00'
scheduler_settings['screensaver3']['type'] = 'Clock 1'
scheduler_settings['screensaver3']['enabled'] = False
f.close()
except:
scheduler_settings = {"shutdown": {"hour": "00", "minute": "00", "enabled": False}, "reboot":{"hour": "00", "minute": "00", "enabled": False}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}}
scheduler_settings = {"shutdown": {"hour": "00", "minute": "00", "enabled": False}, "reboot":{"hour": "00", "minute": "00", "enabled": False}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "screensaver1":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"World Clock", "enabled": False}, "screensaver2":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 1", "enabled": False}, "screensaver3":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 2", "enabled": False}}
# try: # incase this doesnt exist
# api_keys = api_key2[1]
# except:
@ -428,7 +511,14 @@ def index():
'scheduler_settings':scheduler_settings,
'economic_settings':economic_settings,
'jokes_settings':jokes_settings,
'networks_list': networks_list
'place_settings':place_settings,
'market_settings':market_settings,
'sector_settings':sector_settings,
'networks_list': networks_list,
'clock_screensaver': clock_screensaver,
'clock1_settings': clock1_settings,
'clock2_settings': clock2_settings,
'worldclock_settings': worldclock_settings
}
@ -444,7 +534,7 @@ def scheduled_brightness():
schedules = json.load(f)
f.close()
except:
schedules = {"shutdown": {"hour": "00", "minute": "00", "enabled": False}, "reboot":{"hour": "00", "minute": "00", "enabled": False}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}}
schedules = {"shutdown": {"hour": "00", "minute": "00", "enabled": False}, "reboot":{"hour": "00", "minute": "00", "enabled": False}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "screensaver1":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"World Clock", "enabled": False}, "screensaver2":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 1", "enabled": False}, "screensaver3":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 2", "enabled": False}}
timezone_brightness = schedules['timezone']
@ -528,17 +618,133 @@ scheduled_b = Process(target=scheduled_brightness)
scheduled_b.start()
def scheduled_screensaver():
already_running_screensaver_1 = False
already_running_screensaver_2 = False
already_running_screensaver_3 = False
try:
while True:
try:
f = open('csv/scheduler.json','r')
schedules = json.load(f)
f.close()
except:
schedules = {"shutdown": {"hour": "00", "minute": "00", "enabled": False}, "reboot":{"hour": "00", "minute": "00", "enabled": False}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "screensaver1":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"World Clock", "enabled": False}, "screensaver2":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 1", "enabled": False}, "screensaver3":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 2", "enabled": False}}
timezone_screensaver = schedules['timezone']
try:
screensaver1_hour = schedules['screensaver1']['hour']
screensaver1_minute = schedules['screensaver1']['minute']
screensaver1_enabled = schedules['screensaver1']['enabled']
screensaver1_type = [schedules['screensaver1']['type']]
screensaver1_endhour = schedules['screensaver1']['endhour']
screensaver1_endminute = schedules['screensaver1']['endminute']
except:
screensaver1_hour = '00'
screensaver1_minute = '00'
screensaver1_enabled = False
screensaver1_type = ['World Clock']
screensaver1_endhour = '00'
screensaver1_endminute = '00'
try:
screensaver2_hour = schedules['screensaver2']['hour']
screensaver2_minute = schedules['screensaver2']['minute']
screensaver2_enabled = schedules['screensaver2']['enabled']
screensaver2_type = [schedules['screensaver2']['type']]
screensaver2_endhour = schedules['screensaver2']['endhour']
screensaver2_endminute = schedules['screensaver2']['endminute']
except:
screensaver2_hour = '00'
screensaver2_minute = '00'
screensaver2_enabled = False
screensaver2_type = ['Clock 1']
screensaver2_endhour = '00'
screensaver2_endminute = '00'
try:
screensaver3_hour = schedules['screensaver3']['hour']
screensaver3_minute = schedules['screensaver3']['minute']
screensaver3_enabled = schedules['screensaver3']['enabled']
screensaver3_type = [schedules['screensaver3']['type']]
screensaver3_endhour = schedules['screensaver3']['endhour']
screensaver3_endminute = schedules['screensaver3']['endminute']
except:
screensaver3_hour = '00'
screensaver3_minute = '00'
screensaver3_enabled = False
screensaver3_type = ['Clock 2']
screensaver3_endhour = '00'
screensaver3_endminute = '00'
time_now = datetime.datetime.now(pytz.timezone(timezone_screensaver)).strftime("%H:%M")
try:
if screensaver1_enabled and time_now == screensaver1_hour+':'+screensaver1_minute and not already_running_screensaver_1:
requests.post('http://fintic.local:1024/screensaver', json=screensaver1_type)
already_running_screensaver_1 = True
except:
pass
try:
if screensaver1_enabled and time_now == screensaver1_endhour+':'+screensaver1_endminute and already_running_screensaver_1:
already_running_screensaver_1 = False
if ((time_now == screensaver2_hour+':'+screensaver2_minute and screensaver2_enabled) or (time_now == screensaver3_hour+':'+screensaver3_minute and screensaver3_enabled)):
pass
else:
requests.put('http://fintic.local:1024/start')
except:
pass
try:
if screensaver2_enabled and time_now == screensaver2_hour+':'+screensaver2_minute and not already_running_screensaver_2:
requests.post('http://fintic.local:1024/screensaver', json=screensaver2_type)
already_running_screensaver_2 = True
except:
pass
try:
if screensaver2_enabled and time_now == screensaver2_endhour+':'+screensaver2_endminute and already_running_screensaver_2:
already_running_screensaver_2 = False
if (time_now == screensaver1_hour+':'+screensaver1_minute and screensaver1_enabled) or (time_now == screensaver3_hour+':'+screensaver3_minute and screensaver3_enabled):
pass
else:
requests.put('http://fintic.local:1024/start')
except:
pass
try:
if screensaver3_enabled and time_now == screensaver3_hour+':'+screensaver3_minute and not already_running_screensaver_3:
requests.post('http://fintic.local:1024/screensaver', json=screensaver3_type)
already_running_screensaver_3 = True
except:
pass
try:
if screensaver3_enabled and time_now == screensaver3_endhour+':'+screensaver3_endminute and already_running_screensaver_3:
already_running_screensaver_3 = False
if (time_now == screensaver1_hour+':'+screensaver1_minute and screensaver1_enabled) or (time_now == screensaver2_hour+':'+screensaver2_minute and screensaver2_enabled):
pass
else:
requests.put('http://fintic.local:1024/start')
except:
pass
time.sleep(20)
except:
pass
scheduled_s = Process(target=scheduled_screensaver)
scheduled_s.start()
def save_displaying(input_settings):
global professional
all_settings = ['Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)',
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages', 'Movies', 'IPO Calendar', 'Economic Calendar', 'Jokes']
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages', 'Movies', 'IPO Calendar', 'Economic Calendar', 'Jokes', 'Gainers, Losers, Active', 'Sector Performance', 'Place (Reddit)', 'Clock 1', 'Clock 2', 'World Clock']
professional = len(input_settings) == 2
if professional:
all_settings = ['Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Current Weather', 'News', 'Daily Forecast', 'Sports (Upcoming Games)',
'Sports (Past Games)', 'Sports (Team Stats)', 'Sports (Live Games)', 'Custom Messages', 'Custom Images', 'Movies', 'IPO Calendar', 'Economic Calendar', 'Jokes']
'Sports (Past Games)', 'Sports (Team Stats)', 'Sports (Live Games)', 'Custom Messages', 'Custom Images', 'Movies', 'IPO Calendar', 'Economic Calendar', 'Jokes', 'Gainers, Losers, Active', 'Sector Performance', 'Place (Reddit)', 'Clock 1', 'Clock 2', 'World Clock']
positions = []
display_settings = []
@ -581,6 +787,12 @@ def start():
scheduled_b = Process(target=scheduled_brightness)
scheduled_b.start()
global scheduled_s
if scheduled_s.is_alive():
scheduled_s.terminate()
scheduled_s = Process(target=scheduled_screensaver)
scheduled_s.start()
ticker.sendline('K')
ticker.sendline('A')
@ -620,6 +832,7 @@ def stop():
scheduled_b.terminate()
scheduled_s.terminate()
return index()
@ -687,7 +900,18 @@ def save():
save_jokes_settings(input_settings)
elif 'Sports' in feature:
save_sports_settings(input_settings)
elif feature == 'Gainers, Losers, Active':
save_market_settings(input_settings)
elif feature == 'Sector Performance':
save_sector_settings(input_settings)
elif feature == 'Place (Reddit)':
save_place_settings(input_settings)
elif feature == 'Clock 1':
save_clock1_settings(input_settings)
elif feature == 'Clock 2':
save_clock2_settings(input_settings)
elif feature == 'World Clock':
save_worldclock_settings(input_settings)
elif feature in ['Custom GIFs', 'Custom Images']:
images = request.files
@ -1064,28 +1288,26 @@ def screensaver():
if "Pulsating Colors" in data:
screensaver_p = pexpect.spawn("sudo -E python3 pulsing-colors.py --led-gpio-mapping=adafruit-hat --led-slowdown-gpio=4 -r 32 --led-cols 64 -c 2 -P 1")
elif "Rotating Square" in data:
screensaver_p = pexpect.spawn("sudo ./demo --led-gpio-mapping=adafruit-hat --led-rows=32 --led-cols=128 -D 0")
elif "Pulsating brightness" in data:
screensaver_p = pexpect.spawn("sudo -E python3 pulsing-brightness.py --led-gpio-mapping=adafruit-hat --led-slowdown-gpio=4 -r 32 --led-cols 64 -c 2 -P 1")
elif "Volume Bars" in data:
screensaver_p = pexpect.spawn("sudo ./demo --led-gpio-mapping=adafruit-hat --led-rows=32 --led-cols=128 -D 9")
elif "Evolution of Color" in data:
screensaver_p = pexpect.spawn("sudo ./demo --led-gpio-mapping=adafruit-hat --led-rows=32 --led-cols=128 -D 10 -m 100")
elif "Conway's Game of Life" in data:
elif "Conway" in data:
screensaver_p = pexpect.spawn("sudo ./demo --led-gpio-mapping=adafruit-hat --led-rows=32 --led-cols=128 -D 7 -m 100")
elif "Abelian Sandpile Model" in data:
screensaver_p = pexpect.spawn("sudo ./demo --led-gpio-mapping=adafruit-hat --led-rows=32 --led-cols=128 -D 6")
elif "Grayscale Block" in data:
screensaver_p = pexpect.spawn("sudo ./demo --led-gpio-mapping=adafruit-hat --led-rows=32 --led-cols=128 -D 5")
elif "Clock 1" in data:
screensaver_p = pexpect.spawn("sudo python3 clock_screensaver.py")
elif "Clock 2" in data:
screensaver_p = pexpect.spawn("sudo python3 clock_screensaver2.py")
elif "World Clock" in data:
screensaver_p = pexpect.spawn("sudo python3 world_clock2.py")
elif "Sleep" in data:
screensaver_p = DummyProcess()
else: #default in case user hasnt set one yet
@ -1141,9 +1363,9 @@ def save_trade_settings(input_settings):
f.close()
except:
if input_settings['feature'].lower() == 'stocks':
current_settings = {"feature": "Stocks", "speed": "medium", "speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"AAPL": {"current": "164.02", "change": "-1.59", "percent_change": "-0.97"}, "MSFT": {"current": "288.29", "change": "-1.32", "percent_change": "-0.46"}, "GOOG": {"current": "2586.74", "change": "-34.01", "percent_change": "-1.31"}, "NFLX": {"current": "380.52", "change": "-7.59", "percent_change": "-1.99"}}, "prepost": False}
current_settings = {"feature": "Stocks", "speed": "medium", "speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"AAPL": {"current": "164.02", "change": "-1.59", "percent_change": "-0.97"}, "MSFT": {"current": "288.29", "change": "-1.32", "percent_change": "-0.46"}, "GOOG": {"current": "2586.74", "change": "-34.01", "percent_change": "-1.31"}, "NFLX": {"current": "380.52", "change": "-7.59", "percent_change": "-1.99"}}, "prepost": False, "lohivol": False, "display_name": False}
elif input_settings['feature'].lower() == 'crypto':
current_settings = {"feature": "Stocks", "speed": "medium","speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"ETH,USD": {"current": "2629.32", "24hr_change": "-27.6432", "percent_change": "-1.04"}, "BTC,USD": {"current": "38161.00", "24hr_change": "-50.8386", "percent_change": "-0.13"}, "BNB,USD": {"current": "372.57", "24hr_change": "0.4140", "percent_change": "0.11"}, "ADA,BTC": {"current": "0.0000", "24hr_change": "-0.0000", "percent_change": "-3.74"}}}
current_settings = {"feature": "Stocks", "speed": "medium","speed2": "medium", "animation": "down", "percent": False, "point": True, "logos": True, "chart": False, "title": True, "lohivol": False, "display_name": False, "symbols": {"ETH,USD": {"current": "2629.32", "24hr_change": "-27.6432", "percent_change": "-1.04"}, "BTC,USD": {"current": "38161.00", "24hr_change": "-50.8386", "percent_change": "-0.13"}, "BNB,USD": {"current": "372.57", "24hr_change": "0.4140", "percent_change": "0.11"}, "ADA,BTC": {"current": "0.0000", "24hr_change": "-0.0000", "percent_change": "-3.74"}}}
elif input_settings['feature'].lower() == 'indices':
current_settings = {"feature": "Stocks", "speed": "fast", "speed2": "slow", "animation": "up", "percent": True, "point": True, "logos": True, "chart": False, "title": True, "symbols": {"^HSI": {"name": "HSI", "current": "18083.06", "point_change": "1003.55", "percent_change": "5.88"}, "^GSPC": {"name": "S&P 500", "current": "3790.93", "point_change": "112.50", "percent_change": "3.06"}, "^RUT": {"name": "RUSSELL 2000", "current": "1775.77", "point_change": "66.90", "percent_change": "3.91"}, "^GDAXI": {"name": "DAX", "current": "12648.95", "point_change": "-21.53", "percent_change": "-0.17"}, "^FTSE": {"name": "FTSE 100", "current": "7058.68", "point_change": "-27.82", "percent_change": "-0.39"}, "^FCHI": {"name": "CAC 40", "current": "6031.45", "point_change": "-8.24", "percent_change": "-0.14"}, "399001.SZ": {"name": "SZSE", "current": "10778.61", "point_change": "-140.83", "percent_change": "-1.29"}, "^STOXX50E": {"name": "STOXX 50", "current": "3476.55", "point_change": "-7.93", "percent_change": "-0.23"}, "^AXJO": {"name": "ASX 200", "current": "6815.70", "point_change": "116.40", "percent_change": "1.74"}, "^DJI": {"name": "DOW JONES", "current": "30316.32", "point_change": "825.43", "percent_change": "2.80"}, "^STOXX": {"name": "STOXX 600", "current": "402.33", "point_change": "-0.70", "percent_change": "-0.17"}}}
elif input_settings['feature'].lower() == 'commodities':
@ -1161,7 +1383,9 @@ def save_trade_settings(input_settings):
if input_settings['feature'] == 'Stocks':
current_settings['prepost'] = input_settings['prepost']
if input_settings['feature'] == 'Stocks' or input_settings['feature'] == 'Crypto':
current_settings['chart'] = input_settings['chart']
current_settings['chart'] = input_settings['chart']
current_settings['lohivol'] = input_settings['lohivol']
current_settings['display_name'] = input_settings['display_name']
if input_settings['feature'] == 'Commodities':
try:
input_settings['symbols'] = [commodities_dict[symbol] for symbol in input_settings['symbols']]
@ -1397,6 +1621,167 @@ def save_jokes_settings(input_settings):
f.close()
def save_market_settings(input_settings):
filename = 'market_settings.json'
try:
f = open('csv/' + filename, 'r')
current_settings = json.load(f)
f.close()
except:
current_settings = {"feature": "Gainers, Losers, Active", "speed": "medium", "speed2": "medium", "animation": "up", "percent": True, "point": True, "logos": True, "chart": False, "title": True, "lohivol": False, "display_name": False, "categories": ["Top Gainers", "Top Losers", "Most Active"], "gainers": {}, "losers": {}, "mostactive": {}}
current_settings['speed'] = input_settings['speed'].lower()
current_settings['speed2'] = input_settings['speed2'].lower()
current_settings['animation'] = input_settings['animation'].lower()
current_settings['title'] = input_settings['title']
current_settings['logos'] = input_settings['logos']
current_settings['percent'] = input_settings['percent']
current_settings['point'] = input_settings['point']
current_settings['categories'] = input_settings['categories']
current_settings['lohivol'] = input_settings['lohivol']
current_settings['display_name'] = input_settings['display_name']
try:
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
except:
with open('csv/market_settings.json', 'w') as f:
json.dump(current_settings, f)
# f = open('csv/last_updates.json', 'r')
# last_updates = json.load(f)
# f.close()
# last_updates['market']['force'] = True
# f = open('csv/last_updates.json', 'w')
# json.dump(last_updates, f)
# f.close()
def save_sector_settings(input_settings):
filename = 'sector_settings.json'
try:
f = open('csv/' + filename, 'r')
current_settings = json.load(f)
f.close()
except:
current_settings = {"feature": "Sector Performance", "speed": "medium", "speed2": "medium", "animation": "up", "logos": True, "title": True, "sectors": ["Energy", "Financials", "Real Estate", "Technology"], "data": {}}
current_settings['speed'] = input_settings['speed'].lower()
current_settings['speed2'] = input_settings['speed2'].lower()
current_settings['animation'] = input_settings['animation'].lower()
current_settings['title'] = input_settings['title']
current_settings['logos'] = input_settings['logos']
current_settings['sectors'] = input_settings['categories']
try:
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
except:
with open('csv/sector_settings.json', 'w') as f:
json.dump(current_settings, f)
# f = open('csv/last_updates.json', 'r')
# last_updates = json.load(f)
# f.close()
# last_updates['sector']['force'] = True
# f = open('csv/last_updates.json', 'w')
# json.dump(last_updates, f)
# f.close()
def save_clock1_settings(input_settings):
filename = 'clock1_settings.json'
try:
f = open('csv/' + filename, 'r')
current_settings = json.load(f)
f.close()
except:
current_settings = {"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"}
current_settings['speed'] = input_settings['speed'].lower()
current_settings['speed2'] = input_settings['speed2'].lower()
current_settings['transition'] = input_settings['animation'].lower()
current_settings['pause'] = input_settings['pause']
try:
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
except:
with open('csv/clock1_settings.json', 'w') as f:
json.dump(current_settings, f)
def save_clock2_settings(input_settings):
filename = 'clock2_settings.json'
try:
f = open('csv/' + filename, 'r')
current_settings = json.load(f)
f.close()
except:
current_settings = {"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"}
current_settings['speed'] = input_settings['speed'].lower()
current_settings['speed2'] = input_settings['speed2'].lower()
current_settings['transition'] = input_settings['animation'].lower()
current_settings['pause'] = input_settings['pause']
try:
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
except:
with open('csv/clock2_settings.json', 'w') as f:
json.dump(current_settings, f)
def save_worldclock_settings(input_settings):
filename = 'worldclock_settings.json'
try:
f = open('csv/' + filename, 'r')
current_settings = json.load(f)
f.close()
except:
current_settings = {"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"}
current_settings['speed'] = input_settings['speed'].lower()
current_settings['speed2'] = input_settings['speed2'].lower()
current_settings['transition'] = input_settings['animation'].lower()
current_settings['pause'] = input_settings['pause']
try:
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
except:
with open('csv/worldclock_settings.json', 'w') as f:
json.dump(current_settings, f)
def save_place_settings(input_settings):
filename = 'place_settings.json'
try:
f = open('csv/' + filename, 'r')
current_settings = json.load(f)
f.close()
except:
current_settings = {"feature": "Place", "speed": "medium", "speed2": "medium", "animation": "up", "title": True, "width": "128", "pause": "0", "places": ["r/place 2017", "r/place 2022"]}
current_settings['speed'] = input_settings['speed'].lower()
current_settings['speed2'] = input_settings['speed2'].lower()
current_settings['animation'] = input_settings['animation'].lower()
current_settings['title'] = input_settings['title']
current_settings['width'] = input_settings['width']
current_settings['pause'] = input_settings['pause']
current_settings['places'] = input_settings['places']
try:
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
except:
with open('csv/place_settings.json', 'w') as f:
json.dump(current_settings, f)
def save_sports_settings(input_settings):
feature = input_settings['feature']
@ -1502,7 +1887,7 @@ def saveSchedulerSettings():
data= request.data.decode('utf-8')
input_settings = json.loads(data)
initialize_json = '{"shutdown": {"hour": "00", "minute": "00", "enabled": false}, "reboot":{"hour": "00", "minute": "00", "enabled": false}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": false}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": false}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": false}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": false}}'
initialize_json = '{"shutdown": {"hour": "00", "minute": "00", "enabled": false}, "reboot":{"hour": "00", "minute": "00", "enabled": false}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": false}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": false}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": false}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": false}, "screensaver1":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"World Clock", "enabled": false}, "screensaver2":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 1", "enabled": false}, "screensaver3":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 2", "enabled": false}}'
if 'scheduler.json' not in os.listdir('csv/'):
with open('csv/scheduler.json', 'w') as f:
@ -1511,8 +1896,30 @@ def saveSchedulerSettings():
try:
with open('csv/scheduler.json','r') as f:
scheduler_settings = json.load(f)
if 'screensaver' not in str(scheduler_settings):
scheduler_settings['screensaver1'] = {}
scheduler_settings['screensaver1']['hour'] = '00'
scheduler_settings['screensaver1']['minute'] = '00'
scheduler_settings['screensaver1']['endhour'] = '00'
scheduler_settings['screensaver1']['endminute'] = '00'
scheduler_settings['screensaver1']['type'] = 'World Clock'
scheduler_settings['screensaver1']['enabled'] = False
scheduler_settings['screensaver2'] = {}
scheduler_settings['screensaver2']['hour'] = '00'
scheduler_settings['screensaver2']['minute'] = '00'
scheduler_settings['screensaver2']['endhour'] = '00'
scheduler_settings['screensaver2']['endminute'] = '00'
scheduler_settings['screensaver2']['type'] = 'Clock 2'
scheduler_settings['screensaver2']['enabled'] = False
scheduler_settings['screensaver3'] = {}
scheduler_settings['screensaver3']['hour'] = '00'
scheduler_settings['screensaver3']['minute'] = '00'
scheduler_settings['screensaver3']['endhour'] = '00'
scheduler_settings['screensaver3']['endminute'] = '00'
scheduler_settings['screensaver3']['type'] = 'Clock 1'
scheduler_settings['screensaver3']['enabled'] = False
except:
scheduler_settings = {"shutdown": {"hour": "00", "minute": "00", "enabled": False}, "reboot":{"hour": "00", "minute": "00", "enabled": False}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}}
scheduler_settings = {"shutdown": {"hour": "00", "minute": "00", "enabled": False}, "reboot":{"hour": "00", "minute": "00", "enabled": False}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "screensaver1":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"World Clock", "enabled": False}, "screensaver2":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 1", "enabled": False}, "screensaver3":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 2", "enabled": False}}
scheduler_settings['shutdown']['hour'] = input_settings['shutdown_hour']
scheduler_settings['shutdown']['minute'] = input_settings['shutdown_minute']
@ -1541,6 +1948,27 @@ def saveSchedulerSettings():
scheduler_settings['brightness4']['minute'] = input_settings['brightness4_minute']
scheduler_settings['brightness4']['enabled'] = input_settings['brightness4_enabled']
scheduler_settings['brightness4']['bright'] = input_settings['brightness4_bright']
scheduler_settings['screensaver1']['hour'] = input_settings['screensaver1_hour']
scheduler_settings['screensaver1']['minute'] = input_settings['screensaver1_minute']
scheduler_settings['screensaver1']['endhour'] = input_settings['screensaver1_endhour']
scheduler_settings['screensaver1']['endminute'] = input_settings['screensaver1_endminute']
scheduler_settings['screensaver1']['type'] = input_settings['screensaver1_type']
scheduler_settings['screensaver1']['enabled'] = input_settings['screensaver1_enabled']
scheduler_settings['screensaver2']['hour'] = input_settings['screensaver2_hour']
scheduler_settings['screensaver2']['minute'] = input_settings['screensaver2_minute']
scheduler_settings['screensaver2']['endhour'] = input_settings['screensaver2_endhour']
scheduler_settings['screensaver2']['endminute'] = input_settings['screensaver2_endminute']
scheduler_settings['screensaver2']['type'] = input_settings['screensaver2_type']
scheduler_settings['screensaver2']['enabled'] = input_settings['screensaver2_enabled']
scheduler_settings['screensaver3']['hour'] = input_settings['screensaver3_hour']
scheduler_settings['screensaver3']['minute'] = input_settings['screensaver3_minute']
scheduler_settings['screensaver3']['endhour'] = input_settings['screensaver3_endhour']
scheduler_settings['screensaver3']['endminute'] = input_settings['screensaver3_endminute']
scheduler_settings['screensaver3']['type'] = input_settings['screensaver3_type']
scheduler_settings['screensaver3']['enabled'] = input_settings['screensaver3_enabled']
scheduler_settings['timezone'] = input_settings['timezone']
@ -1560,6 +1988,48 @@ def saveSchedulerSettings():
return index()
@app.route("/saveScreensaverSettings", methods = ['PUT', 'POST'])
def saveScreensaverSettings():
data = request.data.decode('utf-8')
input_settings = json.loads(data)
try:
with open('clock_screensaver.json','r') as f:
clock_screensaver = json.load(f)
except:
clock_screensaver = {"clock1": {"time_color": "White", "weekday_color": "Cyan", "date_color": "Blue", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "clock2": {"time_color": "Orange", "date_color": "White", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "world_clock": {"city_color": "White", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}}
clock_screensaver['clock1']['time_color'] = input_settings['clock1_timecolor']
clock_screensaver['clock1']['weekday_color'] = input_settings['clock1_weekdaycolor']
clock_screensaver['clock1']['date_color'] = input_settings['clock1_datecolor']
clock_screensaver['clock1']['timezone'] = input_settings['clock1_timezone']
clock_screensaver['clock1']['brightness'] = input_settings['clock1_brightness']
clock_screensaver['clock1']['display_seconds'] = input_settings['clock1_displayseconds']
clock_screensaver['clock1']['display_pm'] = input_settings['clock1_displaypm']
clock_screensaver['clock1']['12hour'] = input_settings['clock1_12hour']
clock_screensaver['clock2']['time_color'] = input_settings['clock2_timecolor']
clock_screensaver['clock2']['date_color'] = input_settings['clock2_datecolor']
clock_screensaver['clock2']['timezone'] = input_settings['clock2_timezone']
clock_screensaver['clock2']['brightness'] = input_settings['clock2_brightness']
clock_screensaver['clock2']['display_pm'] = input_settings['clock2_displaypm']
clock_screensaver['clock2']['12hour'] = input_settings['clock2_12hour']
clock_screensaver['world_clock']['city_color'] = input_settings['worldclock_citycolor']
clock_screensaver['world_clock']['brightness'] = input_settings['worldclock_brightness']
clock_screensaver['world_clock']['display_pm'] = input_settings['worldclock_displaypm']
clock_screensaver['world_clock']['12hour'] = input_settings['worldclock_12hour']
clock_screensaver['world_clock']['display_seconds'] = input_settings['worldclock_displayseconds']
with open('clock_screensaver.json', 'w') as f:
json.dump(clock_screensaver,f)
return index()
@app.route("/setTop20or10", methods = ['PUT', 'POST'])
def setTop20or10():
@ -1755,6 +2225,67 @@ def scanNetworks2():
return (networks)
@app.route('/upload_stocks', methods=['POST'])
def upload_file_stocks():
file = request.files['file']
filename = file.filename
name, extension = os.path.splitext(filename)
capitalized_name = name.upper()
file_path = 'logos/stocks/' + capitalized_name + extension
file.save(file_path)
image = Image.open(file_path)
if image.height > 32:
new_width = int((32 / image.height) * image.width)
resized_image = image.resize((new_width, 32))
resized_image.save(file_path)
resized_image.close()
image.close()
image = Image.open(file_path)
if image.mode in ('RGBA', 'LA') or (image.mode == 'P' and 'transparency' in image.info):
new_image = Image.new("RGBA", image.size, (0, 0, 0))
new_image.paste(image, (0, 0), image)
new_image.save(file_path)
new_image.close()
image.close()
return index()
@app.route('/upload_crypto', methods=['POST'])
def upload_file_crypto():
file = request.files['file']
filename = file.filename
name, extension = os.path.splitext(filename)
capitalized_name = name.upper()
file_path = 'logos/crypto/' + capitalized_name + extension
file.save(file_path)
image = Image.open(file_path)
if image.height > 32:
new_width = int((32 / image.height) * image.width)
resized_image = image.resize((new_width, 32))
resized_image.save(file_path)
resized_image.close()
image.close()
image = Image.open(file_path)
if image.mode in ('RGBA', 'LA') or (image.mode == 'P' and 'transparency' in image.info):
new_image = Image.new("RGBA", image.size, (0, 0, 0))
new_image.paste(image, (0, 0), image)
new_image.save(file_path)
new_image.close()
image.close()
return index()
if __name__ == "__main__":
app.run(host='0.0.0.0', port=1024, debug=False) # the debuggger causes flickering

File diff suppressed because one or more lines are too long

View File

@ -50,6 +50,12 @@ var moviesFeatures = document.querySelectorAll("#movies-features li");
var ipoFeatures = document.querySelectorAll("#ipo-features li");
var economicFeatures = document.querySelectorAll("#economic-list li");
var jokesFeatures = document.querySelectorAll("#jokes-list li");
var marketFeatures = document.querySelectorAll("#market-list li");
var sectorFeatures = document.querySelectorAll("#sector-list li");
var placeFeatures = document.querySelectorAll("#place-list li");
var clock1Features = document.querySelectorAll("#clock1-features li");
var clock2Features = document.querySelectorAll("#clock2-features li");
var worldclockFeatures = document.querySelectorAll("#worldclock-features li");
var allFeaturesList = [
stocksFeatures,
@ -71,6 +77,12 @@ var allFeaturesList = [
ipoFeatures,
economicFeatures,
jokesFeatures,
marketFeatures,
sectorFeatures,
placeFeatures,
clock1Features,
clock2Features,
worldclockFeatures,
];
// features remove buttons
@ -99,6 +111,12 @@ var moviesRemoveBtn = document.getElementById("movies-remove-btn");
var ipoRemoveBtn = document.getElementById("ipo-remove-btn");
var economicRemoveBtn = document.getElementById("economic-remove-btn");
var jokesRemoveBtn = document.getElementById("jokes-remove-btn");
var marketRemoveBtn = document.getElementById("market-remove-btn");
var sectorRemoveBtn = document.getElementById("sector-remove-btn");
var placeRemoveBtn = document.getElementById("place-remove-btn");
var clock1RemoveBtn = document.getElementById("clock1-remove-btn");
var clock2RemoveBtn = document.getElementById("clock2-remove-btn");
var worldclockRemoveBtn = document.getElementById("worldclock-remove-btn");
var allFeaturesRemoveBtns = [
stocksRemoveBtn,
@ -120,6 +138,12 @@ var allFeaturesRemoveBtns = [
ipoRemoveBtn,
economicRemoveBtn,
jokesRemoveBtn,
marketRemoveBtn,
sectorRemoveBtn,
placeRemoveBtn,
clock1RemoveBtn,
clock2RemoveBtn,
worldclockRemoveBtn,
];
// features increase buttons
var stocksincreaseBtn = document.getElementById("stocks-increase-btn");
@ -147,6 +171,12 @@ var moviesincreaseBtn = document.getElementById("movies-increase-btn");
var ipoincreaseBtn = document.getElementById("ipo-increase-btn");
var economicincreaseBtn = document.getElementById("economic-increase-btn");
var jokesincreaseBtn = document.getElementById("jokes-increase-btn");
var marketincreaseBtn = document.getElementById("market-increase-btn");
var sectorincreaseBtn = document.getElementById("sector-increase-btn");
var placeincreaseBtn = document.getElementById("place-increase-btn");
var clock1increaseBtn = document.getElementById("clock1-increase-btn");
var clock2increaseBtn = document.getElementById("clock2-increase-btn");
var worldclockincreaseBtn = document.getElementById("worldclock-increase-btn");
var allFeaturesIncreaseBtns = [
stocksincreaseBtn,
@ -168,6 +198,12 @@ var allFeaturesIncreaseBtns = [
ipoincreaseBtn,
economicincreaseBtn,
jokesincreaseBtn,
marketincreaseBtn,
sectorincreaseBtn,
placeincreaseBtn,
clock1increaseBtn,
clock2increaseBtn,
worldclockincreaseBtn,
];
// features decrease buttons
@ -196,6 +232,12 @@ var moviesDecreaseBtn = document.getElementById("movies-decrease-btn");
var ipoDecreaseBtn = document.getElementById("ipo-decrease-btn");
var economicDecreaseBtn = document.getElementById("economic-decrease-btn");
var jokesDecreaseBtn = document.getElementById("jokes-decrease-btn");
var marketDecreaseBtn = document.getElementById("market-decrease-btn");
var sectorDecreaseBtn = document.getElementById("sector-decrease-btn");
var placeDecreaseBtn = document.getElementById("place-decrease-btn");
var clock1DecreaseBtn = document.getElementById("clock1-decrease-btn");
var clock2DecreaseBtn = document.getElementById("clock2-decrease-btn");
var worldclockDecreaseBtn = document.getElementById("worldclock-decrease-btn");
var allFeaturesDecreaseBtns = [
stocksDecreaseBtn,
@ -217,6 +259,12 @@ var allFeaturesDecreaseBtns = [
ipoDecreaseBtn,
economicDecreaseBtn,
jokesDecreaseBtn,
marketDecreaseBtn,
sectorDecreaseBtn,
placeDecreaseBtn,
clock1DecreaseBtn,
clock2DecreaseBtn,
worldclockDecreaseBtn,
];
const changeVarValue = () => {
@ -245,6 +293,12 @@ const changeVarValue = () => {
ipoFeatures = document.querySelectorAll("#ipo-features li");
economicFeatures = document.querySelectorAll("#economic-list li");
jokesFeatures = document.querySelectorAll("#jokes-list li");
marketFeatures = document.querySelectorAll("#market-list li");
sectorFeatures = document.querySelectorAll("#sector-list li");
placeFeatures = document.querySelectorAll("#place-list li");
clock1Features = document.querySelectorAll("#clock1-features li");
clock2Features = document.querySelectorAll("#clock2-features li");
worldclockFeatures = document.querySelectorAll("#worldclock-features li");
allFeaturesList = [
stocksFeatures,
@ -266,6 +320,12 @@ const changeVarValue = () => {
ipoFeatures,
economicFeatures,
jokesFeatures,
marketFeatures,
sectorFeatures,
placeFeatures,
clock1Features,
clock2Features,
worldclockFeatures,
];
};
@ -645,6 +705,12 @@ var movies = document.getElementById("movies-features");
var ipos = document.getElementById("ipo-features");
var economics = document.getElementById("economic-list");
var jokes = document.getElementById("jokes-list");
var market = document.getElementById("market-list");
var sector = document.getElementById("sector-list");
var place = document.getElementById("place-list");
var clock1 = document.getElementById("clock1-features");
var clock2 = document.getElementById("clock2-features");
var worldclock = document.getElementById("worldclock-features");
var allFeatures = [
stocks,
@ -666,6 +732,12 @@ var allFeatures = [
ipos,
economics,
jokes,
market,
sector,
place,
clock1,
clock2,
worldclock,
];
// features select box
@ -677,6 +749,9 @@ var teamStatsSelect = document.getElementById("inputTransition103");
var moviesSelect = document.getElementById("inputTransition64");
var economicSelect = document.getElementById("inputTransition2222");
var jokesSelect = document.getElementById("jokes-categories");
var marketSelect = document.getElementById("market-categories");
var sectorSelect = document.getElementById("sector-categories");
var placeSelect = document.getElementById("place-categories");
var allFeaturesSelectBox = [
null,
null,
@ -697,6 +772,12 @@ var allFeaturesSelectBox = [
null,
economicSelect,
jokesSelect,
marketSelect,
sectorSelect,
placeSelect,
null,
null,
null,
];
// features select add buttons
@ -707,6 +788,9 @@ var liveGamesAddBtn = document.getElementById("inputTransitionBtn93");
var teamStatsAddBtn = document.getElementById("inputTransitionBtn103");
var economicAddBtn = document.getElementById("economic-countries-btn");
var jokesAddBtn = document.getElementById("jokes-categories-btn");
var marketAddBtn = document.getElementById("market-categories-btn");
var sectorAddBtn = document.getElementById("sector-categories-btn");
var placeAddBtn = document.getElementById("place-categories-btn");
var allFeaturesSelectAddBtn = [
null,
@ -728,6 +812,12 @@ var allFeaturesSelectAddBtn = [
null,
economicAddBtn,
jokesAddBtn,
marketAddBtn,
sectorAddBtn,
placeAddBtn,
null,
null,
null,
];
allFeaturesSelectAddBtn.map((value, index) => {
@ -767,6 +857,12 @@ var allFeaturesFile = [
null,
null,
null,
null,
null,
null,
null,
null,
null,
];
// features file add button
var imagesFileAddBtn = document.getElementById("inputTextBtn11");
@ -792,6 +888,12 @@ var allFeaturesFileAddBtn = [
null,
null,
null,
null,
null,
null,
null,
null,
null,
];
// features input text
@ -824,6 +926,12 @@ var allFeaturesText = [
null,
null,
null,
null,
null,
null,
null,
null,
null,
];
// features text add button
@ -856,6 +964,12 @@ var allFeaturesTextAddBtn = [
null,
null,
null,
null,
null,
null,
null,
null,
null,
];
@ -879,6 +993,12 @@ var allFeaturesLimit = [
null,
null,
null,
null,
null,
null,
null,
null,
null,
];
@ -1153,6 +1273,12 @@ function getFeatureSettings() {
"IPO Calendar",
"Economic Calendar",
"Jokes",
"Gainers, Losers, Active",
"Sector Performance",
"Place (Reddit)",
"Clock 1",
"Clock 2",
"World Clock",
];
let pageNum = features.indexOf(feature) + 1;
let pageSelector = "Page" + pageNum.toString();
@ -1221,6 +1347,24 @@ function getFeatureSettings() {
case 19:
s = getJokesSettings(page);
break;
case 20:
s = getMarketSettings(page);
break;
case 21:
s = getSectorSettings(page);
break;
case 22:
s = getPlaceSettings(page);
break;
case 23:
s = getClock1Settings(page);
break;
case 24:
s = getClock2Settings(page);
break;
case 25:
s = getWorldclockSettings(page);
break;
}
settings = { ...settings, ...s }; // merge both sets of settings
@ -1286,6 +1430,8 @@ function getTradingSettings(page) {
if (whatFeature == 2) {
let portfolio = page.querySelectorAll(".portfolio-select")[0].checked;
let lohivol = page.querySelectorAll(".lohivol-select")[0].checked;
let display_name = page.querySelectorAll(".name-select")[0].checked;
settings = {
percent: percent,
point: point,
@ -1293,11 +1439,15 @@ function getTradingSettings(page) {
title: title,
symbols: symbols,
chart: portfolio,
lohivol: lohivol,
display_name: display_name,
};
}
else if (whatFeature == 1) {
let prepost = page.querySelectorAll(".prepost-select")[0].checked;
let portfolio = page.querySelectorAll(".portfolio-select")[0].checked;
let lohivol = page.querySelectorAll(".lohivol-select")[0].checked;
let display_name = page.querySelectorAll(".name-select")[0].checked;
settings = {
prepost: prepost,
percent: percent,
@ -1306,6 +1456,8 @@ function getTradingSettings(page) {
title: title,
symbols: symbols,
chart: portfolio,
lohivol: lohivol,
display_name: display_name,
};
}
else {
@ -1414,6 +1566,12 @@ function saveMovieAPIKey(){
"IPO Calendar",
"Economic Calendar",
"Jokes",
"Gainers, Losers, Active",
"Sector Performance",
"Place (Reddit)",
"Clock 1",
"Clock 2",
"World Clock",
];
let pageNum = features.indexOf(feature) + 1;
let pageSelector = "Page" + pageNum.toString();
@ -1457,6 +1615,12 @@ function saveIpoAPIKey(){
"IPO Calendar",
"Economic Calendar",
"Jokes",
"Gainers, Losers, Active",
"Sector Performance",
"Place (Reddit)",
"Clock 1",
"Clock 2",
"World Clock",
];
let pageNum = features.indexOf(feature) + 1;
let pageSelector = "Page" + pageNum.toString();
@ -1732,6 +1896,48 @@ function getEconomicSettings(page) {
}
// market settings
function getMarketSettings(page) {
let title = page.querySelectorAll(".title-select")[0].checked;
let categories = getListItems(page.querySelectorAll(".symbol-list")[0]);
let percent = page.querySelectorAll(".percent-select")[0].checked;
let point = page.querySelectorAll(".point-select")[0].checked;
let no_logos = page.querySelectorAll(".logo-select")[0].checked;
let lohivol = page.querySelectorAll(".lohivol-select")[0].checked;
let display_name = page.querySelectorAll(".name-select")[0].checked;
settings = {
title: title,
categories: categories,
percent: percent,
point: point,
logos: no_logos,
lohivol: lohivol,
display_name: display_name,
};
console.log(settings);
return settings;
}
// sector settings
function getSectorSettings(page) {
let title = page.querySelectorAll(".title-select")[0].checked;
let categories = getListItems(page.querySelectorAll(".symbol-list")[0]);
let no_logos = page.querySelectorAll(".logo-select")[0].checked;
settings = {
title: title,
categories: categories,
logos: no_logos,
};
console.log(settings);
return settings;
}
// jokes settings
function getJokesSettings(page) {
@ -1759,6 +1965,61 @@ function getJokesSettings(page) {
}
// place settings
function getPlaceSettings(page) {
let title = page.querySelectorAll(".title-select")[0].checked;
let places = getListItems(page.querySelectorAll(".symbol-list")[0]);
let pause_place = page.querySelectorAll(".pause-select")[0].value;
let width = page.querySelectorAll(".slider")[0].value;
settings = {
title: title,
places: places,
pause: pause_place,
width: width,
};
console.log(settings);
return settings;
}
// clock1 settings
function getClock1Settings(page) {
let clock1pause = page.querySelectorAll(".pause-select")[0].value;
settings = {
pause: clock1pause,
};
console.log(settings);
return settings;
}
// clock2 settings
function getClock2Settings(page) {
let clock2pause = page.querySelectorAll(".pause-select")[0].value;
settings = {
pause: clock2pause,
};
console.log(settings);
return settings;
}
// world clock settings
function getWorldclockSettings(page) {
let worldclockpause = page.querySelectorAll(".pause-select")[0].value;
settings = {
pause: worldclockpause,
};
console.log(settings);
return settings;
}
// Join Network
let wifiSsidInput = document.getElementById("wifi-ssid-input");
@ -1892,7 +2153,7 @@ inputAnimationBtn.addEventListener("click", () => {
// scroll speed row two
let inputScrollSpeedRow = [];
for (let i = 1; i <= 19; i++) {
for (let i = 1; i <= 25; i++) {
inputScrollSpeedRow.push(
document.getElementById(
i === 1 ? "inputScrollSpeedRow" : `inputScrollSpeedRow${i}`
@ -2748,6 +3009,14 @@ function portfolioCryptoValidate() {
}
// screensaver show div
function showScreensaver() {
document.getElementById('screensaver-div').style.display = "block";
}
function closeScreensaver() {
document.getElementById('screensaver-div').style.display = "none";
document.getElementById('screensaver-saved').style.display = "none";
}
@ -2793,6 +3062,27 @@ function saveSchedulerSettings() {
let brightness4_enabled = document.getElementById("brightness4-enabled").checked;
let brightness4_bright = document.getElementById("brightness4-bright-select").value;
let screensaver1_hour = document.getElementById("screensaver1-hour-select").value;
let screensaver1_minute = document.getElementById("screensaver1-minute-select").value;
let screensaver1_endhour = document.getElementById("screensaver1-endhour-select").value;
let screensaver1_endminute = document.getElementById("screensaver1-endminute-select").value;
let screensaver1_enabled = document.getElementById("screensaver1-enabled").checked;
let screensaver1_type = document.getElementById("screensaver1-type").value;
let screensaver2_hour = document.getElementById("screensaver2-hour-select").value;
let screensaver2_minute = document.getElementById("screensaver2-minute-select").value;
let screensaver2_endhour = document.getElementById("screensaver2-endhour-select").value;
let screensaver2_endminute = document.getElementById("screensaver2-endminute-select").value;
let screensaver2_enabled = document.getElementById("screensaver2-enabled").checked;
let screensaver2_type = document.getElementById("screensaver2-type").value;
let screensaver3_hour = document.getElementById("screensaver3-hour-select").value;
let screensaver3_minute = document.getElementById("screensaver3-minute-select").value;
let screensaver3_endhour = document.getElementById("screensaver3-endhour-select").value;
let screensaver3_endminute = document.getElementById("screensaver3-endminute-select").value;
let screensaver3_enabled = document.getElementById("screensaver3-enabled").checked;
let screensaver3_type = document.getElementById("screensaver3-type").value;
let timezone = document.getElementById("timezone-select").value;
let settings = {
@ -2819,6 +3109,24 @@ function saveSchedulerSettings() {
brightness4_minute: brightness4_minute,
brightness4_bright: brightness4_bright,
brightness4_enabled: brightness4_enabled,
screensaver1_hour: screensaver1_hour,
screensaver1_minute: screensaver1_minute,
screensaver1_endhour: screensaver1_endhour,
screensaver1_endminute: screensaver1_endminute,
screensaver1_enabled: screensaver1_enabled,
screensaver1_type: screensaver1_type,
screensaver2_hour: screensaver2_hour,
screensaver2_minute: screensaver2_minute,
screensaver2_endhour: screensaver2_endhour,
screensaver2_endminute: screensaver2_endminute,
screensaver2_enabled: screensaver2_enabled,
screensaver2_type: screensaver2_type,
screensaver3_hour: screensaver3_hour,
screensaver3_minute: screensaver3_minute,
screensaver3_endhour: screensaver3_endhour,
screensaver3_endminute: screensaver3_endminute,
screensaver3_enabled: screensaver3_enabled,
screensaver3_type: screensaver3_type,
};
console.log(settings);
@ -3260,7 +3568,7 @@ function featureSavePrompt() {
const pageIDs = ['Page1', 'Page2', 'Page3', 'Page4', 'Page5', 'Page6', 'Page7', 'Page8', 'Page9', 'Page10', 'Page11', 'Page12', 'Page13',
'Page14', 'Page15', 'Page16', 'Page17', 'Page18', 'Page19'];
'Page14', 'Page15', 'Page16', 'Page17', 'Page18', 'Page19', 'Page20', 'Page21', 'Page22', 'Page23', 'Page24', 'Page25'];
for (const pageID of pageIDs) {
// Select the parent div
@ -3268,7 +3576,7 @@ for (const pageID of pageIDs) {
// Add event listeners to select menus
const excludedIds = ['base-select', 'quote-select', 'commodities-items', 'indices-items', 'inputTransition73',
'inputTransition83', 'inputTransition93', 'inputTransition103', 'inputTransition2222', 'jokes-categories', 'golf-ranking-number',
'inputScrollSpeed16', 'inputScrollSpeed17', 'inputScrollSpeed19BG'];
'inputScrollSpeed16', 'inputScrollSpeed17', 'inputScrollSpeed19BG', 'market-categories', 'sector-categories', 'place-categories'];
const selectMenus = parentDiv.querySelectorAll('select');
selectMenus.forEach(selectMenu => {
@ -3279,6 +3587,22 @@ for (const pageID of pageIDs) {
});
}
});
// Add event listeners for input text fields specifically for page22 (r/place)
if ((pageID === 'Page22') || (pageID === 'Page23') || (pageID === 'Page24') || (pageID === 'Page25')) {
const inputForms = parentDiv.querySelectorAll('input[type="text"]');
inputForms.forEach(inputForm => {
inputForm.addEventListener('input', function(event) {
displaySavePrompt2();
});
});
}
// Add event listeners for sliders specifically for page22 (r/place)
if (pageID === 'Page22') {
const slider = parentDiv.querySelector('#myRange');
slider.addEventListener('input', function(event) {
displaySavePrompt2();
});
}
// Add event listeners to input checkboxes
const inputForms = parentDiv.querySelectorAll('input[type="checkbox"]');
inputForms.forEach(inputForm => {
@ -3348,3 +3672,112 @@ function scanNetworks() {
}
// UPLOAD CUSTOM STOCK LOGO
function uploadStockLogo() {
const fileInput_stocks = document.getElementById("stocks-logo-upload-browse");
if (fileInput_stocks.value !== "") {
const stock_file = fileInput_stocks.files[0];
const stock_upload_msg = document.getElementById("stocklogoupload");
const formData_stocks = new FormData();
formData_stocks.append('file', stock_file)
fetch('/upload_stocks', {
method: 'POST',
body: formData_stocks
})
stock_upload_msg.style.display = "block";
setTimeout(function hideElement() {
stock_upload_msg.style.display = "none";
}, 5000);
fileInput_stocks.value = "";
}
}
// UPLOAD CUSTOM CRYPTO LOGO
function uploadCryptoLogo() {
const fileInput_crypto = document.getElementById("crypto-logo-upload-browse");
if (fileInput_crypto.value !== "") {
const crypto_file = fileInput_crypto.files[0];
const crypto_upload_msg = document.getElementById("cryptologoupload");
const formData_crypto = new FormData();
formData_crypto.append('file', crypto_file);
fetch('/upload_crypto', {
method: 'POST',
body: formData_crypto
});
crypto_upload_msg.style.display = "block";
setTimeout(function hideElement() {
crypto_upload_msg.style.display = "none";
}, 5000);
fileInput_crypto.value = "";
}
}
// TO GET SLIDER VALUE FOR IMAGE WIDTH IN R/PLACE
var slider = document.getElementById("myRange");
var output = document.getElementById("slider-value");
output.innerHTML = slider.value; // Display the default slider value
// Update the current slider value (each time you drag the slider handle)
slider.oninput = function() {
output.innerHTML = this.value;
}
// save screensaver settings
function saveScreensaverSettings() {
let clock1_timecolor = document.getElementById("clock1-timecolor").value;
let clock1_weekdaycolor = document.getElementById("clock1-weekdaycolor").value;
let clock1_datecolor = document.getElementById("clock1-datecolor").value;
let clock1_timezone = document.getElementById("clock1-timezone").value;
let clock1_brightness = document.getElementById("clock1-brightness").value;
let clock1_displaypm = document.getElementById("clock1-displaypm").checked;
let clock1_displayseconds = document.getElementById("clock1-displayseconds").checked;
let clock1_12hour = document.getElementById("clock1-12hour").checked;
let clock2_timecolor = document.getElementById("clock2-timecolor").value;
let clock2_datecolor = document.getElementById("clock2-datecolor").value;
let clock2_timezone = document.getElementById("clock2-timezone").value;
let clock2_brightness = document.getElementById("clock2-brightness").value;
let clock2_displaypm = document.getElementById("clock2-displaypm").checked;
let clock2_12hour = document.getElementById("clock2-12hour").checked;
let worldclock_citycolor = document.getElementById("worldclock-citycolor").value;
let worldclock_brightness = document.getElementById("worldclock-brightness").value;
let worldclock_displaypm = document.getElementById("worldclock-displaypm").checked;
let worldclock_displayseconds = document.getElementById("worldclock-displayseconds").checked;
let worldclock_12hour = document.getElementById("worldclock-12hour").checked;
let settings = {
clock1_timecolor: clock1_timecolor,
clock1_weekdaycolor: clock1_weekdaycolor,
clock1_datecolor: clock1_datecolor,
clock1_timezone: clock1_timezone,
clock1_brightness: clock1_brightness,
clock1_displaypm: clock1_displaypm,
clock1_displayseconds: clock1_displayseconds,
clock1_12hour: clock1_12hour,
clock2_timecolor: clock2_timecolor,
clock2_datecolor: clock2_datecolor,
clock2_timezone: clock2_timezone,
clock2_brightness: clock2_brightness,
clock2_displaypm: clock2_displaypm,
clock2_12hour: clock2_12hour,
worldclock_citycolor: worldclock_citycolor,
worldclock_brightness: worldclock_brightness,
worldclock_displaypm: worldclock_displaypm,
worldclock_displayseconds: worldclock_displayseconds,
worldclock_12hour: worldclock_12hour,
};
console.log(settings);
fetch("/saveScreensaverSettings", {
method: "POST",
body: JSON.stringify(settings),
});
document.getElementById('screensaver-saved').style.display = "block";
}

View File

@ -1248,6 +1248,12 @@ input[type=checkbox]:hover {
margin-right: 2%;
}
.screensaver-select {
width:40%;
display: inline;
margin-right: 2%;
}
.scheduler-hour-select {
display: inline;
zoom:1.2;
@ -1279,10 +1285,31 @@ input[type=checkbox]:hover {
}
.btn-screensaver-settings {
background-color: #003337;
border-color:#00CFDF;
color:white;
display: inline-block;
margin-right: 5%;
}
.btn-screensaver-settings:hover {
color:white;
background-color:#008993;
border-color:#00EDFF;
}
.btn-screensaver-settings:active {
color:grey;
background-color:#002225;
border-color:#00CFDF;
}
.btn-scheduler {
background-color: #003337;
border-color:#00CFDF;
color:white;
display: inline-block;
}
.btn-scheduler:hover {
@ -1447,3 +1474,88 @@ input[type=checkbox]:hover {
}
}
#screensaver-div {
width: 500px;
height: 430px;
border-radius:20px;
/* background-color: #282828;*/
background-color: rgba(5,5,5,0.7);
backdrop-filter: blur(6px);
border-color: #5D5D5D;
border-style: solid;
border-width: thin;
position: fixed; /*Can also be `fixed`*/
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
/*Solves a problem in which the content is being cut when the div is smaller than its' wrapper:*/
max-width: 100%;
max-height: 100%;
overflow: auto;
z-index:98;
}
#screensaver-close-btn {
background-color: transparent;
border: none;
color: white;
text-decoration: underline;
margin-left:42%;
}
#screensaver-close-btn:hover {
background-color: transparent;
border: none;
color: darkgray;
text-decoration: underline;
}
#screensaver-close-btn:active {
background-color: transparent;
border: none;
color: #4B4B4B;
text-decoration: underline;
}
#screensaver-p {
font-size:20px;
display: inline;
}
#clock1-p {
margin-top: 5%;
margin-bottom: 2%;
}
#clock2-p {
margin-top:6%;
margin-bottom:2%;
}
#worldclock-p {
margin-top:6%;
margin-bottom:2%;
}
#screensaver-top {
margin-top:3%;
padding: 5%;
padding-top: 1%;
}
#inside-screensaver-div {
margin-left: 5%;
}
.screensaver-hour-select {
display: inline;
zoom:1.2;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

264
world_clock2.py Normal file
View File

@ -0,0 +1,264 @@
import time
from datetime import datetime
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
import pytz
import json
try:
with open('clock_screensaver.json', 'r') as f:
settings = json.load(f)['world_clock']
except:
settings1 = {"clock1": {"time_color": "White", "weekday_color": "Cyan", "date_color": "Blue", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "clock2": {"time_color": "Orange", "date_color": "White", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}, "world_clock": {"city_color": "White", "display_seconds": True, "display_pm": True, "12hour": True, "brightness": "10"}}
with open('clock_screensaver.json', 'w') as f:
json.dump(settings1, f)
settings = settings1['world_clock']
options = RGBMatrixOptions()
options.rows = 32
options.cols = 128
options.chain_length = 1
options.parallel = 1
options.hardware_mapping = 'adafruit-hat' # Change this if you have a different GPIO mapping
options.gpio_slowdown = 2
options.brightness = int(settings['brightness'])*10
matrix = RGBMatrix(options=options)
canvas = matrix.CreateFrameCanvas()
font = graphics.Font()
#font.LoadFont("fonts/clR6x12.bdf")
#font.LoadFont("fonts/6x12.bdf") # Change this to the path of your desired font file
city_colors = {
"White": graphics.Color(255,255,255),
"Red": graphics.Color(255, 0,0),
"Green": graphics.Color(0,255,0),
"Dark Green": graphics.Color(0, 100,0),
"Blue": graphics.Color(0,0,255),
"Purple": graphics.Color(145,0,255),
"Pink": graphics.Color(255,0,255),
"Yellow": graphics.Color(255,255,0),
"Orange": graphics.Color(255,130,0),
"Gold": graphics.Color(255,190,0),
"Gray": graphics.Color(100,100,100),
"Cyan": graphics.Color(0,255,255)
}
color = city_colors[settings['city_color']]
line_c = graphics.Color(50,50,50)
font.LoadFont("fonts/5x7.bdf")
time_colors = {
"day": graphics.Color(255, 191, 0), # Orange color
"night": graphics.Color(0, 71,171), # Dark blue / purple color
}
# settings = {'display_seconds': True, 'display_pm': True, '12hour': False}
def getTimes(timezone):
if settings['12hour']:
if settings['display_pm'] and settings['display_seconds']:
time = datetime.now(timezone).strftime("%I:%M:%S %p")
elif settings['display_pm'] and not settings['display_seconds']:
time = datetime.now(timezone).strftime("%I:%M %p")
elif not settings['display_pm'] and settings['display_seconds']:
time = datetime.now(timezone).strftime("%I:%M:%S %p")
else:
time = datetime.now(timezone).strftime("%I:%M %p")
else:
if settings['display_pm'] and settings['display_seconds']:
time = datetime.now(timezone).strftime("%H:%M:%S %p")
elif settings['display_pm'] and not settings['display_seconds']:
time = datetime.now(timezone).strftime("%H:%M %p")
elif not settings['display_pm'] and settings['display_seconds']:
time = datetime.now(timezone).strftime("%H:%M:%S %p")
else:
time = datetime.now(timezone).strftime("%H:%M %p")
return time
def isDaytime(time):
if settings['12hour']:
hour = int(time.split(':')[0])
daytime_start_hour = 6
daytime_end_hour = 6
am_pm = time[-2:]
if (6 <= hour <= 11 and am_pm == 'AM') or (1 <= hour <= 6 and am_pm == 'PM') or (hour == 12 and am_pm == 'PM'):
return True
else:
return False
# if settings['12hour']:
# hour = time.split(':')[0]
# daytime_start_hour = 6
# daytime_end_hour = 6
# print(time)
# if ((6 <= int(hour) <= 11) and time[-2:] == 'AM') or ((12 <= int(hour) <= 6) and time[-2:] == 'PM'):
# return True
# else:
# return False
else:
hour = time.split(':')[0]
daytime_start_hour = 6
daytime_end_hour = 18
if daytime_start_hour <= int(hour) <= daytime_end_hour:
return True
else:
return False
ny_timezone = pytz.timezone('America/New_York')
london_timezone = pytz.timezone('Europe/London')
tokyo_timezone = pytz.timezone('Asia/Tokyo')
au_timezone = pytz.timezone('Australia/Sydney')
dubai_timezone = pytz.timezone('Asia/Dubai')
la_timezone = pytz.timezone('America/Los_Angeles')
cn_timezone = pytz.timezone('Asia/Shanghai')
paris_timezone = pytz.timezone('Europe/Paris')
in_timezone = pytz.timezone('Asia/Kolkata')
auck_timezone = pytz.timezone('Pacific/Auckland')
bang_timezone = pytz.timezone('Asia/Bangkok')
istan_timezone = pytz.timezone('Europe/Istanbul')
counter = 0
if settings['display_pm'] and settings['display_seconds']:
x_offset = 72
elif settings['display_pm'] and not settings['display_seconds']:
x_offset = 87
elif not settings['display_pm'] and settings['display_seconds']:
x_offset = 87
else:
x_offset = 102
while True:
if 0 <= counter <= 5:
canvas.Clear()
#NEW YORK
ny_time = getTimes(ny_timezone)
#LONDON
london_time = getTimes(london_timezone)
#TOKYO TIME
tokyo_time = getTimes(tokyo_timezone)
ny_color = time_colors['day'] if isDaytime(ny_time) else time_colors['night']
london_color = time_colors['day'] if isDaytime(london_time) else time_colors['night']
tokyo_color = time_colors['day'] if isDaytime(tokyo_time) else time_colors['night']
if not settings['display_pm']:
ny_time = ny_time.replace("PM", "").replace("AM", "")
london_time = london_time.replace("PM", "").replace("AM", "")
tokyo_time = tokyo_time.replace("PM", "").replace("AM", "")
graphics.DrawText(canvas, font, 2, 8, color, 'NEW YORK')
graphics.DrawText(canvas, font, x_offset, 8, ny_color, ny_time)
graphics.DrawLine(canvas, 0, 10, 128, 10, line_c)
graphics.DrawText(canvas, font, 2, 19, color, 'LONDON')
graphics.DrawText(canvas, font, x_offset, 19, london_color, london_time)
graphics.DrawLine(canvas, 0, 21, 128, 21, line_c)
graphics.DrawText(canvas, font, 2, 30, color, 'TOKYO')
graphics.DrawText(canvas, font, x_offset, 30, tokyo_color, tokyo_time)
canvas = matrix.SwapOnVSync(canvas)
counter += 1
# print("NY:", ny_time, "LONDON:", london_time, 'TOKYO:', tokyo_time)
elif 6 <= counter <= 11:
canvas.Clear()
#SYDNEY
au_time = getTimes(au_timezone)
#DUBAI
dubai_time = getTimes(dubai_timezone)
#LOS ANGELES
la_time = getTimes(la_timezone)
au_color = time_colors['day'] if isDaytime(au_time) else time_colors['night']
dubai_color = time_colors['day'] if isDaytime(dubai_time) else time_colors['night']
la_color = time_colors['day'] if isDaytime(la_time) else time_colors['night']
if not settings['display_pm']:
au_time = au_time.replace("PM", "").replace("AM", "")
dubai_time = dubai_time.replace("PM", "").replace("AM", "")
la_time = la_time.replace("PM", "").replace("AM", "")
graphics.DrawText(canvas, font, x_offset, 8, au_color, au_time)
graphics.DrawText(canvas, font, 2, 8, color, 'SYDNEY')
graphics.DrawLine(canvas, 0, 10, 128, 10, line_c)
graphics.DrawText(canvas, font, x_offset, 19, dubai_color, dubai_time)
graphics.DrawText(canvas, font, 2, 19, color, 'DUBAI')
graphics.DrawLine(canvas, 0, 21, 128, 21, line_c)
graphics.DrawText(canvas, font, x_offset, 30, la_color, la_time)
graphics.DrawText(canvas, font, 2, 30, color, 'LOS ANGELES')
canvas = matrix.SwapOnVSync(canvas)
counter += 1
# print('DUBAI:', dubai_time, 'AU:', au_time, "LA:", la_time)
elif 12 <= counter <= 17:
canvas.Clear()
#SHANGHAI
cn_time = getTimes(cn_timezone)
#PARIS
paris_time = getTimes(paris_timezone)
#MUMBAI
in_time = getTimes(in_timezone)
cn_color = time_colors['day'] if isDaytime(cn_time) else time_colors['night']
paris_color = time_colors['day'] if isDaytime(paris_time) else time_colors['night']
in_color = time_colors['day'] if isDaytime(in_time) else time_colors['night']
if not settings['display_pm']:
cn_time = cn_time.replace("PM", "").replace("AM", "")
paris_time = paris_time.replace("PM", "").replace("AM", "")
in_time = in_time.replace("PM", "").replace("AM", "")
graphics.DrawText(canvas, font, x_offset, 8, cn_color, cn_time)
graphics.DrawText(canvas, font, 2, 8, color, 'SHANGHAI')
graphics.DrawText(canvas, font, x_offset, 19, paris_color, paris_time)
graphics.DrawLine(canvas, 0, 10, 128, 10, line_c)
graphics.DrawText(canvas, font, 2, 19, color, 'PARIS')
graphics.DrawText(canvas, font, x_offset, 30, in_color, in_time)
graphics.DrawLine(canvas, 0, 21, 128, 21, line_c)
graphics.DrawText(canvas, font, 2, 30, color, 'MUMBAI')
canvas = matrix.SwapOnVSync(canvas)
counter += 1
# print("CN:", cn_time,"PARIS:", paris_time,"MUMBAI:", in_time)
elif 18 <= counter <= 23:
canvas.Clear()
#SHANGHAI
auck_time = getTimes(auck_timezone)
#PARIS
bang_time = getTimes(bang_timezone)
#MUMBAI
istan_time = getTimes(istan_timezone)
auck_color = time_colors['day'] if isDaytime(auck_time) else time_colors['night']
bang_color = time_colors['day'] if isDaytime(bang_time) else time_colors['night']
istan_color = time_colors['day'] if isDaytime(istan_time) else time_colors['night']
if not settings['display_pm']:
auck_time = auck_time.replace("PM", "").replace("AM", "")
bang_time = bang_time.replace("PM", "").replace("AM", "")
istan_time = istan_time.replace("PM", "").replace("AM", "")
graphics.DrawText(canvas, font, x_offset, 8, auck_color, auck_time)
graphics.DrawText(canvas, font, 2, 8, color, 'AUCKLAND')
graphics.DrawText(canvas, font, x_offset, 19, bang_color, bang_time)
graphics.DrawLine(canvas, 0, 10, 128, 10, line_c)
graphics.DrawText(canvas, font, 2, 19, color, 'BANGKOK')
graphics.DrawText(canvas, font, x_offset, 30, istan_color, istan_time)
graphics.DrawLine(canvas, 0, 21, 128, 21, line_c)
graphics.DrawText(canvas, font, 2, 30, color, 'ISTANBUL')
canvas = matrix.SwapOnVSync(canvas)
counter += 1
# print("CN:", cn_time,"PARIS:", paris_time,"MUMBAI:", in_time)
if counter == 24:
counter = 0
time.sleep(1)