當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。