diff --git a/clock_screensaver.py b/clock_screensaver.py new file mode 100644 index 0000000..33448b0 --- /dev/null +++ b/clock_screensaver.py @@ -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) + + + + diff --git a/clock_screensaver2.py b/clock_screensaver2.py new file mode 100644 index 0000000..6db4f25 --- /dev/null +++ b/clock_screensaver2.py @@ -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) + diff --git a/csv/last_updates.json b/csv/last_updates.json index aba9e41..287c653 100644 --- a/csv/last_updates.json +++ b/csv/last_updates.json @@ -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}} diff --git a/database_caller.py b/database_caller.py index 9c359cc..8d4fbee 100755 --- a/database_caller.py +++ b/database_caller.py @@ -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®ion=US&lang=en-US&symbols=' + url1 = 'https://query1.finance.yahoo.com/v7/finance/quote?fields=longName,regularMarketPrice,regularMarketChangePercent,regularMarketChange,regularMarketDayHigh,regularMarketDayLow,regularMarketVolume®ion=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") diff --git a/feature_titles/market.png b/feature_titles/market.png new file mode 100644 index 0000000..d0f08de Binary files /dev/null and b/feature_titles/market.png differ diff --git a/feature_titles/place2017.png b/feature_titles/place2017.png new file mode 100644 index 0000000..76b2b38 Binary files /dev/null and b/feature_titles/place2017.png differ diff --git a/feature_titles/place2022.png b/feature_titles/place2022.png new file mode 100644 index 0000000..0d5df22 Binary files /dev/null and b/feature_titles/place2022.png differ diff --git a/feature_titles/place2023.png b/feature_titles/place2023.png new file mode 100644 index 0000000..7ca3042 Binary files /dev/null and b/feature_titles/place2023.png differ diff --git a/feature_titles/sector.png b/feature_titles/sector.png new file mode 100644 index 0000000..97cf7b2 Binary files /dev/null and b/feature_titles/sector.png differ diff --git a/feature_titles/small_feature_titles/market.png b/feature_titles/small_feature_titles/market.png new file mode 100644 index 0000000..1a9c9b5 Binary files /dev/null and b/feature_titles/small_feature_titles/market.png differ diff --git a/feature_titles/small_feature_titles/place2017.png b/feature_titles/small_feature_titles/place2017.png new file mode 100644 index 0000000..1008a18 Binary files /dev/null and b/feature_titles/small_feature_titles/place2017.png differ diff --git a/feature_titles/small_feature_titles/place2022.png b/feature_titles/small_feature_titles/place2022.png new file mode 100644 index 0000000..ca71843 Binary files /dev/null and b/feature_titles/small_feature_titles/place2022.png differ diff --git a/feature_titles/small_feature_titles/place2023.png b/feature_titles/small_feature_titles/place2023.png new file mode 100644 index 0000000..e251386 Binary files /dev/null and b/feature_titles/small_feature_titles/place2023.png differ diff --git a/feature_titles/small_feature_titles/sector.png b/feature_titles/small_feature_titles/sector.png new file mode 100644 index 0000000..c2c3a6d Binary files /dev/null and b/feature_titles/small_feature_titles/sector.png differ diff --git a/logos/active.png b/logos/active.png new file mode 100644 index 0000000..c0282fb Binary files /dev/null and b/logos/active.png differ diff --git a/logos/active_prof.png b/logos/active_prof.png new file mode 100644 index 0000000..a83def1 Binary files /dev/null and b/logos/active_prof.png differ diff --git a/logos/gainers.png b/logos/gainers.png new file mode 100644 index 0000000..6d7c921 Binary files /dev/null and b/logos/gainers.png differ diff --git a/logos/gainers_prof.png b/logos/gainers_prof.png new file mode 100644 index 0000000..67d0640 Binary files /dev/null and b/logos/gainers_prof.png differ diff --git a/logos/global_stocks/Untitled.rtf b/logos/global_stocks/Untitled.rtf new file mode 100644 index 0000000..262a694 --- /dev/null +++ b/logos/global_stocks/Untitled.rtf @@ -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 } \ No newline at end of file diff --git a/logos/losers.png b/logos/losers.png new file mode 100644 index 0000000..d4d3732 Binary files /dev/null and b/logos/losers.png differ diff --git a/logos/losers_prof.png b/logos/losers_prof.png new file mode 100644 index 0000000..920ba02 Binary files /dev/null and b/logos/losers_prof.png differ diff --git a/logos/r_place/r_place 2017.png b/logos/r_place/r_place 2017.png new file mode 100644 index 0000000..915659a Binary files /dev/null and b/logos/r_place/r_place 2017.png differ diff --git a/logos/r_place/r_place 2022.png b/logos/r_place/r_place 2022.png new file mode 100644 index 0000000..038f810 Binary files /dev/null and b/logos/r_place/r_place 2022.png differ diff --git a/logos/r_place/r_place 2023.png b/logos/r_place/r_place 2023.png new file mode 100644 index 0000000..652a99b Binary files /dev/null and b/logos/r_place/r_place 2023.png differ diff --git a/logos/sector/Communication Services.png b/logos/sector/Communication Services.png new file mode 100644 index 0000000..ff824aa Binary files /dev/null and b/logos/sector/Communication Services.png differ diff --git a/logos/sector/Consumer Discretionary.png b/logos/sector/Consumer Discretionary.png new file mode 100644 index 0000000..ab90710 Binary files /dev/null and b/logos/sector/Consumer Discretionary.png differ diff --git a/logos/sector/Consumer Staples.png b/logos/sector/Consumer Staples.png new file mode 100644 index 0000000..ab90710 Binary files /dev/null and b/logos/sector/Consumer Staples.png differ diff --git a/logos/sector/Energy.png b/logos/sector/Energy.png new file mode 100644 index 0000000..7376f11 Binary files /dev/null and b/logos/sector/Energy.png differ diff --git a/logos/sector/Financials.png b/logos/sector/Financials.png new file mode 100644 index 0000000..4384f92 Binary files /dev/null and b/logos/sector/Financials.png differ diff --git a/logos/sector/Health Care.png b/logos/sector/Health Care.png new file mode 100644 index 0000000..173b04f Binary files /dev/null and b/logos/sector/Health Care.png differ diff --git a/logos/sector/Industrials.png b/logos/sector/Industrials.png new file mode 100644 index 0000000..3ef2ffc Binary files /dev/null and b/logos/sector/Industrials.png differ diff --git a/logos/sector/Materials.png b/logos/sector/Materials.png new file mode 100644 index 0000000..e4adb3b Binary files /dev/null and b/logos/sector/Materials.png differ diff --git a/logos/sector/Real Estate.png b/logos/sector/Real Estate.png new file mode 100644 index 0000000..dbca59a Binary files /dev/null and b/logos/sector/Real Estate.png differ diff --git a/logos/sector/Technology.png b/logos/sector/Technology.png new file mode 100644 index 0000000..7ea1485 Binary files /dev/null and b/logos/sector/Technology.png differ diff --git a/logos/sector/Utilities.png b/logos/sector/Utilities.png new file mode 100644 index 0000000..dc40cfb Binary files /dev/null and b/logos/sector/Utilities.png differ diff --git a/logos/stocks/SHOP.png b/logos/stocks/SHOP.png index e2089ac..e6b75cf 100644 Binary files a/logos/stocks/SHOP.png and b/logos/stocks/SHOP.png differ diff --git a/logos/tiny_sectors/Communication Services.png b/logos/tiny_sectors/Communication Services.png new file mode 100644 index 0000000..f52fd15 Binary files /dev/null and b/logos/tiny_sectors/Communication Services.png differ diff --git a/logos/tiny_sectors/Utilities.png b/logos/tiny_sectors/Utilities.png new file mode 100644 index 0000000..9f45dab Binary files /dev/null and b/logos/tiny_sectors/Utilities.png differ diff --git a/server.py b/server.py index 2a4b808..3ab5d81 100755 --- a/server.py +++ b/server.py @@ -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 diff --git a/setup_config_files.sh b/setup_config_files.sh index 32a8610..d2ce806 100755 --- a/setup_config_files.sh +++ b/setup_config_files.sh @@ -14,23 +14,23 @@ touch crypto_settings.json last_updates.json system_info.json touch league_tables.json mkdir sports touch current_weather.json stocks_settings.json daily_weather.json live_games.json live_mlb.json live_mls.json live_nba.json live_nfl.json live_nhl.json live_pl.json commodities_settings.json indices_settings.json movie_settings.json ipo_settings.json -touch display_settings.json message_settings.json upcoming_games.json forex_settings.json prepost_settings.json scheduler.json economic_settings.json jokes_settings.json -touch GIF_settings.json news_settings.json image_settings.json past_games.json general_settings.json portfolio_settings.json portfolio_crypto_settings.json +touch display_settings.json message_settings.json upcoming_games.json forex_settings.json prepost_settings.json scheduler.json economic_settings.json jokes_settings.json place_settings.json clock1_settings.json clock2_settings.json worldclock_settings.json +touch GIF_settings.json news_settings.json image_settings.json past_games.json general_settings.json portfolio_settings.json portfolio_crypto_settings.json market_settings.json sector_settings.json -filenames="crypto_settings.json last_updates.json league_tables.json current_weather.json stocks_settings.json daily_weather.json live_games.json live_mlb.json live_mls.json live_nba.json live_nfl.json live_nhl.json live_pl.json commodities_settings.json indices_settings.json movie_settings.json ipo_settings.json economic_settings.json display_settings.json message_settings.json upcoming_games.json forex_settings.json GIF_settings.json news_settings.json image_settings.json past_games.json portfolio_settings.json portfolio_crypto_settings.json prepost_settings.json scheduler.json jokes_settings.json" +filenames="crypto_settings.json last_updates.json league_tables.json current_weather.json stocks_settings.json daily_weather.json live_games.json live_mlb.json live_mls.json live_nba.json live_nfl.json live_nhl.json live_pl.json commodities_settings.json indices_settings.json movie_settings.json ipo_settings.json economic_settings.json display_settings.json message_settings.json upcoming_games.json forex_settings.json GIF_settings.json news_settings.json image_settings.json past_games.json portfolio_settings.json portfolio_crypto_settings.json prepost_settings.json scheduler.json jokes_settings.json market_settings.json sector_settings.json place_settings.json clock1_settings.json clock2_settings.json worldclock_settings.json" echo '{"update_available": false, "first_boot": true}' >> system_info.json echo [\"Standard\", [[\"Stocks\", \"Crypto\", \"Forex\"]]] >> display_settings.json -echo '{"scheduler":{"force": false}, "stocks": {"time": "07/03/2022 12:33:06", "force": true}, "crypto": {"time": "07/03/2022 12:28:51", "force": true}, "news": {"time": "07/03/2022 12:28:51", "force": true}, "weather": {"time": "07/03/2022 12:28:51", "force": true}, "forex": {"time": "07/03/2022 12:28:51", "force": true}, "sports_l": {"time": "07/03/2022 12:32:46", "force": true}, "sports_p": {"time": "07/03/2022 12:32:26", "force": true}, "sports_u": {"time": "07/03/2022 12:31:55", "force": true}, "sports_t": {"time": "07/03/2022 12:32:56", "force": true}, "commodities": {"time": "07/03/2022 12:32:56", "force": true}, "indices": {"time": "07/03/2022 12:32:56", "force": true}, "movies": {"time": "07/03/2022 12:32:56", "force": true}, "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}}' >> last_updates.json +echo '{"scheduler":{"force": false}, "stocks": {"time": "07/03/2022 12:33:06", "force": true}, "crypto": {"time": "07/03/2022 12:28:51", "force": true}, "news": {"time": "07/03/2022 12:28:51", "force": true}, "weather": {"time": "07/03/2022 12:28:51", "force": true}, "forex": {"time": "07/03/2022 12:28:51", "force": true}, "sports_l": {"time": "07/03/2022 12:32:46", "force": true}, "sports_p": {"time": "07/03/2022 12:32:26", "force": true}, "sports_u": {"time": "07/03/2022 12:31:55", "force": true}, "sports_t": {"time": "07/03/2022 12:32:56", "force": true}, "commodities": {"time": "07/03/2022 12:32:56", "force": true}, "indices": {"time": "07/03/2022 12:32:56", "force": true}, "movies": {"time": "07/03/2022 12:32:56", "force": true}, "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}}' >> last_updates.json -echo '{"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.json +echo '{"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"}}}' >> crypto_settings.json echo '{"feature": "Stocks", "speed": "fast", "speed2": "fast", "animation": "down", "percent": true, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"BRENTOIL": {"current": "123.053", "unit": "bbl", "24hr_change": "1.0150", "percent_change": "0.83"}, "WTIOIL": {"current": "121.588", "unit": "bbl", "24hr_change": "0.8902", "percent_change": "0.74"}, "XAU": {"current": "1821.205", "unit": "oz", "24hr_change": "4.0045", "percent_change": "0.22"}, "XAG": {"current": "21.1034", "unit": "oz", "24hr_change": "-0.0550", "percent_change": "-0.26"}, "XCU": {"current": "0.2633", "unit": "oz", "24hr_change": "-0.0006", "percent_change": "-0.22"}, "NG": {"current": "8.6595", "unit": "mmbtu", "24hr_change": "-0.0236", "percent_change": "-0.27"}, "WHEAT": {"current": "393.123", "unit": "ton", "24hr_change": "-1.2642", "percent_change": "-0.32"}, "COTTON": {"current": "1.4494", "unit": "lb", "24hr_change": "0.0004", "percent_change": "0.03"}, "RICE": {"current": "16.3849", "unit": "cwt", "24hr_change": "0.0093", "percent_change": "0.06"}, "SUGAR": {"current": "0.1866", "unit": "lb", "24hr_change": "-0.0007", "percent_change": "-0.40"}, "COCOA": {"current": "2374.074", "unit": "ton", "24hr_change": "2.5206", "percent_change": "0.11"}, "LUMBER": {"current": "527.842", "unit": "oz", "24hr_change": "0.2641", "percent_change": "0.05"}, "SOYBEAN": {"current": "17.1621", "unit": "bu", "24hr_change": "0.0270", "percent_change": "0.16"}}}' >> commodities_settings.json echo '{"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"}}}' >> indices_settings.json echo '{"feature": "Sports (Team Stats)", "speed": "medium", "speed2": "medium","animation": "down", "title": true, "top20": 20, "leagues": {}}' >> league_tables.json echo {\"feature\": \"Current Weather\", \"speed\": \"medium\", \"animation\": \"down\", \"temp\": \"celsius\", \"wind_speed\": \"miles/hour\", \"colour\": \"white\", \"city_colour\": \"yellow\", \"title\": true, \"locations\": {}, \"current_weather\": true} >> current_weather.json -echo '{"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.json +echo '{"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}' >> stocks_settings.json echo {\"feature\": \"Current Weather\", \"speed\": \"medium\", \"animation\": \"down\", \"temp\": \"celsius\", \"wind_speed\": \"miles/hour\", \"colour\": \"white\", \"city_colour\": \"yellow\", \"title\": true, \"locations\": {}, \"current_weather\": true} >> daily_weather.json echo '{"feature": "Sports (Live Games)", "speed": "medium", "speed2": "medium", "animation": "down", "title": true, "leagues": {}}' >> live_games.json echo '{"feature": "Sports (Live Games)", "speed": "medium", "speed2": "medium", "animation": "down", "title": true, "leagues": {"MLB": [[{"home_team": "Columbus Blue Jackets", "home_score": "4", "away_team": "Buffalo Sabres", "away_score": "9", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Philadelphia Flyers", "home_score": "1", "away_team": "Washington Capitals", "away_score": "4", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Calgary Flames", "home_score": "5", "away_team": "Minnesota Wild", "away_score": "3", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Colorado Avalanche", "home_score": "0", "away_team": "Boston Bruins", "away_score": "4", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Edmonton Oilers", "home_score": "8", "away_team": "Arizona Coyotes", "away_score": "2", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "Vegas Golden Knights", "home_score": "1", "away_team": "New York Rangers", "away_score": "5", "time": "Final", "date": "2022-12-08", "isLive": "post"}, {"home_team": "San Jose Sharks", "home_score": "5", "away_team": "Vancouver Canucks", "away_score": "6", "time": "Final/OT", "date": "2022-12-08", "isLive": "post"}], false, "no_live", "no_upcoming"]}}' >> live_mlb.json @@ -45,14 +45,20 @@ echo '{"feature": "Stocks", "speed": "medium", "speed2": "medium", "animation": echo '{"speed": "medium", "speed2": "medium", "animation": "down", "title": true, "pause": "2", "images": []}'>> GIF_settings.json echo '{"feature": "News", "speed": "medium", "speed2": "medium", "animation": "down", "country": "US", "category": "General", "title": true, "headlines": [], "use_category": true, "use_country": false, "num_headlines": "10"}' >> news_settings.json echo '{"speed": "slow", "speed2": "medium","animation": "down", "title": true, "pause": "/", "images": []}' >> image_settings.json +echo '{"feature": "Place", "speed": "medium", "speed2": "medium", "animation": "up", "title": true, "width": "128", "pause": "0", "places": ["r/place 2017", "r/place 2022"]}' >> place_settings.json echo '{"feature": "Sports (Past Games)", "speed2": "medium", "speed": "medium", "animation": "down", "title": true, "leagues": {}}' >> past_games.json echo '{"feature": "Movies", "speed": "fast", "speed2": "fast", "animation": "continuous", "category": "Popular All", "title": true, "movies": [{"title": "Avatar: The Way of Water", "language": "EN", "votes": "8.1", "date": "2022-12-14", "media_type": "Movie", "genre": ["Sci-Fi", "Action", "Adventure"], "backdrop": "198vrF8k7mfQ4FjDJsBmdQcaiyq.jpg", "logo": "https://image.tmdb.org/t/p/w500/198vrF8k7mfQ4FjDJsBmdQcaiyq.jpg"}, {"title": "Violent Night", "language": "EN", "votes": "7.3", "date": "2022-11-30", "media_type": "Movie", "genre": ["Action", "Comedy", "Crime", "Thriller"], "backdrop": "g9Kb3RaLjsybI1jpqHQ3QZTCYpB.jpg", "logo": "https://image.tmdb.org/t/p/w500/g9Kb3RaLjsybI1jpqHQ3QZTCYpB.jpg"}, {"title": "Avatar", "language": "EN", "votes": "7.5", "date": "2009-12-15", "media_type": "Movie", "genre": ["Action", "Adventure", "Fantasy", "Sci-Fi"], "backdrop": "Yc9q6QuWrMp9nuDm5R8ExNqbEq.jpg", "logo": "https://image.tmdb.org/t/p/w500/Yc9q6QuWrMp9nuDm5R8ExNqbEq.jpg"}, {"title": "The Banshees of Inisherin", "language": "EN", "votes": "7.7", "date": "2022-10-21", "media_type": "Movie", "genre": ["Drama", "Comedy"], "backdrop": "9Md4CqzUGDtK5oEkRRvozLkGc9d.jpg", "logo": "https://image.tmdb.org/t/p/w500/9Md4CqzUGDtK5oEkRRvozLkGc9d.jpg"}, {"title": "Wednesday", "language": "EN", "votes": "8.8", "date": "2022-11-23", "media_type": "Tv", "genre": ["Sci-Fi & Fantasy", "Mystery", "Comedy"], "backdrop": "iHSwvRVsRyxpX7FE7GbviaDvgGZ.jpg", "logo": "https://image.tmdb.org/t/p/w500/iHSwvRVsRyxpX7FE7GbviaDvgGZ.jpg"}, {"title": "1923", "language": "EN", "votes": "8.8", "date": "2022-12-18", "media_type": "Tv", "genre": ["Drama", "Western"], "backdrop": "9I6LgZ5110ycg4pyobJxGTFWFCF.jpg", "logo": "https://image.tmdb.org/t/p/w500/9I6LgZ5110ycg4pyobJxGTFWFCF.jpg"}, {"title": "The Recruit", "language": "EN", "votes": "7.2", "date": "2022-12-16", "media_type": "Tv", "genre": ["Drama", "Crime"], "backdrop": "rey2eh6752C2UbGYRileKk1PVTo.jpg", "logo": "https://image.tmdb.org/t/p/w500/rey2eh6752C2UbGYRileKk1PVTo.jpg"}, {"title": "Black Adam", "language": "EN", "votes": "7.2", "date": "2022-10-19", "media_type": "Movie", "genre": ["Action", "Fantasy", "Sci-Fi"], "backdrop": "bQXAqRx2Fgc46uCVWgoPz5L5Dtr.jpg", "logo": "https://image.tmdb.org/t/p/w500/bQXAqRx2Fgc46uCVWgoPz5L5Dtr.jpg"}, {"title": "Nanny", "language": "EN", "votes": "5.4", "date": "2022-11-23", "media_type": "Movie", "genre": ["Horror", "Drama"], "backdrop": "nfuPlOK6ywGzKGb0yf7VJKyTFWb.jpg", "logo": "https://image.tmdb.org/t/p/w500/nfuPlOK6ywGzKGb0yf7VJKyTFWb.jpg"}, {"title": "Tom Clancys Jack Ryan", "language": "EN", "votes": "7.7", "date": "2018-08-30", "media_type": "Tv", "genre": ["Action & Adventure", "Drama", "War & Politics"], "backdrop": "6ovk8nrrSmN1ieT14zBAxcHbMU7.jpg", "logo": "https://image.tmdb.org/t/p/w500/6ovk8nrrSmN1ieT14zBAxcHbMU7.jpg"}, {"title": "High Heat", "language": "EN", "votes": "6.5", "date": "2022-12-16", "media_type": "Movie", "genre": ["Action", "Comedy", "Crime"], "backdrop": "gjNM0odqkq5F7V58OjfTxPJ9p9Z.jpg", "logo": "https://image.tmdb.org/t/p/w500/gjNM0odqkq5F7V58OjfTxPJ9p9Z.jpg"}, {"title": "A Not So Merry Christmas", "language": "ES", "votes": "4.8", "date": "2022-12-20", "media_type": "Movie", "genre": ["Comedy"], "backdrop": "8uyJzaiGbiezZ9K48Cy5wXeqnYw.jpg", "logo": "https://image.tmdb.org/t/p/w500/8uyJzaiGbiezZ9K48Cy5wXeqnYw.jpg"}, {"title": "Guillermo del Toros Pinocchio", "language": "EN", "votes": "8.5", "date": "2022-11-09", "media_type": "Movie", "genre": ["Animation", "Fantasy", "Drama"], "backdrop": "e782pDRAlu4BG0ahd777n8zfPzZ.jpg", "logo": "https://image.tmdb.org/t/p/w500/e782pDRAlu4BG0ahd777n8zfPzZ.jpg"}, {"title": "His Dark Materials", "language": "EN", "votes": "8.0", "date": "2019-11-03", "media_type": "Tv", "genre": ["Sci-Fi & Fantasy", "Drama"], "backdrop": "dGOhplPZTL0SKyb0ocTFBHIuKUC.jpg", "logo": "https://image.tmdb.org/t/p/w500/dGOhplPZTL0SKyb0ocTFBHIuKUC.jpg"}, {"title": "The Fabelmans", "language": "EN", "votes": "7.8", "date": "2022-11-11", "media_type": "Movie", "genre": ["Drama", "Comedy"], "backdrop": "6RCf9jzKxyjblYV4CseayK6bcJo.jpg", "logo": "https://image.tmdb.org/t/p/w500/6RCf9jzKxyjblYV4CseayK6bcJo.jpg"}, {"title": "The Seven Deadly Sins: Grudge of Edinburgh Part 1", "language": "JA", "votes": "7.8", "date": "2022-12-20", "media_type": "Movie", "genre": ["Animation", "Fantasy", "Adventure", "Action"], "backdrop": "24fe6ou97ammOg3O6ShCgaiolp4.jpg", "logo": "https://image.tmdb.org/t/p/w500/24fe6ou97ammOg3O6ShCgaiolp4.jpg"}, {"title": "Mindcage", "language": "EN", "votes": "7.6", "date": "2022-12-16", "media_type": "Movie", "genre": ["Mystery", "Thriller", "Crime", "Drama"], "backdrop": "An2M2gm0p8POaiGTcZvP1JnUItH.jpg", "logo": "https://image.tmdb.org/t/p/w500/An2M2gm0p8POaiGTcZvP1JnUItH.jpg"}, {"title": "Private Lesson", "language": "TR", "votes": "7.3", "date": "2022-12-16", "media_type": "Movie", "genre": ["Comedy", "Romance"], "backdrop": "uZtYhcnk3WWvUzQkJLqnNywMQpb.jpg", "logo": "https://image.tmdb.org/t/p/w500/uZtYhcnk3WWvUzQkJLqnNywMQpb.jpg"}, {"title": "Sonic Prime", "language": "EN", "votes": "8.7", "date": "2022-12-15", "media_type": "Tv", "genre": ["Animation", "Family"], "backdrop": "1Iiz2uLcZuLn4Khog2yiKpbl11.jpg", "logo": "https://image.tmdb.org/t/p/w500/1Iiz2uLcZuLn4Khog2yiKpbl11.jpg"}, {"title": "The Big 4", "language": "ID", "votes": "7.0", "date": "2022-12-19", "media_type": "Movie", "genre": ["Action", "Comedy", "Crime"], "backdrop": "clO1mWRYT24ogzN3o6LsqHjqrQu.jpg", "logo": "https://image.tmdb.org/t/p/w500/clO1mWRYT24ogzN3o6LsqHjqrQu.jpg"}]}' >> movie_settings.json echo '{"feature": "IPO", "speed": "medium", "speed2": "medium", "animation": "down", "title": true, "symbols": ["No Data"]}' >> ipo_settings.json echo '{"symbols": {}}' >> portfolio_settings.json echo '{"symbols": {}}' >> portfolio_crypto_settings.json echo '{}' >> prepost_settings.json +echo '{"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"}' >> clock1_settings.json +echo '{"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"}' >> clock2_settings.json +echo '{"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"}' >> worldclock_settings.json +echo '{"feature": "Sector Performance", "speed": "medium", "speed2": "medium", "animation": "up", "logos": true, "title": true, "sectors": ["Energy", "Financials", "Real Estate", "Technology"], "data": {}}' >> sector_settings.json +echo '{"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": {}}' >> market_settings.json echo '{"feature": "Jokes", "speed": "medium", "speed2": "medium", "animation": "up", "title": true, "safe": true, "categories": ["Any"], "blacklist": [], "amount": "5", "jokes": []}' >> jokes_settings.json -echo '{"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.json +echo '{"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.json echo '{"feature": "Economic Calendar", "speed": "medium", "speed2": "medium", "animation": "up", "importance": "Med - High", "title": true, "timezone": "US/Eastern", "countries": ["United States"], "events": []}' >> economic_settings.json echo '{"brightness": 10, "country_code": "GB", "hostname": "fintic"}' >> general_settings.json @@ -108,6 +114,12 @@ touch 'Economic Calendar.ppm' touch 'Economic Calendar Prof.ppm' touch 'Jokes.ppm' touch 'Jokes Prof.ppm' +touch 'Gainers, Losers, Active.ppm' +touch 'Gainers, Losers, Active Prof.ppm' +touch 'Sector Performance.ppm' +touch 'Sector Performance Prof.ppm' +touch 'Place (Reddit).ppm' +touch 'Place (Reddit) Prof.ppm' chmod 777 * diff --git a/static/app.js b/static/app.js index 4ec6dd1..13e663e 100755 --- a/static/app.js +++ b/static/app.js @@ -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"; +} diff --git a/static/style.css b/static/style.css index 0db9b9d..9858303 100755 --- a/static/style.css +++ b/static/style.css @@ -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; +} + + diff --git a/stockTicker.py b/stockTicker.py index 85eabad..e1f6651 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -17,7 +17,7 @@ import time import csv import requests import pexpect -from rgbmatrix import RGBMatrix, RGBMatrixOptions +from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics from rgbmatrix.graphics import * from multiprocessing import Process import traceback @@ -26,6 +26,47 @@ from datetime import datetime import matplotlib.colors as mcolors ny_zone = pytz.timezone('America/New_York') +gmt_zone = pytz.timezone('Etc/GMT') +gmt1_zone = pytz.timezone('Etc/GMT+1') +gmt2_zone = pytz.timezone('Etc/GMT+2') +gmt3_zone = pytz.timezone('Etc/GMT+3') +gmt4_zone = pytz.timezone('Etc/GMT+4') +gmt5_zone = pytz.timezone('Etc/GMT+5') +gmt6_zone = pytz.timezone('Etc/GMT+6') +gmt7_zone = pytz.timezone('Etc/GMT+7') +gmt8_zone = pytz.timezone('Etc/GMT+8') +gmt9_zone = pytz.timezone('Etc/GMT+9') +gmt10_zone = pytz.timezone('Etc/GMT+10') +gmt11_zone = pytz.timezone('Etc/GMT+11') +gmt12_zone = pytz.timezone('Etc/GMT+12') +gmtn1_zone = pytz.timezone('Etc/GMT-1') +gmtn2_zone = pytz.timezone('Etc/GMT-2') +gmtn3_zone = pytz.timezone('Etc/GMT-3') +gmtn4_zone = pytz.timezone('Etc/GMT-4') +gmtn5_zone = pytz.timezone('Etc/GMT-5') +gmtn6_zone = pytz.timezone('Etc/GMT-6') +gmtn7_zone = pytz.timezone('Etc/GMT-7') +gmtn8_zone = pytz.timezone('Etc/GMT-8') +gmtn9_zone = pytz.timezone('Etc/GMT-9') +gmtn10_zone = pytz.timezone('Etc/GMT-10') +gmtn11_zone = pytz.timezone('Etc/GMT-11') +gmtn12_zone = pytz.timezone('Etc/GMT-12') +gmtn13_zone = pytz.timezone('Etc/GMT-13') +gmtn14_zone = pytz.timezone('Etc/GMT-14') +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') + +place_featuretitle = False def getInput(Block=False): if Block or select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []): @@ -66,26 +107,27 @@ class StockTicker(): #sys.exit() self.points = True # display crypto change in points or percent - self.functions = {'Stocks': self.getStockImage, 'Crypto': self.getCryptoImage, 'Forex': self.getForexImage, - 'Daily Forecast':self.getDailyWeatherImage, 'Current Weather': self.getTodayWeatherImage, 'Jokes': self.getJokesImage, + self.functions = {'Stocks': self.getStockImage, 'Crypto': self.getCryptoImage, 'Forex': self.getForexImage, 'Sector Performance': self.getSectorImage, + 'Daily Forecast':self.getDailyWeatherImage, 'Current Weather': self.getTodayWeatherImage, 'Jokes': self.getJokesImage, 'Place (Reddit)': self.getPlaceImage, 'Sports (Team Stats)':lambda : self.getLeagueTableImage('premier_league'), 'Sports (Past Games)': lambda:self.getLeagueImage('NBA', 'past'), 'Sports (Upcoming Games)': lambda : self.getLeagueImage('NHL', 'future'), 'Sports (Live Games)': lambda: self.getLeagueImage('NBA', 'live'), - 'News':self.getNewsImage, 'Custom Messages': self.getUserMessages, 'Commodities': self.getCommoditiesImage, 'Indices': self.getIndicesImage, 'Movies': self.getMoviesImage, - 'Economic Calendar': self.getEconomicImage, 'IPO Calendar':self.getIpoImage, 'IPO Calendar Prof':self.getIpoProfessional, 'Economic Calendar Prof': self.getEconomicProfessional, + 'News':self.getNewsImage, 'Custom Messages': self.getUserMessages, 'Commodities': self.getCommoditiesImage, 'Indices': self.getIndicesImage, 'Movies': self.getMoviesImage, 'Gainers, Losers, Active': self.getMarketImage, + 'Economic Calendar': self.getEconomicImage, 'IPO Calendar':self.getIpoImage, 'IPO Calendar Prof':self.getIpoProfessional, 'Economic Calendar Prof': self.getEconomicProfessional, 'Gainers, Losers, Active Prof': self.getMarketProfessional, - 'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional, 'Jokes Prof': self.getJokesProfessional, - 'Current Weather Prof': self.getTodayWeatherProfessional, 'News Prof':self.getNewsProfessional, 'Commodities Prof':self.getCommoditiesProfessional, 'Indices Prof': self.getIndicesProfessional, + 'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional, 'Jokes Prof': self.getJokesProfessional, 'Place (Reddit) Prof': self.getPlaceImageProfessional, + 'Current Weather Prof': self.getTodayWeatherProfessional, 'News Prof':self.getNewsProfessional, 'Commodities Prof':self.getCommoditiesProfessional, 'Indices Prof': self.getIndicesProfessional, 'Sector Performance Prof': self.getSectorProfessional, 'Daily Forecast Prof':self.getDailyWeatherProfessional, 'Sports (Team Stats) Prof':lambda : self.getLeagueTableProfessional('NHL'), 'Sports (Upcoming Games) Prof': lambda : self.getLeagueProfessional('NHL', 'future'), 'Sports (Past Games) Prof': lambda : self.getLeagueProfessional('NBA', 'past'), 'Custom Messages Prof': self.getUserMessagesProfessional, 'Custom Images Prof': self.getUserImagesProfessional, 'Movies Prof': self.getMoviesProfessional, 'Sports (Live Games) Prof': lambda : self.getLeagueProfessional('NBA', 'live')} self.JSONs = {'Stocks': 'csv/stocks_settings.json', 'Crypto': 'csv/crypto_settings.json', 'Forex': 'csv/forex_settings.json', 'Jokes': 'csv/jokes_settings.json', 'Daily Forecast':'csv/daily_weather.json', 'Current Weather': 'csv/current_weather.json', 'Commodities':'csv/commodities_settings.json', 'Indices': 'csv/indices_settings.json', 'Sports (Team Stats)': 'csv/league_tables.json', 'Sports (Past Games)': 'csv/past_games.json', 'IPO Calendar': 'csv/ipo_settings.json', 'Economic Calendar': 'csv/economic_settings.json', - 'Sports (Upcoming Games)': 'csv/upcoming_games.json', 'Sports (Live Games)': 'csv/live_games.json', 'Movies': 'csv/movie_settings.json', - 'News':'csv/news_settings.json', 'Custom Images': 'csv/image_settings.json', 'Custom GIFs': 'csv/GIF_settings.json', 'Custom Messages': 'csv/message_settings.json', - 'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json', 'Jokes Prof': 'csv/jokes_settings.json', + 'Sports (Upcoming Games)': 'csv/upcoming_games.json', 'Sports (Live Games)': 'csv/live_games.json', 'Movies': 'csv/movie_settings.json', 'Clock 1': 'csv/clock1_settings.json', 'Clock 2': 'csv/clock2_settings.json', 'World Clock': 'csv/worldclock_settings.json', + 'News':'csv/news_settings.json', 'Custom Images': 'csv/image_settings.json', 'Custom GIFs': 'csv/GIF_settings.json', 'Custom Messages': 'csv/message_settings.json', 'Clock 1 Prof': 'csv/clock1_settings.json', 'World Clock Prof': 'csv/worldclock_settings.json', + 'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json', 'Jokes Prof': 'csv/jokes_settings.json', 'Clock 2 Prof': 'csv/clock2_settings.json', 'Current Weather Prof': 'csv/current_weather.json', 'News Prof':'csv/news_settings.json', 'Commodities Prof':'csv/commodities_settings.json', 'Indices Prof': 'csv/indices_settings.json', - 'Daily Forecast Prof':'csv/daily_weather.json', 'Sports (Team Stats) Prof': 'csv/league_tables.json', 'Sports (Upcoming Games) Prof': 'csv/upcoming_games.json', 'Sports (Past Games) Prof': 'csv/past_games.json', 'Custom Messages Prof': 'csv/message_settings.json', 'Custom Images Prof': 'csv/image_settings.json', 'Movies Prof': 'csv/movie_settings.json', 'Sports (Live Games) Prof': 'csv/live_games.json', 'IPO Calendar Prof': 'csv/ipo_settings.json', 'Economic Calendar Prof': 'csv/economic_settings.json'} + 'Daily Forecast Prof':'csv/daily_weather.json', 'Sports (Team Stats) Prof': 'csv/league_tables.json', 'Sports (Upcoming Games) Prof': 'csv/upcoming_games.json', 'Sports (Past Games) Prof': 'csv/past_games.json', 'Custom Messages Prof': 'csv/message_settings.json', 'Custom Images Prof': 'csv/image_settings.json', 'Movies Prof': 'csv/movie_settings.json', 'Sports (Live Games) Prof': 'csv/live_games.json', 'IPO Calendar Prof': 'csv/ipo_settings.json', 'Economic Calendar Prof': 'csv/economic_settings.json', + 'Gainers, Losers, Active':'csv/market_settings.json', 'Gainers, Losers, Active Prof':'csv/market_settings.json', 'Sector Performance':'csv/sector_settings.json', 'Sector Performance Prof':'csv/sector_settings.json', 'Place (Reddit)':'csv/place_settings.json', 'Place (Reddit) Prof':'csv/place_settings.json'} def openImage(self, image_file): @@ -131,11 +173,15 @@ class StockTicker(): (r, g, b) = pixels[x, y] self.matrix.SetPixel(x + offset_x, y + offset_y, r*self.brightness, g*self.brightness, b*self.brightness) - def scrollImage(self, image, offset_x = 0, offset_y = 0, frame_skip = 10, gif = False, pause_frames = 0): + def scrollImage(self, image, offset_x = 0, offset_y = 0, frame_skip = 10, gif = False, pause_frames = 0, place = False): img_width, img_height = image.size kill = False + if place: + value = -85 + else: + value = 0 while offset_x > -(img_width+1): - if offset_x == 0: + if offset_x == value: while pause_frames > 0: if pause_frames%frame_skip == 0: self.incrementGIF(image) @@ -295,7 +341,7 @@ class StockTicker(): for option in options: - if option not in ['Custom GIFs', 'Custom Images', 'Custom Messages']: # these images are already saved in user uploads, dodnt need to update them + if option not in ['Custom GIFs', 'Custom Images', 'Custom Messages', 'Place (Reddit)', 'Clock 1', 'Clock 2', 'World Clock', 'Clock 1 Prof', 'Clock 2 Prof', 'World Clock Prof']: # these images are already saved in user uploads, dodnt need to update them img = self.functions[option]() img.save('./display_images/'+ option+ '.ppm') @@ -336,10 +382,8 @@ class StockTicker(): def scrollFunctionsAnimated(self, options, animation = 'down', repeat = True): # scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed - self.updateMultiple([options[0]]) - kill = False i = 0 # keep track of which image we are displaying self.double_buffer = self.matrix.CreateFrameCanvas() @@ -353,86 +397,102 @@ class StockTicker(): settings = json.load(f) f.close() - self.set_delay(settings['speed']) - animation = settings['animation'].lower() - - if options[i % len(options)] == 'Custom Images': - images = self.getUserImages() + if options[i % len(options)] == 'Clock 1': + kill=self.showClock1() + elif options[i % len(options)] == 'Clock 2': + kill=self.showClock2() + elif options[i % len(options)] == 'World Clock': + kill=self.showWorldclock() + else: + self.set_delay(settings['speed']) + animation = settings['animation'].lower() - elif options[i % len(options)] == 'Custom GIFs': - images = self.getUserGIFs() - - elif options[i % len(options)] == 'Custom Messages': - images = self.getUserMessages() - - - else: #these options just have a single ppm image - image = self.openImage('./display_images/' + options[i % len(options)] +'.ppm') - - images = [image] - - - for image in images: - img_width, img_height = image.size - - offset_x = 0 - if animation == 'continuous': - offset_x = 128 - elif animation in ['up', 'down']: - offset_x = max(0, 128-img_width) - - offset_y = 0 - #first scroll image in from bottom - - - - frame_skip = int((1/15)/self.delay) #controls how fast gifs run - self.frame = 0 - - pause_frames = int(0.5/self.delay) - if animation == 'up': - offset_y = 33 - direction = -1 - kill = self.scrollImageY(image, direction = direction, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'Custom GIFs') - elif animation == 'down': - direction = 1 - offset_y = -33 - kill = self.scrollImageY(image, direction = direction, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'Custom GIFs') + if options[i % len(options)] == 'Custom Images': + images = self.getUserImages() + + elif options[i % len(options)] == 'Place (Reddit)': + images = self.getPlaceImage() - if kill: break - offset_y = 0 - - - if animation in ['up', 'down']: - while pause_frames > 0: - if pause_frames%frame_skip == 0: - self.incrementGIF(image) - - pause_frames -=1 - if options[i % len(options)] != 'Custom GIFs': - self.double_buffer.SetImage(image, offset_x, offset_y) - else: - self.double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y) + elif options[i % len(options)] == 'Custom GIFs': + images = self.getUserGIFs() - self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer) + elif options[i % len(options)] == 'Custom Messages': + images = self.getUserMessages() + + + else: #these options just have a single ppm image + image = self.openImage('./display_images/' + options[i % len(options)] +'.ppm') + + images = [image] + + + for image in images: + img_width, img_height = image.size + + offset_x = 0 + + if animation == 'continuous': + offset_x = 128 + elif animation in ['up', 'down']: + offset_x = max(0, 128-img_width) + + offset_y = 0 + #first scroll image in from bottom + + + + frame_skip = int((1/15)/self.delay) #controls how fast gifs run + self.frame = 0 + + pause_frames = int(0.5/self.delay) + if animation == 'up': + offset_y = 33 + direction = -1 + kill = self.scrollImageY(image, direction = direction, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'Custom GIFs') + elif animation == 'down': + direction = 1 + offset_y = -33 + kill = self.scrollImageY(image, direction = direction, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'Custom GIFs') + + if kill: break + offset_y = 0 + + + if animation in ['up', 'down']: + while pause_frames > 0: + if pause_frames%frame_skip == 0: + self.incrementGIF(image) + + pause_frames -=1 + if options[i % len(options)] != 'Custom GIFs': + self.double_buffer.SetImage(image, offset_x, offset_y) + else: + self.double_buffer.SetImage(image.convert('RGB'), offset_x, offset_y) + + self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer) + + time.sleep(self.delay) + kill = self.checkKilled() + if kill: break + - time.sleep(self.delay) - kill = self.checkKilled() if kill: break - + + + if kill: break + try: + pause = float(settings['pause']) + except: + pause = 0 + pause_frames = int(float(pause)/self.delay) + if options[i % len(options)] == 'Place (Reddit)': + global place_featuretitle + place_true = place_featuretitle + else: + place_true = False + kill = self.scrollImage(image, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'Custom GIFs', pause_frames = pause_frames, place = place_true) if kill: break - - - if kill: break - try: - pause = float(settings['pause']) - except: - pause = 0 - pause_frames = int(float(pause)/self.delay) - kill = self.scrollImage(image, offset_x = offset_x, offset_y = offset_y, frame_skip = frame_skip, gif = options[i % len(options)] == 'Custom GIFs', pause_frames = pause_frames) - - if kill: break if kill:break if not repeat: break @@ -440,16 +500,38 @@ class StockTicker(): update_process.terminate() i+=1 + def scrollProfessionalAnimated(self, options, animation = 'on'): # scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed - top = options[0] bottom = options[1] - - - self.updateMultiple([top[0], bottom[0]]) +# self.updateMultiple([top[0], bottom[0]]) + # ADDING THIS FOR COLORS FOR CLOCK FEATURES + time_colors1 = { + "White": (255,255,255), "Red": (255, 0,0), "Green": (0,255,0), "Dark Green": (0, 100,0), "Blue": (0,0,255), "Purple": (145,0,255), + "Pink": (255,0,255), "Yellow": (255,255,0), "Orange": (255,130,0), "Gold": (255,190,0), "Gray": (100,100,100), "Cyan": (0,255,255)} + day_colors = {"day":(255, 191, 0), "night":(0, 71,171)} + + def isDaytime1(time,twelvehours): + if twelvehours: + 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 + 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 kill = False i1 = 0 # keep track of which image we are displaying @@ -457,66 +539,337 @@ class StockTicker(): self.double_buffer = self.matrix.CreateFrameCanvas() update_process = Process(target = self.updateMultiple, args = ([top[(i1+1) % len(top)]+ ' Prof', bottom[(i2+1) % len(bottom)]+ ' Prof' ],)) - update_process.start() - self.updateMultiple([top[i1 % len(top)]+ ' Prof', bottom[i2 % len(bottom)]+ ' Prof' ]) - - image1 = self.openImage('./display_images/' + top[i1 % len(top)] +' Prof.ppm') - image1 = image1.convert('RGB') - - - image2 = self.openImage('./display_images/' + bottom[i2 % len(bottom)] +' Prof.ppm') - image2 = image2.convert('RGB') - - settings1 = json.load(open(self.JSONs[top[i1 % len(top)]])) - - delay_t1 = self.set_delay(settings1['speed']) - animation1 = settings1['animation'].lower() - settings2 = json.load(open(self.JSONs[bottom[i2 % len(bottom)] ])) + + if 'Clock' not in top[i1 % len(top)]: + image1 = self.openImage('./display_images/' + top[i1 % len(top)] +' Prof.ppm') + image1 = image1.convert('RGB') + elif top[i1 % len(top)] == 'Clock 2': #CLOCK 2 SETTINGS + image1 = Image.new('RGB', (128, 16)) + draw = ImageDraw.Draw(image1) + the_time = time.time() + font = ImageFont.load("fonts/6x12.pil") + font2 = ImageFont.load("fonts/5x8.pil") + try: + with open('clock_screensaver.json', 'r') as f: + clock2_settings = json.load(f)['clock2'] + except: + clock_settings = {"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_settings, f) + clock2_settings = clock_settings['clock2'] + time_color1 = clock2_settings['time_color'] + date_color1 = clock2_settings['date_color'] + timezone1 = clock2_settings['timezone'] + display_s = clock2_settings['display_seconds'] + display_p = clock2_settings['display_pm'] + twelvehours = clock2_settings['12hour'] + if twelvehours: + if display_p and display_s: + time_format = "%I:%M:%S %p" + elif display_p and not display_s: + time_format = "%I:%M %p" + elif not display_p and display_s: + time_format = "%I:%M:%S" + else: + time_format = "%I:%M" + else: + if display_p and display_s: + time_format = "%H:%M:%S %p" + elif display_p and not display_s: + time_format = "%H:%M %p" + elif not display_p and display_s: + time_format = "%H:%M:%S" + else: + time_format = "%H:%M" + if '+' in timezone1: + timezone1 = timezone1.replace('+', '-') + elif '-' in timezone1: + timezone1 = timezone1.replace('-', '+') + elif top[i1 % len(top)] == 'Clock 1': #CLOCK 1 SETTINGS + image1 = Image.new('RGB', (128, 16)) + draw = ImageDraw.Draw(image1) + the_time = time.time() + font_1 = ImageFont.load("fonts/7x14B.pil") + font_2 = ImageFont.load("fonts/5x8.pil") + try: + with open('clock_screensaver.json', 'r') as f: + clock1_settings = json.load(f)['clock1'] + except: + clock_settings = {"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_settings, f) + clock1_settings = clock_settings['clock1'] + time_color2 = clock1_settings['time_color'] + date_color2 = clock1_settings['date_color'] + weekday_color2 = clock1_settings['weekday_color'] + timezone2 = clock1_settings['timezone'] + display_s = clock1_settings['display_seconds'] + display_p = clock1_settings['display_pm'] + twelvehours = clock1_settings['12hour'] + if twelvehours: + if display_p and display_s: + time_format = "%I:%M:%S %p" + elif display_p and not display_s: + time_format = "%I:%M %p" + elif not display_p and display_s: + time_format = "%I:%M:%S" + else: + time_format = "%I:%M" + else: + if display_p and display_s: + time_format = "%H:%M:%S %p" + elif display_p and not display_s: + time_format = "%H:%M %p" + elif not display_p and display_s: + time_format = "%H:%M:%S" + else: + time_format = "%H:%M" + if '+' in timezone2: + timezone2 = timezone2.replace('+', '-') + elif '-' in timezone2: + timezone2 = timezone2.replace('-', '+') + elif top[i1 % len(top)] == 'World Clock': #WORLD CLOCK SETTINGS + image1 = Image.new('RGB', (128, 16)) + draw = ImageDraw.Draw(image1) + the_time = time.time() + next_six_seconds = 0 + counter = 0 + font_1 = ImageFont.load("fonts/4x6.pil") + try: + with open('clock_screensaver.json', 'r') as f: + world_settings = json.load(f)['world_clock'] + except: + clock_settings = {"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_settings, f) + world_settings = clock_settings['world_clock'] + worldcity_color = world_settings['city_color'] + display_s = world_settings['display_seconds'] + display_p = world_settings['display_pm'] + twelvehours = world_settings['12hour'] + if twelvehours: + if display_p and display_s: + time_format = "%I:%M:%S %p" + world_offset = 82 + elif display_p and not display_s: + time_format = "%I:%M %p" + world_offset = 94 + elif not display_p and display_s: + time_format = "%I:%M:%S %p" + world_offset = 94 + else: + time_format = "%I:%M %p" + world_offset = 106 + else: + if display_p and display_s: + time_format = "%H:%M:%S %p" + world_offset = 82 + elif display_p and not display_s: + time_format = "%H:%M %p" + world_offset = 94 + elif not display_p and display_s: + time_format = "%H:%M:%S %p" + world_offset = 94 + else: + time_format = "%H:%M %p" + world_offset = 106 + #BOTTOM SETTINGS + if 'Clock' not in bottom[i2 % len(bottom)]: + image2 = self.openImage('./display_images/' + bottom[i2 % len(bottom)] +' Prof.ppm') + image2 = image2.convert('RGB') + elif bottom[i2 % len(bottom)] == 'Clock 2': #CLOCK 2 SETTINGS + image2 = Image.new('RGB', (128, 16)) + draw2 = ImageDraw.Draw(image2) + the_time2 = time.time() + font_b = ImageFont.load("fonts/6x12.pil") + font2_b = ImageFont.load("fonts/5x8.pil") + try: + with open('clock_screensaver.json', 'r') as f: + clock2_settings = json.load(f)['clock2'] + except: + clock_settings = {"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_settings, f) + clock2_settings = clock_settings['clock2'] + time_color1_b = clock2_settings['time_color'] + date_color1_b = clock2_settings['date_color'] + timezone1_b = clock2_settings['timezone'] + display_s_b = clock2_settings['display_seconds'] + display_p_b = clock2_settings['display_pm'] + twelvehours_b = clock2_settings['12hour'] + if twelvehours_b: + if display_p_b and display_s_b: + time_format_b = "%I:%M:%S %p" + elif display_p_b and not display_s_b: + time_format_b = "%I:%M %p" + elif not display_p_b and display_s_b: + time_format_b = "%I:%M:%S" + else: + time_format_b = "%I:%M" + else: + if display_p_b and display_s_b: + time_format_b = "%H:%M:%S %p" + elif display_p_b and not display_s_b: + time_format_b = "%H:%M %p" + elif not display_p_b and display_s_b: + time_format_b = "%H:%M:%S" + else: + time_format_b = "%H:%M" + if '+' in timezone1_b: + timezone1_b = timezone1_b.replace('+', '-') + elif '-' in timezone1_b: + timezone1_b = timezone1_b.replace('-', '+') + elif bottom[i2 % len(bottom)] == 'Clock 1': #CLOCK 1 SETTINGS + image2 = Image.new('RGB', (128, 16)) + draw2 = ImageDraw.Draw(image2) + the_time2 = time.time() + font_1_b = ImageFont.load("fonts/7x14B.pil") + font_2_b = ImageFont.load("fonts/5x8.pil") + try: + with open('clock_screensaver.json', 'r') as f: + clock1_settings = json.load(f)['clock1'] + except: + clock_settings = {"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_settings, f) + clock1_settings = clock_settings['clock1'] + time_color2_b = clock1_settings['time_color'] + date_color2_b = clock1_settings['date_color'] + weekday_color2_b = clock1_settings['weekday_color'] + timezone2_b = clock1_settings['timezone'] + display_s_b = clock1_settings['display_seconds'] + display_p_b = clock1_settings['display_pm'] + twelvehours_b = clock1_settings['12hour'] + if twelvehours_b: + if display_p_b and display_s_b: + time_format_b = "%I:%M:%S %p" + elif display_p_b and not display_s_b: + time_format_b = "%I:%M %p" + elif not display_p_b and display_s_b: + time_format_b = "%I:%M:%S" + else: + time_format_b = "%I:%M" + else: + if display_p_b and display_s_b: + time_format_b = "%H:%M:%S %p" + elif display_p_b and not display_s_b: + time_format_b = "%H:%M %p" + elif not display_p_b and display_s_b: + time_format_b = "%H:%M:%S" + else: + time_format_b = "%H:%M" + if '+' in timezone2_b: + timezone2_b = timezone2_b.replace('+', '-') + elif '-' in timezone2_b: + timezone2_b = timezone2_b.replace('-', '+') + elif bottom[i2 % len(bottom)] == 'World Clock': #WORLD CLOCK SETTINGS + image2 = Image.new('RGB', (128, 16)) + draw2 = ImageDraw.Draw(image2) + the_time2 = time.time() + next_six_seconds2 = 0 + counter2 = 0 + font_12 = ImageFont.load("fonts/4x6.pil") + try: + with open('clock_screensaver.json', 'r') as f: + world_settings = json.load(f)['world_clock'] + except: + clock_settings = {"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_settings, f) + world_settings = clock_settings['world_clock'] + worldcity_color2 = world_settings['city_color'] + display_s_b = world_settings['display_seconds'] + display_p_b = world_settings['display_pm'] + twelvehours_b = world_settings['12hour'] + if twelvehours_b: + if display_p_b and display_s_b: + time_format_b = "%I:%M:%S %p" + world_offset_b = 82 + elif display_p_b and not display_s_b: + time_format_b = "%I:%M %p" + world_offset_b = 94 + elif not display_p_b and display_s_b: + time_format_b = "%I:%M:%S %p" + world_offset_b = 94 + else: + time_format_b = "%I:%M %p" + world_offset_b = 106 + else: + if display_p_b and display_s_b: + time_format_b = "%H:%M:%S %p" + world_offset_b = 82 + elif display_p_b and not display_s_b: + time_format_b = "%H:%M %p" + world_offset_b = 94 + elif not display_p_b and display_s_b: + time_format_b = "%H:%M:%S %p" + world_offset_b = 94 + else: + time_format_b = "%H:%M %p" + world_offset_b = 106 + + delay_t1 = self.set_delay(settings1['speed']) + try: + animation1 = settings1['animation'].lower() + except: + animation1 = settings1['transition'].lower() try: delay_t2 = self.set_delay(settings2['speed2']) except: delay_t2 = self.set_delay(settings2['speed']) - - animation2 = settings2['animation'].lower() - + try: + animation2 = settings2['animation'].lower() + except: + animation2 = settings2['transition'].lower() + try: + pause1 = int(settings1['pause']) + except: + pause1 = 0 + try: + pause2 = int(settings2['pause']) + except: + pause2 = 0 if animation1 == 'continuous': offset_y1 = 0 offset_x1 = 128 else: offset_y1 = -16 offset_x1 = 0 - if animation2 == 'continuous': offset_y2 = 16 offset_x2 = 128 else: offset_y2 = 32 offset_x2 = 0 - - - frame_skip = int((1/15)/self.delay) #controls how fast gifs run - self.frame = 0 - + # frame_skip = int((1/15)/self.delay) #controls how fast gifs run + # self.frame = 0 img_width1, img_height1 = image1.size img_width2, img_height2 = image2.size + kill = False update_t1 = time.time() update_t2 = time.time() + while True: - + # UPDATE IMAGE 1 WHEN PRIOR FEATURE DONE DISPLAYING if offset_x1 < -(img_width1+1): i1 += 1 settings1 = json.load(open(self.JSONs[top[i1 % len(top)]])) - delay_t1 = self.set_delay(settings1['speed']) - animation1 = settings1['animation'].lower() - + try: + animation1 = settings1['animation'].lower() + except: + animation1 = settings1['transition'].lower() + try: + pause1 = int(settings1['pause']) + except: + pause1 = 0 if animation1 == 'continuous': offset_y1 = 0 offset_x1 = 128 @@ -528,10 +881,142 @@ class StockTicker(): update_process.terminate() update_process = Process(target = self.updateMultiple, args = ([top[(i1+1) % len(top)]+ ' Prof'],)) update_process.start() - image1 = self.openImage('./display_images/' + top[i1 % len(top)] +' Prof.ppm') - image1 = image1.convert('RGB') + if 'Clock' not in top[i1 % len(top)]: + image1 = self.openImage('./display_images/' + top[i1 % len(top)] +' Prof.ppm') + image1 = image1.convert('RGB') + elif top[i1 % len(top)] == 'Clock 2': #CLOCK2 SETTINGS + image1 = Image.new('RGB', (128, 16)) + draw = ImageDraw.Draw(image1) + the_time = time.time() + font = ImageFont.load("fonts/6x12.pil") + font2 = ImageFont.load("fonts/5x8.pil") + try: + with open('clock_screensaver.json', 'r') as f: + clock2_settings = json.load(f)['clock2'] + except: + clock_settings = {"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_settings, f) + clock2_settings = clock_settings['clock2'] + time_color1 = clock2_settings['time_color'] + date_color1 = clock2_settings['date_color'] + timezone1 = clock2_settings['timezone'] + display_s = clock2_settings['display_seconds'] + display_p = clock2_settings['display_pm'] + twelvehours = clock2_settings['12hour'] + if twelvehours: + if display_p and display_s: + time_format = "%I:%M:%S %p" + elif display_p and not display_s: + time_format = "%I:%M %p" + elif not display_p and display_s: + time_format = "%I:%M:%S" + else: + time_format = "%I:%M" + else: + if display_p and display_s: + time_format = "%H:%M:%S %p" + elif display_p and not display_s: + time_format = "%H:%M %p" + elif not display_p and display_s: + time_format = "%H:%M:%S" + else: + time_format = "%H:%M" + if '+' in timezone1: + timezone1 = timezone1.replace('+', '-') + elif '-' in timezone1: + timezone1 = timezone1.replace('-', '+') + elif top[i1 % len(top)] == 'Clock 1': #CLOCK 1 SETTINGS + image1 = Image.new('RGB', (128, 16)) + draw = ImageDraw.Draw(image1) + the_time = time.time() + font_1 = ImageFont.load("fonts/7x14B.pil") + font_2 = ImageFont.load("fonts/5x8.pil") + try: + with open('clock_screensaver.json', 'r') as f: + clock1_settings = json.load(f)['clock1'] + except: + clock_settings = {"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_settings, f) + clock1_settings = clock_settings['clock1'] + time_color2 = clock1_settings['time_color'] + date_color2 = clock1_settings['date_color'] + weekday_color2 = clock1_settings['weekday_color'] + timezone2 = clock1_settings['timezone'] + display_s = clock1_settings['display_seconds'] + display_p = clock1_settings['display_pm'] + twelvehours = clock1_settings['12hour'] + if twelvehours: + if display_p and display_s: + time_format = "%I:%M:%S %p" + elif display_p and not display_s: + time_format = "%I:%M %p" + elif not display_p and display_s: + time_format = "%I:%M:%S" + else: + time_format = "%I:%M" + else: + if display_p and display_s: + time_format = "%H:%M:%S %p" + elif display_p and not display_s: + time_format = "%H:%M %p" + elif not display_p and display_s: + time_format = "%H:%M:%S" + else: + time_format = "%H:%M" + if '+' in timezone2: + timezone2 = timezone2.replace('+', '-') + elif '-' in timezone2: + timezone2 = timezone2.replace('-', '+') + elif top[i1 % len(top)] == 'World Clock': #WORLD CLOCK SETTINGS + image1 = Image.new('RGB', (128, 16)) + draw = ImageDraw.Draw(image1) + the_time = time.time() + next_six_seconds = 0 + counter = 0 + font_1 = ImageFont.load("fonts/4x6.pil") + try: + with open('clock_screensaver.json', 'r') as f: + world_settings = json.load(f)['world_clock'] + except: + clock_settings = {"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_settings, f) + world_settings = clock_settings['world_clock'] + worldcity_color = world_settings['city_color'] + display_s = world_settings['display_seconds'] + display_p = world_settings['display_pm'] + twelvehours = world_settings['12hour'] + if twelvehours: + if display_p and display_s: + time_format = "%I:%M:%S %p" + world_offset = 82 + elif display_p and not display_s: + time_format = "%I:%M %p" + world_offset = 94 + elif not display_p and display_s: + time_format = "%I:%M:%S %p" + world_offset = 94 + else: + time_format = "%I:%M %p" + world_offset = 106 + else: + if display_p and display_s: + time_format = "%H:%M:%S %p" + world_offset = 82 + elif display_p and not display_s: + time_format = "%H:%M %p" + world_offset = 94 + elif not display_p and display_s: + time_format = "%H:%M:%S %p" + world_offset = 94 + else: + time_format = "%H:%M %p" + world_offset = 106 img_width1, img_height1 = image1.size - + + # UPDATE IMAGE 2 WHEN PRIOR FEATURE DONE DISPLAYING if offset_x2 < -(img_width2+1): i2 += 1 settings2 = json.load(open(self.JSONs[bottom[(i2) % len(bottom)]])) @@ -539,8 +1024,14 @@ class StockTicker(): delay_t2 = self.set_delay(settings2['speed2']) except: delay_t2 = self.set_delay(settings2['speed']) - animation2 = settings2['animation'].lower() - + try: + animation2 = settings2['animation'].lower() + except: + animation2 = settings2['transition'].lower() + try: + pause2 = int(settings2['pause']) + except: + pause2 = 0 if animation2 == 'continuous': offset_y2 = 16 offset_x2 = 128 @@ -548,41 +1039,595 @@ class StockTicker(): offset_y2 = 32 offset_x2 = 0 - update_process.join() update_process.terminate() update_process = Process(target = self.updateMultiple, args = ([bottom[i2 % len(bottom)]+ ' Prof'],)) update_process.start() - image2 = self.openImage('./display_images/' + bottom[i2 % len(bottom)] +' Prof.ppm') - image2 = image2.convert('RGB') + if 'Clock' not in bottom[i2 % len(bottom)]: + image2 = self.openImage('./display_images/' + bottom[i2 % len(bottom)] +' Prof.ppm') + image2 = image2.convert('RGB') + elif bottom[i2 % len(bottom)] == 'Clock 2': #CLOCK 2 SETTINGS + image2 = Image.new('RGB', (128, 16)) + draw2 = ImageDraw.Draw(image2) + the_time2 = time.time() + font_b = ImageFont.load("fonts/6x12.pil") + font2_b = ImageFont.load("fonts/5x8.pil") + try: + with open('clock_screensaver.json', 'r') as f: + clock2_settings = json.load(f)['clock2'] + except: + clock_settings = {"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_settings, f) + clock2_settings = clock_settings['clock2'] + time_color1_b = clock2_settings['time_color'] + date_color1_b = clock2_settings['date_color'] + timezone1_b = clock2_settings['timezone'] + display_s_b = clock2_settings['display_seconds'] + display_p_b = clock2_settings['display_pm'] + twelvehours_b = clock2_settings['12hour'] + if twelvehours_b: + if display_p_b and display_s_b: + time_format_b = "%I:%M:%S %p" + elif display_p_b and not display_s_b: + time_format_b = "%I:%M %p" + elif not display_p_b and display_s_b: + time_format_b = "%I:%M:%S" + else: + time_format_b = "%I:%M" + else: + if display_p_b and display_s_b: + time_format_b = "%H:%M:%S %p" + elif display_p_b and not display_s_b: + time_format_b = "%H:%M %p" + elif not display_p_b and display_s_b: + time_format_b = "%H:%M:%S" + else: + time_format_b = "%H:%M" + if '+' in timezone1_b: + timezone1_b = timezone1_b.replace('+', '-') + elif '-' in timezone1_b: + timezone1_b = timezone1_b.replace('-', '+') + elif bottom[i2 % len(bottom)] == 'Clock 1': #CLOCK 1 SETTINGS + image2 = Image.new('RGB', (128, 16)) + draw2 = ImageDraw.Draw(image2) + the_time2 = time.time() + font_1_b = ImageFont.load("fonts/7x14B.pil") + font_2_b = ImageFont.load("fonts/5x8.pil") + try: + with open('clock_screensaver.json', 'r') as f: + clock1_settings = json.load(f)['clock1'] + except: + clock_settings = {"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_settings, f) + clock1_settings = clock_settings['clock1'] + time_color2_b = clock1_settings['time_color'] + date_color2_b = clock1_settings['date_color'] + weekday_color2_b = clock1_settings['weekday_color'] + timezone2_b = clock1_settings['timezone'] + display_s_b = clock1_settings['display_seconds'] + display_p_b = clock1_settings['display_pm'] + twelvehours_b = clock1_settings['12hour'] + if twelvehours_b: + if display_p_b and display_s_b: + time_format_b = "%I:%M:%S %p" + elif display_p_b and not display_s_b: + time_format_b = "%I:%M %p" + elif not display_p_b and display_s_b: + time_format_b = "%I:%M:%S" + else: + time_format_b = "%I:%M" + else: + if display_p_b and display_s_b: + time_format_b = "%H:%M:%S %p" + elif display_p_b and not display_s_b: + time_format_b = "%H:%M %p" + elif not display_p_b and display_s_b: + time_format_b = "%H:%M:%S" + else: + time_format_b = "%H:%M" + if '+' in timezone2_b: + timezone2_b = timezone2_b.replace('+', '-') + elif '-' in timezone2_b: + timezone2_b = timezone2_b.replace('-', '+') + elif bottom[i2 % len(bottom)] == 'World Clock': #WORLD CLOCK SETTINGS + image2 = Image.new('RGB', (128, 16)) + draw2 = ImageDraw.Draw(image2) + the_time2 = time.time() + next_six_seconds2 = 0 + counter2 = 0 + font_12 = ImageFont.load("fonts/4x6.pil") + try: + with open('clock_screensaver.json', 'r') as f: + world_settings = json.load(f)['world_clock'] + except: + clock_settings = {"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_settings, f) + world_settings = clock_settings['world_clock'] + worldcity_color2 = world_settings['city_color'] + display_s_b = world_settings['display_seconds'] + display_p_b = world_settings['display_pm'] + twelvehours_b = world_settings['12hour'] + if twelvehours_b: + if display_p_b and display_s_b: + time_format_b = "%I:%M:%S %p" + world_offset_b = 82 + elif display_p_b and not display_s_b: + time_format_b = "%I:%M %p" + world_offset_b = 94 + elif not display_p_b and display_s_b: + time_format_b = "%I:%M:%S %p" + world_offset_b = 94 + else: + time_format_b = "%I:%M %p" + world_offset_b = 106 + else: + if display_p_b and display_s_b: + time_format_b = "%H:%M:%S %p" + world_offset_b = 82 + elif display_p_b and not display_s_b: + time_format_b = "%H:%M %p" + world_offset_b = 94 + elif not display_p_b and display_s_b: + time_format_b = "%H:%M:%S %p" + world_offset_b = 94 + else: + time_format_b = "%H:%M %p" + world_offset_b = 106 img_width2, img_height2 = image2.size - - - if time.time() - update_t1 > delay_t1: - update_t1 = time.time() - if offset_y1 < 0: - offset_y1+=1 - else: - offset_x1 -= 1 - - if time.time() - update_t2 > delay_t2: - update_t2 = time.time() - if offset_y2 > 16: - offset_y2-=1 - else: - offset_x2 -= 1 - - if kill: break - - #image = image.convert('RGB') - - + # SCROLL, DISPLAY, PAUSE CLOCK 2 + if top[i1 % len(top)] == 'Clock 2': + #Initial image generation so it doesn't appear blank for the first second + if offset_x1 == 128 or offset_y1 == -16: + draw.rectangle([(0,0),(128,16)], (0,0,0)) + current_time = datetime.now(pytz.timezone(timezone1)).strftime(time_format + ",%a %d %b %Y").split(',') + time_t = current_time[0] + date_t = current_time[1].upper() + date_width, date_height = draw.textsize(date_t, font2) + text_width, text_height = draw.textsize(time_t, font) + draw.text(((128-text_width)/2, -2), time_t, time_colors1[time_color1], font) + draw.text(((128-date_width)/2, 8), date_t, time_colors1[date_color1], font2) + #If time now is greater than 1 second of the previously updated image time, update image and reset updated image time to another second + if time.time() >= the_time + 1: + the_time = time.time() + draw.rectangle([(0,0),(128,16)], (0,0,0)) + current_time = datetime.now(pytz.timezone(timezone1)).strftime(time_format + ",%a %d %b %Y").split(',') + time_t = current_time[0] + date_t = current_time[1].upper() + date_width, date_height = draw.textsize(date_t, font2) + text_width, text_height = draw.textsize(time_t, font) + draw.text(((128-text_width)/2, -2), time_t, time_colors1[time_color1], font) + draw.text(((128-date_width)/2, 8), date_t, time_colors1[date_color1], font2) + if time.time() - update_t1 > delay_t1: + update_t1 = time.time() + #Get the pause time right before image is done transitioning in + if offset_y1 == -1 or offset_x1 == 1: + pause_time = time.time() + pause1 + if offset_y1 < 0: + offset_y1+=1 + else: #If the scrolling reaches 0 pixel, pause it + if offset_x1 != 0: + offset_x1 -= 1 + else: + try: #after the pause time, scroll iamge past 0 pixel to continue scrolling + if time.time() >= pause_time: + offset_x1 -= 1 + except: + pass + # SCROLL, DISPLAY, PAUSE CLOCK 1 + elif top[i1 % len(top)] == 'Clock 1': + #Initial image generation so it doesn't appear blank for the first second + if offset_x1 == 128 or offset_y1 == -16: + draw.rectangle([(0,0),(128,16)], (0,0,0)) + current_time = datetime.now(pytz.timezone(timezone2)).strftime(time_format + ",%A,%d %b").split(',') + time_t = current_time[0] + weekday_t = current_time[1].upper() + date_t = current_time[2].upper() + date_width, date_height = draw.textsize(date_t, font_2) + wday_width, wday_height = draw.textsize(weekday_t, font_2) + text_width, text_height = draw.textsize(time_t, font_1) + total_width = text_width + 5 + max(wday_width, date_width) + starting_coord = (128-total_width)/2 + draw.text((starting_coord, 1), time_t, time_colors1[time_color2], font_1) + draw.text((starting_coord + text_width + 5, 1), date_t, time_colors1[date_color2], font_2) + draw.text((starting_coord + text_width + 6, 8), weekday_t, time_colors1[weekday_color2], font_2) + #If time now is greater than 1 second of the previously updated image time, update image and reset updated image time to another second + if time.time() >= the_time + 1: + the_time = time.time() + draw.rectangle([(0,0),(128,16)], (0,0,0)) + current_time = datetime.now(pytz.timezone(timezone2)).strftime(time_format + ",%A,%d %b").split(',') + time_t = current_time[0] + weekday_t = current_time[1].upper() + date_t = current_time[2].upper() + date_width, date_height = draw.textsize(date_t, font_2) + wday_width, wday_height = draw.textsize(weekday_t, font_2) + text_width, text_height = draw.textsize(time_t, font_1) + total_width = text_width + 5 + max(wday_width, date_width) + starting_coord = (128-total_width)/2 + draw.text((starting_coord, 1), time_t, time_colors1[time_color2], font_1) + draw.text((starting_coord + text_width + 5, 1), date_t, time_colors1[date_color2], font_2) + draw.text((starting_coord + text_width + 6, 8), weekday_t, time_colors1[weekday_color2], font_2) + if time.time() - update_t1 > delay_t1: + update_t1 = time.time() + #Get the pause time right before image is done transitioning in + if offset_y1 == -1 or offset_x1 == 1: + pause_time = time.time() + pause1 + if offset_y1 < 0: + offset_y1+=1 + else: #If the scrolling reaches 0 pixel, pause it + if offset_x1 != 0: + offset_x1 -= 1 + else: + try: #after the pause time, scroll iamge past 0 pixel to continue scrolling + if time.time() >= pause_time: + offset_x1 -= 1 + except: + pass + # SCROLL, DISPLAY, PAUSE WORLD CLOCK + elif top[i1 % len(top)] == 'World Clock': + #Initial image generation so it doesn't appear blank for the first second + if offset_x1 == 128 or offset_y1 == -16: + draw.rectangle([(0,0),(128,16)], (0,0,0)) + ny_time = datetime.now(pytz.timezone('America/New_York')).strftime(time_format) + london_time = datetime.now(pytz.timezone('Europe/London')).strftime(time_format) + ny_color = day_colors['day'] if isDaytime1(ny_time,twelvehours) else day_colors['night'] + london_color = day_colors['day'] if isDaytime1(london_time,twelvehours) else day_colors['night'] + if not display_p: + ny_time = ny_time.replace("PM", "").replace("AM", "") + london_time = london_time.replace("PM", "").replace("AM", "") + draw.text((world_offset, 1), ny_time, ny_color, font_1) + draw.text((world_offset, 9), london_time, london_color, font_1) + draw.line([0,7,128,7],(50,50,50), width=1) + draw.text((3, 1), 'NEW YORK', time_colors1[worldcity_color], font_1) + draw.text((3, 9), 'LONDON', time_colors1[worldcity_color], font_1) + #If time now is greater than 1 second of the previously updated image time, update image and reset updated image time to another second + if time.time() >= the_time + 1: + the_time = time.time() + if counter == 0 or counter == 1: + draw.rectangle([(0,0),(128,16)], (0,0,0)) + ny_time = datetime.now(pytz.timezone('America/New_York')).strftime(time_format) + london_time = datetime.now(pytz.timezone('Europe/London')).strftime(time_format) + ny_color = day_colors['day'] if isDaytime1(ny_time,twelvehours) else day_colors['night'] + london_color = day_colors['day'] if isDaytime1(london_time,twelvehours) else day_colors['night'] + if not display_p: + ny_time = ny_time.replace("PM", "").replace("AM", "") + london_time = london_time.replace("PM", "").replace("AM", "") + draw.text((world_offset, 1), ny_time, ny_color, font_1) + draw.text((world_offset, 9), london_time, london_color, font_1) + draw.line([0,7,128,7],(50,50,50), width=1) + draw.text((3, 1), 'NEW YORK', time_colors1[worldcity_color], font_1) + draw.text((3, 9), 'LONDON', time_colors1[worldcity_color], font_1) + elif counter == 2: + draw.rectangle([(0,0),(128,16)], (0,0,0)) + tokyo_time = datetime.now(pytz.timezone('Asia/Tokyo')).strftime(time_format) + au_time = datetime.now(pytz.timezone('Australia/Sydney')).strftime(time_format) + tokyo_color = day_colors['day'] if isDaytime1(tokyo_time,twelvehours) else day_colors['night'] + au_color = day_colors['day'] if isDaytime1(au_time,twelvehours) else day_colors['night'] + if not display_p: + au_time = au_time.replace("PM", "").replace("AM", "") + tokyo_time = tokyo_time.replace("PM", "").replace("AM", "") + draw.text((world_offset, 1), tokyo_time, tokyo_color, font_1) + draw.text((world_offset, 9), au_time, au_color, font_1) + draw.line([0,7,128,7],(50,50,50), width=1) + draw.text((3, 1), 'TOKYO', time_colors1[worldcity_color], font_1) + draw.text((3, 9), 'SYDNEY', time_colors1[worldcity_color], font_1) + elif counter == 3: + draw.rectangle([(0,0),(128,16)], (0,0,0)) + dubai_time = datetime.now(pytz.timezone('Asia/Dubai')).strftime(time_format) + la_time = datetime.now(pytz.timezone('America/Los_Angeles')).strftime(time_format) + dubai_color = day_colors['day'] if isDaytime1(dubai_time,twelvehours) else day_colors['night'] + la_color = day_colors['day'] if isDaytime1(la_time,twelvehours) else day_colors['night'] + if not display_p: + dubai_time = dubai_time.replace("PM", "").replace("AM", "") + la_time = la_time.replace("PM", "").replace("AM", "") + draw.text((world_offset, 1), dubai_time, dubai_color, font_1) + draw.text((world_offset, 9), la_time, la_color, font_1) + draw.line([0,7,128,7],(50,50,50), width=1) + draw.text((3, 1), 'DUBAI', time_colors1[worldcity_color], font_1) + draw.text((3, 9), 'LOS ANGELES', time_colors1[worldcity_color], font_1) + elif counter == 4: + draw.rectangle([(0,0),(128,16)], (0,0,0)) + cn_time = datetime.now(pytz.timezone('Asia/Shanghai')).strftime(time_format) + paris_time = datetime.now(pytz.timezone('Europe/Paris')).strftime(time_format) + cn_color = day_colors['day'] if isDaytime1(cn_time,twelvehours) else day_colors['night'] + paris_color = day_colors['day'] if isDaytime1(paris_time,twelvehours) else day_colors['night'] + if not display_p: + cn_time = cn_time.replace("PM", "").replace("AM", "") + paris_time = paris_time.replace("PM", "").replace("AM", "") + draw.text((world_offset, 1), cn_time, cn_color, font_1) + draw.text((world_offset, 9), paris_time, paris_color, font_1) + draw.line([0,7,128,7],(50,50,50), width=1) + draw.text((3, 1), 'SHANGHAI', time_colors1[worldcity_color], font_1) + draw.text((3, 9), 'PARIS', time_colors1[worldcity_color], font_1) + elif counter == 5: + draw.rectangle([(0,0),(128,16)], (0,0,0)) + in_time = datetime.now(pytz.timezone('Asia/Kolkata')).strftime(time_format) + auck_time = datetime.now(pytz.timezone('Pacific/Auckland')).strftime(time_format) + in_color = day_colors['day'] if isDaytime1(in_time,twelvehours) else day_colors['night'] + auck_color = day_colors['day'] if isDaytime1(auck_time,twelvehours) else day_colors['night'] + if not display_p: + in_time = in_time.replace("PM", "").replace("AM", "") + auck_time = auck_time.replace("PM", "").replace("AM", "") + draw.text((world_offset, 1), in_time, in_color, font_1) + draw.text((world_offset, 9), auck_time, auck_color, font_1) + draw.line([0,7,128,7],(50,50,50), width=1) + draw.text((3, 1), 'MUMBAI', time_colors1[worldcity_color], font_1) + draw.text((3, 9), 'AUCKLAND', time_colors1[worldcity_color], font_1) + elif counter == 6: + draw.rectangle([(0,0),(128,16)], (0,0,0)) + bang_time = datetime.now(pytz.timezone('Asia/Bangkok')).strftime(time_format) + istan_time = datetime.now(pytz.timezone('Europe/Istanbul')).strftime(time_format) + bang_color = day_colors['day'] if isDaytime1(bang_time,twelvehours) else day_colors['night'] + istan_color = day_colors['day'] if isDaytime1(istan_time,twelvehours) else day_colors['night'] + if not display_p: + istan_time = istan_time.replace("PM", "").replace("AM", "") + bang_time = bang_time.replace("PM", "").replace("AM", "") + draw.text((world_offset, 1), bang_time, bang_color, font_1) + draw.text((world_offset, 9), istan_time, istan_color, font_1) + draw.line([0,7,128,7],(50,50,50), width=1) + draw.text((3, 1), 'BANGKOK', time_colors1[worldcity_color], font_1) + draw.text((3, 9), 'ISTANBUL', time_colors1[worldcity_color], font_1) + if the_time >= next_six_seconds: + counter += 1 + next_six_seconds = the_time + 6 + if counter > 6: + counter = 1 + if time.time() - update_t1 > delay_t1: + update_t1 = time.time() + #Get the pause time right before image is done transitioning in + if offset_y1 == -1 or offset_x1 == 1: + pause_time = time.time() + pause1 + if offset_y1 < 0: + offset_y1+=1 + else: #If the scrolling reaches 0 pixel, pause it + if offset_x1 != 0: + offset_x1 -= 1 + else: + try: #after the pause time, scroll iamge past 0 pixel to continue scrolling + if time.time() >= pause_time: + offset_x1 -= 1 + except: + pass + #NORMAL SCROLLING + elif 'Clock' not in top[i1 % len(top)]: + if time.time() - update_t1 > delay_t1: + update_t1 = time.time() + if offset_y1 < 0: + offset_y1+=1 + else: + offset_x1 -= 1 + + #BOTTOM ROW + if 'Clock' not in bottom[i2 % len(bottom)]: + if time.time() - update_t2 > delay_t2: + update_t2 = time.time() + if offset_y2 > 16: + offset_y2-=1 + else: + offset_x2 -= 1 + # SCROLL, DISPLAY, PAUSE CLOCK 2 + elif bottom[i2 % len(bottom)] == 'Clock 2': + #Initial image generation so it doesn't appear blank for the first second + if offset_x2 == 128 or offset_y2 == 32: + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + current_time_b = datetime.now(pytz.timezone(timezone1_b)).strftime(time_format_b + ",%a %d %b %Y").split(',') + time_t_b = current_time_b[0] + date_t_b = current_time_b[1].upper() + date_width_b, date_height_b = draw2.textsize(date_t_b, font2_b) + text_width_b, text_height_b = draw2.textsize(time_t_b, font_b) + draw2.text(((128-text_width_b)/2, -2), time_t_b, time_colors1[time_color1_b], font_b) + draw2.text(((128-date_width_b)/2, 8), date_t_b, time_colors1[date_color1_b], font2_b) + #If time now is greater than 1 second of the previously updated image time, update image and reset updated image time to another second + if time.time() >= the_time2 + 1: + the_time2 = time.time() + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + current_time_b = datetime.now(pytz.timezone(timezone1_b)).strftime(time_format_b + ",%a %d %b %Y").split(',') + time_t_b = current_time_b[0] + date_t_b = current_time_b[1].upper() + date_width_b, date_height_b = draw2.textsize(date_t_b, font2_b) + text_width_b, text_height_b = draw2.textsize(time_t_b, font_b) + draw2.text(((128-text_width_b)/2, -2), time_t_b, time_colors1[time_color1_b], font_b) + draw2.text(((128-date_width_b)/2, 8), date_t_b, time_colors1[date_color1_b], font2_b) + if time.time() - update_t2 > delay_t2: + update_t2 = time.time() + #Get the pause time right before image is done transitioning in + if offset_y2 == 17 or offset_x2 == 1: + pause_time2 = time.time() + pause2 + if offset_y2 > 16: + offset_y2-=1 + else: #If the scrolling reaches 0 pixel, pause it + if offset_x2 != 0: + offset_x2 -= 1 + else: + try: #after the pause time, scroll iamge past 0 pixel to continue scrolling + if time.time() >= pause_time2: + offset_x2 -= 1 + except: + pass + # SCROLL, DISPLAY, PAUSE CLOCK 1 + elif bottom[i2 % len(bottom)] == 'Clock 1': + #Initial image generation so it doesn't appear blank for the first second + if offset_x2 == 128 or offset_y2 == 32: + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + current_time_b = datetime.now(pytz.timezone(timezone2_b)).strftime(time_format_b + ",%A,%d %b").split(',') + time_t_b = current_time_b[0] + weekday_t_b = current_time_b[1].upper() + date_t_b = current_time_b[2].upper() + date_width_b, date_height_b = draw2.textsize(date_t_b, font_2_b) + wday_width_b, wday_height_b = draw2.textsize(weekday_t_b, font_2_b) + text_width_b, text_height_b = draw2.textsize(time_t_b, font_1_b) + total_width_b = text_width_b + 5 + max(wday_width_b, date_width_b) + starting_coord_b = (128-total_width_b)/2 + draw2.text((starting_coord_b, 1), time_t_b, time_colors1[time_color2_b], font_1_b) + draw2.text((starting_coord_b + text_width_b + 5, 1), date_t_b, time_colors1[date_color2_b], font_2_b) + draw2.text((starting_coord_b + text_width_b + 6, 8), weekday_t_b, time_colors1[weekday_color2_b], font_2_b) + #If time now is greater than 1 second of the previously updated image time, update image and reset updated image time to another second + if time.time() >= the_time2 + 1: + the_time2 = time.time() + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + current_time_b = datetime.now(pytz.timezone(timezone2_b)).strftime(time_format_b + ",%A,%d %b").split(',') + time_t_b = current_time_b[0] + weekday_t_b = current_time_b[1].upper() + date_t_b = current_time_b[2].upper() + date_width_b, date_height_b = draw2.textsize(date_t_b, font_2_b) + wday_width_b, wday_height_b = draw2.textsize(weekday_t_b, font_2_b) + text_width_b, text_height_b = draw2.textsize(time_t_b, font_1_b) + total_width_b = text_width_b + 5 + max(wday_width_b, date_width_b) + starting_coord_b = (128-total_width_b)/2 + draw2.text((starting_coord_b, 1), time_t_b, time_colors1[time_color2_b], font_1_b) + draw2.text((starting_coord_b + text_width_b + 5, 1), date_t_b, time_colors1[date_color2_b], font_2_b) + draw2.text((starting_coord_b + text_width_b + 6, 8), weekday_t_b, time_colors1[weekday_color2_b], font_2_b) + if time.time() - update_t2 > delay_t2: + update_t2 = time.time() + #Get the pause time right before image is done transitioning in + if offset_y2 == 17 or offset_x2 == 1: + pause_time2 = time.time() + pause2 + if offset_y2 > 16: + offset_y2-=1 + else: #If the scrolling reaches 0 pixel, pause it + if offset_x2 != 0: + offset_x2 -= 1 + else: + try: #after the pause time, scroll iamge past 0 pixel to continue scrolling + if time.time() >= pause_time2: + offset_x2 -= 1 + except: + pass + # SCROLL, DISPLAY, PAUSE WORLD CLOCK + elif bottom[i2 % len(bottom)] == 'World Clock': + #Initial image generation so it doesn't appear blank for the first second + if offset_x2 == 128 or offset_y2 == 32: + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + ny_time_b = datetime.now(pytz.timezone('America/New_York')).strftime(time_format_b) + london_time_b = datetime.now(pytz.timezone('Europe/London')).strftime(time_format_b) + ny_color_b = day_colors['day'] if isDaytime1(ny_time_b,twelvehours_b) else day_colors['night'] + london_color_b = day_colors['day'] if isDaytime1(london_time_b,twelvehours_b) else day_colors['night'] + if not display_p_b: + ny_time_b = ny_time_b.replace("PM", "").replace("AM", "") + london_time_b = london_time_b.replace("PM", "").replace("AM", "") + draw2.text((world_offset_b, 1), ny_time_b, ny_color_b, font_12) + draw2.text((world_offset_b, 9), london_time_b, london_color_b, font_12) + draw2.line([0,7,128,7],(50,50,50), width=1) + draw2.text((3, 1), 'NEW YORK', time_colors1[worldcity_color2], font_12) + draw2.text((3, 9), 'LONDON', time_colors1[worldcity_color2], font_12) + #If time now is greater than 1 second of the previously updated image time, update image and reset updated image time to another second + if time.time() >= the_time2 + 1: + the_time2 = time.time() + if counter2 == 0 or counter2 == 1: + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + ny_time_b = datetime.now(pytz.timezone('America/New_York')).strftime(time_format_b) + london_time_b = datetime.now(pytz.timezone('Europe/London')).strftime(time_format_b) + ny_color_b = day_colors['day'] if isDaytime1(ny_time_b,twelvehours_b) else day_colors['night'] + london_color_b = day_colors['day'] if isDaytime1(london_time_b,twelvehours_b) else day_colors['night'] + if not display_p_b: + ny_time_b = ny_time_b.replace("PM", "").replace("AM", "") + london_time_b = london_time_b.replace("PM", "").replace("AM", "") + draw2.text((world_offset_b, 1), ny_time_b, ny_color_b, font_12) + draw2.text((world_offset_b, 9), london_time_b, london_color_b, font_12) + draw2.line([0,7,128,7],(50,50,50), width=1) + draw2.text((3, 1), 'NEW YORK', time_colors1[worldcity_color2], font_12) + draw2.text((3, 9), 'LONDON', time_colors1[worldcity_color2], font_12) + elif counter2 == 2: + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + tokyo_time_b = datetime.now(pytz.timezone('Asia/Tokyo')).strftime(time_format_b) + au_time_b = datetime.now(pytz.timezone('Australia/Sydney')).strftime(time_format_b) + tokyo_color_b = day_colors['day'] if isDaytime1(tokyo_time_b,twelvehours_b) else day_colors['night'] + au_color_b = day_colors['day'] if isDaytime1(au_time_b,twelvehours_b) else day_colors['night'] + if not display_p_b: + au_time_b = au_time_b.replace("PM", "").replace("AM", "") + tokyo_time_b = tokyo_time_b.replace("PM", "").replace("AM", "") + draw2.text((world_offset_b, 1), tokyo_time_b, tokyo_color_b, font_12) + draw2.text((world_offset_b, 9), au_time_b, au_color_b, font_12) + draw2.line([0,7,128,7],(50,50,50), width=1) + draw2.text((3, 1), 'TOKYO', time_colors1[worldcity_color2], font_12) + draw2.text((3, 9), 'SYDNEY', time_colors1[worldcity_color2], font_12) + elif counter2 == 3: + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + dubai_time_b = datetime.now(pytz.timezone('Asia/Dubai')).strftime(time_format_b) + la_time_b = datetime.now(pytz.timezone('America/Los_Angeles')).strftime(time_format_b) + dubai_color_b = day_colors['day'] if isDaytime1(dubai_time_b,twelvehours_b) else day_colors['night'] + la_color_b = day_colors['day'] if isDaytime1(la_time_b,twelvehours_b) else day_colors['night'] + if not display_p_b: + dubai_time_b = dubai_time_b.replace("PM", "").replace("AM", "") + la_time_b = la_time_b.replace("PM", "").replace("AM", "") + draw2.text((world_offset_b, 1), dubai_time_b, dubai_color_b, font_12) + draw2.text((world_offset_b, 9), la_time_b, la_color_b, font_12) + draw2.line([0,7,128,7],(50,50,50), width=1) + draw2.text((3, 1), 'DUBAI', time_colors1[worldcity_color2], font_12) + draw2.text((3, 9), 'LOS ANGELES', time_colors1[worldcity_color2], font_12) + elif counter2 == 4: + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + cn_time_b = datetime.now(pytz.timezone('Asia/Shanghai')).strftime(time_format_b) + paris_time_b = datetime.now(pytz.timezone('Europe/Paris')).strftime(time_format_b) + cn_color_b = day_colors['day'] if isDaytime1(cn_time_b,twelvehours_b) else day_colors['night'] + paris_color_b = day_colors['day'] if isDaytime1(paris_time_b,twelvehours_b) else day_colors['night'] + if not display_p_b: + cn_time_b = cn_time_b.replace("PM", "").replace("AM", "") + paris_time_b = paris_time_b.replace("PM", "").replace("AM", "") + draw2.text((world_offset_b, 1), cn_time_b, cn_color_b, font_12) + draw2.text((world_offset_b, 9), paris_time_b, paris_color_b, font_12) + draw2.line([0,7,128,7],(50,50,50), width=1) + draw2.text((3, 1), 'SHANGHAI', time_colors1[worldcity_color2], font_12) + draw2.text((3, 9), 'PARIS', time_colors1[worldcity_color2], font_12) + elif counter2 == 5: + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + in_time_b = datetime.now(pytz.timezone('Asia/Kolkata')).strftime(time_format_b) + auck_time_b = datetime.now(pytz.timezone('Pacific/Auckland')).strftime(time_format_b) + in_color_b = day_colors['day'] if isDaytime1(in_time_b,twelvehours_b) else day_colors['night'] + auck_color_b = day_colors['day'] if isDaytime1(auck_time_b,twelvehours_b) else day_colors['night'] + if not display_p_b: + in_time_b = in_time_b.replace("PM", "").replace("AM", "") + auck_time_b = auck_time_b.replace("PM", "").replace("AM", "") + draw2.text((world_offset_b, 1), in_time_b, in_color_b, font_12) + draw2.text((world_offset_b, 9), auck_time_b, auck_color_b, font_12) + draw2.line([0,7,128,7],(50,50,50), width=1) + draw2.text((3, 1), 'MUMBAI', time_colors1[worldcity_color2], font_12) + draw2.text((3, 9), 'AUCKLAND', time_colors1[worldcity_color2], font_12) + elif counter2 == 6: + draw2.rectangle([(0,0),(128,16)], (0,0,0)) + bang_time_b = datetime.now(pytz.timezone('Asia/Bangkok')).strftime(time_format_b) + istan_time_b = datetime.now(pytz.timezone('Europe/Istanbul')).strftime(time_format_b) + bang_color_b = day_colors['day'] if isDaytime1(bang_time_b,twelvehours_b) else day_colors['night'] + istan_color_b = day_colors['day'] if isDaytime1(istan_time_b,twelvehours_b) else day_colors['night'] + if not display_p_b: + istan_time_b = istan_time_b.replace("PM", "").replace("AM", "") + bang_time_b = bang_time_b.replace("PM", "").replace("AM", "") + draw2.text((world_offset_b, 1), bang_time_b, bang_color_b, font_12) + draw2.text((world_offset_b, 9), istan_time_b, istan_color_b, font_12) + draw2.line([0,7,128,7],(50,50,50), width=1) + draw2.text((3, 1), 'BANGKOK', time_colors1[worldcity_color2], font_12) + draw2.text((3, 9), 'ISTANBUL', time_colors1[worldcity_color2], font_12) + if the_time2 >= next_six_seconds2: + counter2 += 1 + next_six_seconds2 = the_time2 + 6 + if counter2 > 6: + counter2 = 1 + if time.time() - update_t2 > delay_t2: + update_t2 = time.time() + #Get the pause time right before image is done transitioning in + if offset_y2 == 17 or offset_x2 == 1: + pause_time2 = time.time() + pause2 + if offset_y2 > 16: + offset_y2-=1 + else: #If the scrolling reaches 0 pixel, pause it + if offset_x2 != 0: + offset_x2 -= 1 + else: + try: #after the pause time, scroll iamge past 0 pixel to continue scrolling + if time.time() >= pause_time2: + offset_x2 -= 1 + except: + pass + + if kill: break + + # SCROLLING OF THE IMAGE self.double_buffer.SetImage(image1, offset_x1, offset_y1) self.double_buffer.SetImage(image2, offset_x2, offset_y2) - buff = 0 - # remove the ppixels behind the image, to stop trailing self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer) for y in range(16): @@ -591,15 +1636,10 @@ class StockTicker(): for y in range(16,32): self.matrix.SetPixel(offset_x2 + img_width2 +1 , y , 0,0,0) self.matrix.SetPixel(offset_x2 + img_width2 , y , 0,0,0) - - kill = self.checkKilled() if kill: break - - - if kill: break @@ -920,7 +1960,6 @@ class StockTicker(): w1, text_height = self.get_text_dimensions(TICKER, font) w2, text_height = self.get_text_dimensions(CURRENT, font) - text_width_current = max(w1,w2) img = Image.new('RGB', (text_width_current +1000 , 32)) @@ -933,18 +1972,16 @@ class StockTicker(): d.text(((w1+7), 14 - text_height), percent_change, fill=self.greenORred, font=font) w, h = self.get_text_dimensions(percent_change, font) w1 += 7 + w - - - if point_change: img.paste(ARROW, ((w2+ 9),18)) d.text(((w2+29), 16), point_change, fill=self.greenORred, font=font) w,h = self.get_text_dimensions(point_change, font) w2 += 29 + w + if not point_change and not percent_change: + img.paste(ARROW, ((w2+ 9),18)) + w2 += ARROW.size[0] + 9 - - - img = img.crop((0,0,max(w1, w2) + 20,32)) + img = img.crop((0,0,max(w1, w2) + 8,32)) return img @@ -968,6 +2005,40 @@ class StockTicker(): newWidth = max(w2 + text_width_change, text_width_current) +15 img = img.crop((0,0,newWidth,32)) + elif 'display_name' in TICKER: + TICKER = TICKER.replace('display_name','') + w1, text_height = self.get_text_dimensions(TICKER, font) + w2, text_height = self.get_text_dimensions(CURRENT, font) + text_width_current = max(w1,w2) + + img = Image.new('RGB', (text_width_current +100 , 32)) + d = ImageDraw.Draw(img) + + d.text((4, 0), TICKER, fill=(255, 255, 255), font=font) + d.text((4, 8), CURRENT, fill=self.greenORred, font=font) + + img.paste(ARROW, ((w2 + 7),10)) + d.text(((w2+18), 8), CHANGE, fill=self.greenORred, font=font) + + text_width_change, text_height = self.get_text_dimensions(CHANGE, font) + newWidth = max(w2 + 15 + text_width_change, text_width_current) +15 + img = img.crop((0,0,newWidth,32)) + + elif 'Sector' in CHANGE: + w1, text_height = self.get_text_dimensions(TICKER, font) + w2, text_height = self.get_text_dimensions(CURRENT, font) + text_width_current = max(w1,w2) + + img = Image.new('RGB', (text_width_current +100 , 32)) + d = ImageDraw.Draw(img) + + d.text((4, 0), TICKER, fill=(255, 255, 255), font=font) + d.text((4, 8), CURRENT, fill=self.greenORred, font=font) + + img.paste(ARROW, ((w2 + 7),10)) + newWidth = max(w2 + ARROW.size[0] + 7, text_width_current) +15 + img = img.crop((0,0,newWidth,32)) + else: text_width_current, text_height = self.get_text_dimensions(CURRENT, font) @@ -1026,7 +2097,15 @@ class StockTicker(): f.close() except: pass - + try: + if all_crypto_settings['display_name']: + names = True + else: + names = False + except: + names = False + pass + coin_info = all_crypto_settings['symbols'] coin_bases = list(coin_info.keys()) @@ -1039,9 +2118,7 @@ class StockTicker(): point_changefinal = '{0:.10f}'.format(point_change2).rstrip("0") current_final = '{0:.10f}'.format(current).rstrip("0") percent_change = float(coin_info[cb]["percent_change"]) - - - + arrow, change = self.getArrow(point_change) percent_change = '%.2f' % abs(percent_change) + '%' @@ -1061,13 +2138,21 @@ class StockTicker(): percent_change = False if not all_crypto_settings['point']: point_change = False - - midFrame = self.textToImage(ticker + '(' + base + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT + + if names: + try: + ticker = coin_info[cb]['name'].upper() + midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT + except: + ticker, base = cb.split(',') + midFrame = self.textToImage(ticker + '(' + base + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT + else: + midFrame = self.textToImage(ticker + '(' + base + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT if all_crypto_settings['logos']: try: + ticker, base = cb.split(',') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto') - logo = self.openImage(os.path.join(logos_path, ticker + '.png')) stitchedStock = self.stitchImage([logo,midFrame]) except Exception as e: @@ -1075,7 +2160,44 @@ class StockTicker(): stitchedStock = midFrame else: stitchedStock = midFrame - + + try: + if all_crypto_settings['lohivol']: + font = ImageFont.load("./fonts/5x8.pil") + try: + day_low1 = '{0:.10f}'.format(float(coin_info[cb]['day_low'])).rstrip("0") + day_high1 = '{0:.10f}'.format(float(coin_info[cb]['day_high'])).rstrip("0") + day_low2 = day_low1.split('.') + day_high2 = day_high1.split('.') + if len(day_low2[1]) <= 1: + day_low = '%.2f' % float(day_low1) + else: + day_low = day_low1 + if len(day_high2[1]) <= 1: + day_high = '%.2f' % float(day_high1) + else: + day_high = day_high1 + volume = coin_info[cb]['volume'] + + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_img.size[0] + daylow_t_img.size[0], dayhi_img.size[0] + dayhi_t_img.size[0], + vol_img.size[0] + vol_t_img.size[0]) + 5, 32)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 12)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 12)) + lohivol_img.paste(vol_t_img, (0, 21)) + lohivol_img.paste(vol_img, (vol_t_img.size[0], 21)) + except: + pass + except: + pass + try: if all_crypto_settings['chart'] and (cb in portfolio_settings): #IF USER INPUTTED PORTFOLIO SETTINGS, DISPLAY PORTFOLIO INFO try: @@ -1164,6 +2286,14 @@ class StockTicker(): pass image_list.append(stitchedStock) + try: + if all_crypto_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass try: if all_crypto_settings['chart'] and (cb in portfolio_settings): try: @@ -1203,7 +2333,14 @@ class StockTicker(): f.close() except: pass - + try: + if all_crypto_settings['display_name']: + names = True + else: + names = False + except: + names = False + pass coin_info = all_crypto_settings['symbols'] coin_bases = list(coin_info.keys()) @@ -1233,9 +2370,18 @@ class StockTicker(): else: current = str(current_final) - midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT + if names: + try: + ticker = coin_info[cb]['name'].upper() + 'display_name' + midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT + except: + ticker, base = cb.split(',') + midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT + else: + midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT if all_crypto_settings['logos']: try: + ticker, base = cb.split(',') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto') logo = self.openImage(os.path.join(logos_path, ticker + '.png')) @@ -1247,6 +2393,41 @@ class StockTicker(): stitchedStock = midFrame else: stitchedStock = midFrame + try: + if all_crypto_settings['lohivol']: + font = ImageFont.load("./fonts/4x6.pil") + try: + day_low1 = '{0:.10f}'.format(float(coin_info[cb]['day_low'])).rstrip("0") + day_high1 = '{0:.10f}'.format(float(coin_info[cb]['day_high'])).rstrip("0") + day_low2 = day_low1.split('.') + day_high2 = day_high1.split('.') + if len(day_low2[1]) <= 1: + day_low = '%.2f' % float(day_low1) + else: + day_low = day_low1 + if len(day_high2[1]) <= 1: + day_high = '%.2f' % float(day_high1) + else: + day_high = day_high1 + volume = coin_info[cb]['volume'] + + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0] + vol_img.size[0] + 8, 16)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 9)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 9)) + lohivol_img.paste(vol_t_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0])+2, 3)) + lohivol_img.paste(vol_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0], 3)) + except: + pass + except: + pass try: if all_crypto_settings['chart'] and (cb in portfolio_settings): #IF USER INPUTTED PORTFOLIO SETTINGS, DISPLAY PORTFOLIO INFO @@ -1340,7 +2521,14 @@ class StockTicker(): pass image_list.append(stitchedStock) - + try: + if all_crypto_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass try: if all_crypto_settings['chart'] and (cb in portfolio_settings): try: @@ -1898,14 +3086,12 @@ class StockTicker(): f = open('csv/stocks_settings.json', 'r') all_stocks_settings = json.load(f) f.close() - if all_stocks_settings['title']: title_img = self.openImage('feature_titles/stocks.png') image_list = [title_img] image_list.append(self.blank) else: image_list = [] - if all_stocks_settings['chart']: try: f = open('csv/portfolio_settings.json', 'r') @@ -1913,7 +3099,6 @@ class StockTicker(): f.close() except: pass - try: if all_stocks_settings['prepost']: try: @@ -1924,19 +3109,32 @@ class StockTicker(): pass except: pass - + try: + if all_stocks_settings['display_name']: + names = True + else: + names = False + except: + names = False + pass + stock_info = all_stocks_settings['symbols'] symbols = list(stock_info.keys()) timenow = datetime.now(ny_zone).replace(tzinfo=None).strftime("%H:%M:%S") weekday = datetime.now(ny_zone).replace(tzinfo=None).weekday() for i, symbol in enumerate(symbols): - try: info = stock_info[symbol] change = float(info['change']) #TEXT - ticker = symbol #TEXT + if names: + try: + ticker = info['name'].upper() #TEXT + except: + ticker = symbol + else: + ticker = symbol arrow, change = self.getArrow(change) @@ -1949,21 +3147,46 @@ class StockTicker(): percent_change = False if not all_stocks_settings['point']: point_change = False - + midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT - + if all_stocks_settings['logos']: try: + ticker = symbol logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks') - logo = self.openImage(os.path.join(logos_path, ticker + '.png')) stitchedStock = self.stitchImage([logo,midFrame]) except Exception as e: - stitchedStock = midFrame else: stitchedStock = midFrame + try: + if all_stocks_settings['lohivol']: + font = ImageFont.load("./fonts/5x8.pil") + try: + day_low = '%.2f' % float(info['day_low']) + day_high = '%.2f' % float(info['day_high']) + volume = info['volume'] + + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_img.size[0] + daylow_t_img.size[0], dayhi_img.size[0] + dayhi_t_img.size[0], + vol_img.size[0] + vol_t_img.size[0]) + 5, 32)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 12)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 12)) + lohivol_img.paste(vol_t_img, (0, 21)) + lohivol_img.paste(vol_img, (vol_t_img.size[0], 21)) + except: + pass + except: + pass try: if all_stocks_settings['prepost']: font = ImageFont.load("./fonts/6x13.pil") @@ -2040,7 +3263,6 @@ class StockTicker(): except: pass - try: if all_stocks_settings['chart'] and (symbol in portfolio_settings): #IF USER INPUTTED PORTFOLIO SETTINGS, DISPLAY PORTFOLIO INFO try: @@ -2128,7 +3350,14 @@ class StockTicker(): pass image_list.append(stitchedStock) - + try: + if all_stocks_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass try: if all_stocks_settings['prepost']: try: @@ -2137,7 +3366,6 @@ class StockTicker(): pass except: pass - try: if all_stocks_settings['chart'] and (symbol in portfolio_settings): try: @@ -2176,7 +3404,6 @@ class StockTicker(): f.close() except: pass - try: if all_stocks_settings['prepost']: try: @@ -2187,7 +3414,14 @@ class StockTicker(): pass except: pass - + try: + if all_stocks_settings['display_name']: + names = True + else: + names = False + except: + names = False + pass stock_info = all_stocks_settings['symbols'] symbols = list(stock_info.keys()) timenow = datetime.now(ny_zone).replace(tzinfo=None).strftime("%H:%M:%S") @@ -2199,8 +3433,13 @@ class StockTicker(): info = stock_info[symbol] change = float(info['change'])#TEXT - ticker = symbol #TEXT - + if names: + try: + ticker = info['name'].upper() + 'display_name' #TEXT + except: + ticker = symbol + else: + ticker = symbol arrow, change = self.getArrow(change, professional=True) if all_stocks_settings["percent"]: @@ -2208,11 +3447,11 @@ class StockTicker(): else: change = '%.2f' % abs(change) - current = '%.2f' % float(info['current']) #TEXT midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT if all_stocks_settings['logos']: + ticker = symbol try: try: #load the tiny logo logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'tiny_stocks') @@ -2230,11 +3469,34 @@ class StockTicker(): logo = logo.resize((int(width/2), int(height/2))) stitchedStock = self.stitchImage([logo,midFrame]) except Exception as e: - stitchedStock = midFrame else: stitchedStock = midFrame + try: + if all_stocks_settings['lohivol']: + font = ImageFont.load("./fonts/4x6.pil") + try: + day_low = '%.2f' % float(info['day_low']) + day_high = '%.2f' % float(info['day_high']) + volume = info['volume'] + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0] + vol_img.size[0] + 8, 16)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 9)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 9)) + lohivol_img.paste(vol_t_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0])+2, 3)) + lohivol_img.paste(vol_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0], 3)) + except: + pass + except: + pass try: if all_stocks_settings['prepost']: font = ImageFont.load("./fonts/5x8.pil") @@ -2272,7 +3534,6 @@ class StockTicker(): prepost_img.paste(prechange_img, (preprice_img.size[0] + arrow.size[0] + 2,7)) except: pass - elif ((timenow < "04:00:00" or timenow > "16:00:00") and (weekday <= 4)) or (weekday > 4): #postmarket try: postprice = '%.2f' % abs(float(prepost_settings[symbol]['Post-market']['postprice'])) @@ -2306,10 +3567,8 @@ class StockTicker(): prepost_img.paste(postchange_img, (postprice_img.size[0] + arrow.size[0] + 2,7)) except: pass - except: pass - try: if all_stocks_settings['chart'] and (symbol in portfolio_settings): #IF USER INPUTTED PORTFOLIO SETTINGS, DISPLAY PORTFOLIO INFO try: @@ -2402,7 +3661,14 @@ class StockTicker(): pass image_list.append(stitchedStock) - + try: + if all_stocks_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass try: if all_stocks_settings['prepost']: try: @@ -5423,8 +6689,163 @@ class StockTicker(): return GIFs - + + def getPlaceImage(self): + + f = open('csv/place_settings.json', 'r') + all_settings = json.load(f) + f.close() + + imgs = [] + feature_title = False + global place_featuretitle + place_featuretitle = False + + for place in all_settings['places']: + if "2017" in place: + try: + img = self.openImage('logos/r_place/r_place 2017.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/place2017.png') + place_featuretitle = True + except: + pass + elif "2022" in place: + try: + img = self.openImage('logos/r_place/r_place 2022.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/place2022.png') + place_featuretitle = True + except: + pass + elif "2023" in place: + try: + img = self.openImage('logos/r_place/r_place 2023.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/place2023.png') + place_featuretitle = True + except: + pass + try: + max_x = img.width - int(all_settings['width']) + max_y = img.height - 32 + x = random.randint(0, max_x) + y = random.randint(0, max_y) + snapshot = img.crop((x, y, x + int(all_settings['width']), y + 32)) + + try: + imgs.append(self.stitchImage([feature_title,snapshot])) + except: + imgs.append(snapshot) + img.close() + try: + feature_title.close() + except: + pass + except: + pass + + return imgs + + + def getPlaceImageProfessional(self): + + f = open('csv/place_settings.json', 'r') + all_settings = json.load(f) + f.close() + + imgs = [] + feature_title = False + + for i,place in enumerate(all_settings['places']): + if (i == len(all_settings['places'])-1): + if "2017" in place: + try: + img = self.openImage('logos/r_place/r_place 2017.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2017.png') + except: + pass + elif "2022" in place: + try: + img = self.openImage('logos/r_place/r_place 2022.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2022.png') + except: + pass + elif "2023" in place: + try: + img = self.openImage('logos/r_place/r_place 2023.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2023.png') + except: + pass + try: + max_x = img.width - int(all_settings['width']) + max_y = img.height - 16 + x = random.randint(0, max_x) + y = random.randint(0, max_y) + snapshot = Image.new('RGB', (int(all_settings['width']) + 5, 32)) + snapshot2 = img.crop((x, y, x + int(all_settings['width']), y + 16)) + snapshot.paste(snapshot2, (0,0)) + try: + imgs.append(self.stitchImage([feature_title,snapshot])) + except: + imgs.append(snapshot) + img.close() + try: + feature_title.close() + except: + pass + except: + pass + else: + if "2017" in place: + try: + img = self.openImage('logos/r_place/r_place 2017.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2017.png') + except: + pass + elif "2022" in place: + try: + img = self.openImage('logos/r_place/r_place 2022.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2022.png') + except: + pass + elif "2023" in place: + try: + img = self.openImage('logos/r_place/r_place 2023.png') + if all_settings['title']: + feature_title = self.openImage('feature_titles/small_feature_titles/place2023.png') + except: + pass + try: + max_x = img.width - int(all_settings['width']) + max_y = img.height - 16 + x = random.randint(0, max_x) + y = random.randint(0, max_y) + snapshot = Image.new('RGB', (int(all_settings['width']) + 130, 32)) + snapshot2 = img.crop((x, y, x + int(all_settings['width']), y + 16)) + snapshot.paste(snapshot2, (0,0)) + try: + imgs.append(self.stitchImage([feature_title,snapshot])) + except: + imgs.append(snapshot) + img.close() + try: + feature_title.close() + except: + pass + except: + pass + + return self.stitchImage(imgs) + + + def getMoviesImage(self): f = open('csv/movie_settings.json', 'r') @@ -6307,6 +7728,1993 @@ class StockTicker(): return self.stitchImage(image_list) + + def getMarketImage(self): + f = open('csv/market_settings.json', 'r') + market_settings = json.load(f) + f.close() + if market_settings['title']: + title_img = self.openImage('feature_titles/market.png') + image_list = [title_img] + image_list.append(self.blank) + else: + image_list = [] + try: + if market_settings['display_name']: + names = True + else: + names = False + except: + names = False + pass + active_info = market_settings['mostactive'] + active_symbols = list(active_info.keys()) + gainers_info = market_settings['gainers'] + gainers_symbols = list(gainers_info.keys()) + losers_info = market_settings['losers'] + losers_symbols = list(losers_info.keys()) + + for category in market_settings['categories']: + if category == 'Most Active': + most_active = self.openImage('logos/active.png') + image_list.append(most_active) + for i, symbol in enumerate(active_symbols): + try: + info = active_info[symbol] + change = float(info['change']) #TEXT + if names: + try: + ticker = info['name'].upper() #TEXT + except: + ticker = symbol + else: + ticker = symbol + arrow, change = self.getArrow(change) + percent_change = '%.2f' % abs(float(info['percent_change'])) + '%' + point_change = '%.2f' % abs(change) + current = '%.2f' % float(info['current']) #TEXT + if not market_settings['percent']: + percent_change = False + if not market_settings['point']: + point_change = False + midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT + if market_settings['logos']: + try: + ticker = symbol + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks') + logo = self.openImage(os.path.join(logos_path, ticker + '.png')) + stitchedStock = self.stitchImage([logo,midFrame]) + except Exception as e: + stitchedStock = midFrame + else: + stitchedStock = midFrame + try: + if market_settings['lohivol']: + font = ImageFont.load("./fonts/5x8.pil") + try: + day_low = '%.2f' % float(info['day_low']) + day_high = '%.2f' % float(info['day_high']) + volume = info['volume'] + + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_img.size[0] + daylow_t_img.size[0], dayhi_img.size[0] + dayhi_t_img.size[0], + vol_img.size[0] + vol_t_img.size[0]) + 5, 32)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 12)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 12)) + lohivol_img.paste(vol_t_img, (0, 21)) + lohivol_img.paste(vol_img, (vol_t_img.size[0], 21)) + except: + pass + except: + pass + image_list.append(stitchedStock) + try: + if market_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass + image_list.append(self.blank) + except: + pass + + elif category == 'Top Gainers': + top_gainers = self.openImage('logos/gainers.png') + image_list.append(top_gainers) + for i, symbol in enumerate(gainers_symbols): + try: + info = gainers_info[symbol] + change = float(info['change']) #TEXT + if names: + try: + ticker = info['name'].upper() #TEXT + except: + ticker = symbol + else: + ticker = symbol + arrow, change = self.getArrow(change) + percent_change = '%.2f' % abs(float(info['percent_change'])) + '%' + point_change = '%.2f' % abs(change) + current = '%.2f' % float(info['current']) #TEXT + if not market_settings['percent']: + percent_change = False + if not market_settings['point']: + point_change = False + midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT + if market_settings['logos']: + try: + ticker = symbol + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks') + logo = self.openImage(os.path.join(logos_path, ticker + '.png')) + stitchedStock = self.stitchImage([logo,midFrame]) + except Exception as e: + stitchedStock = midFrame + else: + stitchedStock = midFrame + try: + if market_settings['lohivol']: + font = ImageFont.load("./fonts/5x8.pil") + try: + day_low = '%.2f' % float(info['day_low']) + day_high = '%.2f' % float(info['day_high']) + volume = info['volume'] + + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_img.size[0] + daylow_t_img.size[0], dayhi_img.size[0] + dayhi_t_img.size[0], + vol_img.size[0] + vol_t_img.size[0]) + 5, 32)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 12)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 12)) + lohivol_img.paste(vol_t_img, (0, 21)) + lohivol_img.paste(vol_img, (vol_t_img.size[0], 21)) + except: + pass + except: + pass + image_list.append(stitchedStock) + try: + if market_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass + image_list.append(self.blank) + except: + pass + + elif category == 'Top Losers': + top_losers = self.openImage('logos/losers.png') + image_list.append(top_losers) + for i, symbol in enumerate(losers_symbols): + try: + info = losers_info[symbol] + change = float(info['change']) #TEXT + if names: + try: + ticker = info['name'].upper() + except: + ticker = symbol + else: + ticker = symbol #TEXT + arrow, change = self.getArrow(change) + percent_change = '%.2f' % abs(float(info['percent_change'])) + '%' + point_change = '%.2f' % abs(change) + current = '%.2f' % float(info['current']) #TEXT + if not market_settings['percent']: + percent_change = False + if not market_settings['point']: + point_change = False + midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT + if market_settings['logos']: + try: + ticker = symbol + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks') + logo = self.openImage(os.path.join(logos_path, ticker + '.png')) + stitchedStock = self.stitchImage([logo,midFrame]) + except Exception as e: + stitchedStock = midFrame + else: + stitchedStock = midFrame + try: + if market_settings['lohivol']: + font = ImageFont.load("./fonts/5x8.pil") + try: + day_low = '%.2f' % float(info['day_low']) + day_high = '%.2f' % float(info['day_high']) + volume = info['volume'] + + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_img.size[0] + daylow_t_img.size[0], dayhi_img.size[0] + dayhi_t_img.size[0], + vol_img.size[0] + vol_t_img.size[0]) + 5, 32)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 12)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 12)) + lohivol_img.paste(vol_t_img, (0, 21)) + lohivol_img.paste(vol_img, (vol_t_img.size[0], 21)) + except: + pass + except: + pass + image_list.append(stitchedStock) + try: + if market_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass + image_list.append(self.blank) + except: + pass + finalDisplayImage = self.stitchImage(image_list) + return finalDisplayImage + + + def getMarketProfessional(self): + self.blank = Image.new('RGB', (0, 16)) + + f = open('csv/market_settings.json', 'r') + market_settings = json.load(f) + f.close() + + if market_settings['title']: + title_img = self.openImage('feature_titles/small_feature_titles/market.png') + image_list = [title_img, Image.new('RGB', (5, 16))] + image_list.append(self.blank) + else: + image_list = [] + try: + if market_settings['display_name']: + names = True + else: + names = False + except: + names = False + pass + active_info = market_settings['mostactive'] + active_symbols = list(active_info.keys()) + gainers_info = market_settings['gainers'] + gainers_symbols = list(gainers_info.keys()) + losers_info = market_settings['losers'] + losers_symbols = list(losers_info.keys()) + + for category in market_settings['categories']: + if category == 'Most Active': + most_active = self.openImage('logos/active_prof.png') + image_list.append(most_active) + for i, symbol in enumerate(active_symbols): + try: + info = active_info[symbol] + change = float(info['change'])#TEXT + if names: + try: + ticker = info['name'].upper() + 'display_name' #TEXT + except: + ticker = symbol + else: + ticker = symbol + arrow, change = self.getArrow(change, professional=True) + + if market_settings["percent"]: + change = '%.2f' % abs(float(info['percent_change'])) + '%' + else: + change = '%.2f' % abs(change) + + current = '%.2f' % float(info['current']) #TEXT + midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT + + if market_settings['logos']: + ticker = symbol + try: + try: #load the tiny logo + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'tiny_stocks') + logo = Image.open(os.path.join(logos_path, ticker + '.png')) + except: # load the big logo and scale it + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks') + logo = Image.open(os.path.join(logos_path, ticker + '.png')) + # half the size of the logo + width, height = logo.size + + logo = logo.resize((int(width/2), int(height/2))) + stitchedStock = self.stitchImage([logo,midFrame]) + except Exception as e: + stitchedStock = midFrame + else: + stitchedStock = midFrame + try: + if market_settings['lohivol']: + font = ImageFont.load("./fonts/4x6.pil") + try: + day_low = '%.2f' % float(info['day_low']) + day_high = '%.2f' % float(info['day_high']) + volume = info['volume'] + + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0] + vol_img.size[0] + 8, 16)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 9)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 9)) + lohivol_img.paste(vol_t_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0])+2, 3)) + lohivol_img.paste(vol_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0], 3)) + except: + pass + except: + pass + image_list.append(stitchedStock) + try: + if market_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass + image_list.append(self.blank) + + except Exception as e: + pass + + elif category == 'Top Losers': + top_losers = self.openImage('logos/losers_prof.png') + image_list.append(top_losers) + for i, symbol in enumerate(losers_symbols): + try: + info = losers_info[symbol] + change = float(info['change'])#TEXT + if names: + try: + ticker = info['name'].upper() + 'display_name' #TEXT + except: + ticker = symbol + else: + ticker = symbol + + arrow, change = self.getArrow(change, professional=True) + + if market_settings["percent"]: + change = '%.2f' % abs(float(info['percent_change'])) + '%' + else: + change = '%.2f' % abs(change) + + current = '%.2f' % float(info['current']) #TEXT + midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT + + if market_settings['logos']: + ticker = symbol + try: + try: #load the tiny logo + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'tiny_stocks') + + logo = Image.open(os.path.join(logos_path, ticker + '.png')) + + except: # load the big logo and scale it + + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks') + + logo = Image.open(os.path.join(logos_path, ticker + '.png')) + # half the size of the logo + width, height = logo.size + + logo = logo.resize((int(width/2), int(height/2))) + stitchedStock = self.stitchImage([logo,midFrame]) + except Exception as e: + stitchedStock = midFrame + else: + stitchedStock = midFrame + try: + if market_settings['lohivol']: + font = ImageFont.load("./fonts/4x6.pil") + try: + day_low = '%.2f' % float(info['day_low']) + day_high = '%.2f' % float(info['day_high']) + volume = info['volume'] + + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0] + vol_img.size[0] + 8, 16)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 9)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 9)) + lohivol_img.paste(vol_t_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0])+2, 3)) + lohivol_img.paste(vol_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0], 3)) + except: + pass + except: + pass + image_list.append(stitchedStock) + try: + if market_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass + image_list.append(self.blank) + except Exception as e: + pass + + elif category == 'Top Gainers': + top_gainers = self.openImage('logos/gainers_prof.png') + image_list.append(top_gainers) + for i, symbol in enumerate(gainers_symbols): + try: + info = gainers_info[symbol] + change = float(info['change'])#TEXT + if names: + try: + ticker = info['name'].upper() + 'display_name' #TEXT + except: + ticker = symbol + else: + ticker = symbol + arrow, change = self.getArrow(change, professional=True) + if market_settings["percent"]: + change = '%.2f' % abs(float(info['percent_change'])) + '%' + else: + change = '%.2f' % abs(change) + current = '%.2f' % float(info['current']) #TEXT + midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT + + if market_settings['logos']: + ticker = symbol + try: + try: #load the tiny logo + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'tiny_stocks') + + logo = Image.open(os.path.join(logos_path, ticker + '.png')) + + except: # load the big logo and scale it + + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks') + + logo = Image.open(os.path.join(logos_path, ticker + '.png')) + # half the size of the logo + width, height = logo.size + + logo = logo.resize((int(width/2), int(height/2))) + stitchedStock = self.stitchImage([logo,midFrame]) + except Exception as e: + stitchedStock = midFrame + else: + stitchedStock = midFrame + try: + if market_settings['lohivol']: + font = ImageFont.load("./fonts/4x6.pil") + try: + day_low = '%.2f' % float(info['day_low']) + day_high = '%.2f' % float(info['day_high']) + volume = info['volume'] + + daylow_img = self.textImage(day_low, font, r=0, g=255, b=0) + daylow_t_img = self.textImage('Lo', font, r=255, g=255, b=255) + dayhi_img = self.textImage(day_high, font, r=0,g=255,b=0) + dayhi_t_img = self.textImage('Hi', font, r=255,g=255,b=255) + vol_img = self.textImage(volume, font, r=0,g=255,b=0) + vol_t_img = self.textImage('Vol', font, r=255,g=255,b=255) + lohivol_img = Image.new('RGB', (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0] + vol_img.size[0] + 8, 16)) + lohivol_img.paste(daylow_t_img, (0, 3)) + lohivol_img.paste(daylow_img, (daylow_t_img.size[0],3)) + lohivol_img.paste(dayhi_t_img, (0, 9)) + lohivol_img.paste(dayhi_img, (dayhi_t_img.size[0], 9)) + lohivol_img.paste(vol_t_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0])+2, 3)) + lohivol_img.paste(vol_img, (max(daylow_t_img.size[0] + daylow_img.size[0], dayhi_t_img.size[0] + dayhi_img.size[0]) + 2+vol_t_img.size[0], 3)) + except: + pass + except: + pass + image_list.append(stitchedStock) + try: + if market_settings['lohivol']: + try: + image_list.append(lohivol_img) + except: + pass + except: + pass + image_list.append(self.blank) + except Exception as e: + pass + + finalDisplayImage = self.stitchImage(image_list) + self.blank = Image.new('RGB', (10, 32)) + return finalDisplayImage + + + def getSectorImage(self): + + f = open('csv/sector_settings.json', 'r') + sector_settings = json.load(f) + f.close() + + if sector_settings['title']: + title_img = self.openImage('feature_titles/sector.png') + image_list = [title_img] + image_list.append(self.blank) + else: + image_list = [] + + data_info = sector_settings['data'] + data_symbols = list(data_info.keys()) + + for category in sector_settings['sectors']: + try: + info = data_info[category] + change = float(info['current']) #TEXT + ticker = category.upper() #TEXT + arrow, change = self.getArrow(change) + current = '%.2f' % abs(float(info['current'])) + '%' #TEXT + percent_change = False + point_change = False + midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT + if sector_settings['logos']: + try: + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'sector') + logo = self.openImage(os.path.join(logos_path, category + '.png')) + stitchedStock = self.stitchImage([logo,midFrame]) + except Exception as e: + stitchedStock = midFrame + else: + stitchedStock = midFrame + + image_list.append(stitchedStock) + image_list.append(self.blank) + except: + pass + + finalDisplayImage = self.stitchImage(image_list) + return finalDisplayImage + + + def getSectorProfessional(self): + self.blank = Image.new('RGB', (0, 16)) + + f = open('csv/sector_settings.json', 'r') + sector_settings = json.load(f) + f.close() + + if sector_settings['title']: + title_img = self.openImage('feature_titles/small_feature_titles/sector.png') + image_list = [title_img, Image.new('RGB', (5, 16))] + image_list.append(self.blank) + else: + image_list = [] + + data_info = sector_settings['data'] + data_symbols = list(data_info.keys()) + + for category in sector_settings['sectors']: + try: + info = data_info[category] + change = float(info['current'])#TEXT + ticker = category.upper() #TEXT + arrow, change = self.getArrow(change, professional=True) + change = 'Sector' + current = '%.2f' % abs(float(info['current'])) + '%' #TEXT + midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT + if sector_settings['logos']: + try: + try: #load the tiny logo + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'tiny_sectors') + logo = Image.open(os.path.join(logos_path, category + '.png')) + except: # load the big logo and scale it + logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'sector') + logo = Image.open(os.path.join(logos_path, category + '.png')) + # half the size of the logo + width, height = logo.size + logo = logo.resize((int(width/2), int(height/2))) + stitchedStock = self.stitchImage([logo,midFrame]) + except Exception as e: + stitchedStock = midFrame + else: + stitchedStock = midFrame + image_list.append(stitchedStock) + image_list.append(self.blank) + + except Exception as e: + pass + + finalDisplayImage = self.stitchImage(image_list) + self.blank = Image.new('RGB', (10, 32)) + return finalDisplayImage + + + def showClock1(self): + kill=False + canvas = self.double_buffer + try: + with open('csv/clock1_settings.json', 'r') as f: + clock1_set = json.load(f) + except: + clock1_set1 = {"speed": "fast", "transition": "up", "pause": "20", "speed2": "fast"} + with open('csv/clock1_settings.json', 'w') as f: + json.dump(clock1_set1, f) + clock1_set = clock1_set1 + 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'] + + gmt1 = settings['timezone'] + if '+' in gmt1: + gmt = gmt1.replace('+', '-') + elif '-' in gmt1: + gmt = gmt1.replace('-', '+') + else: + gmt = gmt1 + #TIMEZONE NOT WORKING?!?!?!!?!?!?!?!?!?? + timezone = pytz.timezone(gmt) + 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 + 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 + colon_counter = 0 + counter = 0 + counter2 = 0 + pause = int(clock1_set['pause']) + transition = clock1_set['transition'].lower() + if clock1_set['speed'].lower() == 'slow': + speed = 0.05 + elif clock1_set['speed'].lower() == 'medium': + speed = 0.02 + else: + speed = 0.01 + #DOWN + y_coord_down = -32 + y_time_down = 44 + y_date_down = 63 + y_weekday_down = 54 + #UP + y_coord_up = 32 + y_time_up = -20 + y_date_up = -1 + y_weekday_up = -10 + #CONT + x_coordinate_weekday = 0 + x_coordinate_date = 0 + x_coordinate_time = 0 + x_coordinate_weekday2 = 128 + x_coordinate_time2 = 128 + x_coordinate_date2 = 128 + x_coord_cont = 0 + #SCROLL OUT + x_coord = 0 + x_date = 0 + x_time = 0 + x_weekday = 0 + + if settings['12hour']: + if settings['display_pm'] and settings['display_seconds']: + the_time = "%I:%M:%S %p" + elif settings['display_pm'] and not settings['display_seconds']: + the_time = "%I:%M %p" + elif not settings['display_pm'] and settings['display_seconds']: + the_time = "%I:%M:%S" + else: + the_time = "%I:%M" + else: + if settings['display_pm'] and settings['display_seconds']: + the_time = "%H:%M:%S %p" + elif settings['display_pm'] and not settings['display_seconds']: + the_time = "%H:%M %p" + elif not settings['display_pm'] and settings['display_seconds']: + the_time = "%H:%M:%S" + else: + the_time = "%H:%M" + + while counter2 <= 130: + while counter <= (pause*2): + canvas.Clear() + + current_time = datetime.now(timezone).strftime(the_time) + 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((128 - weekday_width) / 2) + x_coordinate_time = int((128 - time_width) / 2) + x_coordinate_date = int((128 - date_width) /2) + x_coordinate_weekday2 += x_coordinate_weekday + x_coordinate_time2 += x_coordinate_time + x_coordinate_date2 += x_coordinate_date + + if transition == 'up': + while y_coord_down < 0: + y_coord_down += 1 + y_time_down -= 1 + y_date_down -= 1 + y_weekday_down -= 1 + if colon_counter % (0.5/speed) == 0: + current_time = datetime.now(timezone).strftime(the_time) + 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((128 - weekday_width) / 2) + x_coordinate_time = int((128 - time_width) / 2) + x_coordinate_date = int((128 - date_width) /2) + + graphics.DrawText(canvas, font2, x_coordinate_time, y_time_down, time_colors[settings['time_color']], current_time) + graphics.DrawText(canvas, font, x_coordinate_weekday, y_weekday_down, time_colors[settings['weekday_color']], current_weekday.upper()) + graphics.DrawText(canvas, font, x_coordinate_date, y_date_down, time_colors[settings['date_color']], current_date.upper()) + + canvas = self.matrix.SwapOnVSync(canvas) + canvas.Clear() + colon_counter += 1 + time.sleep(speed) + if y_coord_down == 0: + break + + if transition == 'down': + while y_coord_up > 0: + y_coord_up -= 1 + y_time_up += 1 + y_date_up += 1 + y_weekday_up += 1 + if colon_counter % (0.5/speed) == 0: + current_time = datetime.now(timezone).strftime(the_time) + 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((128 - weekday_width) / 2) + x_coordinate_time = int((128 - time_width) / 2) + x_coordinate_date = int((128 - date_width) /2) + + graphics.DrawText(canvas, font2, x_coordinate_time, y_time_up, time_colors[settings['time_color']], current_time) + graphics.DrawText(canvas, font, x_coordinate_weekday, y_weekday_up, time_colors[settings['weekday_color']], current_weekday.upper()) + graphics.DrawText(canvas, font, x_coordinate_date, y_date_up, time_colors[settings['date_color']], current_date.upper()) + + canvas = self.matrix.SwapOnVSync(canvas) + canvas.Clear() + colon_counter += 1 + time.sleep(speed) + if y_coord_up == 0: + break + if transition == 'continuous': + while x_coord_cont < 128: + x_coord_cont += 1 + x_coordinate_date2 -= 1 + x_coordinate_time2 -= 1 + x_coordinate_weekday2 -= 1 + if colon_counter % (0.5/speed) == 0: + current_time = datetime.now(timezone).strftime(the_time) + 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") + graphics.DrawText(canvas, font2, x_coordinate_time2, 12, time_colors[settings['time_color']], current_time) + graphics.DrawText(canvas, font, x_coordinate_weekday2, 22, time_colors[settings['weekday_color']], current_weekday.upper()) + graphics.DrawText(canvas, font, x_coordinate_date2, 31, time_colors[settings['date_color']], current_date.upper()) + + canvas = self.matrix.SwapOnVSync(canvas) + canvas.Clear() + colon_counter += 1 + time.sleep(speed) + if x_coord_cont == 0: + break + # 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 = self.matrix.SwapOnVSync(canvas) + counter += 1 + # Wait for 1 second before updating the clock + time.sleep(0.5) + # if counter == (pause*2): + # break + kill=self.checkKilled() + if kill:break + + canvas.Clear() + + if colon_counter % (0.5/speed) == 0: + current_time = datetime.now(timezone).strftime(the_time) + 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((128 - weekday_width) / 2) + x_coordinate_time = int((128 - time_width) / 2) + x_coordinate_date = int((128 - date_width) /2) + + graphics.DrawText(canvas, font2, x_coordinate_time+x_time, 12, time_colors[settings['time_color']], current_time) + graphics.DrawText(canvas, font, x_coordinate_weekday+x_weekday, 22, time_colors[settings['weekday_color']], current_weekday.upper()) + graphics.DrawText(canvas, font, x_coordinate_date+x_date, 31, time_colors[settings['date_color']], current_date.upper()) + + x_date -= 1 + x_time -= 1 + x_weekday -= 1 + counter2 += 1 + colon_counter += 1 + canvas = self.matrix.SwapOnVSync(canvas) + time.sleep(speed) + #if counter2 == 130: + # break + kill=self.checkKilled() + if kill:break + + return kill + + + def showClock2(self): + kill = False + try: + with open('csv/clock2_settings.json', 'r') as f: + clock2_set = json.load(f) + except: + clock2_set = {"speed": "fast", "transition": "up", "pause": "20", "speed2": "fast"} + with open('csv/clock2_settings.json', 'w') as f: + json.dump(clock2_set, f) + 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'] + + # Create a canvas to draw on + canvas = self.double_buffer + gmt1 = settings['timezone'] + if '+' in gmt1: + gmt = gmt1.replace('+', '-') + elif '-' in gmt1: + gmt = gmt1.replace('-', '+') + else: + gmt = gmt1 + #TIMEZONE NOT WORKING?!?!?!!?!?!?!?!?!?? + timezone = pytz.timezone(gmt) + # 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 + colon_counter = 0 + counter = 0 + counter2 = 0 + pause = int(clock2_set['pause']) + transition = clock2_set['transition'].lower() + if clock2_set['speed'].lower() == 'slow': + speed = 0.05 + elif clock2_set['speed'].lower() == 'medium': + speed = 0.02 + else: + speed = 0.01 + #DOWN + y_coord_down = -32 + y_time_down = 53 + y_date_down = 63 + #UP + y_coord_up = 32 + y_time_up = -11 + y_date_up = -1 + #CONT + x_coordinate_time = 0 + x_coordinate_date = 0 + x_coordinate_time2 = 128 + x_coordinate_date2 = 128 + x_coord_cont = 0 + #SCROLL OUT + x_coord = 0 + x_date = 0 + x_time = 0 + + if settings['12hour']: + if settings['display_pm']: + the_time = "%I:%M %p" + else: + the_time = "%I:%M" + else: + if settings['display_pm']: + the_time = "%H:%M %p" + else: + the_time = "%H:%M" + + while counter2 <= 130: + while counter <= (pause*2): + canvas.Clear() + + current_time = datetime.now(timezone).strftime(the_time) + 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((128 - time_width) / 2) + x_coordinate_date = int((128 - date_width) /2) + x_coordinate_date2 += x_coordinate_date + x_coordinate_time2 += x_coordinate_time + + if transition == 'up': + while y_coord_down < 0: + y_coord_down += 1 + y_time_down -= 1 + y_date_down -= 1 + #current_time = datetime.now(timezone).strftime(the_time) + if colon_counter % (0.5/speed) == 0: + current_time = datetime.now(timezone).strftime(the_time) + 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((128 - time_width) / 2) + x_coordinate_date = int((128 - date_width) /2) + + graphics.DrawText(canvas, font2, x_coordinate_time, y_time_down, time_colors[settings['time_color']], current_time) + graphics.DrawText(canvas, font, x_coordinate_date, y_date_down, time_colors[settings['date_color']], current_date.upper()) + + canvas = self.matrix.SwapOnVSync(canvas) + canvas.Clear() + colon_counter += 1 + time.sleep(speed) + if y_coord_down == 0: + break + + if transition == 'down': + while y_coord_up > 0: + y_coord_up -= 1 + y_time_up += 1 + y_date_up += 1 + # current_time = datetime.now(timezone).strftime(the_time) + if colon_counter % (0.5/speed) == 0: + current_time = datetime.now(timezone).strftime(the_time) + 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((128- time_width) / 2) + x_coordinate_date = int((128 - date_width) /2) + + graphics.DrawText(canvas, font2, x_coordinate_time, y_time_up, time_colors[settings['time_color']], current_time) + graphics.DrawText(canvas, font, x_coordinate_date, y_date_up, time_colors[settings['date_color']], current_date.upper()) + + canvas = self.matrix.SwapOnVSync(canvas) + canvas.Clear() + colon_counter += 1 + time.sleep(speed) + if y_coord_up == 0: + break + + if transition == 'continuous': + while x_coord_cont < 128: + x_coord_cont+= 1 + x_coordinate_date2 -= 1 + x_coordinate_time2 -= 1 + # current_time = datetime.now(timezone).strftime(the_time) + if colon_counter % (0.5/speed) == 0: + current_time = datetime.now(timezone).strftime(the_time) + 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_time2, 21, time_colors[settings['time_color']], current_time) + graphics.DrawText(canvas, font, x_coordinate_date2, 31, time_colors[settings['date_color']], current_date.upper()) + + canvas = self.matrix.SwapOnVSync(canvas) + canvas.Clear() + colon_counter += 1 + time.sleep(speed) + if x_coord_cont == 0: + break + + 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 = self.matrix.SwapOnVSync(canvas) + counter += 1 + time.sleep(0.5) + kill = self.checkKilled() + if kill: + break + # if counter == (pause*2): + # break + canvas.Clear() + + if colon_counter % (0.5/speed) == 0: + current_time = datetime.now(timezone).strftime(the_time) + 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((128 - time_width) / 2) + x_coordinate_date = int((128 - date_width) /2) + + graphics.DrawText(canvas, font2, x_coordinate_time+x_time, 21, time_colors[settings['time_color']], current_time) + graphics.DrawText(canvas, font, x_coordinate_date+x_date, 31, time_colors[settings['date_color']], current_date.upper()) + + x_date -= 1 + x_time -= 1 + counter2 += 1 + colon_counter += 1 + canvas = self.matrix.SwapOnVSync(canvas) + time.sleep(speed) + kill = self.checkKilled() + if kill: + break + #if counter2 == 130: + # break + return kill + + + def showWorldclock(self): + kill=False + canvas = self.double_buffer + try: + with open('csv/worldclock_settings.json', 'r') as f: + worldclock_set = json.load(f) + except: + worldclock_set1 = {"speed": "fast", "transition": "up", "pause": "20", "speed2": "fast"} + with open('csv/worldclock_settings.json', 'w') as f: + json.dump(worldclock_set1, f) + worldclock_set = worldclock_set1 + 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'] + + font = graphics.Font() + + 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 + } + + 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 + 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') + + pause = int(worldclock_set['pause']) + if pause % 2 != 0: + pause += 1 + transition = worldclock_set['transition'].lower() + if worldclock_set['speed'].lower() == 'slow': + speed = 0.05 + elif worldclock_set['speed'].lower() == 'medium': + speed = 0.02 + else: + speed = 0.01 + counter = 0 + counter2 = 0 + time_offset = 0 + #DOWN + y_coord_down = -32 + y_time1_down = 40 + y_time2_down = 51 + y_time3_down = 62 + y_line1_down = 42 + y_line2_down = 53 + #UP + y_coord_up = 32 + y_time1_up = -24 + y_time2_up = -13 + y_time3_up = -2 + y_line1_up = -22 + y_line2_up = -11 + #CONT + 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 + x_coord_cont = 0 + x_time = x_offset + 128 + x_line = 128 + x_city = 130 + #SCROLL OUT + finalcount = 0 + counter3 = 0 + x_time_out = 0 + x_line_out = 0 + x_city_out = 0 + time_offset2 = 0 + + while counter3 <= 130: + while counter2 <= (pause): + if transition == 'up': + while y_coord_down < 0: + y_coord_down += 1 + y_time1_down -= 1 + y_time2_down -= 1 + y_time3_down -= 1 + y_line1_down -= 1 + y_line2_down -= 1 + + if 0 <= counter <= 5: + canvas.Clear() + if time_offset % (1/speed) == 0: + ny_time = getTimes(ny_timezone) + london_time = getTimes(london_timezone) + tokyo_time = getTimes(tokyo_timezone) + counter += 1 + 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, y_time1_down, color, 'NEW YORK') + graphics.DrawText(canvas, font, x_offset, y_time1_down, ny_color, ny_time) + graphics.DrawLine(canvas, 0, y_line1_down, 128, y_line1_down, line_c) + graphics.DrawText(canvas, font, 2, y_time2_down, color, 'LONDON') + graphics.DrawText(canvas, font, x_offset, y_time2_down, london_color, london_time) + graphics.DrawLine(canvas, 0, y_line2_down, 128, y_line2_down, line_c) + graphics.DrawText(canvas, font, 2, y_time3_down, color, 'TOKYO') + graphics.DrawText(canvas, font, x_offset, y_time3_down, tokyo_color, tokyo_time) + canvas = self.matrix.SwapOnVSync(canvas) + + elif 6 <= counter <= 11: + canvas.Clear() + if counter == 6: + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + 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 time_offset % (1/speed) == 0: + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + la_time = getTimes(la_timezone) + counter += 1 + 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, y_time1_down, au_color, au_time) + graphics.DrawText(canvas, font, 2, y_time1_down, color, 'SYDNEY') + graphics.DrawLine(canvas, 0, y_line1_down, 128, y_line1_down, line_c) + graphics.DrawText(canvas, font, x_offset, y_time2_down, dubai_color, dubai_time) + graphics.DrawText(canvas, font, 2, y_time2_down, color, 'DUBAI') + graphics.DrawLine(canvas, 0, y_line2_down, 128, y_line2_down, line_c) + graphics.DrawText(canvas, font, x_offset, y_time3_down, la_color, la_time) + graphics.DrawText(canvas, font, 2, y_time3_down, color, 'LOS ANGELES') + canvas = self.matrix.SwapOnVSync(canvas) + + elif 12 <= counter <= 17: + canvas.Clear() + if counter == 12: + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + 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 time_offset % (1/speed) == 0: + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + in_time = getTimes(in_timezone) + counter += 1 + 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, y_time1_down, cn_color, cn_time) + graphics.DrawText(canvas, font, 2, y_time1_down, color, 'SHANGHAI') + graphics.DrawText(canvas, font, x_offset, y_time2_down, paris_color, paris_time) + graphics.DrawLine(canvas, 0, y_line1_down, 128, y_line1_down, line_c) + graphics.DrawText(canvas, font, 2, y_time2_down, color, 'PARIS') + graphics.DrawText(canvas, font, x_offset, y_time3_down, in_color, in_time) + graphics.DrawLine(canvas, 0, y_line2_down, 128, y_line2_down, line_c) + graphics.DrawText(canvas, font, 2, y_time3_down, color, 'MUMBAI') + canvas = self.matrix.SwapOnVSync(canvas) + + elif 18 <= counter <= 23: + canvas.Clear() + if counter == 18: + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + 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 time_offset % (1/speed) == 0: + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + istan_time = getTimes(istan_timezone) + counter += 1 + 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, y_time1_down, auck_color, auck_time) + graphics.DrawText(canvas, font, 2, y_time1_down, color, 'AUCKLAND') + graphics.DrawText(canvas, font, x_offset, y_time2_down, bang_color, bang_time) + graphics.DrawLine(canvas, 0, y_line1_down, 128, y_line1_down, line_c) + graphics.DrawText(canvas, font, 2, y_time2_down, color, 'BANGKOK') + graphics.DrawText(canvas, font, x_offset, y_time3_down, istan_color, istan_time) + graphics.DrawLine(canvas, 0, y_line2_down, 128, y_line2_down, line_c) + graphics.DrawText(canvas, font, 2, y_time3_down, color, 'ISTANBUL') + canvas = self.matrix.SwapOnVSync(canvas) + + if counter == 24: + counter = 0 + + time_offset += 1 + time.sleep(speed) + if y_coord_down == 0: + break + if transition == 'down': + while y_coord_up > 0: + y_coord_up -= 1 + y_time1_up += 1 + y_time2_up += 1 + y_time3_up += 1 + y_line1_up += 1 + y_line2_up += 1 + + if 0 <= counter <= 5: + canvas.Clear() + if time_offset % (1/speed) == 0: + ny_time = getTimes(ny_timezone) + london_time = getTimes(london_timezone) + tokyo_time = getTimes(tokyo_timezone) + counter += 1 + 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, y_time1_up, color, 'NEW YORK') + graphics.DrawText(canvas, font, x_offset, y_time1_up, ny_color, ny_time) + graphics.DrawLine(canvas, 0, y_line1_up, 128, y_line1_up, line_c) + graphics.DrawText(canvas, font, 2, y_time2_up, color, 'LONDON') + graphics.DrawText(canvas, font, x_offset, y_time2_up, london_color, london_time) + graphics.DrawLine(canvas, 0, y_line2_up, 128, y_line2_up, line_c) + graphics.DrawText(canvas, font, 2, y_time3_up, color, 'TOKYO') + graphics.DrawText(canvas, font, x_offset, y_time3_up, tokyo_color, tokyo_time) + canvas = self.matrix.SwapOnVSync(canvas) + + elif 6 <= counter <= 11: + canvas.Clear() + if counter == 6: + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + 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 time_offset % (1/speed) == 0: + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + la_time = getTimes(la_timezone) + counter += 1 + 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, y_time1_up, au_color, au_time) + graphics.DrawText(canvas, font, 2, y_time1_up, color, 'SYDNEY') + graphics.DrawLine(canvas, 0, y_line1_up, 128, y_line1_up, line_c) + graphics.DrawText(canvas, font, x_offset, y_time2_up, dubai_color, dubai_time) + graphics.DrawText(canvas, font, 2, y_time2_up, color, 'DUBAI') + graphics.DrawLine(canvas, 0, y_line2_up, 128, y_line2_up, line_c) + graphics.DrawText(canvas, font, x_offset, y_time3_up, la_color, la_time) + graphics.DrawText(canvas, font, 2, y_time3_up, color, 'LOS ANGELES') + canvas = self.matrix.SwapOnVSync(canvas) + + elif 12 <= counter <= 17: + canvas.Clear() + if counter == 12: + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + 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 time_offset % (1/speed) == 0: + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + in_time = getTimes(in_timezone) + counter += 1 + 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, y_time1_up, cn_color, cn_time) + graphics.DrawText(canvas, font, 2, y_time1_up, color, 'SHANGHAI') + graphics.DrawText(canvas, font, x_offset, y_time2_up, paris_color, paris_time) + graphics.DrawLine(canvas, 0, y_line1_up, 128, y_line1_up, line_c) + graphics.DrawText(canvas, font, 2, y_time2_up, color, 'PARIS') + graphics.DrawText(canvas, font, x_offset, y_time3_up, in_color, in_time) + graphics.DrawLine(canvas, 0, y_line2_up, 128, y_line2_up, line_c) + graphics.DrawText(canvas, font, 2, y_time3_up, color, 'MUMBAI') + canvas = self.matrix.SwapOnVSync(canvas) + + elif 18 <= counter <= 23: + canvas.Clear() + if counter == 18: + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + 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 time_offset % (1/speed) == 0: + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + istan_time = getTimes(istan_timezone) + counter += 1 + 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, y_time1_up, auck_color, auck_time) + graphics.DrawText(canvas, font, 2, y_time1_up, color, 'AUCKLAND') + graphics.DrawText(canvas, font, x_offset, y_time2_up, bang_color, bang_time) + graphics.DrawLine(canvas, 0, y_line1_up, 128, y_line1_up, line_c) + graphics.DrawText(canvas, font, 2, y_time2_up, color, 'BANGKOK') + graphics.DrawText(canvas, font, x_offset, y_time3_up, istan_color, istan_time) + graphics.DrawLine(canvas, 0, y_line2_up, 128, y_line2_up, line_c) + graphics.DrawText(canvas, font, 2, y_time3_up, color, 'ISTANBUL') + canvas = self.matrix.SwapOnVSync(canvas) + + if counter == 24: + counter = 0 + + time_offset += 1 + time.sleep(speed) + if y_coord_up == 0: + break + if transition == 'continuous': + while x_coord_cont < 128: + x_coord_cont += 1 + x_time -= 1 + x_line -= 1 + x_city -= 1 + + if 0 <= counter <= 5: + canvas.Clear() + if time_offset % (1/speed) == 0: + ny_time = getTimes(ny_timezone) + london_time = getTimes(london_timezone) + tokyo_time = getTimes(tokyo_timezone) + counter += 1 + 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, x_city, 8, color, 'NEW YORK') + graphics.DrawText(canvas, font, x_time, 8, ny_color, ny_time) + graphics.DrawLine(canvas, x_line, 10, 128, 10, line_c) + graphics.DrawText(canvas, font, x_city, 19, color, 'LONDON') + graphics.DrawText(canvas, font, x_time, 19, london_color, london_time) + graphics.DrawLine(canvas, x_line, 21, 128, 21, line_c) + graphics.DrawText(canvas, font, x_city, 30, color, 'TOKYO') + graphics.DrawText(canvas, font, x_time, 30, tokyo_color, tokyo_time) + canvas = self.matrix.SwapOnVSync(canvas) + + elif 6 <= counter <= 11: + canvas.Clear() + if counter == 6: + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + 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 time_offset % (1/speed) == 0: + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + la_time = getTimes(la_timezone) + counter += 1 + 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_time, 8, au_color, au_time) + graphics.DrawText(canvas, font, x_city, 8, color, 'SYDNEY') + graphics.DrawLine(canvas, x_line, 10, 128, 10, line_c) + graphics.DrawText(canvas, font, x_time, 19, dubai_color, dubai_time) + graphics.DrawText(canvas, font, x_city, 19, color, 'DUBAI') + graphics.DrawLine(canvas, x_line, 21, 128, 21, line_c) + graphics.DrawText(canvas, font, x_time, 30, la_color, la_time) + graphics.DrawText(canvas, font, x_city, 30, color, 'LOS ANGELES') + canvas = self.matrix.SwapOnVSync(canvas) + + elif 12 <= counter <= 17: + canvas.Clear() + if counter == 12: + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + 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 time_offset % (1/speed) == 0: + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + in_time = getTimes(in_timezone) + counter += 1 + 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_time, 8, cn_color, cn_time) + graphics.DrawText(canvas, font, x_city, 8, color, 'SHANGHAI') + graphics.DrawText(canvas, font, x_time, 19, paris_color, paris_time) + graphics.DrawLine(canvas, x_line, 10, 128, 10, line_c) + graphics.DrawText(canvas, font, x_city, 19, color, 'PARIS') + graphics.DrawText(canvas, font, x_time, 30, in_color, in_time) + graphics.DrawLine(canvas, x_line, 21, 128, 21, line_c) + graphics.DrawText(canvas, font, x_city, 30, color, 'MUMBAI') + canvas = self.matrix.SwapOnVSync(canvas) + + elif 18 <= counter <= 23: + canvas.Clear() + if counter == 18: + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + 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 time_offset % (1/speed) == 0: + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + istan_time = getTimes(istan_timezone) + counter += 1 + 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_time, 8, auck_color, auck_time) + graphics.DrawText(canvas, font, x_city, 8, color, 'AUCKLAND') + graphics.DrawText(canvas, font, x_time, 19, bang_color, bang_time) + graphics.DrawLine(canvas, x_line, 10, 128, 10, line_c) + graphics.DrawText(canvas, font, x_city, 19, color, 'BANGKOK') + graphics.DrawText(canvas, font, x_time, 30, istan_color, istan_time) + graphics.DrawLine(canvas, x_line, 21, 128, 21, line_c) + graphics.DrawText(canvas, font, x_city, 30, color, 'ISTANBUL') + canvas = self.matrix.SwapOnVSync(canvas) + + if counter == 24: + counter = 0 + + time_offset += 1 + time.sleep(speed) + if x_coord_cont == 0: + break + + #WHEN TRANSITION ENDS, PAUSE ON SCREEN + if 0 <= counter <= 5: + canvas.Clear() + ny_time = getTimes(ny_timezone) + london_time = getTimes(london_timezone) + 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 = self.matrix.SwapOnVSync(canvas) + counter += 1 + + elif 6 <= counter <= 11: + canvas.Clear() + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + 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 = self.matrix.SwapOnVSync(canvas) + counter += 1 + + elif 12 <= counter <= 17: + canvas.Clear() + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + 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 = self.matrix.SwapOnVSync(canvas) + counter += 1 + + elif 18 <= counter <= 23: + canvas.Clear() + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + 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 = self.matrix.SwapOnVSync(canvas) + counter += 1 + + if counter == 24: + counter = 0 + + counter2 += 1 + time.sleep(1) + kill=self.checkKilled() + if kill:break + + #SCROLL OUT BEGINS + if finalcount == 0: + ny_time = getTimes(ny_timezone) + london_time = getTimes(london_timezone) + 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'] + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + 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'] + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + 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'] + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + 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'] + finalcount += 1 + + if 0 <= counter <= 5: + canvas.Clear() + if time_offset2 % (1/speed) == 0: + counter += 1 + ny_time = getTimes(ny_timezone) + london_time = getTimes(london_timezone) + 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 + x_city_out, 8, color, 'NEW YORK') + graphics.DrawText(canvas, font, x_offset + x_time_out, 8, ny_color, ny_time) + graphics.DrawLine(canvas, 0, 10, 128 + x_line_out, 10, line_c) + graphics.DrawText(canvas, font, 2 + x_city_out, 19, color, 'LONDON') + graphics.DrawText(canvas, font, x_offset + x_time_out, 19, london_color, london_time) + graphics.DrawLine(canvas, 0, 21, 128 + x_line_out, 21, line_c) + graphics.DrawText(canvas, font, 2 + x_city_out, 30, color, 'TOKYO') + graphics.DrawText(canvas, font, x_offset + x_time_out, 30, tokyo_color, tokyo_time) + canvas = self.matrix.SwapOnVSync(canvas) + + elif 6 <= counter <= 11: + canvas.Clear() + if counter == 6: + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + 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 time_offset2 % (1/speed) == 0: + counter += 1 + au_time = getTimes(au_timezone) + dubai_time = getTimes(dubai_timezone) + 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 + x_time_out, 8, au_color, au_time) + graphics.DrawText(canvas, font, 2 + x_city_out, 8, color, 'SYDNEY') + graphics.DrawLine(canvas, 0, 10, 128 + x_line_out, 10, line_c) + graphics.DrawText(canvas, font, x_offset + x_time_out, 19, dubai_color, dubai_time) + graphics.DrawText(canvas, font, 2 + x_city_out, 19, color, 'DUBAI') + graphics.DrawLine(canvas, 0, 21, 128 + x_line_out, 21, line_c) + graphics.DrawText(canvas, font, x_offset + x_time_out, 30, la_color, la_time) + graphics.DrawText(canvas, font, 2 + x_city_out, 30, color, 'LOS ANGELES') + canvas = self.matrix.SwapOnVSync(canvas) + + elif 12 <= counter <= 17: + canvas.Clear() + if counter == 12: + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + 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 time_offset2 % (1/speed) == 0: + counter += 1 + cn_time = getTimes(cn_timezone) + paris_time = getTimes(paris_timezone) + 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 + x_time_out, 8, cn_color, cn_time) + graphics.DrawText(canvas, font, 2 + x_city_out, 8, color, 'SHANGHAI') + graphics.DrawText(canvas, font, x_offset + x_time_out, 19, paris_color, paris_time) + graphics.DrawLine(canvas, 0, 10, 128 + x_line_out, 10, line_c) + graphics.DrawText(canvas, font, 2 + x_city_out, 19, color, 'PARIS') + graphics.DrawText(canvas, font, x_offset + x_time_out, 30, in_color, in_time) + graphics.DrawLine(canvas, 0, 21, 128 + x_line_out, 21, line_c) + graphics.DrawText(canvas, font, 2 + x_city_out, 30, color, 'MUMBAI') + canvas = self.matrix.SwapOnVSync(canvas) + + elif 18 <= counter <= 23: + canvas.Clear() + if counter == 18: + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + 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 time_offset2 % (1/speed) == 0: + counter += 1 + auck_time = getTimes(auck_timezone) + bang_time = getTimes(bang_timezone) + 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 + x_time_out, 8, auck_color, auck_time) + graphics.DrawText(canvas, font, 2 + x_city_out, 8, color, 'AUCKLAND') + graphics.DrawText(canvas, font, x_offset + x_time_out, 19, bang_color, bang_time) + graphics.DrawLine(canvas, 0, 10, 128 + x_line_out, 10, line_c) + graphics.DrawText(canvas, font, 2 + x_city_out, 19, color, 'BANGKOK') + graphics.DrawText(canvas, font, x_offset + x_time_out, 30, istan_color, istan_time) + graphics.DrawLine(canvas, 0, 21, 128 + x_line_out, 21, line_c) + graphics.DrawText(canvas, font, 2 + x_city_out, 30, color, 'ISTANBUL') + canvas = self.matrix.SwapOnVSync(canvas) + + if counter == 24: + counter = 0 + + time_offset2 += 1 + x_city_out -= 1 + x_time_out -= 1 + x_line_out -= 1 + counter3 += 1 + time.sleep(speed) + kill=self.checkKilled() + if kill:break + + return kill + + def ip_viewer(self): @@ -6351,6 +9759,11 @@ class StockTicker(): messages = self.getUserMessagesProfessional() images = self.getUserImagesProfessional() ipo = self.getIpoProfessional() + economic = self.getEconomicProfessional() + jokes = self.getJokesProfessional() + market = self.getMarketProfessional() + sector = self.getSectorProfessional() + place = self.getPlaceImageProfessional() x_offset = 0 news.paste(weather, (x_offset, 16)) @@ -6387,6 +9800,12 @@ class StockTicker(): x_offset += economic.size[0] news.paste(jokes, (x_offset, 16)) x_offset += jokes.size[0] + news.paste(market, (x_offset, 16)) + x_offset += market.size[0] + news.paste(sector, (x_offset, 16)) + x_offset += sector.size[0] + news.paste(place, (x_offset, 16)) + x_offset += place.size[0] self.double_buffer = self.matrix.CreateFrameCanvas() while True: kill = stock_ticker.scrollImage(news, offset_x = 128) @@ -6435,6 +9854,10 @@ class StockTicker(): elif msg == 'I': # image self.scrollFunctionsAnimated(['display_image', 'display_image'], animation = 'traditional') + + elif msg == 'RP': # image + + self.scrollFunctionsAnimated(['place', 'place'], animation = 'traditional') elif msg == 'G': # gif @@ -6475,7 +9898,22 @@ class StockTicker(): elif msg == 'JO': # jokes self.scrollFunctionsAnimated(['jokes', 'jokes'],animation = 'traditional') - + + elif msg == 'MA': # market + self.scrollFunctionsAnimated(['market', 'market'],animation = 'traditional') + + elif msg == 'SE': + self.scrollFunctionsAnimated(['sector', 'sector'],animation = 'traditional') + + elif msg == 'CL': + self.scrollFunctionsAnimated(['clock1', 'clock1'],animation = 'traditional') + + elif msg == 'CL2': + self.scrollFunctionsAnimated(['clock2', 'clock2'],animation = 'traditional') + + elif msg == 'WCL': + self.scrollFunctionsAnimated(['worldclock', 'worldclock'],animation = 'traditional') + elif msg == 'A': #everything #userSettings = ['display_gif', 'text', 'display_image', 'stocks', 'crypto', 'forex', 'today_weather', 'daily_weather', 'league_table', 'league_games', 'news'] # these wil be read from csv, just for demo diff --git a/templates/index.html b/templates/index.html index 3749c74..fbcfe08 100644 --- a/templates/index.html +++ b/templates/index.html @@ -39,7 +39,7 @@ - + @@ -99,7 +99,7 @@ -

Version 1.3.7

+

Version 1.3.8

Changelog

@@ -249,43 +249,28 @@
- - - +


- -
- -
@@ -400,13 +385,260 @@

-
+
+ Clock Settings Scheduler Settings

+ + + + + @@ -1372,69 +2225,42 @@
- -
- -
-
- -
- -
@@ -1444,33 +2270,20 @@
- -
- -
@@ -1480,46 +2293,53 @@
- -
- -
- -
- -
+
+
+ +
+
+ +
+
+ +
+ +
@@ -1565,85 +2385,88 @@
-
- -
- +
+
+
+
+
+
+ +
-
-
- -
- - +
+
+ +
+
+
+
+ +
@@ -1881,154 +2704,119 @@
- -
- -
-
- -
- -
-
- -
- -
-
-
- -
-
- -
-
- -
+
+
+ +
+
+ +
+ +
+ +
+ +
@@ -2037,127 +2825,113 @@
-
- -
- -
-
-
- -
-
- -
-
+
+
+ +
+
+ +
+
-
- +
+
+ +
+
+ +
+
+ -
- -
-
@@ -7181,9 +7955,901 @@
- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +