def draw_bubbles(): x, y, _ = clue.acceleration level_bubble1 = Circle(int(x + 120), int(180), 15, fill=clue.GREEN, outline=clue.BLUE) level_bubble2 = Circle(int(120), int(90 + y), 15, fill=clue.GREEN, outline=clue.BLUE) bubble_groupx.append(level_bubble1) bubble_groupy.append(level_bubble2)
def make_dot(x,y,fill,size=5): # use the group to set x and y position # so that the display re-draws the dot when # x and y is set. dot_group = displayio.Group(x=x,y=y) dot = Circle(0,0, size, fill=fill) dot_group.append(dot) return dot_group
def main(): # Make the display context splash = displayio.Group(max_size=20) board.DISPLAY.show(splash) # Make a background color fill color_bitmap = displayio.Bitmap(320, 240, 1) color_palette = displayio.Palette(1) color_palette[0] = 0xFFFFFF bg_sprite = displayio.TileGrid(color_bitmap, x=0, y=0, pixel_shader=color_palette) splash.append(bg_sprite) ########################################################################## splash.append(Line(220, 130, 270, 210, 0xFF0000)) splash.append(Line(270, 210, 220, 210, 0xFF0000)) splash.append(Line(220, 210, 270, 130, 0xFF0000)) splash.append(Line(270, 130, 220, 130, 0xFF0000)) #Draw a blue star polygon = Polygon([(255, 40), (262, 62), (285, 62), (265, 76), (275, 100), (255, 84), (235, 100), (245, 76), (225, 62), (248, 62)], outline=0x0000FF) splash.append(polygon) triangle = Triangle(170, 50, 120, 140, 210, 160, fill=0x00FF00, outline=0xFF00FF) splash.append(triangle) rect = Rect(80, 20, 41, 41, fill=0x0) splash.append(rect) circle = Circle(100, 100, 20, fill=0x00FF00, outline=0xFF00FF) splash.append(circle) rect2 = Rect(50, 100, 61, 81, outline=0x0, stroke=3) splash.append(rect2) roundrect = RoundRect(10, 10, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6) splash.append(roundrect) sleep(4) running = False
def test_shapes(self): expected_images = [] for i in range(5): img = Image.open( os.path.join( self.abs_path, CONSTANTS.IMG_DIR_NAME, f"test_image_shapes_{i+1}.bmp", )) img.putalpha(255) expected_images.append(img.load()) # TAKEN FROM ADAFRUIT'S DISPLAY SHAPES LIBRARY # https://github.com/ladyada/Adafruit_CircuitPython_Display_Shapes/blob/master/examples/display_shapes_simpletest.py splash = displayio.Group(max_size=10) splash._Group__show = self.__send_helper board.DISPLAY.show(splash) color_bitmap = displayio.Bitmap(320, 240, 1) color_palette = displayio.Palette(1) color_palette[0] = 0xFFFFFF bg_sprite = displayio.TileGrid(color_bitmap, x=0, y=0, pixel_shader=color_palette) splash.append(bg_sprite) helper._Helper__test_image_equality(self.main_img.load(), expected_images[0]) rect = Rect(80, 20, 41, 41, fill=0x00FF00) splash.append(rect) helper._Helper__test_image_equality(self.main_img.load(), expected_images[1]) circle = Circle(100, 100, 20, fill=0x00FF00, outline=0xFF00FF) splash.append(circle) helper._Helper__test_image_equality(self.main_img.load(), expected_images[2]) rect2 = Rect(50, 100, 61, 81, outline=0x0, stroke=3) splash.append(rect2) helper._Helper__test_image_equality(self.main_img.load(), expected_images[3]) roundrect = RoundRect(10, 10, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6) splash.append(roundrect) helper._Helper__test_image_equality(self.main_img.load(), expected_images[4])
def __init__(self, display, layout_json): self.json = layout_json if "view_type" not in layout_json: raise MissingTypeError if layout_json["view_type"] != "Circle": raise IncorrectTypeError( "view_type '{}' does not match Layout Class 'Circle'".format( layout_json["view_type"])) self._display = display if "attributes" in layout_json: _missing_attrs = [] for attribute in REQUIRED_ATTRIBUTES: if attribute not in layout_json['attributes']: _missing_attrs.append(attribute) if len(_missing_attrs) > 0: raise MissingRequiredAttributesError( "Missing required attributes: {}".format(_missing_attrs)) _outline = 0xFFFFFF if "outline" in layout_json["attributes"]: _outline = int(layout_json["attributes"]["outline"], 16) _fill = 0x000000 if "fill" in layout_json["attributes"]: _fill = int(layout_json["attributes"]["fill"], 16) _stroke = 0 if "stroke" in layout_json["attributes"]: _stroke = self.keyword_compiler( layout_json["attributes"]["stroke"]) _r = 0 if "radius" in layout_json["attributes"]: _r = self.keyword_compiler(layout_json["attributes"]["radius"]) _width = _r * 2 _height = _r * 2 _x = 0 if "x" in layout_json["attributes"]: _x = self.keyword_compiler(layout_json["attributes"]["x"], { "WIDTH": _width, "HEIGHT": _height }) _y = 0 if "y" in layout_json["attributes"]: _y = self.keyword_compiler(layout_json["attributes"]["y"], { "WIDTH": _width, "HEIGHT": _height }) self.circle = Circle(_x, _y, _r, fill=_fill, outline=_outline) self.view = self.circle else: raise MissingAttributesError()
def __init__(self, pin, my_pyportal): self.switch = digitalio.DigitalInOut(pin) self.switch.direction = digitalio.Direction.OUTPUT rect = RoundRect(SWITCHX, SWITCHY, 31, 60, 16, fill=0x0, outline=DISPLAY_COLOR, stroke=3) my_pyportal.splash.append(rect) self.circle_on = Circle(SWITCHX + 15, SWITCHY + 16, 10, fill=0x0) my_pyportal.splash.append(self.circle_on) self.circle_off = Circle(SWITCHX + 15, SWITCHY + 42, 10, fill=DISPLAY_COLOR) my_pyportal.splash.append(self.circle_off)
def circle(self, x, y, r, fill=None, outline=None, stroke=1, index=None): """ Draw a circle """ fl = self._pal[fill] if fill else None ol = self._pal[outline] if outline else None c = Circle(x, y, r, fill=fl, outline=ol, stroke=stroke) if index: self._group.insert(index, c) else: self._group.append(c) return c
def magnet_circ_set(mag_ut): """Display a filled circle to represent the magnetic value mag_ut in microteslas.""" global magnet_circ_dob global last_mag_radius ### map microteslas to a radius with minimum of 1 and ### maximum of MAG_MAX_RADIUS radius = min(max(round(math.sqrt(mag_ut) * 4), 1), MAG_MAX_RADIUS) if radius == last_mag_radius: return if magnet_circ_dob is not None: screen_group.remove(magnet_circ_dob) magnet_circ_dob = Circle(60, 180, radius, fill=BLUE) screen_group.append(magnet_circ_dob)
def __init__(self, diameter, start_x, start_y, debug=False): # Store local variables in our object to access later in other functions self.diameter = diameter self.x = start_x self.y = start_y self.start_x = start_x self.start_y = start_y # Create a circle object for the screen self.circle = Circle(self.x, self.y, self.diameter, fill=0x00FF00, outline=0xFF00FF) # default to moving right self.going_right = True # up/down movement amount. Default to horizontal only self.y_offset = 0 # Need screen height and width to check for collision with top/bottom and both side edges self.SCREEN_HEIGHT = 128 self.SCREEN_WIDTH = 160
def __init__(self, diameter, start_x, start_y, debug=False): # Store local variables in our object to access later in other functions self.diameter = diameter self.x = start_x self.y = start_y self.start_x = start_x self.start_y = start_y # Create a circle object for the screen self.circle = Circle(self.x, self.y, self.diameter, fill=0x00FF00, outline=0xFF00FF) # default to moving right self.going_right = True # Need screen height and width to check for collision with top/bottom and both side edges self.SCREEN_HEIGHT = 128 self.SCREEN_WIDTH = 160 # Badger object for easy button handling self.badger = PyBadger()
# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense """CLUE Spirit Level Demo""" import board import displayio from adafruit_display_shapes.circle import Circle from adafruit_clue import clue display = board.DISPLAY clue_group = displayio.Group() outer_circle = Circle(120, 120, 119, outline=clue.WHITE) middle_circle = Circle(120, 120, 75, outline=clue.YELLOW) inner_circle = Circle(120, 120, 35, outline=clue.GREEN) clue_group.append(outer_circle) clue_group.append(middle_circle) clue_group.append(inner_circle) x, y, _ = clue.acceleration bubble_group = displayio.Group() level_bubble = Circle(int(x + 120), int(y + 120), 20, fill=clue.RED, outline=clue.RED) bubble_group.append(level_bubble) clue_group.append(bubble_group) display.show(clue_group)
) # makes the black background transparent so we only see the cresent moon palette.make_transparent(0) tile_grid = displayio.TileGrid( bitmap, pixel_shader=palette, width=1, height=1, tile_height=120, tile_width=120, default_tile=0, ) # two circles for the center "jewel" jewel_outline = Circle(x0=120, y0=120, r=40, fill=0xFBF236) jewel = Circle(x0=120, y0=120, r=35, fill=0xF70570) # adding the two jewel circle elements to a group jewel_splash = displayio.Group() jewel_splash.append(jewel_outline) jewel_splash.append(jewel) # making a group for the crescent moon sequence # scale is 2 because at full 240x240 resolution image is too big moon_group = displayio.Group(scale=2) # group to hold all of the display elements main_group = displayio.Group() # adding the crescent moon tile grid to the moon group moon_group.append(tile_grid)
unit_mode = False # set the temperature unit_mode. True = centigrade, False = farenheit # Setup homescreen color_bitmap = displayio.Bitmap(120, 120, 1) color_palette = displayio.Palette(1) color_palette[0] = BURNT bg_sprite = displayio.TileGrid(color_bitmap, x=120, y=0, pixel_shader=color_palette) homescreen_screen.append(bg_sprite) clue_color = [GREEN, BLUE, RED, ORANGE, YELLOW, PURPLE] outer_circle = Circle(120, 120, 119, fill=BLACK, outline=BURNT) homescreen_screen.append(outer_circle) title_font = bitmap_font.load_font("/font/GothamBlack-50.bdf") title_font.load_glyphs("BQLUE".encode("utf-8")) title_label = label.Label(title_font, text="BBQLUE", color=clue.ORANGE) title_label.x = 12 title_label.y = 120 homescreen_screen.append(title_label) clue.display.show(homescreen_screen) # Setup temperatures screen temp_font = bitmap_font.load_font("/font/GothamBlack-25.bdf") temp_font.load_glyphs("0123456789FC.-<".encode("utf-8"))
if WIDTH > 320: BACKGROUND_FILE = "/background_480.bmp" pyportal = PyPortal( default_bg=BACKGROUND_FILE, image_json_path=["data", 0, "images", "web", "url"], image_dim_json_path=(["data", 0, "images", "web", "width"], ["data", 0, "images", "web", "height"]), image_resize=(WIDTH, HEIGHT - 15), image_position=(0, 0), text_font="/fonts/OpenSans-9.bdf", json_path=["data", 0, "title"], text_position=(4, HEIGHT - 9), text_color=0xFFFFFF) circle = Circle(WIDTH - 8, HEIGHT - 7, 5, fill=0) pyportal.splash.append(circle) loopcount = 0 errorcount = 0 while True: response = None try: circle.fill = 0xFF0000 itemid = random.randint(1, IMAGECOUNT) # itemid = 20 # portrait mode example # itemid = 21 # landscape mode example print("retrieving url:", APIURL + str(itemid)) response = pyportal.fetch(APIURL + str(itemid)) circle.fill = 0 print("Response is", response) loopcount = loopcount + 1
date_label = Label(FONT, text="0000-00-00", color=DATE_COLOR, x=165, y=223) time_label = Label(FONT, text="00:00:00", color=TIME_COLOR, x=240, y=223) pyportal.splash.append(date_label) pyportal.splash.append(time_label) # ISS trail trail_bitmap = displayio.Bitmap(3, 3, 1) trail_palette = displayio.Palette(1) trail_palette[0] = TRAIL_COLOR trail = displayio.Group(max_size=TRAIL_LENGTH) pyportal.splash.append(trail) # ISS location marker marker = displayio.Group(max_size=MARK_THICKNESS) for r in range(MARK_SIZE - MARK_THICKNESS, MARK_SIZE): marker.append(Circle(0, 0, r, outline=MARK_COLOR)) pyportal.splash.append(marker) def get_location(width=WIDTH, height=HEIGHT): """Fetch current lat/lon, convert to (x, y) tuple scaled to width/height.""" # Get location try: location = pyportal.fetch() except RuntimeError: return None, None # Compute (x, y) coordinates lat = float(location["latitude"]) # degrees, -90 to 90 lon = float(location["longitude"]) # degrees, -180 to 180
palette=displayio.Palette) bg_grid = displayio.TileGrid(bg_bitmap, pixel_shader=bg_palette) # loading the crescent moon bitmap sequence bitmap, palette = adafruit_imageload.load("/moon_anime.bmp", bitmap=displayio.Bitmap, palette=displayio.Palette) # makes the black background transparent so we only see the cresent moon palette.make_transparent(0) tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette, width = 1, height = 1, tile_height = 120, tile_width = 120, default_tile = 0) # two circles for the center "jewel" jewel_outline = Circle(x0=120, y0=120, r=40, fill=0xfbf236) jewel = Circle(x0=120, y0=120, r=35, fill=0xf70570) # adding the two jewel circle elements to a group jewel_splash = displayio.Group(max_size=20) jewel_splash.append(jewel_outline) jewel_splash.append(jewel) # making a group for the crescent moon sequence # scale is 2 because at full 240x240 resolution image is too big moon_group = displayio.Group(scale = 2) # group to hold all of the display elements main_group = displayio.Group() # adding the crescent moon tile grid to the moon group moon_group.append(tile_grid)
break R_knob_last = R_knob G_knob_last = G_knob B_knob_last = B_knob # user is ready, so turn off all the neopixels and blank the screen for i in range(NUMPIXELS): neopixels[i] = (0, 0, 0) neopixels.show() splash.pop() # undisplay the opening graphic # end of startup splash mode ====================================================================== # ================================================================================================= big_circle = Circle(80, 36, 25, fill=D_BLACK, outline=D_WHITE) splash.append(big_circle) circle_mem_1 = Circle(35, 12, 12, fill=D_BLACK, outline=D_WHITE) splash.append(circle_mem_1) circle_mem_2 = Circle(35, 60, 12, fill=D_BLACK, outline=D_WHITE) splash.append(circle_mem_2) circle_mem_3 = Circle(125, 12, 12, fill=D_BLACK, outline=D_WHITE) splash.append(circle_mem_3) circle_mem_4 = Circle(125, 60, 12, fill=D_BLACK, outline=D_WHITE) splash.append(circle_mem_4) text = "" text_group_r = displayio.Group(max_size=2, scale=2, x=5, y=86) disp_r_textbox = label.Label(terminalio.FONT, text=text,
(248, 62), ], outline=0x0000FF, ) splash.append(polygon) triangle = Triangle(170, 50, 120, 140, 210, 160, fill=0x00FF00, outline=0xFF00FF) splash.append(triangle) rect = Rect(80, 20, 41, 41, fill=0x0) splash.append(rect) circle = Circle(100, 100, 20, fill=0x00FF00, outline=0xFF00FF) splash.append(circle) rect2 = Rect(50, 100, 61, 81, outline=0x0, stroke=3) splash.append(rect2) roundrect = RoundRect(10, 10, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6) splash.append(roundrect) while True: pass
def _create_switch(self): # The main function that creates the switch display elements switch_x = self._radius switch_y = self._radius # Define the motion "keyframes" that define the switch movement if self._horizontal: # horizontal switch orientation self._x_motion = self._width - 2 * self._radius - 1 self._y_motion = 0 else: # vertical orientation self._x_motion = 0 self._y_motion = self._width - 2 * self._radius - 1 self._angle_motion = 0 if self._flip: self._x_motion = -1 * self._x_motion self._y_motion = -1 * self._y_motion self._angle_motion = -1 * self._angle_motion # Initialize the display elements - These should depend upon the # orientation (`horizontal` and `flip`) # # Initialize the Circle circle_x0 = switch_x circle_y0 = switch_y if self._flip: circle_x0 = circle_x0 - self._x_motion circle_y0 = circle_y0 - self._y_motion self._switch_circle = Circle( x0=circle_x0, y0=circle_y0, r=self._radius, fill=self._fill_color_off, outline=self._outline_color_off, stroke=self._switch_stroke, ) # Initialize the RoundRect for the background if self._horizontal: # Horizontal orientation self._switch_roundrect = RoundRect( x=switch_x - self._radius, y=switch_y - self._radius, r=self._radius, width=self._width, height=2 * self._radius + 1, fill=self._background_color_off, outline=self._background_outline_color_off, stroke=self._switch_stroke, ) else: # Vertical orientation self._switch_roundrect = RoundRect( x=switch_x - self._radius, y=switch_y - self._radius, r=self._radius, width=2 * self._radius + 1, height=self._width, fill=self._background_color_off, outline=self._background_outline_color_off, stroke=self._switch_stroke, ) # The "0" text circle shape self._text_0 = Circle( x0=circle_x0, y0=circle_y0, r=self._radius // 2, fill=self._fill_color_off, outline=self._outline_color_off, stroke=self._text_stroke, ) # The "1" text rectangle shape text1_x_offset = (-1 * self._switch_stroke) + 1 text1_y_offset = -self._radius // 2 self._text_1 = Rect( x=circle_x0 + text1_x_offset, y=circle_y0 + text1_y_offset, height=self._radius, width=self._text_stroke, fill=self._fill_color_off, outline=self._outline_color_off, stroke=self._text_stroke, ) # bounding_box defines the "local" x and y. # Must be offset by self.x and self.y to get the raw display coordinates # if self._horizontal: # Horizontal orientation self._bounding_box = [ 0, 0, self._width, 2 * self._radius + 1, ] else: # Vertical orientation self._bounding_box = [ 0, 0, 2 * self._radius + 1, self._width, ] self.touch_boundary = [ self._bounding_box[0] - self._touch_padding, self._bounding_box[1] - self._touch_padding, self._bounding_box[2] + 2 * self._touch_padding, self._bounding_box[3] + 2 * self._touch_padding, ] # Store initial positions of moving elements to be used in _draw_function self._switch_initial_x = self._switch_circle.x self._switch_initial_y = self._switch_circle.y self._text_0_initial_x = self._text_0.x self._text_0_initial_y = self._text_0.y self._text_1_initial_x = self._text_1.x self._text_1_initial_y = self._text_1.y # Set the initial switch position based on the starting value if self._value: self._draw_position(1) else: self._draw_position(0) # pop any items off the current self group, in case this is updating # an existing switch for _ in range(len(self)): self.pop() # Add the display elements to the self group self.append(self._switch_roundrect) self.append(self._switch_circle) # If display_button_text is True, append the correct text element (0 or 1) if self._display_button_text: self.append(self._text_0) self.append(self._text_1) if self._value: self._text_0.hidden = True self._text_1.hidden = False else: self._text_0.hidden = False self._text_1.hidden = True # update the anchor position, if required # this calls the parent Widget class to update the anchored_position # due to any changes that might have occurred in the bounding_box self._update_position()
color_bitmap = displayio.Bitmap(display.width, display.height, 1) color_palette = displayio.Palette(1) color_palette[0] = 0xFFFFFF bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0) main_group.append(bg_sprite) # Setting up the Circle starting position posx = 50 posy = 50 # Define Circle characteristics circle_radius = 20 circle = Circle(posx, posy, circle_radius, fill=0x00FF00, outline=0xFF00FF) main_group.append(circle) # Define Circle Animation Steps delta_x = 2 delta_y = 2 # Showing the items on the screen display.show(main_group) while True: if circle.y + circle_radius >= display.height - circle_radius: delta_y = -1 if circle.x + circle_radius >= display.width - circle_radius: delta_x = -1
label1 = label.Label(font, text="Warm light", anchor_point=(0, 0.5), anchored_position=(235, 120)) splash.append(label1) label2 = label.Label(font, text="Cool light", anchor_point=(0, 0.5), anchored_position=(235, 170)) splash.append(label2) menu = [label1, label2] # Set up clock circle = Circle(114, 128, 96, outline=0xFFFFFF) splash.append(circle) circle = Circle(114, 128, 3, outline=0xFFFFFF, fill=0xFFFFFF) splash.append(circle) twelve = Line(114, 32, 114, 16, 0xFFFFFF) splash.append(twelve) for i in range(-2, 9): y0 = int((96 * math.sin(math.pi * (i / 6))) + 128) x0 = int((96 * math.cos(math.pi * (i / 6))) + 114) y1 = int((108 * math.sin(math.pi * (i / 6))) + 128) x1 = int((108 * math.cos(math.pi * (i / 6))) + 114) hour = Line(x0, y0, x1, y1, 0xFFFFFF) splash.append(hour)
#设置显示元素个数,最大20个 splash = displayio.Group(max_size=20, scale=1) display.show(splash) ######################################## # 添加元素,添加后默认自动显示 ######################################## #画线 splash.append(Line(5, 10, 40, 10, 0xFFFFFF)) #画矩形 rect = Rect(5, 20, 30, 20, outline=0xFFFFFF, fill=0x0) splash.append(rect) #画圆 circle = Circle(20, 60, 10, fill=0x0, outline=0xFFFFFF) splash.append(circle) # 字符显示,使用Label对象 text_area = label.Label(terminalio.FONT, text="Hello 01Studio!", color=0xFFFFFF, x=10, y=100) splash.append(text_area) while True: pass
# Account for slight screen difference if you want LEFT_Y_OFFSET = 0 # 12 # my left screen is a tad higher SCREEN_SIZE = 240 i2c_bus = board.I2C() mask = adafruit_monsterm4sk.MonsterM4sk(i2c=i2c_bus) left_group = displayio.Group(max_size=4) mask.left_display.show(left_group) right_group = displayio.Group(max_size=4) mask.right_display.show(right_group) right_circle = Circle(SCREEN_SIZE // 2, SCREEN_SIZE // 2, 40, fill=0x0000FF) right_group.append(right_circle) left_circle = Circle(SCREEN_SIZE // 2, SCREEN_SIZE // 2, 40, fill=0x00AA66) left_group.append(left_circle) while True: # print(mask.boop) if mask.boop: left_circle.x = 0 right_circle.x = SCREEN_SIZE - 40 - 40 - 2 right_circle.y = SCREEN_SIZE // 4 - 40 left_circle.y = SCREEN_SIZE // 4 - 40 + LEFT_Y_OFFSET print(mask.acceleration) print(mask.light)
timer_label.x = 5 timer_label.y = 120 display_group.append(timer_label) timer_data = label.Label(font3, text=format_time(timediff)) timer_data.x = 10 timer_data.y = 140 display_group.append(timer_data) temp_label = label.Label(font1, text="Temp(C):", color=0xAAAAAA) temp_label.x = 5 temp_label.y = 160 display_group.append(temp_label) temp_data = label.Label(font3, text="--") temp_data.x = 10 temp_data.y = 180 display_group.append(temp_data) circle = Circle(308, 12, 8, fill=0) display_group.append(circle) sgraph = Graph() # sgraph.xstart = 100 # sgraph.ystart = 4 sgraph.xstart = 0 sgraph.ystart = 0 # sgraph.width = WIDTH - sgraph.xstart - 4 # 216 for standard PyPortal # sgraph.height = HEIGHT - 80 # 160 for standard PyPortal sgraph.width = GWIDTH # 216 for standard PyPortal sgraph.height = GHEIGHT # 160 for standard PyPortal sgraph.xmin = oven.sprofile["time_range"][0] sgraph.xmax = oven.sprofile["time_range"][1] sgraph.ymin = oven.sprofile["temp_range"][0]
# list of circle positions spots = ((246, 53), (246, 75), (206, 42), (206, 64), (206, 86), (176, 31), (176, 53), (176, 75), (176, 97), (136, 42), (136, 64), (136, 86), (106, 31), (106, 53), (106, 75), (106, 97), (66, 31), (66, 53), (66, 75), (66, 97), (36, 20), (36, 42), (36, 64), (36, 86), (36, 108)) # circles to cover-up bitmap's number ornaments ball_color = [0x555555, 0xaaaaaa, 0xFFFFFF] # All colors except black (0x000000) ball_index = 0 # creating the circles & pulling in positions from spots for spot in spots: circle = Circle(x0=spot[0], y0=spot[1], r=11, fill=ball_color[ball_index]) # Each ball has a color ball_index += 1 ball_index %= len(ball_color) # adding circles to their display group circle_group.append(circle) # adding circles group to main display group group.append(circle_group) # grabs time from network magtag.get_local_time() # parses time into month, date, etc now = time.localtime() month = now[1] day = now[2]
prev_hour_hand1 = None prev_hour_hand2 = None prev_hour_hand3 = None prev_hour_hand4 = None second = 0.0 minute = 15.0 hour = 6.0 * 5 origin1 = Point(int(240 / 4), int(240 / 4)) origin2 = Point(int(240 / 4 + 240 / 2), int(240 / 4)) origin3 = Point(int(240 / 4), int(240 / 4 + 240 / 2)) origin4 = Point(int(240 / 4 + 240 / 2), int(240 / 4 + 240 / 2)) face1 = Circle(origin1.x, origin1.y, FACE_RADIUS, fill=FACE_COLOR, outline=FACE_COLOR) face2 = Circle(origin2.x, origin2.y, FACE_RADIUS, fill=FACE_COLOR, outline=FACE_COLOR) face3 = Circle(origin3.x, origin3.y, FACE_RADIUS, fill=FACE_COLOR, outline=FACE_COLOR) face4 = Circle(origin4.x, origin4.y, FACE_RADIUS,
(48, 48), (80, 48), (112, 48), (16, 80), (48, 80), (80, 80), (112, 80), (16, 112), (48, 112), (80, 112), (112, 112), ) # creating the circles & pulling in positions from spots for spot in spots: circle = Circle(x0=spot[0], y0=spot[1], r=14, fill=0x888888) # adding circles to their display group circle_group.append(circle) # square to show position on menu rect = Rect(0, 0, 33, 33, fill=None, outline=0x00FF00, stroke = 3) splash.append(circle_group) splash.append(rect) # strings and positions for the MIDI note text labels texts = [ {'num': "60", 'pos': (12, 16)}, {'num': "61", 'pos': (44, 16)}, {'num': "62", 'pos': (76, 16)}, {'num': "63", 'pos': (108, 16)}, {'num': "64", 'pos': (12, 48)},
) funhouse.add_text( text="Pressure:", text_position=(20, 170), text_color=0xFF88FF, text_font="fonts/Arial-Bold-24.pcf", ) pres_label = funhouse.add_text( text_position=(120, 200), text_anchor_point=(0.5, 0.5), text_color=0xFFFF00, text_font="fonts/Arial-Bold-24.pcf", ) funhouse.display.show(funhouse.splash) status = Circle(229, 10, 10, fill=0xFF0000, outline=0x880000) funhouse.splash.append(status) def update_enviro(): global environment temp = funhouse.peripherals.temperature unit = "C" if USE_FAHRENHEIT: temp = temp * (9 / 5) + 32 unit = "F" environment["temperature"] = temp environment["pressure"] = funhouse.peripherals.pressure environment["humidity"] = funhouse.peripherals.relative_humidity
tft_cs = board.D10 tft_dc = board.D7 displayio.release_displays() display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9) display = ST7735R(display_bus, width=160, height=128, rotation=90, bgr=True) # Make the display context splash = displayio.Group(max_size=10) display.show(splash) left_circle = Circle(40, 30, 15, fill=D_RED) splash.append(left_circle) right_circle = Circle(120, 30, 15, fill=D_RED) splash.append(right_circle) text = "" text_group1 = displayio.Group(max_size=2, scale=2, x=0, y=88) line1_textbox = label.Label(terminalio.FONT, text=text, color=D_YELLOW, max_glyphs=12) text_group1.append(line1_textbox) splash.append(text_group1) text_group2 = displayio.Group(max_size=2, scale=2, x=0, y=112) line2_textbox = label.Label(terminalio.FONT,
# 79x111 minimum left_iris_tilegrid, right_iris_tilegrid = iris_processing("/iris.bmp") # fix memory error gc.collect() # same for the sclera # BMP file, 8bits or 256 colors work fine (16 or 24bits bmp are unsupported) # 86x121 minimum left_eye, right_eye = sclera_processing("/sclera.bmp") gc.collect() left_eye_outline, right_eye_outline = draw_outlines() left_pupil = Circle(0, 0, 7, fill=0x000000) left_sclera_group = displayio.Group(scale=2) left_sclera_group.append(left_eye) left_eye_group = displayio.Group() left_eye_group.append(left_sclera_group) left_mobile_group = displayio.Group() left_mobile_group.append(left_iris_tilegrid) left_pupil_group = displayio.Group() left_pupil_group.append(left_pupil) left_mobile_group.append(left_pupil_group) left_eye_group.append(left_mobile_group) left_eye_group.append(left_eye_outline) left_mobile_group.x = left_mobile_group.y = 120 # right eye graph initialisation right_pupil = Circle(0, 0, 7, fill=0x000000)