def option_2():###Select a website to create the light show
        your_webiste_choice = raw_input("Please enter the web address")
        final_address = "http://%s" %(your_webiste_choice)
        print "finding", final_address 
        website = urllib2.urlopen(final_address )
        ##print website.read()

        sentence = website.read()

        print sentence
        
        ###Checks the letters in the website, then works out the co- ordinates###
        for letter in sentence:
            index  = ord(letter)-65
            #print index ### remove when complete###
            if index > 0:
                x = int(index/8.0)
                #print x ### remove when complete###
                #x = x - 4
                y = int(index%8)
                #print (x, y)
                
                UH.clear
                UH.brightness(0.2)
                UH.set_pixel(y, x, 0, 255, 0)
                UH.set_pixel(x, y, 0, 255, 0)
                UH.show()
                time.sleep(0.02)
                UH.clear()

            elif index <= 0:
                random_sparkle()
def option_1():###User enters a sentance to create the light show###
      
        phrase = raw_input("Please enter your phrase ").lower()

        ###Checks the letters in the phrase, then works out the co- ordinates###
        for letter in phrase:
            index  = ord(letter)-65
            #print index ### remove when complete###
            if index > 0:
                x = int(index/8.0)
                #print x ### remove when complete###
                x = x - 4
                y = int(index%8)
                #print (x, y)
                
                UH.clear
                UH.brightness(0.20)
                UH.set_pixel(y, x, 255, 255, 255)
                #UH.set_pixel(x, y, 0, 255, 0)
                UH.show()
                time.sleep(0.5)
                UH.clear()

            elif index <= 0:
                random_sparkle()        
def mum2():
    unicorn.set_pixel(4,0,0,132,0)
    unicorn.set_pixel(4,1,0,132,0)
    unicorn.set_pixel(3,1,0,132,0)
    unicorn.set_pixel(5,1,0,132,0)
    unicorn.set_pixel(5,2,0,132,0)
    unicorn.set_pixel(4,2,0,132,0)
    unicorn.set_pixel(3,2,0,132,0)
    unicorn.set_pixel(2,2,0,132,0)
    unicorn.set_pixel(6,2,0,132,0)
    unicorn.set_pixel(5,3,0,132,0)
    unicorn.set_pixel(4,3,0,132,0)
    unicorn.set_pixel(3,3,0,132,0)
    unicorn.set_pixel(2,4,0,132,0)
    unicorn.set_pixel(3,4,0,132,0)
    unicorn.set_pixel(5,4,0,132,0)
    unicorn.set_pixel(6,4,0,132,0)
    unicorn.set_pixel(3,5,0,132,0)
    unicorn.set_pixel(4,4,0,132,0)
    unicorn.set_pixel(4,5,0,132,0)
    unicorn.set_pixel(5,5,0,132,0)
    unicorn.set_pixel(4,6,132,101,0)
    unicorn.set_pixel(4,7,132,101,0)
    unicorn.set_pixel(3,6,255,0,0)
    unicorn.set_pixel(5,6,255,0,0)
    unicorn.show()
    time.sleep(2)
    unicorn.clear()
def mum3():
    unicorn.set_pixel(4,0,255,255,0)
    unicorn.set_pixel(3,1,255,255,0)
    unicorn.set_pixel(2,2,255,255,0)
    unicorn.set_pixel(2,3,255,255,0)
    unicorn.set_pixel(3,4,255,255,0)
    unicorn.set_pixel(5,4,255,255,0)
    unicorn.set_pixel(4,5,255,255,0)
    unicorn.set_pixel(4,6,255,255,255)
    unicorn.set_pixel(4,7,255,255,255)
    unicorn.set_pixel(3,6,255,255,255)
    unicorn.set_pixel(3,7,255,255,255)
    unicorn.set_pixel(3,5,255,255,0)
    unicorn.set_pixel(2,4,255,255,0)
    unicorn.set_pixel(3,0,255,255,0)
    unicorn.set_pixel(5,2,255,255,0)
    unicorn.set_pixel(4,1,255,255,0)
    unicorn.set_pixel(5,3,255,255,0)
    unicorn.set_pixel(4,4,255,255,0)
    unicorn.set_pixel(4,2,255,118,0)
    unicorn.set_pixel(3,2,255,118,0)
    unicorn.set_pixel(3,3,255,118,0)
    unicorn.set_pixel(4,3,255,118,0)
    unicorn.show()
    time.sleep(2)
    unicorn.clear()
Exemple #5
0
def message(message):
    unicorn.rotation(270)
    for _ in range(2):
        unicorn_scroll(message,'white',255,0.1)
    unicorn.clear()
    unicorn.show()
    return "ok"
Exemple #6
0
def clearsystem():
    led.clear()
    led.rotation(0)
    os.system("arp -d *")
    os.system("ip neigh flush all")
    led.show()
    return;
    def display_frame(self, screen):
        #screen used to display information to the player, also required to detect pygame events
        #Unicorn hat display is also handled here
        if self.game_over or self.start:
            screen.fill(WHITE)
            font = pygame.font.SysFont('serif', 25)
            title = font.render('Unicorn Snake.', True, BLACK)
            text = font.render('Press any key to play.', True, BLACK)
            instructions = font.render('Use the arrow keys to control your snake on the unicorn hat', True, BLACK)
            title_center_x = (SCREEN_WIDTH // 2) - (title.get_width() // 2)
            text_center_x = (SCREEN_WIDTH // 2) - (text.get_width() // 2)
            instructions_center_x = (SCREEN_WIDTH // 2) - (instructions.get_width() // 2)
            top_y = title.get_height() * 2
            center_y = (SCREEN_HEIGHT // 2) - (text.get_height() // 2)
            bottom_y = SCREEN_HEIGHT - (instructions.get_height() * 2)
            screen.blit( title, [title_center_x, top_y] )
            screen.blit( text, [text_center_x, center_y] )
            screen.blit( instructions, [instructions_center_x, bottom_y] )
            unicorn.clear() # removes last snake image from unicorn hat
        else:
            screen.fill(BLACK)
            font = pygame.font.SysFont('serif', 25)
            title = font.render('Unicorn Snake.', True, WHITE)
            text = font.render('Game on', True, WHITE)
            title_center_x = (SCREEN_WIDTH // 2) - (title.get_width() // 2)
            text_center_x = (SCREEN_WIDTH // 2) - (text.get_width() // 2)
            top_y = title.get_height() * 2
            center_y = (SCREEN_HEIGHT // 2) - (text.get_height() // 2)
            screen.blit( title, [title_center_x, top_y] )
            screen.blit( text, [text_center_x, center_y] )
            unicorn.show() # display the snake and food on the unicorn hat

        pygame.display.flip()
Exemple #8
0
def icon(icon):
    unicorn.rotation(270)
    for _ in range(5):
        playIcon(icon)
    unicorn.clear()
    unicorn.show()
    return "ok"
def kick_rainbow():
    random_r = randint(0,255)
    random_g = randint(0,255)
    random_b = randint(0,255)
    random_math_r = randint(32,640)
    random_math_g = randint(32,640)
    random_math_b = randint(32,640)
    bright = 1
    i = 0.0
    offset = 30

    for q in range(20): #splash a kick for 20 revs
        i = i + 0.3
        for y in range(4):
            for x in range(8):
                r = 0#x * 32
                g = 0#y * 32
                xy = x + y / 4
                r = (math.cos((x+i)/2.0) + math.cos((y+i)/2.0)) * 64 + 128.0
                g = (math.sin((x+i)/1.5) + math.sin((y+i)/2.0)) * 64 + 128.0
                b = (math.sin((x+i)/2.0) + math.cos((y+i)/1.5)) * 64 + 128.0
                r = max(0, min(random_r, r + offset))
                g = max(0, min(random_g, g + offset))
                b = max(0, min(random_b, b + offset))
                unicorn.set_pixel(x,y,int(r),int(g),int(b))
            unicorn.brightness(bright)
            unicorn.show()
            time.sleep(0.001)
            if bright > 0.3:
                bright = bright - 0.01 #fade on each pass until black
    unicorn.clear()
Exemple #10
0
def paint():
    global last_members
    index = 0
    members = r.find_members()
    if(len(last_members) != len(members)):
        UH.clear()
        UH.show()

    last_members = members
    for member in members:
        temp = r.get_key(member + ".temp")
        baseline = r.get_key(member + ".temp.baseline")
        motion = r.get_key(member + ".motion")

        if safeFloat(motion) > 0:
            if(quiet == False):
                print("moved")
            on(index, 0, 0, 255)
        elif is_hot(temp, baseline):
            on(index, 255, 0, 0)
            if(quiet == False):
                print("HOT")
        else:
            on(index, 0, 255, 0)
        index = index +1
Exemple #11
0
def led_field(colour):
    led.clear()
    for y in range(8):
        for x in range(8):
            led.set_pixel(x, y, colour[0], colour[1], colour[2])
    led.show()
    time.sleep(w)
    return;
Exemple #12
0
def blink_pixel(x, y, starting_brightness, ending_brightness,
                num_brightness_steps, delay, color):
    for brightness in np.linspace(starting_brightness, ending_brightness,
                                  num_brightness_steps):
        unicorn.brightness(brightness)
        unicorn.set_pixel(x, y, color[0], color[1], color[2])
        unicorn.show()
        time.sleep(delay)
    unicorn.clear()
    unicorn.show()
Exemple #13
0
def piLoad():  # Loads image onto AstroPi matrix
    #grid, grid_png = buildGrid()
    #ap.set_pixels(grid)
    uh.clear()
    for led in leds:
        if led.lit:
            uh.set_pixel(led.pos[0], led.pos[1], led.color[0], led.color[1],
                         led.color[2])
            #print str(led.pos[0])+ ' ' +str(led.pos[1]) + ' ' + str(led.color[1])
    uh.show()
def random_sparkle(): ### Code for a random LED if the letter value is below zero###
        x = randint(0, 7)
        y = randint(0, 7)
        r = randint(0, 255)
        g = randint(0, 255)
        b = randint(0, 255)
        UH.set_pixel(x, y, r, g, b)
        UH.show()
        time.sleep(0.10)
        UH.clear()
Exemple #15
0
 def police(self):
     for i in range(3):
         for j in range(8):
             self.drawRect(0, 0, 8, 8, 80, 100, 255)
             time.sleep(0.05)
             unicorn.clear()
             unicorn.show()
             time.sleep(0.05)
         time.sleep(0.25)
     unicorn.off()
Exemple #16
0
def random_sparkle(
):  ### Code for a random LED if the letter value is below zero###
    x = randint(0, 7)
    y = randint(0, 7)
    r = randint(0, 255)
    g = randint(0, 255)
    b = randint(0, 255)
    UH.set_pixel(x, y, r, g, b)
    UH.show()
    time.sleep(0.10)
    UH.clear()
    def __init__(self):
        unicornhat.set_layout(unicornhat.AUTO)
        unicornhat.rotation(270)
        unicornhat.clear()
        unicornhat.brightness(.5)
        width,height=unicornhat.get_shape()
        self.ROW_LENGTH = height
        self._leds = np.zeros((width,height), np.bool)

        self.prev_sent = 0
        self.prev_recv = 0
Exemple #18
0
def move_pixel(pixel_path, delay):
    for path_group in pixel_path:
        for path in path_group:
            brightness = path[2]
            color = path[3]
            x, y = path[0], path[1]
            unicorn.brightness(brightness)
            unicorn.set_pixel(x, y, color[0], color[1], color[2])
        unicorn.show()
        time.sleep(delay)
        unicorn.clear()
Exemple #19
0
    def show_bars(self, values, color=colors['white']):
        for i in range(0, max(0, self.columns - len(values))):
            values.append(0)

        values.reverse()
        unicorn.clear()

        for x in range(0, self.columns):
            for y in range(int(math.ceil(values[x]))):
                self.set_pixel(x, y, color)
        unicorn.show()
Exemple #20
0
def render_matrix_offset(matrix, offset, blackwhite=True):
    import unicornhat as unicorn
    unicorn.clear()
    for y in range(0, rows):
        for x in range(0, columns):
            if blackwhite:
                r, g, b = _get_color(matrix[y][x + offset])
            else:
                r, g, b = _get_multi_color(matrix[y][x + offset])
            unicorn.set_pixel(x, y, r, g, b)
    unicorn.show()
def flashit(time_to_flash,steps):
    for j in range(0,steps):
        steps = float(steps * 1.0)
        brightness = float(j/steps)
        print j,brightness
        print time_to_flash 
        unicorn.brightness(brightness)
        unicorn.show()
        time.sleep(time_to_flash/(j+1))
    unicorn.clear()
    unicorn.brightness(0.1)
def bar(fraction, red, green, blue, delay=0, flip=False):
    """ Light middle bar with specified color """
    unicorn.clear()
    # flip the bar and therefore the range?
    _range = range(int(fraction * _width)) if not flip else reversed(
        range(int((1 - fraction) * (_width)), _width))
    for x in _range:
        for y in range(1, _height - 1):
            unicorn.set_pixel(x, y, red, green, blue)
            unicorn.show()
        time.sleep(delay)
    unicorn.show()
Exemple #23
0
def wave(r,g,b,brightness):
    uh.brightness(brightness)
    random_distance = 80
    while True:
        new_r = r + int(random.uniform(-1*random_distance, random_distance))
        new_g = r + int(random.uniform(-1*random_distance, random_distance))
        for x in range(8):
            for y in range(4):
                uh.set_pixel(x, y, new_r, new_g, b)
            uh.show()
            time.sleep(.2)
            uh.clear()
def main():
    shift = 8
    while shift > -30:
        uh.clear()
        for column in columns:
            pos = column['offset'] + shift
            if pos >= 0 and pos < 8:
                for x, y in column['pixels']:
                    uh.set_pixel(x + pos, y, RED)
        shift -= 1
        uh.show()
        time.sleep(0.2)
Exemple #25
0
def blinker(blinks, color=[255, 0, 0], speed=0.02):
    uh.rotation(270)

    for b in range(blinks):
        r, g, b = color
        uh.set_all(r, g, b)
        uh.show()
        time.sleep(speed)

        uh.clear()
        uh.show()
        time.sleep(speed)
def show_zero():
    while True:
        # x 0
        unicornhat.set_pixel(0, 2, 100, 149, 237)
        unicornhat.set_pixel(0, 3, 100, 149, 237)
        unicornhat.set_pixel(0, 4, 100, 149, 237)
        unicornhat.set_pixel(0, 5, 100, 149, 237)
        # ----------------------------------
        # x 1
        unicornhat.set_pixel(1, 1, 100, 149, 237)
        unicornhat.set_pixel(1, 2, 100, 149, 237)
        unicornhat.set_pixel(1, 5, 100, 149, 237)
        unicornhat.set_pixel(1, 6, 100, 149, 237)
        # ----------------------------------
        # x 2
        unicornhat.set_pixel(2, 1, 100, 149, 237)
        unicornhat.set_pixel(2, 2, 100, 149, 237)
        unicornhat.set_pixel(2, 5, 100, 149, 237)
        unicornhat.set_pixel(2, 6, 100, 149, 237)
        # ----------------------------------
        # x 3
        unicornhat.set_pixel(3, 1, 100, 149, 237)
        unicornhat.set_pixel(3, 2, 100, 149, 237)
        unicornhat.set_pixel(3, 5, 100, 149, 237)
        unicornhat.set_pixel(3, 6, 100, 149, 237)
        # ----------------------------------
        # x 4
        unicornhat.set_pixel(4, 1, 100, 149, 237)
        unicornhat.set_pixel(4, 2, 100, 149, 237)
        unicornhat.set_pixel(4, 5, 100, 149, 237)
        unicornhat.set_pixel(4, 6, 100, 149, 237)
        # ----------------------------------
        # x 5
        unicornhat.set_pixel(5, 1, 100, 149, 237)
        unicornhat.set_pixel(5, 2, 100, 149, 237)
        unicornhat.set_pixel(5, 5, 100, 149, 237)
        unicornhat.set_pixel(5, 6, 100, 149, 237)
        # ----------------------------------
        # x 6
        unicornhat.set_pixel(6, 1, 100, 149, 237)
        unicornhat.set_pixel(6, 2, 100, 149, 237)
        unicornhat.set_pixel(6, 5, 100, 149, 237)
        unicornhat.set_pixel(6, 6, 100, 149, 237)
        # ----------------------------------
        # x 7
        unicornhat.set_pixel(7, 2, 100, 149, 237)
        unicornhat.set_pixel(7, 3, 100, 149, 237)
        unicornhat.set_pixel(7, 4, 100, 149, 237)
        unicornhat.set_pixel(7, 5, 100, 149, 237)
        # ----------------------------------
        unicornhat.show()
        time.sleep(0.5)
        unicornhat.clear()
Exemple #27
0
 def apply(self):
     # The display coordinates (xp, yp) mapping to image pixels (x, y)
     # x = mWidth - 1 - yp
     # y = xp
     uh.clear()
     for xp in range(self.mHeight):
         y = xp
         for yp in range(self.mWidth):
             x = self.mWidth - 1 - yp
             p = self.getPixel(x, y)
             uh.set_pixel(xp, yp, p[0], p[1], p[2])
     uh.show()
Exemple #28
0
def scanner(scans=1, speed=1):
    uh.rotation(270)
    r, g, b = [255, 0, 0]

    for s in range(scans):
        # speed = 1.0 / bpm * 60
        time.sleep(0.22 * speed)
        for h in range(height + 1):
            for w in range(width):
                uh.set_pixel(w, h, r, g, b)
            uh.show()
            time.sleep(0.024 * speed)
            uh.clear()
Exemple #29
0
def led_arrow():
    x = 0
    y = 7
    while x <= 6:
        led.set_pixel(x, y, blue[0], blue[1], blue[2])
        led.set_pixel((x + 1), (y - 1), blue[0], blue[1], blue[2])
        led.set_pixel(x, (y - 2), blue[0], blue[1], blue[2])
        led.show()
        # led_eth(x)
        time.sleep(w)
        x += 1
        led.clear()
    return;
def simulation(generations):
    #initialize unicorn hat
    unicornhat.brightness(0.4)

    matrix = numpy.random.randint(2, size=(8, 8))
    matrix_update = numpy.zeros((8, 8), dtype=int)
    lightup(matrix)
    for generation in range(generations):
        time.sleep(1)
        unicornhat.clear()
        output = pop_update(matrix, matrix_update)
        lightup(output)
        matrix = output
Exemple #31
0
def redalert():

    count = 0
    while (count < 16):
        for x in range(8):
            for y in range(4):
                uh.set_pixel(x, y, 255, 0, 0)
        uh.show()
        time.sleep(0.85)
        uh.clear()
        uh.show()
        time.sleep(0.5)
        count = count + 1
Exemple #32
0
def displayCharacter(f):
    # x = 3 - yp
    # y = xp
    hue = int(time.time() * 10) % 360
    r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(hue / 360.0, 1.0, 1.0)]
    uh.clear()
    for xp in range(8):
        y = xp
        for yp in range(4):
            x = 3 - yp
            if f.getPixel(x, y) != 0:
                uh.set_pixel(xp, yp, r, g, b)
    uh.show()
Exemple #33
0
def main():
	print("Start")
	# set params for unicorn hat
	unicorn.set_layout(unicorn.PHAT)
	unicorn.rotation(0)
	unicorn.brightness(0.3)
	hatWidth,hatHeight=unicorn.get_shape()

	for xx in range(10):
		print("Showing number", xx)
		unicorn.clear()
		setUniPxNum(xx,(255,0,0),4)
		time.sleep(3)
Exemple #34
0
 def render(self):
     print "StreamView.render:"
     unicornhat.clear()
     # Because we render one event per-pixel, we need to only
     # render the most recent self.max_events events
     start = self.max_events * -1
     for i, event in enumerate(self.events[start:]):
         x = i % COLS
         y = i // ROWS
         r, g, b = self._event_colour(event)
         unicornhat.set_pixel(x, y, r, g, b)
     unicornhat.show()
     print "   done."
Exemple #35
0
def snowalert():

    count = 0
    while (count < 11):
        for x in range(8):
            for y in range(4):
                uh.set_pixel(x, y, 255, 255, 255)
        uh.show()
        time.sleep(0.5)
        uh.clear()
        uh.show()
        time.sleep(0.5)
        count = count + 1
def shutdownsequence():
    unicornhat.clear()
    for n in range(9,-1,-1):
        plotnum(n)
        time.sleep(2)
        batterystatus=str(getbatterystatus())
        if batterystatus.find("Charging")>0: # Back on charge?
            unicornhat.clear()  # Clear the display
            drawbattery()   # Draw the battery
            unicornhat.show()
            return()        # Carry on
#    subprocess.call("sudo shutdown -h now")  # Issue shutdown command
    p = subprocess.Popen(["sudo shutdown -h now"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    sys.exit(0)             # Quit this program
Exemple #37
0
def flashHour():

    fulltime = time.localtime()
    hour = int(time.strftime("%I"))

    for h in range(0, hour):
        for x in range(8):
            for y in range(4):
                uh.set_pixel(x, y, 0, 0, 255)
        uh.show()
        time.sleep(0.5)
        uh.clear()
        uh.show()
        time.sleep(0.5)
    def clear(self, fast=False):
        log_str('clear unicorn')

        if not fast:
            for x in range(self.width):
                for y in range(self.height):
                    unicorn.set_pixel(x, y, 0, 0, 0)

                    sleep(0.025)
                    unicorn.show()

        unicorn.clear()
        unicorn.show()
        unicorn.off()
Exemple #39
0
def rainbow():
    uh.brightness(1.0)
    spacing = 360.0 / 16.0
    hue = 0
    t_end = time.time() + 60 * 1
    while time.time() < t_end:
        hue = int(time.time() * 100) % 360
        for x, y in it.product(range(8), range(4)):
            offset = x * spacing
            h = ((hue + offset) % 360) / 360.0
            r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
            uh.set_pixel(x, y, r, g, b)
        uh.show()
        uh.clear()
Exemple #40
0
def main():
    for scroll in range(7, -2, -1):
        uh.clear()
        print_2(scroll + 0, RED)
        print_O(scroll + 3, RED)
        uh.show()
        time.sleep(0.5)

    for scroll in range(7, -2, -1):
        uh.clear()
        print_O(scroll + 0, RED)
        print_M(scroll + 4, RED)
        uh.show()
        time.sleep(0.5)
def hattie1():
    unicorn.set_pixel(1,2,255,255,0)
    unicorn.set_pixel(1,3,255,0,0)
    unicorn.set_pixel(1,4,255,0,0)
    unicorn.set_pixel(1,5,0,0,255)
    unicorn.set_pixel(1,5,255,0,0)
    unicorn.set_pixel(1,6,0,255,0)
    unicorn.set_pixel(1,6,255,0,0)
    unicorn.set_pixel(1,7,255,255,0)
    unicorn.set_pixel(2,0,0,0,255)
    unicorn.set_pixel(2,2,0,255,0)
    unicorn.set_pixel(2,2,255,0,0)
    unicorn.set_pixel(2,3,0,255,0)
    unicorn.set_pixel(2,4,255,0,0)
    unicorn.set_pixel(2,5,255,0,0)
    unicorn.set_pixel(2,6,0,255,0)
    unicorn.set_pixel(2,7,255,0,0)
    unicorn.set_pixel(3,1,0,0,255)
    unicorn.set_pixel(3,2,255,0,0)
    unicorn.set_pixel(3,3,255,0,0)
    unicorn.set_pixel(3,4,255,255,0)
    unicorn.set_pixel(3,5,255,255,0)
    unicorn.set_pixel(3,6,255,0,0)
    unicorn.set_pixel(3,7,255,0,0)
    unicorn.set_pixel(4,1,0,0,255)
    unicorn.set_pixel(4,2,255,0,0)
    unicorn.set_pixel(4,3,0,0,255)
    unicorn.set_pixel(4,3,255,0,0)
    unicorn.set_pixel(4,4,255,0,0)
    unicorn.set_pixel(4,4,255,255,0)
    unicorn.set_pixel(4,5,255,255,0)
    unicorn.set_pixel(4,6,255,0,0)
    unicorn.set_pixel(4,7,255,0,0)
    unicorn.set_pixel(5,0,0,0,255)
    unicorn.set_pixel(5,2,255,0,0)
    unicorn.set_pixel(5,3,0,255,0)
    unicorn.set_pixel(5,4,255,0,0)
    unicorn.set_pixel(5,5,255,0,0)
    unicorn.set_pixel(5,6,0,255,0)
    unicorn.set_pixel(5,7,255,0,0)
    unicorn.set_pixel(6,2,255,255,0)
    unicorn.set_pixel(6,3,255,0,0)
    unicorn.set_pixel(6,4,255,0,0)
    unicorn.set_pixel(6,5,255,0,0)
    unicorn.set_pixel(6,6,255,0,0)
    unicorn.set_pixel(6,7,255,255,0)
    unicorn.show()
    time.sleep(2)
    unicorn.clear()
def main():
    reverse_snake = []
    uh.clear()
    while snake:
        x, y = snake.pop(0)
        uh.set_pixel(x, y, PURPLE)
        reverse_snake.append((x, y))
        uh.show()
        time.sleep(0.4)
    while reverse_snake:
        x, y = reverse_snake.pop()
        uh.set_pixel(x, y, GREEN)
        uh.show()
        time.sleep(0.1)
    time.sleep(3)
def draw_vpgs(healthy, warn, error):
    total = healthy + warn + error
    unicorn.clear()
    for y in range(height):
        for x in range(width):
            if error > 0:
                unicorn.set_pixel(x, y, 255, 0, 0)
                error -= 1
            elif warn > 0:
                unicorn.set_pixel(x, y, 255, 255, 0)
                warn -= 1
            elif healthy > 0:
                unicorn.set_pixel(x, y, 0, 255, 0)
                healthy -= 1
    unicorn.show()
def beep(tone, timer):
    for key in tone_values:
        if key == tone:
            value = tone_values[key]
            for x in range(8):
                for y in range(4):
                    uh.set_pixel(x, y, value['r'], value['g'], value['b'])
    uh.show()
    time.sleep(timer)
    uh.clear()
    for x in range(8):
        for y in range(4):
            uh.set_pixel(x, y, 0, 0, 0)
    uh.show()
    time.sleep(0.05)
def randomLights():

    uh.set_layout(uh.PHAT)
    uh.brightness(0.7)

    for x in range(8):
        for y in range(4):
            a = random.randint(0, 255)
            b = random.randint(0, 255)
            c = random.randint(0, 255)
            uh.set_pixel(x, y, a, b, c)
    uh.show()
    time.sleep(5)
    uh.clear()
    uh.show()
Exemple #46
0
 def kitt(self):
     steps = 64
     for i in range(0, steps):
         unicorn.clear()
         mod = i % 13
         if (mod < 6):
             x = mod
         else:
             x = 6 - (mod - 6)
         for y in range(3, 6):
             unicorn.set_pixel(x, y, 255, 0, 0)
             unicorn.set_pixel(x + 1, y, 255, 0, 0)
         unicorn.show()
         time.sleep(0.1)
     unicorn.off()
def rainbow_clock():
    while not EXIT:
        rgb_value=datetime.datetime.now().time()
        r=rgb_value.hour
        r= int( (r / 23) * 255)
        g=rgb_value.minute
        g= int( (g / 59) * 255)
        b=rgb_value.second
        b=int((b / 59) * 255)
        for i in range(8):
            for j in range(8):
                UH.set_pixel(i,j,r,g,b)
        UH.show()
        time.sleep(1)
        print datetime.datetime.now().time()
        print r,g,b
    UH.clear()
    UH.show()
Exemple #48
0
def led_poweroff(hostn):
    x = 0
    while (os.system("ping -c " + p + " " + hostn)) == 0:
        led.clear()
        if x == 0:
            # line
            led.set_pixel(0, 3, red[0], red[1], red[2])
            led.set_pixel(0, 4, red[0], red[1], red[2])
            led.set_pixel(1, 3, red[0], red[1], red[2])
            led.set_pixel(1, 4, red[0], red[1], red[2])
            led.set_pixel(2, 3, red[0], red[1], red[2])
            led.set_pixel(2, 4, red[0], red[1], red[2])
            led.set_pixel(3, 3, red[0], red[1], red[2])
            led.set_pixel(3, 4, red[0], red[1], red[2])
            x += 1
        else:
            led.set_pixel(0, 3, blue[0], blue[1], blue[2])
            led.set_pixel(0, 4, blue[0], blue[1], blue[2])
            led.set_pixel(1, 3, blue[0], blue[1], blue[2])
            led.set_pixel(1, 4, blue[0], blue[1], blue[2])
            led.set_pixel(2, 3, blue[0], blue[1], blue[2])
            led.set_pixel(2, 4, blue[0], blue[1], blue[2])
            led.set_pixel(3, 3, blue[0], blue[1], blue[2])
            led.set_pixel(3, 4, blue[0], blue[1], blue[2])
            x = 0
        # ring
        led.set_pixel(1, 1, red[0], red[1], red[2])
        led.set_pixel(1, 6, red[0], red[1], red[2])
        led.set_pixel(2, 0, red[0], red[1], red[2])
        led.set_pixel(2, 7, red[0], red[1], red[2])
        led.set_pixel(3, 0, red[0], red[1], red[2])
        led.set_pixel(3, 7, red[0], red[1], red[2])
        led.set_pixel(4, 0, red[0], red[1], red[2])
        led.set_pixel(4, 7, red[0], red[1], red[2])
        led.set_pixel(5, 0, red[0], red[1], red[2])
        led.set_pixel(5, 7, red[0], red[1], red[2])
        led.set_pixel(6, 1, red[0], red[1], red[2])
        led.set_pixel(6, 6, red[0], red[1], red[2])
        led.set_pixel(7, 2, red[0], red[1], red[2])
        led.set_pixel(7, 3, red[0], red[1], red[2])
        led.set_pixel(7, 4, red[0], red[1], red[2])
        led.set_pixel(7, 5, red[0], red[1], red[2])
        led.show()
        time.sleep(w)
def hihat_splash():
    unicorn.brightness(1)
    y_loc = randint(0,2)
    x_loc = randint(0,6)
    red = randint(192,255)
    gre = randint(192,255)
    blu = randint(192,255)
    unicorn.set_pixel(x_loc, y_loc, red, gre, blu)
    unicorn.set_pixel((x_loc + 1), y_loc, red, gre, blu)
    unicorn.set_pixel((x_loc + 1), (y_loc + 1), red, gre, blu)
    unicorn.set_pixel(x_loc, (y_loc + 1), red, gre, blu)
    for p in range(7):
        red2 = randint(0,255)
        gre2 = randint(0,255)
        blu2 = randint(0,255)
        unicorn.set_pixel(randint(0,8), randint(0,4), red2, gre2, blu2)
    unicorn.show()
    time.sleep(0.05)
    unicorn.clear()
    unicorn.show()
Exemple #50
0
def led_reset():
    led.clear()
    led.set_pixel(1, 1, orange[0], orange[1], orange[2])
    led.set_pixel(1, 3, orange[0], orange[1], orange[2])
    led.set_pixel(1, 4, orange[0], orange[1], orange[2])
    led.set_pixel(2, 1, orange[0], orange[1], orange[2])
    led.set_pixel(2, 2, orange[0], orange[1], orange[2])
    led.set_pixel(2, 5, orange[0], orange[1], orange[2])
    led.set_pixel(3, 1, orange[0], orange[1], orange[2])
    led.set_pixel(3, 2, orange[0], orange[1], orange[2])
    led.set_pixel(3, 3, orange[0], orange[1], orange[2])
    led.set_pixel(3, 6, orange[0], orange[1], orange[2])
    led.set_pixel(4, 6, orange[0], orange[1], orange[2])
    led.set_pixel(5, 2, orange[0], orange[1], orange[2])
    led.set_pixel(5, 5, orange[0], orange[1], orange[2])
    led.set_pixel(6, 3, orange[0], orange[1], orange[2])
    led.set_pixel(6, 4, orange[0], orange[1], orange[2])
    led.show()
    time.sleep(w)
    return;
Exemple #51
0
def main():
    while True:
        led.clear()
        led.show()
        timestamp = datetime.datetime.now().time()
        if (os.system("ping -c " + p + " 192.168.111.25")) == 0:
            if starttime <= timestamp <= endtime:
                clearsystem()
                if (os.system("ping -c " + p + " " + hosts[1])) == 0:
                    led_reset()
                    led_piping()
                else:
                    led_reset()
                    led_router()
            else:
                if (os.system("ping -c " + p + " " + hosts[8])) == 0:
                    led.clear()
                    sshconnect(hosts[8], "base64-password", "poweroff")
                    led_poweroff(hosts[8])
                    led_reset()
                if (os.system("ping -c " + p + " " + hosts[10])) == 0:
                    led.clear()
                    sshconnect(hosts[10], "base64-password", "poweroff")
                    led_poweroff(hosts[10])
                    led_reset()
                continue
        else:
            led_arrow()
            continue
def mum1():
    unicorn.set_pixel(3,0,140,255,255)
    unicorn.set_pixel(4,0,140,255,255)
    unicorn.set_pixel(3,1,140,255,255)
    unicorn.set_pixel(4,1,140,255,255)
    unicorn.set_pixel(4,2,140,255,255)
    unicorn.set_pixel(3,2,140,255,255)
    unicorn.set_pixel(3,3,140,255,255)
    unicorn.set_pixel(4,3,140,255,255)
    unicorn.set_pixel(3,4,140,255,255)
    unicorn.set_pixel(3,5,140,255,255)
    unicorn.set_pixel(3,7,140,255,255)
    unicorn.set_pixel(3,6,140,255,255)
    unicorn.set_pixel(4,4,140,255,255)
    unicorn.set_pixel(4,7,140,255,255)
    unicorn.set_pixel(4,6,140,255,255)
    unicorn.set_pixel(4,5,140,255,255)
    unicorn.set_pixel(5,3,140,255,255)
    unicorn.set_pixel(5,4,140,255,255)
    unicorn.set_pixel(6,3,140,255,255)
    unicorn.set_pixel(6,4,140,255,255)
    unicorn.set_pixel(7,3,140,255,255)
    unicorn.set_pixel(7,4,140,255,255)
    unicorn.set_pixel(2,3,140,255,255)
    unicorn.set_pixel(2,4,140,255,255)
    unicorn.set_pixel(1,3,140,255,255)
    unicorn.set_pixel(1,4,140,255,255)
    unicorn.set_pixel(0,3,140,255,255)
    unicorn.set_pixel(0,4,140,255,255)
    unicorn.set_pixel(6,1,255,255,255)
    unicorn.set_pixel(5,2,255,255,255)
    unicorn.set_pixel(1,1,255,255,255)
    unicorn.set_pixel(2,2,255,255,255)
    unicorn.set_pixel(2,5,255,255,255)
    unicorn.set_pixel(1,6,255,255,255)
    unicorn.set_pixel(5,5,255,255,255)
    unicorn.set_pixel(6,6,255,255,255)
    unicorn.show()
    time.sleep(2)
    unicorn.clear()
Exemple #53
0
def led_piping():
    x = 0
    y = 0
    h = 0
    led.clear()
    led.show()
    time.sleep(w)
    while h <= 15:
        if hosts[h] == "":
            led.set_pixel(x, y, blue[0], blue[1], blue[2])
            led.set_pixel(x, (y + 1), blue[0], blue[1], blue[2])
            led.set_pixel((x + 1), y, blue[0], blue[1], blue[2])
            led.set_pixel((x + 1), (y + 1), blue[0], blue[1], blue[2])
            led.show()
        else:
            if (os.system("ping -c " + p + " " + hosts[h])) == 0:
                led.set_pixel(x, y, green[0], green[1], green[2])
                led.set_pixel(x, (y + 1), green[0], green[1], green[2])
                led.set_pixel((x + 1), y, green[0], green[1], green[2])
                led.set_pixel((x + 1), (y + 1), green[0], green[1], green[2])
                led.show()
            else:
                led.set_pixel(x, y, red[0], red[1], red[2])
                led.set_pixel(x, (y + 1), red[0], red[1], red[2])
                led.set_pixel((x + 1), y, red[0], red[1], red[2])
                led.set_pixel((x + 1), (y + 1), red[0], red[1], red[2])
                led.show()
                if h == 8:
                    wol(hostsmac[h])
                if h == 10:
                    wol(hostsmac[h])
        x += 2
        if x == 8:
            x = 0
            y += 2
        h += 1
        time.sleep(w)
    return;
def james1():
    unicorn.set_pixel(0,0,0,152,152)
    unicorn.set_pixel(1,0,0,152,152)
    unicorn.set_pixel(2,0,0,152,152)
    unicorn.set_pixel(3,0,0,152,152)
    unicorn.set_pixel(4,0,0,152,152)
    unicorn.set_pixel(5,0,0,152,152)
    unicorn.set_pixel(6,0,0,152,152)
    unicorn.set_pixel(7,0,0,152,152)
    unicorn.set_pixel(0,1,0,152,152)
    unicorn.set_pixel(1,1,0,152,152)
    unicorn.set_pixel(2,1,0,152,152)
    unicorn.set_pixel(3,1,0,152,152)
    unicorn.set_pixel(4,1,0,152,152)
    unicorn.set_pixel(5,1,0,152,152)
    unicorn.set_pixel(6,1,0,152,152)
    unicorn.set_pixel(7,1,0,152,152)
    unicorn.set_pixel(0,2,0,152,152)
    unicorn.set_pixel(1,2,0,152,152)
    unicorn.set_pixel(2,2,0,152,152)
    unicorn.set_pixel(3,2,0,152,152)
    unicorn.set_pixel(4,2,0,152,152)
    unicorn.set_pixel(5,2,0,152,152)
    unicorn.set_pixel(6,2,0,152,152)
    unicorn.set_pixel(7,2,0,152,152)
    unicorn.set_pixel(0,3,0,152,152)
    unicorn.set_pixel(1,3,0,152,152)
    unicorn.set_pixel(2,3,0,152,152)
    unicorn.set_pixel(3,3,0,152,152)
    unicorn.set_pixel(4,3,0,152,152)
    unicorn.set_pixel(5,3,0,152,152)
    unicorn.set_pixel(6,3,0,152,152)
    unicorn.set_pixel(7,3,0,152,152)
    unicorn.set_pixel(0,4,0,152,152)
    unicorn.set_pixel(1,4,0,152,152)
    unicorn.set_pixel(2,4,0,152,152)
    unicorn.set_pixel(3,4,0,152,152)
    unicorn.set_pixel(4,4,0,152,152)
    unicorn.set_pixel(5,4,0,152,152)
    unicorn.set_pixel(6,4,0,152,152)
    unicorn.set_pixel(7,4,0,152,152)
    unicorn.set_pixel(0,5,0,152,152)
    unicorn.set_pixel(1,5,0,152,152)
    unicorn.set_pixel(2,5,0,152,152)
    unicorn.set_pixel(3,5,0,152,152)
    unicorn.set_pixel(4,5,0,152,152)
    unicorn.set_pixel(5,5,0,152,152)
    unicorn.set_pixel(6,5,0,152,152)
    unicorn.set_pixel(7,5,0,152,152)
    unicorn.set_pixel(0,6,0,152,152)
    unicorn.set_pixel(1,6,0,152,152)
    unicorn.set_pixel(2,6,0,152,152)
    unicorn.set_pixel(3,6,0,152,152)
    unicorn.set_pixel(4,6,0,152,152)
    unicorn.set_pixel(5,6,0,152,152)
    unicorn.set_pixel(6,6,0,152,152)
    unicorn.set_pixel(7,6,0,152,152)
    unicorn.set_pixel(0,7,0,152,152)
    unicorn.set_pixel(1,7,0,152,152)
    unicorn.set_pixel(2,7,0,152,152)
    unicorn.set_pixel(3,7,0,152,152)
    unicorn.set_pixel(4,7,0,152,152)
    unicorn.set_pixel(5,7,0,152,152)
    unicorn.set_pixel(6,7,0,152,152)
    unicorn.set_pixel(7,7,0,152,152)
    unicorn.set_pixel(2,7,255,255,255)
    unicorn.set_pixel(3,7,255,255,255)
    unicorn.set_pixel(4,7,255,255,255)
    unicorn.set_pixel(5,6,255,255,255)
    unicorn.set_pixel(6,5,255,255,255)
    unicorn.set_pixel(6,4,255,255,255)
    unicorn.set_pixel(6,3,255,255,255)
    unicorn.set_pixel(5,2,255,255,255)
    unicorn.set_pixel(5,3,255,255,255)
    unicorn.set_pixel(4,3,255,255,255)
    unicorn.set_pixel(3,3,255,255,255)
    unicorn.set_pixel(2,4,0,132,132)
    unicorn.set_pixel(2,3,255,255,255)
    unicorn.set_pixel(1,4,255,255,255)
    unicorn.set_pixel(1,5,255,255,255)
    unicorn.set_pixel(2,6,255,255,255)
    unicorn.set_pixel(1,7,0,0,0)
    unicorn.set_pixel(1,7,0,152,152)
    unicorn.set_pixel(4,2,0,152,152)
    unicorn.set_pixel(4,1,0,152,152)
    unicorn.set_pixel(5,2,0,152,152)
    unicorn.set_pixel(6,3,0,152,152)
    unicorn.set_pixel(2,4,0,152,152)
    unicorn.set_pixel(2,6,0,0,0)
    unicorn.set_pixel(1,5,0,0,0)
    unicorn.set_pixel(1,4,0,0,0)
    unicorn.set_pixel(1,6,255,255,255)
    unicorn.set_pixel(0,5,255,255,255)
    unicorn.set_pixel(0,4,255,255,255)
    unicorn.set_pixel(1,3,255,255,255)
    unicorn.set_pixel(3,4,255,255,255)
    unicorn.set_pixel(4,4,255,255,255)
    unicorn.set_pixel(5,4,255,255,255)
    unicorn.set_pixel(2,5,255,255,255)
    unicorn.set_pixel(3,5,255,255,255)
    unicorn.set_pixel(4,5,255,255,255)
    unicorn.set_pixel(5,5,255,255,255)
    unicorn.set_pixel(3,6,255,255,255)
    unicorn.set_pixel(4,6,255,255,255)
    unicorn.set_pixel(2,4,255,255,255)
    unicorn.set_pixel(1,4,255,255,255)
    unicorn.set_pixel(1,5,255,255,255)
    unicorn.set_pixel(2,6,255,255,255)
    unicorn.set_pixel(3,4,0,0,132)
    unicorn.set_pixel(3,4,255,255,255)
    unicorn.set_pixel(3,3,0,0,132)
    unicorn.set_pixel(3,5,0,0,132)
    unicorn.set_pixel(3,7,0,0,132)
    unicorn.set_pixel(5,5,132,0,0)
    unicorn.set_pixel(6,5,132,0,0)
    unicorn.set_pixel(7,4,132,0,0)
    unicorn.set_pixel(7,6,132,0,0)
    unicorn.set_pixel(2,2,255,255,255)
    unicorn.set_pixel(3,1,255,255,255)
    unicorn.set_pixel(4,2,255,255,255)
    unicorn.set_pixel(4,1,255,255,255)
    unicorn.set_pixel(2,1,255,255,255)
    unicorn.set_pixel(3,2,255,255,255)
    unicorn.set_pixel(4,0,255,255,255)
    unicorn.set_pixel(3,0,255,255,255)
    unicorn.set_pixel(2,0,255,255,255)
    unicorn.set_pixel(5,0,255,255,255)
    unicorn.set_pixel(5,1,255,255,255)
    unicorn.set_pixel(5,2,255,255,255)
    unicorn.set_pixel(1,2,255,255,255)
    unicorn.set_pixel(1,1,255,255,255)
    unicorn.set_pixel(1,0,255,255,255)
    unicorn.set_pixel(6,3,255,255,255)
    unicorn.set_pixel(0,3,255,255,255)
    unicorn.set_pixel(2,0,132,0,0)
    unicorn.set_pixel(4,0,132,0,0)
    unicorn.set_pixel(1,1,132,0,0)
    unicorn.set_pixel(1,1,255,255,255)
    unicorn.set_pixel(2,3,255,0,0)
    unicorn.set_pixel(2,4,255,0,0)
    unicorn.set_pixel(1,2,255,0,0)
    unicorn.set_pixel(2,2,255,0,0)
    unicorn.set_pixel(3,2,255,0,0)
    unicorn.set_pixel(4,2,255,0,0)
    unicorn.set_pixel(5,2,255,0,0)
    unicorn.set_pixel(3,1,255,132,0)
    unicorn.set_pixel(5,1,255,255,255)
    unicorn.set_pixel(4,1,255,255,255)
    unicorn.show()
    time.sleep(2)
    unicorn.clear()
Exemple #55
0
def led_router():
    led.clear()
    led.show()
    while not (os.system("ping -c " + p + " " + hosts[1])) == 0:
        h = 0
        wol(hostsmac[8])
        wol(hostsmac[10])
        while h <= 4:
            # arrow 1
            if h == 0:
                led.set_pixel(0, 5, green[0], green[1], green[2])
                led.set_pixel(0, 7, green[0], green[1], green[2])
                led.set_pixel(1, 5, green[0], green[1], green[2])
                led.set_pixel(1, 6, green[0], green[1], green[2])
                led.set_pixel(2, 5, green[0], green[1], green[2])
                led.set_pixel(2, 6, green[0], green[1], green[2])
                led.set_pixel(2, 7, green[0], green[1], green[2])
            else:
                led.set_pixel(0, 5, red[0], red[1], red[2])
                led.set_pixel(0, 7, red[0], red[1], red[2])
                led.set_pixel(1, 5, red[0], red[1], red[2])
                led.set_pixel(1, 6, red[0], red[1], red[2])
                led.set_pixel(2, 5, red[0], red[1], red[2])
                led.set_pixel(2, 6, red[0], red[1], red[2])
                led.set_pixel(2, 7, red[0], red[1], red[2])
            # arrow 2
            if h == 1:
                led.set_pixel(0, 0, green[0], green[1], green[2])
                led.set_pixel(0, 1, green[0], green[1], green[2])
                led.set_pixel(0, 2, green[0], green[1], green[2])
                led.set_pixel(1, 0, green[0], green[1], green[2])
                led.set_pixel(1, 1, green[0], green[1], green[2])
                led.set_pixel(2, 0, green[0], green[1], green[2])
                led.set_pixel(2, 2, green[0], green[1], green[2])
            else:
                led.set_pixel(0, 0, red[0], red[1], red[2])
                led.set_pixel(0, 1, red[0], red[1], red[2])
                led.set_pixel(0, 2, red[0], red[1], red[2])
                led.set_pixel(1, 0, red[0], red[1], red[2])
                led.set_pixel(1, 1, red[0], red[1], red[2])
                led.set_pixel(2, 0, red[0], red[1], red[2])
                led.set_pixel(2, 2, red[0], red[1], red[2])
            # arrow 3
            if h == 2:
                led.set_pixel(5, 0, green[0], green[1], green[2])
                led.set_pixel(5, 1, green[0], green[1], green[2])
                led.set_pixel(5, 2, green[0], green[1], green[2])
                led.set_pixel(6, 1, green[0], green[1], green[2])
                led.set_pixel(6, 2, green[0], green[1], green[2])
                led.set_pixel(7, 0, green[0], green[1], green[2])
                led.set_pixel(7, 2, green[0], green[1], green[2])
            else:
                led.set_pixel(5, 0, red[0], red[1], red[2])
                led.set_pixel(5, 1, red[0], red[1], red[2])
                led.set_pixel(5, 2, red[0], red[1], red[2])
                led.set_pixel(6, 1, red[0], red[1], red[2])
                led.set_pixel(6, 2, red[0], red[1], red[2])
                led.set_pixel(7, 0, red[0], red[1], red[2])
                led.set_pixel(7, 2, red[0], red[1], red[2])
            # arrow 4
            if h == 3:
                led.set_pixel(5, 5, green[0], green[1], green[2])
                led.set_pixel(5, 7, green[0], green[1], green[2])
                led.set_pixel(6, 6, green[0], green[1], green[2])
                led.set_pixel(6, 7, green[0], green[1], green[2])
                led.set_pixel(7, 5, green[0], green[1], green[2])
                led.set_pixel(7, 6, green[0], green[1], green[2])
                led.set_pixel(7, 7, green[0], green[1], green[2])
            else:
                led.set_pixel(5, 5, red[0], red[1], red[2])
                led.set_pixel(5, 7, red[0], red[1], red[2])
                led.set_pixel(6, 6, red[0], red[1], red[2])
                led.set_pixel(6, 7, red[0], red[1], red[2])
                led.set_pixel(7, 5, red[0], red[1], red[2])
                led.set_pixel(7, 6, red[0], red[1], red[2])
                led.set_pixel(7, 7, red[0], red[1], red[2])
            led.show()
            h += 1
            time.sleep(w)
    return;
Exemple #56
0
len_middle = 0.2
len_short = 2
len_long = 3.5

while True:
    currenttime = time.localtime()
    currenthour = currenttime.tm_hour
    currentmin = currenttime.tm_min
    currentsec = currenttime.tm_sec

    ah = (1 + currenthour / 6.0) * math.pi
    am = (1 + currentmin / 30.0) * math.pi
    asec = (1 + currentsec / 30.0) * math.pi

    circle((255, 0, 255))

    line(getX(asec, len_middle), getY(asec, len_middle),
         getX(asec, len_long), getY(asec, len_long), (255, 0, 0))
    line(getX(am, len_middle), getY(am, len_middle),
         getX(am, len_long), getY(am, len_long), (0, 255, 0))
    line(getX(ah, len_middle), getY(ah, len_middle),
         getX(ah, len_short), getY(ah, len_short), (0, 0, 255))

    # ensure at least one pixel shows the seconds
    u.set_pixel(getX(asec, len_long), getY(asec, len_long), 255, 0, 0)

    u.show()
    time.sleep(1)
    u.clear()
Exemple #57
0
def plot_points():

    uh.clear()
    for point in points:
        uh.set_pixel(point.x, point.y, point.colour[0], point.colour[1], point.colour[2])
    uh.show()
Exemple #58
0
#!/usr/bin/env python
import unicornhat as unicorn
unicorn.clear()
unicorn.show()

import unicornhat as UH
import time
import random

if __name__=='__main__':
  UH.brightness(0.01)
  UH.rotation(90)
  r = range(0,8)
  while True:
    for x in r:
      y = random.choice(r)
      for fill in range(0, y):
        UH.set_pixel(x,fill,255,0,255)

    UH.show()
    time.sleep(0.05)
    UH.clear()
    UH.show()
    time.sleep(0.05)
def christmas_tree():
    unicorn.brightness(0.4)
    r = int(0)
    g = int(255)
    b = int(0)
    rt = int(102)
    gt = int(51)
    bt = int(0)
    unicorn.set_pixel(0,5,255,0,0)
    unicorn.set_pixel(1,5,r,g,b)
    unicorn.set_pixel(2,5,r,g,b)
    unicorn.set_pixel(3,5,r,g,b)
    unicorn.set_pixel(4,5,r,g,b)
    unicorn.set_pixel(5,5,r,g,b)
    unicorn.set_pixel(6,5,r,g,b)
    unicorn.set_pixel(7,5,r,g,b)
    unicorn.set_pixel(1,4,r,g,b)
    unicorn.set_pixel(3,4,r,g,b)
    unicorn.set_pixel(5,4,r,g,b)
    unicorn.set_pixel(2,3,r,g,b)
    unicorn.set_pixel(4,3,r,g,b)
    unicorn.set_pixel(3,2,r,g,b)
    unicorn.set_pixel(3,1,r,g,b)
    #### Tree base
    unicorn.set_pixel(3,7,rt,gt,bt)
    unicorn.set_pixel(3,6,rt,gt,bt)
    #### Star
    unicorn.set_pixel(3,0,255,255,0)
    
    
    unicorn.set_pixel(0,5,255,0,b)
    unicorn.set_pixel(2,5,255,0,b)
    unicorn.set_pixel(4,5,255,0,b)
    unicorn.set_pixel(6,5,255,0,b)
    unicorn.set_pixel(0,4,51,0,153)
    unicorn.set_pixel(2,4,51,0,153)
    unicorn.set_pixel(4,4,51,0,153)
    unicorn.set_pixel(6,4,51,0,153)
    unicorn.set_pixel(1,3,255,0,0)
    unicorn.set_pixel(3,3,255,0,0)
    unicorn.set_pixel(5,3,255,0,0)
    unicorn.set_pixel(2,2,51,0,153)
    unicorn.set_pixel(4,2,51,0,153)
    #### Star
    unicorn.show()
    time.sleep(1)
    unicorn.brightness(0.5)
    unicorn.set_pixel(3,0,255,255,255)
    unicorn.show()
    time.sleep(0.1)
    unicorn.set_pixel(3,0,255,255,0)
    unicorn.brightness(0.4)
    unicorn.show()
    time.sleep(2)
    unicorn.set_pixel(0,5,51,0,153)
    unicorn.set_pixel(2,5,51,0,153)
    unicorn.set_pixel(4,5,51,0,153)
    unicorn.set_pixel(6,5,51,0,153)
    unicorn.set_pixel(0,4,255,0,0)
    unicorn.set_pixel(2,4,255,0,0)
    unicorn.set_pixel(4,4,255,0,0)
    unicorn.set_pixel(6,4,255,0,0)
    unicorn.set_pixel(1,3,51,0,153)
    unicorn.set_pixel(3,3,51,0,153)
    unicorn.set_pixel(5,3,51,0,153)
    unicorn.set_pixel(2,2,255,0,0)
    unicorn.set_pixel(4,2,255,0,0)
    unicorn.show()
    time.sleep(2)
    unicorn.clear()