diff --git a/stockTicker.py b/stockTicker.py index 692de6c..6dc8281 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -301,7 +301,7 @@ class StockTicker(): for option in options: - if option not in ['Custom GIFs', 'Custom Images', 'Custom Messages', 'Place (Reddit)']: # 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']: # these images are already saved in user uploads, dodnt need to update them img = self.functions[option]() img.save('./display_images/'+ option+ '.ppm') @@ -342,10 +342,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() @@ -359,95 +357,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() + + if options[i % len(options)] == 'Custom Images': + images = self.getUserImages() - elif options[i % len(options)] == 'Place (Reddit)': - images = self.getPlaceImage() + elif options[i % len(options)] == 'Place (Reddit)': + images = self.getPlaceImage() + + elif options[i % len(options)] == 'Custom GIFs': + images = self.getUserGIFs() + + elif options[i % len(options)] == 'Custom Messages': + images = self.getUserMessages() + - elif options[i % len(options)] == 'Custom GIFs': - images = self.getUserGIFs() + else: #these options just have a single ppm image + image = self.openImage('./display_images/' + options[i % len(options)] +'.ppm') + + images = [image] + - 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 + 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 animation == 'continuous': + offset_x = 128 + elif animation in ['up', 'down']: + offset_x = max(0, 128-img_width) - 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) + offset_y = 0 + #first scroll image in from bottom - self.double_buffer = self.matrix.SwapOnVSync(self.double_buffer) + + + 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) - 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 if not repeat: break @@ -7215,7 +7220,520 @@ class StockTicker(): 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'] + + #TIMEZONE NOT WORKING?!?!?!!?!?!?!?!?!?? + timezone = pytz.timezone('America/New_York') + + 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 == 'down': + 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 == 'up': + 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 + timezone = pytz.timezone('America/New_York') + # 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 == 'down': + 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 == 'up': + 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 ip_viewer(self):