• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python unicornhat.set_pixel函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中unicornhat.set_pixel函数的典型用法代码示例。如果您正苦于以下问题:Python set_pixel函数的具体用法?Python set_pixel怎么用?Python set_pixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_pixel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: go

def go():
    unicorn.brightness(1)
    unicorn.rotation(90)

    wrd_rgb = [[154, 173, 154], [0, 255, 0], [0, 200, 0], [0, 162, 0], [0, 145, 0], [0, 96, 0], [0, 74, 0], [0, 0, 0,]]

    clock = 0

    blue_pilled_population = [[randint(0,7), 7]]
    t_end = time.time() + 10
    while time.time() < t_end:
            for person in blue_pilled_population:
                    y = person[1]
                    for rgb in wrd_rgb:
                            if (y <= 7) and (y >= 0):
                                    unicorn.set_pixel(person[0], y, 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,7), 7])
            if clock % 7 == 0:
                    blue_pilled_population.append([randint(0,7), 7])
            while len(blue_pilled_population) > 100:
                    blue_pilled_population.pop(0)
开发者ID:Stimul8d,项目名称:SpeakyBuild,代码行数:27,代码来源:good.py


示例2: option_2

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()
开发者ID:TeCoEd,项目名称:Unicorn-HAT-alphabet-disco,代码行数:32,代码来源:working+version+1.py


示例3: set_build_success

 def set_build_success(self):
     self.logger.debug("Last build worked !")
     for y in range(8):
         for x in range(8):
             UH.set_pixel(x, y, 0, 255, 0)
             UH.show()
             time.sleep(0.05)
开发者ID:sneakybeaky,项目名称:pi-build-monitor,代码行数:7,代码来源:build_monitor.py


示例4: uh_show_matrix

def uh_show_matrix(mat, pause = .075):
    for y in range(len(mat)):
        for x in range(len(mat[0])):
            uh.set_pixel(x, y, mat[x][y][0], mat[x][y][1], mat[x][y][2])
            
    uh.show()
    time.sleep(pause)
开发者ID:secutor,项目名称:raspi,代码行数:7,代码来源:pomo.py


示例5: fill

def fill(r=0,g=255,b=0):
    for x in range(8):
        for y in range(8):
            unicorn.set_pixel(8-x-1, 8-y-1, r, g, b)
            unicorn.show()
            time.sleep(0.05)
    time.sleep(2)
开发者ID:ericosur,项目名称:ericosur-snippet,代码行数:7,代码来源:char.py


示例6: drawpet

def drawpet(pet):
	for y in range(8):
		for x in range(8):
			#set pixel with color
			r, g, b = pet[y][x]
			unicorn.set_pixel(x,y,r,g,b)
	unicorn.show()
开发者ID:monkeymademe,项目名称:raspberryjamberlin_resources,代码行数:7,代码来源:unikitty.py


示例7: showTime

def showTime(time,col,r,g,b):
	binary = '{0:08b}'.format(time)
	for y in range(8):
		if binary[y] == '1':
			uni.set_pixel(col,y,r,g,b)
		else:
			uni.set_pixel(col,y,0,0,0)
开发者ID:davidgouge,项目名称:binaryclock,代码行数:7,代码来源:binary_clock.py


示例8: go

def go():
    effects = [tunnel, rainbow_search, checker, swirl]

    unicorn.brightness(1)

    step = 0
    t_end = time.time() + 10
    while time.time() < t_end:
        for i in range(500):
            for y in range(8):
                for x in range(8):              
                    r, g, b = effects[0](x, y, step)
                    if i > 400:
                        r2, g2, b2 = effects[-1](x, y, step)

                        ratio = (500.00 - i) / 100.0
                        r = r * ratio + r2 * (1.0 - ratio)
                        g = g * ratio + g2 * (1.0 - ratio)
                        b = b * ratio + b2 * (1.0 - ratio)
                    r = int(max(0, min(255, r)))
                    g = int(max(0, min(255, g)))
                    b = int(max(0, min(255, b)))
                    unicorn.set_pixel(x, y, r, g, b)

            step += 1
            
            unicorn.show()

            time.sleep(0.01)

        effect = effects.pop()
        effects.insert(0, effect)
开发者ID:Stimul8d,项目名称:SpeakyBuild,代码行数:32,代码来源:inprog.py


示例9: draw_heart

def draw_heart(hue, brightness):
  for x, y in pixels_to_light:
    color = colorsys.hsv_to_rgb(hue, 1, brightness)
    color = [int(c * 255) for c in color]
    r, g, b = color  
    unicorn.set_pixel(x, y, r, g, b)
  unicorn.show()
开发者ID:PaulineLc,项目名称:JustUnicornThings,代码行数:7,代码来源:show_heart.py


示例10: display_binary

def display_binary(value, row, color):
	binary_str = "{0:8b}".format(value)
	for x in range(0, 8):
		if binary_str[x] == '1':
			hat.set_pixel(x, row, color[0], color[1], color[2])
		else:
			hat.set_pixel(x, row, 0, 0, 0)
开发者ID:chr15murray,项目名称:pi_magazine,代码行数:7,代码来源:binary_clock_uni.py


示例11: writePixel

def writePixel(pixel):
   #try:
      #GPIO.setup(int(pin), GPIO.IN)
      #if GPIO.input(int(pin)) == True:
      #   response = "Pin number " + pin + " is high!"
      #else:
      #   response = "Pin number " + pin + " is low!"
   #except:
      #response = "There was an error reading pin " + pin + "."

   color = int(pixel)

   for i in range(0,8):
   	UH.set_pixel(0,i,color,color,color)

   UH.show()

   response="All correct"   

   now = datetime.datetime.now()
   timeString = now.strftime("%Y-%m-%d %H:%M")

   templateData = {
      'title' : 'Status of Pixel' + str(pixel),
      'time': timeString,
      'response' : response
      }

   return render_template('main.html', **templateData)
开发者ID:tejonbiker,项目名称:flask_iot,代码行数:29,代码来源:hello_pixel.py


示例12: effect

def effect():
    # trigger effect
    for i in range(steps_per * 8):
        for y in range(8):
            for x in range(8):              
                r, g, b = background(x, y, i)
                r = int(max(0, min(255, r)))
                g = int(max(0, min(255, g)))
                b = int(max(0, min(255, b)))
                unicorn.set_pixel(x, y, r, g, b)

        unicorn.show()

        time.sleep(0.01)

    for i in range(200):
        v = (math.sin(i / 6.0) + 1.0) / 2.0
        for y in range(8):
            for x in range(8):
                r = 0
                b = 0             
                g = 100
                g *= tick_mask[y][x]
                g *= v
                r = int(max(0, min(255, r)))
                g = int(max(0, min(255, g)))
                b = int(max(0, min(255, b)))
                unicorn.set_pixel(x, y, r, g, b)

        unicorn.show()

        time.sleep(0.02)
开发者ID:bendo,项目名称:unicorn-hat,代码行数:32,代码来源:eve.py


示例13: display_matrix

 def display_matrix(max_x, max_y, text=False, r=255, g=255, b=255):
     """
     Display the matrix, either on the unicorn or on the stdout
     :param max_x:
     :param max_y:
     :param text: If True, display on stdout instead of unicornhat. For debugging
     """
     if text:
         for x in range(max_x):
             for y in range(max_y):
                 coordinate_tuple = (x, y)
                 if LifeCell.matrix[coordinate_tuple].current_state == 'alive':
                     print '*',
                 else:
                     print '.',
             print
         print
     else:
         for x in range(max_x):
             for y in range(max_y):
                 coordinate_tuple = (x, y)
                 if LifeCell.matrix[coordinate_tuple].current_state == 'alive':
                     unicorn.set_pixel(x, y, r, g, b)
                 else:
                     unicorn.set_pixel(x, y, 0, 0, 0)
         unicorn.show()
开发者ID:SnakeNuts,项目名称:unicorn-hat-experiments,代码行数:26,代码来源:life.py


示例14: random_pixel

    def random_pixel(color_function):
        """ Generate a randomly positioned pixel with the color returned
        by color_function.

        Args:
            color_function (func): Should return a (R,G,B) color value.
        """
        color = color_function()

        def random_position():
            """ Get the position of a random pixel bound by
            function_pos. """
            x = randint(0, function_pos[load_sparkles])
            y = randint(0, (height-1))
            return (x,y)
        selected_pixel = random_position()

        ''' Aesthetic: If the randomly generated pixel is currently lit,
        turn it off and try with a new pixel. Also works as sort of a

        population control on how many pixels will be lit. '''
        while sum(unicorn.get_pixel(*selected_pixel)) > 0:
            unicorn.set_pixel(*(selected_pixel + (0, 0, 0)))
            selected_pixel = random_position()
        unicorn.set_pixel(*(selected_pixel + color))
        return
开发者ID:tusing,项目名称:unicorn_phat,代码行数:26,代码来源:functional_threaded.py


示例15: uni_show

def uni_show(prev_x, prev_y):
    a = np.random.rand(1)
    b = np.random.rand(1)
    c = np.random.rand(1)
    rgb_on  = colorsys.hsv_to_rgb(a, b, c)
    rgb_off = colorsys.hsv_to_rgb(0.5, 0.5, 0.1)

    r_on  = int(rgb_on[0]*255.0)
    g_on  = int(rgb_on[1]*255.0)
    b_on  = int(rgb_on[2]*255.0)

    r_off = int(rgb_off[0]*255.0)
    g_off = int(rgb_off[1]*255.0)
    b_off = int(rgb_off[2]*255.0)	

    a = np.random.rand(1)
    x = int(a[0] * 8)-1
    b = np.random.rand(1)	
    y = int(b[0] * 8)-1
    
    #print x, y
    
    if x < 0:
      x = 0
    if y < 0:
      y = 0

    unicorn.set_pixel(x, y, r_on, g_on, b_on)
    unicorn.set_pixel(prev_x, prev_y, r_off, g_off, b_off)

    unicorn.show()
    return x, y
开发者ID:ruanpienaar,项目名称:python,代码行数:32,代码来源:snake.py


示例16: load_rainbow

def load_rainbow(update_rate=5):
    """ A lightly modified version of Pimeroni's "rainbow" example.
    Displays a moving rainbow of colors that increases with load.

    Args:
        update_rate (float): How often to update the load value (seconds).
    """

    i = 0.0
    offset = 30
    function_values[load_fetcher] = 1
    threading.Thread(target=load_fetcher).start()
    while True:
        load_function = function_values[load_fetcher]/10 if function_values[load_fetcher] <= 10 else 10
        for w in range(int(update_rate/0.01)):
            i = i + load_function
            for y in range(height):
                for x in range(function_pos[load_rainbow] + 1):
                    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.0 + 128.0
                    g = (math.sin((x+i)/1.5) + math.sin((y+i)/2.0)) * 64.0 + 128.0
                    b = (math.sin((x+i)/2.0) + math.cos((y+i)/1.5)) * 64.0 + 128.0
                    r = max(0, min(255, r + offset))
                    g = max(0, min(255, g + offset))
                    b = max(0, min(255, b + offset))
                    unicorn.set_pixel(x,y,int(r),int(g),int(b))
            unicorn.show()
            time.sleep(0.01)
开发者ID:tusing,项目名称:unicorn_phat,代码行数:30,代码来源:functional_threaded.py


示例17: kick_rainbow

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()
开发者ID:jairly,项目名称:pimoroni_pHAT_python_scripts,代码行数:31,代码来源:kick_rainbow.py


示例18: initialize

def initialize():
        for i in range(8):
                unicorn.set_pixel(0,i, 255,255,255)
                unicorn.set_pixel(7,i, 255,255,255)        
                unicorn.show()
                sleep(0.1-i*float(0.01))

        ship_pos = [3,7]
        for i in range(2): 
                
                unicorn.set_pixel(ship_pos[0],ship_pos[1], ship[1], ship[2], ship[3])
                unicorn.show()
                sleep(0.2)
                unicorn.set_pixel(ship_pos[0],ship_pos[1], 0,0,0)
                unicorn.show()
                sleep(0.2)
        
        cell = [None,0,0,0] 
        temp_mat = []
        matrix = []
        for y in range(0,8):
                temp_mat.append(list(cell))
        for x in range(0,8):
                matrix.append(list(temp_mat))

        matrix[ship_pos[0]][ship_pos[1]] = ship
        print matrix
        unicorn.set_pixel(ship_pos[0],ship_pos[1], ship[1], ship[2], ship[3])
        unicorn.show()
        return matrix
开发者ID:carloartieri,项目名称:raspberry_pi,代码行数:30,代码来源:hyperspace.py


示例19: option_1

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()        
开发者ID:TeCoEd,项目名称:Unicorn-HAT-alphabet-disco,代码行数:25,代码来源:working+version+1.py


示例20: draw_dot

def draw_dot( x1, y1, r1, g1, b1, str1):
  "This draws the dot and outputs some text"
  UH.set_pixel(x1,y1,r1,g1,b1)
  UH.show()
  # print (str1 + str(x1) + ' ' + str(y1))
  time.sleep(0.1)
  return
开发者ID:ruanpienaar,项目名称:python,代码行数:7,代码来源:spiral.py



注:本文中的unicornhat.set_pixel函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python unicornhat.show函数代码示例发布时间:2022-05-27
下一篇:
Python unicornhat.rotation函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap