import time import board import displayio from adafruit_display_shapes.rect import Rect from rtc import RTC # Set up the display display = board.DISPLAY display_group = displayio.Group() display.root_group = display_group # Set the root_group instead of using .show() # Define colors WHITE = 0xFFFFFF BLACK = 0x000000 RED = 0xFF0000 GREEN = 0x006400 BLUE = 0x0000FF CYAN = 0x00FFFF MAGENTA = 0xFF00FF # Define the sizes and positions of the Fibonacci squares with a 1-pixel border square_sizes = [(52, 52), (25, 25), (25, 25), (79, 79), (133, 133)] positions = [(12, 1), (66, 1), (66, 28), (12, 55), (93, 1)] # Adjust positions to fit screen with a 1-pixel border # Create the rectangles rectangles = [] for (size, pos) in zip(square_sizes, positions): rectangles.append(Rect(pos[0], pos[1], size[0], size[1], fill=WHITE)) # Add rectangles to the display group for rect in rectangles: display_group.append(rect) # Initialize RTC rtc = RTC() # Function to get color based on conditions def get_color(value, hr_factors, min_factors): if value in hr_factors and value in min_factors: return BLUE elif value in hr_factors: return RED elif value in min_factors: return GREEN else: return WHITE while True: current_time = rtc.datetime hr = current_time.tm_hour % 12 # Convert to 12-hour format mn = current_time.tm_min // 5 # Use multiples of 5 minutes # Adjust hour and minute to your logic hr_factors = [] # Placeholder for hour factors min_factors = [] # Placeholder for minute factors # Decompose hours and minutes into Fibonacci sequence for fib in [5, 3, 2, 1]: if hr >= fib: hr_factors.append(fib) hr -= fib if mn >= fib: min_factors.append(fib) mn -= fib # Assign colors color_of_1 = get_color(1, hr_factors, min_factors) color_of_2 = get_color(2, hr_factors, min_factors) color_of_3 = get_color(3, hr_factors, min_factors) color_of_5 = get_color(5, hr_factors, min_factors) # Update colors on the display rectangles[0].fill = color_of_2 rectangles[1].fill = color_of_1 # First 1x1 block rectangles[2].fill = color_of_1 # Second 1x1 block rectangles[3].fill = color_of_3 rectangles[4].fill = color_of_5 display.refresh() time.sleep(60) # Update every minute