diff --git a/stockTicker.py b/stockTicker.py index 2901a4d..4f33308 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -26,6 +26,24 @@ 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') +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): @@ -82,7 +100,7 @@ class StockTicker(): 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', 'Clock 1': 'csv/clock1_settings.json', 'Clock 2': 'csv/clock2_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', 'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json', 'Jokes Prof': 'csv/jokes_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', @@ -361,8 +379,8 @@ class StockTicker(): kill=self.showClock1() elif options[i % len(options)] == 'Clock 2': kill=self.showClock2() - # elif options[i % len(options)] == 'World Clock': - # kill=self.showWorldclock() + elif options[i % len(options)] == 'World Clock': + kill=self.showWorldclock() else: self.set_delay(settings['speed']) animation = settings['animation'].lower() @@ -7344,7 +7362,7 @@ class StockTicker(): x_coordinate_time2 += x_coordinate_time x_coordinate_date2 += x_coordinate_date - if transition == 'down': + if transition == 'up': while y_coord_down < 0: y_coord_down += 1 y_time_down -= 1 @@ -7379,7 +7397,7 @@ class StockTicker(): if y_coord_down == 0: break - if transition == 'up': + if transition == 'down': while y_coord_up > 0: y_coord_up -= 1 y_time_up += 1 @@ -7596,7 +7614,7 @@ class StockTicker(): x_coordinate_date2 += x_coordinate_date x_coordinate_time2 += x_coordinate_time - if transition == 'down': + if transition == 'up': while y_coord_down < 0: y_coord_down += 1 y_time_down -= 1 @@ -7627,7 +7645,7 @@ class StockTicker(): if y_coord_down == 0: break - if transition == 'up': + if transition == 'down': while y_coord_up > 0: y_coord_up -= 1 y_time_up += 1 @@ -7734,6 +7752,839 @@ class StockTicker(): 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']) + 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): @@ -7929,6 +8780,9 @@ class StockTicker(): elif msg == 'CL2': self.scrollFunctionsAnimated(['clock2', 'clock2'],animation = 'traditional') + + elif msg == 'WCL': + self.scrollFunctionsAnimated(['worldclock', 'worldclock'],animation = 'traditional') elif msg == 'A': #everything