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

Python unicornhat.rotation函数代码示例

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

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



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

示例1: show_letter

def show_letter(letter,colour,brightness): #displays a single letter on th UH
	UH.rotation(_scrollrotation)		
	for i in range(8):
		for j in range(8):
			if letter[j][i]:
				if colour == 'red':
					UH.set_pixel(j,flip[i],brightness,0,0)
				elif colour == 'green':
					UH.set_pixel(j,flip[i],0,brightness,0)
				elif colour == 'blue':
					UH.set_pixel(j,flip[i],0,0,brightness)
				elif colour == 'white':
					UH.set_pixel(j,flip[i],brightness,brightness,brightness)
				elif colour == 'pink':
					UH.set_pixel(j,flip[i],brightness,52,179)
				elif colour == 'cyan':
					UH.set_pixel(j,flip[i],0,brightness,brightness)
				elif colour == 'yellow':
					UH.set_pixel(j,flip[i],brightness,brightness,0)
				elif colour == 'orange':
					UH.set_pixel(j,flip[i],brightness,128,0)
			else:
				UH.set_pixel(j,flip[i],0,0,0)

	UH.show()
开发者ID:PinkFreud,项目名称:UnicornHatScroll,代码行数:25,代码来源:UHScroll.py


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


示例3: message

def message(message):
    unicorn.rotation(270)
    for _ in range(2):
        unicorn_scroll(message,'white',255,0.1)
    unicorn.clear()
    unicorn.show()
    return "ok"
开发者ID:dmatthams,项目名称:ifttpi,代码行数:7,代码来源:messenger.py


示例4: clearsystem

def clearsystem():
    led.clear()
    led.rotation(0)
    os.system("arp -d *")
    os.system("ip neigh flush all")
    led.show()
    return;
开发者ID:Conneckter,项目名称:PiPing,代码行数:7,代码来源:piping.py


示例5: icon

def icon(icon):
    unicorn.rotation(270)
    for _ in range(5):
        playIcon(icon)
    unicorn.clear()
    unicorn.show()
    return "ok"
开发者ID:dmatthams,项目名称:ifttpi,代码行数:7,代码来源:messenger.py


示例6: rotate

def rotate(): #Rotates image on AstroPi LED matrix
	global rotation
	if rotation == 270:
		rotation = 0
	else:
		rotation = rotation + 90
	#ap.set_rotation(rotation)
	uh.rotation(rotation)
开发者ID:rarshonsky,项目名称:RPi_8x8GridDraw,代码行数:8,代码来源:8x8grid-unicorn.py


示例7: show_letter_rgb

def show_letter_rgb(letter,r,g,b): #displays a single letter on th UH
	UH.rotation(270)		
	for i in range(8):
		for j in range(8):
			if letter[j][i]:
				
				UH.set_pixel(j,flip[i],r,g,b)
				
					
			else:
				UH.set_pixel(j,flip[i],0,0,0)

	UH.show()
开发者ID:xabertum,项目名称:UnicornHatScroll,代码行数:13,代码来源:UHScroll_custom_colors.py


示例8: range

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)
开发者ID:Naoto-Ida,项目名称:rave-unicorn,代码行数:19,代码来源:rave-unicorn.py


示例9: row

	's': [0x00, 0x00, 0x38, 0x40, 0x38, 0x04, 0x78, 0x00],
	't': [0x00, 0x10, 0x38, 0x10, 0x10, 0x10, 0x0c, 0x00],
	'u': [0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00],
	'v': [0x00, 0x00, 0x44, 0x44, 0x28, 0x28, 0x10, 0x00],
	'w': [0x00, 0x00, 0x44, 0x54, 0x54, 0x54, 0x28, 0x00],
	'x': [0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00],
	'y': [0x00, 0x00, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x38],
	'z': [0x00, 0x00, 0x7c, 0x08, 0x10, 0x20, 0x7c, 0x00],
	'{': [0x00, 0x0e, 0x08, 0x30, 0x08, 0x08, 0x0e, 0x00],
	'|': [0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00],
	'}': [0x00, 0x70, 0x10, 0x0c, 0x10, 0x10, 0x70, 0x00],
	'~': [0x00, 0x14, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00],
	'©': [0x3c, 0x42, 0x99, 0xa1, 0xa1, 0x99, 0x42, 0x3c]
}

unihat.rotation(180);

# a virtual framebuffer, which we'll copy to the unicorn hat.
# we're using a framebuffer of 24x8 pixels, which equates to eight rows of three bytes.
# we will only draw byte 1 of each row (row is byte 0, 1, 2) so that we use byte 0 and 2
# as "offscreen" drawing area. this gives us left/right shiftable screen area.
vfb = [
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00]
];
开发者ID:aphlor,项目名称:unicornhat-sidescroller,代码行数:31,代码来源:sidescroller.py


示例10: Buffer

import itertools

from twitterpibot.hardware.myhardware import is_linux
from twitterpibot.hardware.unicorn.canvas import Buffer
from twitterpibot.hardware.unicorn.myunicornhatmodes import *

if is_linux:
    import unicornhat

    unicornhat.rotation(270)
else:
    from twitterpibot.hardware.unicorn import unicornhat_viz as unicornhat

_buffer = Buffer(8, 8)

# TODO unicorn hat patterns

# Sin Wave
# Swipes
# graphic equalizer
# starfield

# bouncing ball/line

# snake
# game of life
# battleships
# chess/draughts

# strobe
# lifts?
开发者ID:andrewtatham,项目名称:twitterpibot,代码行数:31,代码来源:myunicornhat.py


示例11: set_rotation

 def set_rotation(self,rotation):
     unicornhat.rotation(rotation)
开发者ID:RobWC,项目名称:pyunicorn-ui,代码行数:2,代码来源:pyunicorn-ui.py


示例12:

            print 'The market is up', numfloat, 'percent.'
            print ""
       

#optional delay
#time.sleep(2)     
           
   #unicorn hat matrix color change based on market direction

    import unicornhat as unicorn
    from random import randint
    import time

    #tie LED brightness to change magnitude here
    unicorn.brightness(0.30)
    unicorn.rotation(90)

    #colors if market is up, down,or zero change
    if numfloat > 0:
        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,]]
    elif numfloat == 0:
        wrd_rgb = [[255, 20, 20], [245, 10, 10], [200, 0, 10], [162, 0, 0], [145, 0, 0], [96, 0, 0], [74, 0, 0], [0, 0, 0,]]
    else:     #maybe change this to rainbow sparkles
        wrd_rgb = [[255, 255, 154], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0,]]

    clock = 0

    blue_pilled_population = [[randint(0,7), 7]]
 
    #while True:
    timeout_start = time.time()
开发者ID:qfinger,项目名称:stockmarket-indicator,代码行数:31,代码来源:updwn.py


示例13: randrange

#!/usr/bin/env python3

import unicornhat as uh
import time
from random import randrange

uh.brightness(0.1)
uh.rotation(270)

while True:
    r = randrange(200, 255, 1)
    b = randrange(0, 200, 1)

    x = (r, 0, b)
    o = (0, 0, 0)

    heart = [
        [o, o, o, o, o, o, o, o],
        [o, x, x, o, o, x, x, o],
        [x, x, x, x, x, x, x, x],
        [x, x, x, x, x, x, x, x],
        [o, x, x, x, x, x, x, o],
        [o, o, x, x, x, x, o, o],
        [o, o, o, x, x, o, o, o],
        [o, o, o, o, o, o, o, o],
    ]

    uh.set_pixels(heart)
    uh.show()
    time.sleep(0.5)
开发者ID:bendo,项目名称:pi,代码行数:30,代码来源:heart.py


示例14: line

#!/usr/bin/python3
# my own attempt at displaying a clock. WIP

import unicornhat as u
import time, math

u.rotation(180)
u.brightness(0.5)

def line(x1, y1, x2, y2, color=(255, 255, 255)):
    x1 = int(x1)
    y1 = int(y1)
    x2 = int(x2)
    y2 = int(y2)

    dx = abs(x2 - x1)
    dy = abs(y2 - y1)
    sx = 1 if x1 < x2 else -1
    sy = 1 if y1 < y2 else -1
    err = dx - dy

    u.set_pixel(x1, y1, *color)
    while x1 != x2 or y1 != y2:
        e = 2 * err
        if e > -dy:
            err -= dy
            x1 += sx
        if e < dx:
            err += dx
            y1 += sy
        u.set_pixel(x1, y1, *color)
开发者ID:ClementGillard,项目名称:unicorn,代码行数:31,代码来源:clock.py


示例15: make_gaussian

#!/usr/bin/env python

import unicornhat as unicorn
import time, colorsys
import numpy as np

unicorn.set_layout(unicorn.AUTO)
unicorn.rotation(0)	# tested on pHAT/HAT with rotation 0, 90, 180 & 270
unicorn.brightness(0.4)
width,height=unicorn.get_shape()

if height==width:
    delta=0
else:
    delta=2


def make_gaussian(fwhm):
	x = np.arange(0, 8, 1, float)
	y = x[:, np.newaxis]
	x0, y0 = 3.5, 3.5
	fwhm = fwhm
	gauss = np.exp(-4 * np.log(2) * ((x - x0) ** 2 + (y - y0) ** 2) / fwhm ** 2)
	return gauss

while True:
	for z in list(range(1, 10)[::-1]) + list(range(1, 10)):
		fwhm = 5.0/z
		gauss = make_gaussian(fwhm)
                start = time.time()
		for y in range(height):
开发者ID:dglaude,项目名称:unicorn-hat-dg,代码行数:31,代码来源:rainbow_blinky.py


示例16: initialize

                else:
                        lpos += 1
        return lpos                   

if __name__ == '__main__':

        #Initialize curses
        stdscr = curses.initscr()
        curses.cbreak()
        curses.noecho()
        stdscr.nodelay(1)
        stdscr.keypad(1)

        #Initialize the Unicorn Hat
        unicorn.brightness(0.1)
        unicorn.rotation(180)

        ship = ['s',255,0,0]
        ship_pos = [3,7]
        matrix = initialize()
        
        #Global variables
        time = 0
        lpos = 0        #Position of lightspeed trails
        dodge_blue = 0  #How many blue asteroids dodged
        dodge_green = 0  #How many blue asteroids dodged

        while True:
                press = get_input(stdscr.getch()) #Get input
                #ship_pos = move_ship(ship_pos,press)        
                
开发者ID:carloartieri,项目名称:raspberry_pi,代码行数:30,代码来源:hyperspace.py


示例17: make_gaussian

#!/usr/bin/env python

import unicornhat as unicorn
import time, colorsys
import numpy as np

unicorn.brightness(0.5)
unicorn.rotation(270)

def make_gaussian(fwhm):
        x = np.arange(0, 8, 1, float)
        y = x[:, np.newaxis]
        x0, y0 = 3.5, 3.5
        fwhm = fwhm
        gauss = np.exp(-4 * np.log(2) * ((x - x0) ** 2 + (y - y0) ** 2) / fwhm ** 2)
        return gauss

heart = [[0,0,0,0,0,0,0,0],
         [0,1,1,0,0,1,1,0],
         [1,1,1,1,1,1,1,1],
         [1,1,1,1,1,1,1,1],
         [0,1,1,1,1,1,1,0],
         [0,0,1,1,1,1,0,0],
         [0,0,0,1,1,0,0,0],
         [0,0,0,0,0,0,0,0]]

heart = np.array(heart) * make_gaussian(7.5)

while True:
	for i in 2*(range(1,11)[::-1]+range(1,10)):
		for y in range(8):
开发者ID:sandyjmacdonald,项目名称:unicorn-hat,代码行数:31,代码来源:heartbeat.py


示例18: showColour

        index += 1
        if index >= maxPixels:
            #print index, maxPixels
            pixels = pixels[:maxPixels-1]    #trim the list as we've maxed out
            break
    UH.show()

#show all pixels one colour
def showColour(c):
    for coords in pattern:
        UH.set_pixel(coords[0], coords[1], c[0], c[1], c[2])
    UH.show()
                  
#main program

UH.rotation(180)
UH.brightness(0.4)

#process the currently available list of colours
data = getJSON("feed.json")
if mode != 2 and len(data) > 0:
    for feedItem in data["feeds"]:
        parseColour(feedItem)
    showPixels()

#check for new colour requests
while True:
    data = getJSON("field/1/last.json")
    
    if getEntryID(data) > lastID:   #Has this entry_id been processed before?
        parseColour(data)
开发者ID:ForToffee,项目名称:UnicornHAT,代码行数:31,代码来源:cheertree.py


示例19: setup

#!/usr/bin/env python

import unicornhat as uh
import time
from random import randint

uh.rotation(0)
heights = []


def setup():

    global heights
    heights = []
    for b in range(0, 6):
        heights.append(0)
    uh.off()
    for b in range(0, 8):
        uh.set_pixel(0, b, 255, 255, 255)
    for b in range(0, 8):
        uh.set_pixel(7, b, 255, 255, 255)
    for b in range(1, 7):
        uh.set_pixel(b, 0, 255, 255, 255)
    uh.show()


def drop_ball():

    ball_colour = [randint(100, 255), randint(100, 255), randint(100, 255)]
    ball_column = randint(0, 5)
开发者ID:AndrewAlexMac,项目名称:unicorn-hat,代码行数:30,代码来源:drop.py


示例20: exit

    import numpy as np
except ImportError:
    exit("This script requires the numpy module\nInstall with: sudo pip install numpy")

import unicornhat as unicorn

print("""Random Blinky

Blinks random yellow-orange-red LEDs.

If you're using a Unicorn HAT and only half the screen lights up, 
edit this example and  change 'unicorn.AUTO' to 'unicorn.HAT' below.
""")

unicorn.set_layout(unicorn.AUTO)
unicorn.rotation(0)
unicorn.brightness(0.4)
width,height=unicorn.get_shape()


while True:
    rand_mat = np.random.rand(width,height)
    for y in range(height):
        for x in range(width):
            h = 0.1 * rand_mat[x, y]
            s = 0.8
            v = rand_mat[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)
开发者ID:Gadgetoid,项目名称:unicorn-hat,代码行数:31,代码来源:random_blinky.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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