当前位置: 首页>>代码示例>>Python>>正文


Python SenseHat.set_rotation方法代码示例

本文整理汇总了Python中sense_hat.SenseHat.set_rotation方法的典型用法代码示例。如果您正苦于以下问题:Python SenseHat.set_rotation方法的具体用法?Python SenseHat.set_rotation怎么用?Python SenseHat.set_rotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sense_hat.SenseHat的用法示例。


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

示例1: Display

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
class Display(base_display.DisplayBase):

    """
    Control Raspberry Pi Sense Hat LED Matrix
    """

    def __init__(self):
        self.sense = SenseHat()
        self.defer = None

    def cb_show_text(self, *args, **kwargs):
        self.defer = None

    def show_text(self, text):
        self.show(text, None, None)
        
    def show(self, text, textcolor, bgcolor):
        if not textcolor:
            textcolor = (0xff,0xff,0xff)
        if not bgcolor:
            bgcolor = (0,0,0)
            
        if self.defer is None:
            self.sense.set_rotation(90, False)
            self.defer = threads.defer_to_thread(self.sense.show_message, text, text_colour=textcolor, back_colour=bgcolor)
            self.defer.addCallback(self.cb_show_text)
            self.defer.addErrback(self.cb_show_text)

    def clear(self):
        self.sense.clear()
开发者ID:f1soft,项目名称:calvin-base,代码行数:32,代码来源:display.py

示例2: main

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
def main():
    # Initialization stuff
    sense = SenseHat()
    sense.low_light = True
    # Display a random pixel matrix
    pixelValues = [ [ random.randint( 0, 255 ) for j in range( 3 ) ] for i in range( 64 ) ]
    sense.set_pixels( pixelValues )
    time.sleep( 3 )
    # Create a colour 'beat'
    for i in range( 3 ):
        sense.clear( 255, 0, 0 )
        time.sleep ( 0.333 )
        sense.clear( 0, 255, 0 )
        time.sleep ( 0.333 )
        sense.clear( 0, 0, 255 )
        time.sleep ( 0.333 )
    # Toy around with text display
    message = "Einfach Mensch..."
    sense.show_message( message, 0.05 )
    rotation = 0
    for letter in message:
        sense.set_rotation( rotation, False )
        rotation += 90
        if rotation == 270:
            rotation = 0
        sense.show_letter( letter )
        time.sleep( 0.24 )
    sense.clear()
开发者ID:markuspg,项目名称:SenseHatStuff,代码行数:30,代码来源:randomPixels.py

示例3: new_game

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
        def new_game():
            global sense, a, b, r, t, m, w, k, y, x, h
            print("new_game ")
    
            #Sense hat reset
            sense.stick.direction_up = None
            sense.stick.direction_down = None
            sense.stick.direction_right = None
            sense.stick.direction_left = None
            sense.stick.direction_middle = None
            
            sense = SenseHat()
            sense.set_rotation(180)
            sense.clear()

            #Sense hat reset func
            sense.set_pixels(imagemenu)
            r = randint(0,4)
            t = randint(0,7)
            m = randint(4,7)
            w = randint(0,7)
            k = randint(2,6)
            y = 0
            x = 0
            a, b = (3, 4)
            sense.stick.get_events()
开发者ID:Coding4Kids,项目名称:cidadeinteligente,代码行数:28,代码来源:FugaAosQuadrados.py

示例4: menu

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
        def menu():
            global sense, time1, time2, r, t, m, w, k, a, b, elapsed
            sense = SenseHat()
            
            sense.set_rotation(180)
            sense.clear()
            sense.set_pixels(imagemenu)
            
            sense.stick.get_events()
            while True:
                print (" new game1",a," ",b)
                y1 = sense.get_accelerometer_raw()['y']
                y1 = round(y1, 0)

                if y1 == -1:
                    sense.show_message("Highscore '%s'"% (h))
                    sense.set_pixels(imagemenu)
                for event in sense.stick.get_events():
                    if event.action == "pressed" and event.direction == "middle":
                        elapsed = timedelta(seconds=0)
                        sense.set_rotation(180)
                        sense.stick.direction_up = move_up
                        sense.stick.direction_down = move_down
                        sense.stick.direction_right = move_right
                        sense.stick.direction_left = move_left
                        x=0
                        y=0
                        time1 = datetime.now()
                        print(elapsed, " elapsed and e ", e)
                        while elapsed < e:
                            sense.clear()
                            draw_player()
                            test = draw_enemy(x, y)
                            print("menu nivel1 ",test)
                            if test == 1:
                                new_game()
                                break
                            sleep(0.25)
                            y = y+1
                            if y > 7:
                                r = randint(0,7)
                                t = randint(0,7)
                                m = randint(0,7)
                                y = 0
                            x = x+1
                            if x > 7:
                                w = randint(0,7)
                                k = randint(0,7)
                                x = 0
                        if elapsed > e:
                                sense.show_message("Next level", scroll_speed=0.05)
                                sense.set_pixels(imagesmile)
                                sleep(1)
                                level_2(x,y)
                                new_game()
                                break
                    if event.action == "pressed" and (event.direction == "up" or event.direction == "down" or event.direction == "left" or event.direction == "right"):
                        return
开发者ID:Coding4Kids,项目名称:cidadeinteligente,代码行数:60,代码来源:FugaAosQuadrados.py

示例5: sensors

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
def sensors():

    from sense_hat import SenseHat

    sense = SenseHat()

    tempC = sense.get_temperature()  # obtains temperature in Celsius from sensor
    tempC = round(tempC, 1)
    tempF = c_to_f(tempC)  # conversion from Celsius to Fahrenheit
    tempF = round(tempF, 1)

    print "\nThe temperature at the Sense Hat is", tempC, "C or", tempF, "F"

    humidity = sense.get_humidity()
    humidity = round(humidity, 1)

    print "The relative humidity at the Sense Hat is", humidity, "%"

    pressure = sense.get_pressure()
    pressure = round(pressure, 1)

    print "The atmospheric pressure at the Sense Hat is", pressure, "mbar\n"

    # outputing the temp, humidity, and pressure to the matrix
    sense.clear()  # clear the 8x8 matrix
    sense.set_rotation(0)  # sets orientation of Sense Hat matrix

    # setting colors for the scrolling text on the matrix
    red = (255, 0, 0)
    green = (0, 255, 0)
    blue = (0, 0, 255)

    speed = 0.02  # speed of text scroll (0.10 is default)
    sleep = 0.2  # time of pause in seconds

    sense.show_message("Temp:", text_colour=red, scroll_speed=speed)
    sense.show_message(str(tempC), text_colour=red, scroll_speed=speed)
    sense.show_message("C", text_colour=red, scroll_speed=speed)
    sense.show_message("or", text_colour=red, scroll_speed=speed)
    sense.show_message(str(tempF), text_colour=red, scroll_speed=speed)
    sense.show_message("F", text_colour=red, scroll_speed=speed)
    time.sleep(sleep)
    sense.show_message("Humidity:", text_colour=green, scroll_speed=speed)
    sense.show_message(str(humidity), text_colour=green, scroll_speed=speed)
    sense.show_message("%", text_colour=green, scroll_speed=speed)
    time.sleep(sleep)
    sense.show_message("Pressure:", text_colour=blue, scroll_speed=speed)
    sense.show_message(str(pressure), text_colour=blue, scroll_speed=speed)
    sense.show_message("mbar", text_colour=blue, scroll_speed=speed)

    sense.clear()
开发者ID:muku42,项目名称:initial-foray-into-raspberry-pi,代码行数:53,代码来源:sensor_plus_apollo_soyuz.py

示例6: show_tph

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
def show_tph():
    sense = SenseHat()
    t = 0
    h = 0
    p = 0
    while p < 1:
        p = sense.get_pressure()
        time.sleep(1)

    t = sense.get_temperature()
    h = sense.get_humidity()
    t = round(t, 1)
    p = round(p, 0)
    h = round(h, 0)

    msg = "P{0}H{1}".format(p,h)
    msg1 = "T{0}".format(t)

    sense.set_rotation(rotate_degree)
    sense.show_message(msg, text_colour=cadetblue)
    sense.show_message(msg1, text_colour=red)
开发者ID:ericosur,项目名称:ericosur-snippet,代码行数:23,代码来源:tph.py

示例7: Display

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
class Display(base_display.DisplayBase):

    """
    Control Raspberry Pi Sense Hat LED Matrix
    """

    def __init__(self):
        self.sense = SenseHat()
        self.defer = None

    def cb_show_text(self, *args, **kwargs):
        self.defer = None

    def show_text(self, text):
        if self.defer is None:
            self.sense.set_rotation(90, False)
            self.defer = threads.defer_to_thread(self.sense.show_message, text)
            self.defer.addCallback(self.cb_show_text)
            self.defer.addErrback(self.cb_show_text)

    def clear(self):
        self.sense.clear()
开发者ID:JvanDalfsen,项目名称:calvin-base,代码行数:24,代码来源:display.py

示例8: round

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
humidity = sense.get_humidity()
humidity = round(humidity, 1)

print "The relative humidity at the Sense Hat is", humidity, "%"

sense.clear()

pressure = sense.get_pressure()
pressure = round(pressure, 1)

print "The atmospheric pressure at the Sense Hat is", pressure, "mbar"

# outputing the temp, humidity, and pressure to the matrix

sense.clear()
sense.set_rotation(0) # sets orientation of Sense Hat matrix

# setting colors for the scrolling text on the matrix
red = (255, 0, 0)
green = (0, 255, 0)
blue = (0, 0, 255)

speed = (0.06) # speed of text scroll (0.10 is default)
sleep = (0.6) # time of break in seconds

sense.show_message("Temp:", text_colour=red, scroll_speed=speed)
sense.show_message(str(tempC), text_colour=red, scroll_speed=speed)
sense.show_message("C", text_colour=red, scroll_speed=speed)
sense.show_message("or", text_colour=red, scroll_speed=speed)
sense.show_message(str(tempF), text_colour=red, scroll_speed=speed)
sense.show_message("F", text_colour=red, scroll_speed=speed)
开发者ID:muku42,项目名称:initial-foray-into-raspberry-pi,代码行数:33,代码来源:sensor_samples.py

示例9: message

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
def message():
    sense = SenseHat()
    sense.set_rotation(180)
    color = tuple(map(ord, request.form['color'].decode('hex')))
    sense.show_message(request.form['message'], text_colour=color)
    return redirect(url_for('root'))
开发者ID:kuinak,项目名称:raspberry_pi,代码行数:8,代码来源:sense_hat_app.py

示例10:

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
e,e,y,b,b,y,e,e,
e,y,y,y,y,y,y,e
]


sense.set_pixels(image1)
time.sleep(2)
sense.set_pixels(image2)
time.sleep(2)
sense.set_pixels(image3)
time.sleep(2)
sense.set_pixels(image4)
time.sleep(2)
sense.set_pixels(image5)

sense.set_rotation(90)
time.sleep(0.5)
sense.set_rotation(180)
time.sleep(0.5)
sense.set_rotation(270)
time.sleep(0.5)
sense.set_rotation(180)
time.sleep(0.5)

sense.set_pixels(image4)
time.sleep(2)
sense.set_pixels(image3)
time.sleep(2)
sense.set_pixels(image2)
time.sleep(2)
sense.set_pixels(image1)
开发者ID:geomapping,项目名称:raspi-python,代码行数:33,代码来源:Sanduhr.py

示例11: print

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
from sense_hat import SenseHat
import os
import time
import pygame  # See http://www.pygame.org/docs
from pygame.locals import *


print("Press Escape to quit")
time.sleep(1)

pygame.init()
pygame.display.set_mode((640, 480))

sense = SenseHat()
sense.clear()  # Blank the LED matrix
sense.set_rotation(270)  # Flight orientation

# 0, 0 = Top left
# 7, 7 = Bottom right
UP_PIXELS = [[3, 0], [4, 0]]
DOWN_PIXELS = [[3, 7], [4, 7]]
LEFT_PIXELS = [[0, 3], [0, 4]]
RIGHT_PIXELS = [[7, 3], [7, 4]]
CENTRE_PIXELS = [[3, 3], [4, 3], [3, 4], [4, 4]]


def set_pixels(pixels, col):
    for p in pixels:
        sense.set_pixel(p[0], p[1], col[0], col[1], col[2])

开发者ID:raspberrypilearning,项目名称:3d-printed-astro-pi-flight-case,代码行数:31,代码来源:pygame_test.py

示例12: eoSerialCommunicator

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
forecast_bom_today = ""
forecast_bom_tomorrow = ""
forecast_file_today = ""
forecast_toggle = 0
global_init=True
readings = {}
# pywws data
if config.getboolean('Output','PYWWS_PUBLISH'):
	ds = DataStore.data_store(config.get('PYWWS','STORAGE'))
	dstatus = DataStore.status(config.get('PYWWS','STORAGE'))
if config.getboolean('Output','ADA_LCD'):
	AdaLcd.clear()
if config.getboolean('Output','SENSEHAT_DISPLAY'):
	# Set up display
	PiSenseHat.clear()
	PiSenseHat.set_rotation(config.get('SenseHat','ROTATION'))
if config.getboolean('Sensors','ENOCEAN'):
	eoCommunicator = eoSerialCommunicator(port=config.get('EnOcean','PORT'))
	eoCommunicator.start()
# Warm up sensors
print "Waiting for sensors to settle"
for i in range(1,6):
	Sample()
	time.sleep(1)
global_init=False
if config.getboolean('Sensors','FORECAST_BOM'):
	ForecastBoM()
if config.getboolean('Sensors','FORECAST_FILE'):
	ForecastFile()
Sample()
print "Scheduling events..."
开发者ID:cbarrac,项目名称:PiWeather,代码行数:33,代码来源:weather_event.py

示例13: SenseHat

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
#!/usr/bin/env python

from sense_hat import SenseHat
import time, datetime

hat = SenseHat()
hat.set_rotation(180)
year_color = (0, 255, 0)
month_color = (0, 0, 255)
day_color = (255, 0, 0)
hour_color = (0, 255, 0)
minute_color = (0, 0, 255)
second_color = (255, 0, 0)
hundrefths_color = (127, 127, 0)
off = (0, 0, 0)

hat.clear()

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)
		else:
			hat.set_pixel(x, row, off)

try:
    while True:
	t = datetime.datetime.now()
	display_binary(t.year % 100, 0, year_color)
	display_binary(t.month, 1, month_color)
开发者ID:wprebel,项目名称:RPiBinaryClock,代码行数:33,代码来源:binary_clock_sh.py

示例14: range

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
pixelOffset = 0
index = 0
for indexLoop in range(0, 4):
	for counterLoop in range(0, 4):
		if (hour >= 10):
			clockImage[index] = number[int(hour/10)*16+pixelOffset]
		clockImage[index+4] = number[int(hour%10)*16+pixelOffset]
		clockImage[index+32] = number[int(minute/10)*16+pixelOffset]
		clockImage[index+36] = number[int(minute%10)*16+pixelOffset]
		pixelOffset = pixelOffset + 1
		index = index + 1
	index = index + 4

# Colour the hours and minutes

for index in range(0, 64):
	if (clockImage[index]):
		if index < 32:
			clockImage[index] = hourColour
		else:
			clockImage[index] = minuteColour
	else:
		clockImage[index] = empty

# Display the time

sense.set_rotation(90) # Optional
sense.low_light = True # Optional
sense.set_pixels(clockImage)
开发者ID:SteveAmor,项目名称:Raspberry-Pi-Sense-Hat-Clock,代码行数:31,代码来源:clock.py

示例15: SenseHat

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import set_rotation [as 别名]
import pygame
import picamera
from pygame.locals import *
import sweaty_astronaut_framed as saf
import RPi.GPIO as GPIO

UP=26
DOWN=13
RIGHT=19
LEFT=20
A=16
B=21
GPIO.setmode(GPIO.BCM)

ap = SenseHat()
ap.set_rotation(270)

def button_pressed(button):
    #written by Richard
	global ap
	global pressed
	#print(button)
	pressed = 1
	
for pin in [UP, DOWN, LEFT, RIGHT, A, B]:
        
    GPIO.setup(pin, GPIO.IN, GPIO.PUD_UP)
    GPIO.add_event_detect(pin, GPIO.FALLING, callback=button_pressed, bouncetime=100)

# Logging code by Alfie
tmstmp = time.strftime("%Y%m%d-%H%M%S")
开发者ID:topshed,项目名称:SweatyAstronautCode,代码行数:33,代码来源:sweaty_astronaut_functions.py


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