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


Python AstroPi.set_rotation方法代码示例

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


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

示例1: AstroPi

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

ap = AstroPi()
ap.set_rotation(180)
ap.show_message("One small step for Pi!", text_colour=[255, 0, 0])
开发者ID:New380,项目名称:astro-pi-hat,代码行数:8,代码来源:text_scroll.py

示例2: orient_message

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import set_rotation [as 别名]
    orient_message("Shake Me")

    while shake_check() == False:
        time.sleep(0.1)

    play = True
    score = 0
    lives = 3

    pause = 2.5
    while play == True:
        last_arrow = arrow
        while arrow == last_arrow:
          arrow = random.choice([0,90,180,270])

        ap.set_rotation(arrow)
 
        num = random.random()
        if num > 0.1:
            plot_image(shake_img,w,bl)
            time.sleep(pause)
            if shake_check():
                plot_image(shake_img,g,bl)
                score = score + 1
            else:
                plot_image(shake_img,r,bl)
                lives = lives -1
        elif num > 0.9 and ap.get_humidity()<60:
            hum = ap.get_humidity()
            plot_image(breath_img,w,bl)
            time.sleep(pause)
开发者ID:gbaman,项目名称:getting-started-with-astro-pi,代码行数:33,代码来源:reaction_game_v2.py

示例3: print

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import set_rotation [as 别名]
e,e,e,g,g,e,e,e,
e,e,e,g,g,e,e,e
]

pause = 3
score = 0
angle = 0
play = True

ap.show_message("Keep the arrow pointing up",scroll_speed=0.05,text_colour=[100,100,100])

while play == True:
    last_angle = angle
    while angle == last_angle:
      angle = random.choice([0,90,180,270])
    ap.set_rotation(angle)
    ap.set_pixels(arrow)
    time.sleep(pause)

    x,y,z = ap.get_accelerometer_raw().values()
    x=round(x,0)
    y=round(y,0)

    print (angle)
    print (x)
    print (y)

    if x == -1 and angle == 180:
      ap.set_pixels(arrow_green)
      score = score + 1
    elif x == 1 and angle == 0:
开发者ID:LornaLynch,项目名称:getting-started-with-astro-pi,代码行数:33,代码来源:reaction_game.py

示例4: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import set_rotation [as 别名]
from astro_pi import AstroPi
ap = AstroPi()
import time

ap.show_letter("J")

while True:
  x,y,z = ap.get_accelerometer_raw().values()

  x=round(x,0)
  y=round(y,0)

  if x == -1:
      ap.set_rotation(180)
  elif y == 1:
      ap.set_rotation(90)
  elif y == -1:
      ap.set_rotation(270)
  else:
      ap.set_rotation(0)

  time.sleep(0.1)
开发者ID:LornaLynch,项目名称:getting-started-with-astro-pi,代码行数:24,代码来源:rotating_letter.py

示例5: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi 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 = AstroPi()
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:astro-pi,项目名称:SweatyAstronautCode,代码行数:33,代码来源:sweaty_astronaut_functions.py

示例6: AstroPi

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

ap = AstroPi()
temp = ap.get_temperature()
humidity = ap.get_humidity()
pressure = ap.get_pressure()


print("Temperature: %s C" % temp)               # Show temp on console
print("Humidity: %s %%rH" % humidity)        # Show humidity on console
print("Pressure: %s Millibars" % pressure)    # Show pressure on console

ap.set_rotation(180)        # Set LED matrix to scroll from right to left
              
ap.show_message("Temperature: %.2f C" % temp, scroll_speed=0.05, text_colour=[0, 255, 0])

time.sleep(1)           # Wait 1 second

ap.show_message("Humidity: %.2f %%rH" % humidity, scroll_speed=0.05, text_colour=[255, 0, 0]) 

time.sleep(1)      # Wait 1 second

ap.show_message("Pressure: %.2f Millibars" % humidity, scroll_speed=0.05, text_colour=[0, 0, 255])

ap.clear()      # Clear LED matrix
开发者ID:ontheplains,项目名称:Raspberry-Pi-Code,代码行数:29,代码来源:astroPi.py

示例7: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import set_rotation [as 别名]
from astro_pi import AstroPi
import time

ap = AstroPi()

ap.show_letter("J")

for r in (0,90,180,270,0,90,180,270):
    ap.set_rotation(r)
    time.sleep(0.5)
开发者ID:LornaLynch,项目名称:getting-started-with-astro-pi,代码行数:12,代码来源:spinning_j.py

示例8: AstroPi

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

# To get good results with the magnetometer you must first calibrate it using
# the program in RTIMULib/Linux/RTIMULibCal
# The calibration program will produce the file RTIMULib.ini
# Copy it into the same folder as your Python code

led_loop = [4, 5, 6, 7, 15, 23, 31, 39, 47, 55, 63, 62, 61, 60, 59, 58, 57, 56, 48, 40, 32, 24, 16, 8, 0, 1, 2, 3]

ap = AstroPi()
ap.set_rotation(0)
ap.clear()

prev_x = 0
prev_y = 0

led_degree_ratio = len(led_loop) / 360.0

while True:
    dir = ap.get_compass()
    dir_inverted = 360 - dir  # So LED appears to follow North
    led_index = int(led_degree_ratio * dir_inverted)
    offset = led_loop[led_index]

    y = offset // 8  # row
    x = offset % 8  # column

    if x != prev_x or y != prev_y:
        ap.set_pixel(prev_x, prev_y, 0, 0, 0)
开发者ID:New380,项目名称:astro-pi-hat,代码行数:33,代码来源:compass.py


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