def display_animation(image, brightness): #displays a animation as multi png unicornhathd.rotation(90) unicornhathd.brightness(brightness) width, height = unicornhathd.get_shape() img = Image.open(image) try: while True: for o_x in range(int(img.size[0] / width)): for o_y in range(int(img.size[1] / height)): valid = False for x in range(width): for y in range(height): pixel = img.getpixel( ((o_x * width) + y, (o_y * height) + x)) r, g, b = int(pixel[0]), int(pixel[1]), int( pixel[2]) if r or g or b: valid = True unicornhathd.set_pixel(x, y, r, g, b) if valid: unicornhathd.show() time.sleep(1) except KeyboardInterrupt: unicornhathd.off() return
def display_percent(self, bar_percent): # Calculate number of pixels to illuminate. If asked to display something more than the number of pixels, set # to the max available todo Make this a parameter rather than hard coding it to 16 pixels if bar_percent > 100: bar_percent = 100 bar_pixels = bar_percent / 100 * (self.y_size - 1) #print("@@ {}".format(bar_pixels)) # Figure out the colour to display based on the percentage state_colour = self.colour_list[int( bar_percent / 100 * 15)] # 15 is the maximum colours in the colour list # Set the pixels as required, using the colour for the state. Pixels not actively lit use the background # colour (could be black). for i in range(self.x_size): for j in range(self.y_size, ): if j >= 15 - int(bar_pixels): unicornhathd.set_pixel_hsv(self.x_loc + i, j, state_colour) else: unicornhathd.set_pixel(self.x_loc + i, j, self.back_colour[0], self.back_colour[1], self.back_colour[2])
def run(imgFile='lofi.png'): unicornhathd.rotation(0) unicornhathd.brightness(0.6) width, height = unicornhathd.get_shape() img = Image.open(imgFile) a_list = [] threading.Thread(target=input_thread, args=(a_list, )).start() while not a_list: for o_x in range(int(img.size[0] / width)): for o_y in range(int(img.size[1] / height)): valid = False for x in range(width): for y in range(height): pixel = img.getpixel( ((o_x * width) + y, (o_y * height) + x)) r, g, b = int(pixel[0]), int(pixel[1]), int(pixel[2]) if r or g or b: valid = True unicornhathd.set_pixel(x, y, r, g, b) if valid: unicornhathd.show() time.sleep(0.5) unicornhathd.off()
def updateColour(colour, value): #Print the colour name and value associated with it #print(str(colour) + " : " + str(value)) #Get the X coordinate of the first bar for the colour xCoord1 = colours[colour][0] #Get the X coordinate of the second bar for the colour xCoord2 = colours[colour][1] #Get the R, G and B values for the colour r = colours[colour][2] g = colours[colour][3] b = colours[colour][4] #If the magnitude of a colour is >0, set that many pixels to that colour #Stop extreme values overrunning the size of the HAT if value > 16: value = 16 #Set the two coloumns of the bar for the colour: for x in range(xCoord1, xCoord2): #Set the height of the bars for y in range(0, value): unicornhathd.set_pixel(x, y, r, g, b) #Blank unused pixels in those columns for x in range(xCoord1, xCoord2): for y in range(value, 16): unicornhathd.set_pixel(x, y, 0, 0, 0)
def displayNumber(x,y,d): for i in digit[d]: for j in range(3): r,g,b = (255,255,255) if i[j] == "*" else (0,0,0) unicorn.set_pixel(x+j, y, r, g, b) y-=1 unicorn.show()
def _animate_icon(self, image, repeat=3, cycle_time=0.10): if image == None or type(image) is str == False: print("Not a string:", image) return self._lock_ui.acquire() for i in range(0, repeat): # this is the original pimoroni function for drawing sprites for o_x in range(int(image.size[0] / self._unicorn_width)): for o_y in range(int(image.size[1] / self._unicorn_height)): valid = False for x in range(self._unicorn_width): for y in range(self._unicorn_height): pixel = image.getpixel(((o_x * self._unicorn_width) + y, (o_y * self._unicorn_height) + x)) r, g, b = int(pixel[0]), int(pixel[1]), int(pixel[2]) if r or g or b: valid = True unicorn.set_pixel((self._unicorn_height - y - 1), x, r, g, b) if valid: unicorn.show() time.sleep(cycle_time) unicorn.off() self._lock_ui.release()
def load(saveName): with open(os.path.join(SAVES_DIR, saveName), "rb") as f: pixels = pickle.load(f) for x, row in enumerate(pixels): for y, pixel in enumerate(row): unicorn.set_pixel(x, y, *pixel) unicorn.show()
def refreshDisplay(tempture, pressure): image = Image.new("RGB", (width, height), (0, 0, 0)) draw = ImageDraw.Draw(image) draw.text((0, -1), '{0:d}℃'.format(tempture), fill=COLOR, font=font) draw.text((0, 4), '{0:04d}'.format(pressure), fill=COLOR, font=font) draw.text((4, 10), 'hPa', fill=COLOR, font=font) unicornhathd.clear() # x, yを指定して1ドットずつ描写する for x in range(width): for y in range(height): r, g, b = image.getpixel((x, y)) # ここの部分でx軸を反転させている unicornhathd.set_pixel(width - x - 1, y, r, g, b) # 現在時刻の秒を基準にドットの点滅をさせる if datetime.datetime.now().second % 2: unicornhathd.set_pixel(15, 15, *COLOR) unicornhathd.set_pixel(15, 14, *COLOR) unicornhathd.set_pixel(14, 15, *COLOR) unicornhathd.set_pixel(14, 14, *COLOR) # 画面のリフレッシュ命令 unicornhathd.show()
def calibrate_preview(): '''Opens a preview for user focusing, then takes series of pics for averaging and background subtraction''' with picamera.PiCamera() as camera: camera.resolution = (1664, 1232) camera.awb_mode = 'off' camera.awb_gains = (1.2, 1.2) camera.framerate = 30 camera.start_preview() pihat.brightness(1.0) pihat.clear() for y in range(16): for x in range(16): v = display[x, y] # brightness depends on range if v == 0: red = int(255) # makes 0-1 range > 0-255 range green = int(255) blue = int(255) elif v == 1: red = int(0) green = int(0) blue = int(0) elif v == 2: red = int(0) green = int(0) blue = int(0) pihat.set_pixel(x, y, red, green, blue) # sets pixels on the hat pihat.rotation(180) pihat.show() # show the pixels GPIO.output(VALVE, True) time.sleep(20) GPIO.output(VALVE, False) pihat.clear() pihat.off() camera.stop_preview()
def draw(): for x in range(0, view.w): for y in range(0, view.h): color = frame_buffer[x * view.w + y] unicornhathd.set_pixel(x, y, color.x * 255, color.y * 255, color.z * 255) unicornhathd.show()
def go(style=0): effects = [gradient, tunnel, rainbow_search, checker, swirl] effect = effects[style] step = 0 a_list = [] threading.Thread(target=input_thread, args=(a_list, )).start() i = 0 while ((not a_list) and (i < 100)): if i == 99: i = 0 else: i = i + 1 for y in range(u_height): for x in range(u_width): r, g, b = effect(x, y, step) r = int(max(0, min(255, r))) g = int(max(0, min(255, g))) b = int(max(0, min(255, b))) unicornhathd.set_pixel(x, y, r, g, b) step += 2 unicornhathd.show() unicornhathd.off()
def run_specific(run, running, func): step = 0 try: running(True) keepRunning = run() while keepRunning: for i in range(100): keepRunning = run() if not keepRunning: break start = current_milli_time() for y in range(u_height): for x in range(u_width): r, g, b = func(x, y, step) r = int(max(0, min(255, r))) g = int(max(0, min(255, g))) b = int(max(0, min(255, b))) unicornhathd.set_pixel(x, y, r, g, b) step += 2 unicornhathd.show() unicornhathd.off() running(False) except KeyboardInterrupt: unicornhathd.off()
def show(): text = open('./isaax-project.env', 'r').readlines()[0] matchObj = re.match(r'.*?="(.*)"$', text) lines = matchObj.group(1).split(',') colours = [ tuple([ int(n * 255) for n in colorsys.hsv_to_rgb(x / float(len(lines)), 1.0, 1.0) ]) for x in range(len(lines)) ] FONT = ("/usr/share/fonts/truetype/roboto/Roboto-Bold.ttf", 10) unicornhathd.rotation(0) unicornhathd.brightness(1.0) width, height = unicornhathd.get_shape() text_x = width text_y = 2 font_file, font_size = FONT font = ImageFont.truetype(font_file, font_size) text_width, text_height = width, 0 for line in lines: w, h = font.getsize(line) text_width += w + width text_height = max(text_height, h) text_width += width + text_x + 1 image = Image.new("RGB", (text_width, max(16, text_height)), (0, 0, 0)) draw = ImageDraw.Draw(image) offset_left = 0 for index, line in enumerate(lines): draw.text((text_x + offset_left, text_y), line, colours[index], font=font) offset_left += font.getsize(line)[0] + width for scroll in range(text_width - width): for x in range(width): for y in range(height): pixel = image.getpixel((x + scroll, y)) r, g, b = [int(n) for n in pixel] unicornhathd.set_pixel(width - 1 - x, y, r, g, b) unicornhathd.show() time.sleep(0.01) unicornhathd.off() return True
def draw_level(self, level, x, y): nb_p = int(level/20) #nb de palliers de 20% atteints: 0 à 5 h = self.hue_level(level) #HUE en fonction du level (0:vert à 100 rouge) for i in range(5): unicornhathd.set_pixel(x,y+i,self.c_gris_fonce[0],self.c_gris_fonce[1],self.c_gris_fonce[2]) # fond gris if (level/20>i): unicornhathd.set_pixel_hsv(x,y+i, self.hue_level(level), 1.0, (i+1)/(1+nb_p)) #dégradé bas(-) vers haut(+)
def UnicornImage(): print("Showing image " + conf.IMAGE_NAME) unicorn.rotation(0) lenght = conf.IMAGE_LENGHT current_pos = 1 width, height = unicorn.get_shape() img = Image.open(conf.IMAGE_NAME) while current_pos <= lenght: for o_x in range(int(img.size[0] / width)): for o_y in range(int(img.size[1] / height)): valid = False for x in range(width): for y in range(height): pixel = img.getpixel( ((o_x * width) + y, (o_y * height) + x)) r, g, b = int(pixel[0]), int(pixel[1]), int(pixel[2]) if r or g or b: valid = True unicorn.set_pixel(x, y, r, g, b) if valid: unicorn.show() time.sleep(0.5) current_pos = current_pos + 1 unicorn.off() return 0
def UnicornStarfield(): print("Running starfield") unicorn.rotation(270) lenght = conf.STARFIELD_LENGHT current_pos = 1 star_count = 25 star_speed = 0.05 stars = [] for i in range(0, star_count): stars.append((random.uniform(4, 11), random.uniform(4, 11), 0)) while current_pos <= lenght: unicorn.clear() for i in range(0, star_count): stars[i] = (stars[i][0] + ((stars[i][0] - 8.1) * star_speed), stars[i][1] + ((stars[i][1] - 8.1) * star_speed), stars[i][2] + star_speed * 50) if stars[i][0] < 0 or stars[i][1] < 0 or stars[i][0] > 16 or stars[ i][1] > 16: stars[i] = (random.uniform(4, 11), random.uniform(4, 11), 0) v = stars[i][2] unicorn.set_pixel(stars[i][0], stars[i][1], v, v, v) unicorn.show() current_pos = current_pos + 1 #print(current_pos) unicorn.clear() unicorn.off() return 0
def draw_animation(image): # this is the original pimoroni function for drawing sprites try: for o_x in range(int(image.size[0] / width)): for o_y in range(int(image.size[1] / height)): valid = False for x in range(width): for y in range(height): pixel = image.getpixel( ((o_x * width) + y, (o_y * height) + x)) r, g, b = int(pixel[0]), int(pixel[1]), int(pixel[2]) if r or g or b: valid = True unicorn.set_pixel(x, y, r, g, b) if valid: unicorn.show() time.sleep(cycle_time) except KeyboardInterrupt: unicorn.off()
def main(): # 無限ループ while True: # 描写用キャンバスの新規作成 image = Image.new("RGB", (width, height), (0, 0, 0)) draw = ImageDraw.Draw(image) # 現在時刻の取得 now = datetime.datetime.now() # キャンバスに時、分の描写 draw.text((0, -2), '{0:02}'.format(now.hour), fill=COLOR) draw.text((0, 7), '{0:02}'.format(now.minute), fill=COLOR) # ここからunicornhatへキャンバス描写作業 unicornhathd.clear() # x, yを指定して1ドットずつ描写する for x in range(width): for y in range(height): r, g, b = image.getpixel((x, y)) # ここの部分でx軸を反転させている unicornhathd.set_pixel(width - x - 1, y, r, g, b) # コロンの代わりに2x2のドットを描写する if now.second % 2: unicornhathd.set_pixel(0, height - 1, *COLOR) unicornhathd.set_pixel(1, height - 1, *COLOR) unicornhathd.set_pixel(0, height - 2, *COLOR) unicornhathd.set_pixel(1, height - 2, *COLOR) # 画面のリフレッシュ命令 unicornhathd.show() time.sleep(0.1)
def run(params): star_count = 25 star_speed = 0.05 stars = [] for i in range(0, star_count): stars.append((random.uniform(4, 11), random.uniform(4, 11), 0)) try: while True: unicornhathd.clear() for i in range(0, star_count): stars[i] = ( stars[i][0] + ((stars[i][0] - 8.1) * star_speed), stars[i][1] + ((stars[i][1] - 8.1) * star_speed), stars[i][2] + star_speed * 50) if stars[i][0] < 0 or stars[i][1] < 0 or stars[i][0] > 16 or stars[i][1] > 16: stars[i] = (random.uniform(4, 11), random.uniform(4, 11), 0) v = stars[i][2] unicornhathd.set_pixel(int(stars[i][0]), int(stars[i][1]), v, v, v) unicornhathd.show() except KeyboardInterrupt: unicornhathd.off()
def run(params): def compute_z(x, y, t, pattern): x = x + t y = y + t if pattern == 'parallel': z = math.sin(x) + math.cos(x) z = (z + 2) / 4 elif pattern == 'diagonal': z = math.sin(x + y) + math.cos(x + y) z = (z + 2) / 4 elif pattern == 'crisscross': z = math.sin(x) + math.cos(y) z = (z + 2) / 4 return z patterns = ['parallel', 'diagonal', 'crisscross'] while True: for pattern in patterns: for t in range(50): for y in range(16): for x in range(16): h = 0.1 s = 1.0 v = compute_z(x, y, t, pattern) rgb = colorsys.hsv_to_rgb(h, s, v) r = int(rgb[0] * 255.0) g = int(rgb[1] * 255.0) b = int(rgb[2] * 255.0) unicorn.set_pixel(x, y, r, g, b) unicorn.show() time.sleep(0.08)
def run(params): wrd_rgb = [[154, 173, 154], [0, 255, 0], [0, 235, 0], [0, 220, 0], [0, 185, 0], [0, 165, 0], [0, 128, 0], [ 0, 0, 0, ], [154, 173, 154], [0, 145, 0], [0, 125, 0], [0, 100, 0], [0, 80, 0], [0, 60, 0], [0, 40, 0], [ 0, 0, 0, ]] clock = 0 blue_pilled_population = [[randint(0, 15), 15]] while True: for person in blue_pilled_population: y = person[1] for rgb in wrd_rgb: if (y <= 15) and (y >= 0): unicorn.set_pixel(y, person[0], rgb[0], rgb[1], rgb[2]) y += 1 person[1] -= 1 unicorn.show() time.sleep(0.1) clock += 1 if clock % 5 == 0: blue_pilled_population.append([randint(0, 15), 15]) if clock % 7 == 0: blue_pilled_population.append([randint(0, 15), 15]) while len(blue_pilled_population) > 100: blue_pilled_population.pop(0)
def run_ticker(bg_color, text): FONT = ("DejaVuSans-Bold.ttf", 10) unicornhathd.rotation(90) unicornhathd.brightness(0.6) width, height = unicornhathd.get_shape() text_x = width text_y = 2 font_file, font_size = FONT font = ImageFont.truetype(font_file, font_size) text_width, text_height = width, 0 w, h = font.getsize(text) text_width += w + width text_height = max(text_height, h) text_width += width + text_x + 1 image = Image.new('RGB', (text_width, max(16, text_height)), color) draw = ImageDraw.Draw(image) offset_left = 0 draw.text((text_x + offset_left, text_y), text, fill="white", font=font) offset_left += font.getsize(text)[0] + width while True: for scroll in range(text_width - width): for x in range(width): for y in range(height): pixel = image.getpixel((x + scroll, y)) r, g, b = [int(n) for n in pixel] unicornhathd.set_pixel(width - 1 - x, y, r, g, b) unicornhathd.show() time.sleep(0.01)
def available_status(): text = "I am currently available. Feel freeto enter :)" unicornhathd.clear() unicornhathd.brightness(.6) for xValue in range(0, 15): for yValue in range(0, 15): unicornhathd.set_pixel(xValue, yValue, 0, 255, 0) try: while True: for xValue in range(0, 15): for yValue in range(0, 15): unicornhathd.set_pixel(xValue, yValue, 0, 255, 0) unicornhathd.show() time.sleep(4) unicornhathd.clear() unicornhathd.off() print_status(text, 255, 0, 0) unicornhathd.clear() time.sleep(2) except KeyboardInterrupt: print("error") unicornhathd.off()
def main(run,running): running(True) step = 0 while run(): step += 1 for x in range(0, 16): for y in range(0, 16): dx = 7 dy = 7 dx = (math.sin(step / 20.0) * 15.0) + 7.0 dy = (math.cos(step / 15.0) * 15.0) + 7.0 sc = (math.cos(step / 10.0) * 10.0) + 16.0 h = math.sqrt(math.pow(x - dx, 2) + math.pow(y - dy, 2)) / sc r, g, b = colorsys.hsv_to_rgb(h, 1, 1) r *= 255.0 g *= 255.0 b *= 255.0 unicornhathd.set_pixel(x, y, r, g, b) unicornhathd.show() time.sleep(1.0 / 60) unicornhathd.off() running(False)
def setPictureShow(pic, run, running, frequency): running(True) pictureList = pic.split("|") list_cycle = cycle(pictureList) continue_loop = run() while continue_loop: x = 0 y = 0 current_list = next(list_cycle) current_list = decompress(current_list) if (current_list == None or len(current_list) != 256 * 6): continue_loop = run() continue list = re.findall('......', current_list) for val in list: pixel = fromHex(val) unicorn.set_pixel(x, y, pixel[0], pixel[1], pixel[2]) x += 1 if x == 16: x = 0 y += 1 unicorn.show() now = time.monotonic() while time.monotonic() < now + frequency: continue_loop = run() if not continue_loop: break else: time.sleep(0.05) unicorn.off() running(False)
def main(run, running): running(True) star_count = randint(20, 25) star_speed = 0.05 stars = [] for i in range(0, star_count): stars.append((random.uniform(4, 11), random.uniform(4, 11), 0)) while run(): unicornhathd.clear() for i in range(0, star_count): stars[i] = (stars[i][0] + ((stars[i][0] - 8.1) * star_speed), stars[i][1] + ((stars[i][1] - 8.1) * star_speed), stars[i][2] + star_speed * 50) if stars[i][0] < 0 or stars[i][1] < 0 or stars[i][0] > 16 or stars[ i][1] > 16: stars[i] = (random.uniform(4, 11), random.uniform(4, 11), 0) v = stars[i][2] unicornhathd.set_pixel(stars[i][0], stars[i][1], v, v, v) unicornhathd.show() unicornhathd.off() running(False)
def printMessage(): unicornhathd.rotation(90) text_width, text_height = width, 0 for line in lines: w, h = font.getsize(line) text_width += w + width text_height = max(text_height, h) text_width += width + text_x + 1 image = Image.new('RGB', (text_width, max(16, text_height)), (0, 0, 0)) draw = ImageDraw.Draw(image) offset_left = 0 for index, line in enumerate(lines): draw.text((text_x + offset_left, text_y), line, colours[index], font=font) offset_left += font.getsize(line)[0] + width for scroll in range(text_width - width): for x in range(width): for y in range(height): pixel = image.getpixel((x + scroll, y)) r, g, b = [int(n) for n in pixel] unicornhathd.set_pixel(width - 1 - x, y, r, g, b) unicornhathd.show() time.sleep(0.02)
def OutputText(energy, power, r, g, b): today = "Energy: " + str(energy) + energy_units current = "Power: " + str(power) + power_units lines = [current, today] colours = (r, g, b) FONT = ('/usr/share/fonts/truetype/freefont/FreeSansBold.ttf', 10) width, height = unicornhathd.get_shape() text_x = width text_y = 2 font_file, font_size = FONT font = ImageFont.truetype(font_file, font_size) text_width, text_height = width, 0 for line in lines: w, h = font.getsize(line) text_width += w + width text_height = max(text_height, h) image = Image.new('RGB', (text_width, max(16, text_height)), (0, 0, 0)) draw = ImageDraw.Draw(image) offset_left = 0 for index, line in enumerate(lines): draw.text((text_x + offset_left, text_y), line, colours, font=font) offset_left += font.getsize(line)[0] + width for scroll in range(text_width - width): for x in range(width): for y in range(height): pixel = image.getpixel((x + scroll, y)) red, green, blue = [int(n) for n in pixel] unicornhathd.set_pixel(width - 1 - x, y, red, green, blue) unicornhathd.show() time.sleep(0.05)
def run(params): step = 0 try: while True: step += STEP_RATE for x in range(0, 16): for y in range(0, 16): dx = 7 dy = 7 dx = (math.sin(step / 20.0) * 15.0) + 7.0 dy = (math.cos(step / 15.0) * 15.0) + 7.0 sc = (math.cos(step / 10.0) * 10.0) + 16.0 h = math.sqrt(math.pow(x - dx, 2) + math.pow(y - dy, 2)) / sc r, g, b = colorsys.hsv_to_rgb(h, 1, 1) r *= 255.0 g *= 255.0 b *= 255.0 unicornhathd.set_pixel(x, y, r, g, b) unicornhathd.show() except KeyboardInterrupt: unicornhathd.off()
def display_remote_image(url: str, brightness: float = 0.3) -> None: import unicornhathd response = requests.get(url) source = Image.open(BytesIO(response.content)) unicornhathd.rotation(0) unicornhathd.brightness(brightness) width, height = unicornhathd.get_shape() sat_booster = ImageEnhance.Color(source) img = sat_booster.enhance(1.25) # increase contrast of image contr_booster = ImageEnhance.Contrast(img) img = contr_booster.enhance(1.2) # reduce the number of colors used in picture img = img.convert("P", palette=Image.ADAPTIVE, colors=10) img = source.resize((width, height), resample=Image.BICUBIC) img = ImageOps.mirror(img) for x in range(width): for y in range(height): pixel = img.getpixel((x, y)) r, g, b = int(pixel[0]), int(pixel[1]), int(pixel[2]) unicornhathd.set_pixel(x, y, r, g, b) unicornhathd.show()
return radius = random.randint(1, 8) x = int((math.cos(angle) * radius) + center_x) y = int((math.sin(angle) * radius) + center_y) blips[angle] = (x, y) # unicorn.set_pixel(x, y, 255, 0, 0) while True: angle += 0.1 # if angle > 2 * math.pi: # angle = 0.0 if angle in blips: x, y = blips[angle] print 'Deleting blip: %d %d %f' % (x, y, angle) unicorn.set_pixel(x, y, 0, 0, 0) del blips[angle] drawLine(angle-0.3, 0, 50, 0) drawLine(angle-0.2, 0, 100, 0) drawLine(angle-0.1, 0, 150, 0) drawLine(angle, 0, 255, 0) makeBlip(angle) for blipangle, (x, y) in blips.items(): dim = int((angle - blipangle) * 30) if dim < 0: dim = 0 if dim > 255: dim = 255 unicorn.set_pixel(x, y, 255 - dim, 0, 0)
def drawLine(angle, r, g, b): end_x = (math.cos(angle) * 20.0) + center_x end_y = (math.sin(angle) * 20.0) + center_y for x, y in bresenham(center_x, center_y, int(end_x), int(end_y)): if x > 0 and x <= 15 and y > 0 and y <= 15: unicorn.set_pixel(x, y, r, g, b)
def turn_off(self): unicornhathd.set_pixel(self.x, self.y, 0, 0, 0)
def setPixel(x, y, r, g, b): unicorn.set_pixel((width-1)-x, y, r, g, b)
from unicorn_hat_sim import unicornhathd as unicorn width = 16 height = 16 x = 0 y = 0 def randcolor(): b = random.randint(0, 255) return b b = randcolor() while y <= 15: while x <= 15: b = randcolor() unicorn.set_pixel(x, y, 0, 0, b) unicorn.show() x = x+1 x = 0 y = y+1 while True: unicorn.show() # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # 0 X X X X X X X X X X X X X X X X # 1 # 2 # 3 # 4 # 5
def turn_on(self): unicornhathd.set_pixel(self.x, self.y, 255, 255, 255)