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

Python unicornhat.brightness函数代码示例

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

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



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

示例1: 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


示例2: 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


示例3: 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


示例4: 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


示例5: __init__

 def __init__(self):
     self._logger = logging.getLogger(self.__class__.__name__)
     self._current_value = self.BLUE
     UH.brightness(1.0)
     pixels = self._set_whole_grid(self._current_value)
     UH.set_pixels(pixels)
     UH.show()
开发者ID:muppet3000,项目名称:rpi-eco-light,代码行数:7,代码来源:lighting.py


示例6: 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


示例7: __init__

  def __init__(self):
    self.prefs_file = "prefs.json"
    self.prefs = {}

    print("Clock online")
    self.__load_preferences()
    UH.brightness(self.prefs['brightness'])
    self.t = None
开发者ID:nmunro,项目名称:BinaryClock,代码行数:8,代码来源:clock.py


示例8: setBrightness

def setBrightness(currenttime):
  currenthour = currenttime.tm_hour
  # if it's between 10 am and 8 pm,
  # use dimmer brightness
  if(currenthour < 10 or currenthour > 20):
    unicorn.brightness(0.5)
  else:
    unicorn.brightness(1)
开发者ID:AndrewAlexMac,项目名称:unicorn-hat,代码行数:8,代码来源:clock.py


示例9: go

def go():
    UH.brightness(1)
    for y in range(8):
        for x in range(8):
            UH.set_pixel(x,y,255,0,0)
            UH.show()
            time.sleep(0.05)
    time.sleep(1)
开发者ID:Stimul8d,项目名称:SpeakyBuild,代码行数:8,代码来源:error.py


示例10: __init__

    def __init__(self, go_server, buildname):
        self.go_server = go_server
        self.buildname = buildname
        self.logger = logging.getLogger(__name__ + '.Monitor')

        self.logger.debug("Monitoring {0}".format(buildname))
        self.swirly = Swirly()
        UH.brightness(0.2)
        self.building_event = None
开发者ID:sneakybeaky,项目名称:pi-build-monitor,代码行数:9,代码来源:build_monitor.py


示例11: show_all_pixels

def show_all_pixels(r, g, b, brightness=0.5):
    unicornhat.brightness(brightness)

    grid = [
        [(r, g, b) for col in xrange(NUM_COLS)]
        for row in xrange(NUM_ROWS)
    ]

    unicornhat.set_pixels(grid)
    unicornhat.show()
开发者ID:harryjubb,项目名称:unicorn-hat-scripts,代码行数:10,代码来源:unicorntools.py


示例12: flashit

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)
开发者ID:tommybobbins,项目名称:ChristmasUnicornHat,代码行数:11,代码来源:matrix.py


示例13: showflagwhite

def showflagwhite():
	pixels = [[(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)],
	[(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)],
	[(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)],
	[(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)],
	[(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)],
	[(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)],
	[(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)],
	[(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)]]
	unicornhat.set_pixels(pixels)
	unicornhat.brightness(0.1)
	unicornhat.show()
开发者ID:AutodropNL,项目名称:pflag,代码行数:12,代码来源:pflag.py


示例14: showflagdoubleyellow

def showflagdoubleyellow():
	pixels = [[(255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0)],
	[(255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0)],
	[(255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0)],
	[(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)],
	[(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)],
	[(255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0)],
	[(255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0)],
	[(255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0), (255, 255, 0)]]
	unicornhat.set_pixels(pixels)
	unicornhat.brightness(0.1)
	unicornhat.show()
开发者ID:AutodropNL,项目名称:pflag,代码行数:12,代码来源:pflag.py


示例15: showflagblack

def showflagblack():
	pixels = [[(255, 255, 255), (255, 255, 255), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 255, 255), (255, 255, 255)],
	[(255, 255, 255), (255, 255, 255), (255, 255, 255), (0, 0, 0), (0, 0, 0), (255, 255, 255), (255, 255, 255), (255, 255, 255)],
	[(0, 0, 0), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (0, 0, 0)],
	[(0, 0, 0), (0, 0, 0), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (0, 0, 0), (0, 0, 0)],
	[(0, 0, 0), (0, 0, 0), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (0, 0, 0), (0, 0, 0)],
	[(0, 0, 0), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), (0, 0, 0)],
	[(255, 255, 255), (255, 255, 255), (255, 255, 255), (0, 0, 0), (0, 0, 0), (255, 255, 255), (255, 255, 255), (255, 255, 255)],
	[(255, 255, 255), (255, 255, 255), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 255, 255), (255, 255, 255)]]
	unicornhat.set_pixels(pixels)
	unicornhat.brightness(0.1)
	unicornhat.show()
开发者ID:AutodropNL,项目名称:pflag,代码行数:12,代码来源:pflag.py


示例16: showflagblue

def showflagblue():
	pixels = [[(132, 132, 0), (132, 132, 0), (0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132)],
	[(132, 132, 0), (132, 132, 0), (132, 132, 0), (0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132)],
	[(0, 0, 132), (132, 132, 0), (132, 132, 0), (132, 132, 0), (0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132)],
	[(0, 0, 132), (0, 0, 132), (132, 132, 0), (132, 132, 0), (132, 132, 0), (0, 0, 132), (0, 0, 132), (0, 0, 132)],
	[(0, 0, 132), (0, 0, 132), (0, 0, 132), (132, 132, 0), (132, 132, 0), (132, 132, 0), (0, 0, 132), (0, 0, 132)],
	[(0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132), (132, 132, 0), (132, 132, 0), (132, 132, 0), (0, 0, 132)],
	[(0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132), (132, 132, 0), (132, 132, 0), (132, 132, 0)],
	[(0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132), (0, 0, 132), (132, 132, 0), (132, 132, 0)]]
	unicornhat.set_pixels(pixels)
	unicornhat.brightness(0.1)
	unicornhat.show()
开发者ID:AutodropNL,项目名称:pflag,代码行数:12,代码来源:pflag.py


示例17: showflaggreen

def showflaggreen():
	pixels = [[(0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0)], 
	[(0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0)],
	[(0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0)],
	[(0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0)],
	[(0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0)],
	[(0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0)],
	[(0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0)],
	[(0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0), (0, 255, 0)]]
	unicornhat.set_pixels(pixels)
	unicornhat.brightness(0.1)
	unicornhat.show()
开发者ID:AutodropNL,项目名称:pflag,代码行数:12,代码来源:pflag.py


示例18: play

def play(xml_path, brightness=0.2, no_unicorns=False, verbose=False):
    """This script parses a TEI XML encoded play, and applies sentiment
    analysis to each speech. The result of the sentiment analysis is displayed
    on the Unicorn HAT - one pixel per speech - using a range of colours from
    red (negative sentiment) to blue (positive sentiment)."""
    unicorns = not no_unicorns

    if unicorns:
        uh.brightness(brightness)

    lines = _get_lines_from_xml(xml_path)

    for idx, line in enumerate(lines):
        _process_line(idx, line, unicorns, verbose)
开发者ID:ginestra,项目名称:sentiment-pi,代码行数:14,代码来源:play.py


示例19: change_color

def change_color(color):

    r = color['r']
    g = color['g']
    b = color['b']
    a = color['a']

    logger.debug("Setting to r:%d g:%d b:%d brightness:%.2f" % (r,g,b,a))

    unicorn.brightness(a)

    for y in range(8):
            for x in range(8):
                    unicorn.set_pixel(x,y,int(r),int(g),int(b))
                    unicorn.show()
开发者ID:rk295,项目名称:UnicornHue,代码行数:15,代码来源:color-changer.py


示例20: go

def go():    
    unicorn.brightness(1)
    t_end = time.time() + 10
    while time.time() < t_end:
        for z in list(range(1, 10)[::-1]) + list(range(1, 10)):
            fwhm = 5.0/z
            gauss = make_gaussian(fwhm)
            for y in range(8):
                for x in range(8):
                    h = 1.0/(x + y + 1)
                    s = 0.8
                    v = gauss[x,y]
                    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.005)
开发者ID:Stimul8d,项目名称:SpeakyBuild,代码行数:19,代码来源:bad.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python unicornhat.rotation函数代码示例发布时间:2022-05-27
下一篇:
Python ucd_3_2_0.category函数代码示例发布时间: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