本文整理汇总了Python中astro_pi.AstroPi类的典型用法代码示例。如果您正苦于以下问题:Python AstroPi类的具体用法?Python AstroPi怎么用?Python AstroPi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AstroPi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(
self, fb_device="/dev/fb1", imu_settings_file="RTIMULib", text_assets="astro_pi_text", sample_rate=0.01
):
self.sample_rate = sample_rate
AstroPi.__init__(self, fb_device, imu_settings_file, text_assets)
self._orientation = AstroPi.get_orientation(self)
# start the orientation thread
thread.start_new_thread(self._get_orientation_threaded, ())
示例2: _get_orientation_threaded
def _get_orientation_threaded(self):
"""
Internal. called in a thread to continuously read the astro pi data
"""
self.stopped = False
self.running = True
while not self.stopped:
self._orientation = AstroPi.get_orientation(self)
sleep(self.sample_rate)
self.running = False
示例3: AstroPi
#05/06/15
import pygame, random, datetime, math, os, time
from pygame.locals import *
from astro_pi import AstroPi
ap = AstroPi()
ap.clear()
pygame.init()
pygame.display.set_mode((640, 480))
#Handle the joystick input
def handle_event(event):
if event.key == pygame.K_DOWN:
return "DOWN"
elif event.key == pygame.K_UP:
return "UP"
elif event.key == pygame.K_LEFT:
return "LEFT"
elif event.key == pygame.K_RIGHT:
return "RIGHT"
elif event.key == pygame.K_RETURN:
return "RETURN"
示例4: print
Clears the mc astro pi
"""
self.ap.clear()
self.mcastropi.clear()
# run
if __name__ == "__main__":
print("SpaceCRAFT - Minecraft Interactive Astro Pi")
# create connection to minecraft
mc = Minecraft.create()
# create the astro pi object
ap = AstroPi()
# read data from the astro pi to initialise it
ap.get_orientation()
ap.get_humidity()
ap.get_pressure()
# find the players position and create the astro pi 10 blocks above them
pos = mc.player.getTilePos()
pos.y += 10
mcap = MCInteractiveAstroPi(mc, ap, pos)
try:
print("CTRL C to quit")
while True:
# each time a block is hit pass it to the interactive astro pi
for blockHit in mc.events.pollBlockHits():
示例5: AstroPi
from astro_pi import AstroPi
ap = AstroPi()
while True:
ap.show_message("Astro Pi is awesome!!",scroll_speed=0.05,text_colour=[255,255,0],back_colour=[0,0,255])
示例6: AstroPi
#testing the led matrix
from astro_pi import AstroPi
ap = AstroPi()
ap.clear()
#ap.show_message("Hello Space")
ap.set_pixel(0, 0, 255, 0, 0)
ap.set_pixel(7, 7, 255, 255, 255)
#ap.set_pixel(7, 7, 0, 0, 0)
ap.clear()
#ap.clear([0,0,255])
示例7: AstroPi
#!/usr/bin/python
import time
from astro_pi import AstroPi
ap = AstroPi()
r = 255
g = 0
b = 0
msleep = lambda x: time.sleep(x / 1000.0)
def next_colour():
global r
global g
global b
if (r == 255 and g < 255 and b == 0):
g += 1
if (g == 255 and r > 0 and b == 0):
r -= 1
if (g == 255 and b < 255 and r == 0):
b += 1
if (b == 255 and g > 0 and r == 0):
g -= 1
if (b == 255 and r < 255 and g == 0):
示例8: AstroPi
#!/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])
示例9: AstroPi
# Magic 8 Ball
import random
import time
from astro_pi import AstroPi
ap = AstroPi()
ap.show_message("Ask a question", scroll_speed=(0.06))
time.sleep(3)
replies = [
"Signs point to yes",
"Without a doubt",
"You may rely on it",
"Do not count on it",
"Looking good",
"Cannot predict now",
"It is decidedly so",
"Outlook not so good",
]
ap.show_message(random.choice(replies), scroll_speed=(0.06))
示例10: AstroPi
# 30/05/15
import pygame, random, datetime, time
from pygame.locals import *
from astro_pi import AstroPi
ap = AstroPi()
pygame.init()
pygame.display.set_mode((640, 480))
# Handle the joystick input
def handle_event(event):
if event.key == pygame.K_DOWN:
return "DOWN"
elif event.key == pygame.K_UP:
return "UP"
elif event.key == pygame.K_LEFT:
return "LEFT"
elif event.key == pygame.K_RIGHT:
return "RIGHT"
elif event.key == pygame.K_RETURN:
return "RETURN"
# Gets a joystick input with optional timeout
def joystick(timeout=-1):
示例11: AstroPi
from astro_pi import AstroPi
ap = AstroPi()
ap.set_pixel(2,2,[0,0,255])
ap.set_pixel(4,2,[0,0,255])
ap.set_pixel(3,4,[100,0,0])
ap.set_pixel(1,5,[255,0,0])
ap.set_pixel(2,6,[255,0,0])
ap.set_pixel(3,6,[255,0,0])
ap.set_pixel(4,6,[255,0,0])
ap.set_pixel(5,5,[255,0,0])
示例12: AstroPi
#!/usr/bin/python
from astro_pi import AstroPi
import time
ap = AstroPi()
temp = ap.get_temperature()
humidity = ap.get_humidity()
pressure = ap.get_pressure()
while True:
ap.set_rotation(180)
print("Temperature: %s C" % temp)
ap.show_message("Temperature: %.1f C" % temp, scroll_speed=0.1, text_colour$
time.sleep(1)
print("Humidity: %.2f %%rH" % humidity)
ap.show_message("Humidity: %.1f %%rH" % humidity, scroll_speed=0.1, text_co$
time.sleep(1)
print("Pressure: %.2f mb" % pressure)
ap.show_message("Pressure: %.1f mb" % pressure, scroll_speed=0.1, text_colo$
time.sleep(1)
ap.clear()
示例13: AstroPi
import pygame, random, datetime, time, math
import time as ti
from pygame.locals import *
from astro_pi import AstroPi
ap = AstroPi()
pygame.init()
pygame.display.set_mode((640, 480))
def handle_event(event):
if event.key == pygame.K_DOWN:
return "DOWN"
elif event.key == pygame.K_UP:
return "UP"
elif event.key == pygame.K_LEFT:
return "LEFT"
elif event.key == pygame.K_RIGHT:
return "RIGHT"
elif event.key == pygame.K_RETURN:
return "RETURN"
#Gets a joystick input with optional timeout
#This version of the of joystick checks the time regularaly which is less efficient
#But that allows for a higher degree of accuracy which was needed as the speed of
#The ball is relatively high
def joystick(timeout=-1):
示例14: AstroPi
#!/usr/bin/python
import time
from astro_pi import AstroPi
ap = AstroPi()
pixels = [
[255, 0, 0], [255, 0, 0], [255, 87, 0], [255, 196, 0], [205, 255, 0], [95, 255, 0], [0, 255, 13], [0, 255, 122],
[255, 0, 0], [255, 96, 0], [255, 205, 0], [196, 255, 0], [87, 255, 0], [0, 255, 22], [0, 255, 131], [0, 255, 240],
[255, 105, 0], [255, 214, 0], [187, 255, 0], [78, 255, 0], [0, 255, 30], [0, 255, 140], [0, 255, 248], [0, 152, 255],
[255, 223, 0], [178, 255, 0], [70, 255, 0], [0, 255, 40], [0, 255, 148], [0, 253, 255], [0, 144, 255], [0, 34, 255],
[170, 255, 0], [61, 255, 0], [0, 255, 48], [0, 255, 157], [0, 243, 255], [0, 134, 255], [0, 26, 255], [83, 0, 255],
[52, 255, 0], [0, 255, 57], [0, 255, 166], [0, 235, 255], [0, 126, 255], [0, 17, 255], [92, 0, 255], [201, 0, 255],
[0, 255, 66], [0, 255, 174], [0, 226, 255], [0, 117, 255], [0, 8, 255], [100, 0, 255], [210, 0, 255], [255, 0, 192],
[0, 255, 183], [0, 217, 255], [0, 109, 255], [0, 0, 255], [110, 0, 255], [218, 0, 255], [255, 0, 183], [255, 0, 74]
]
msleep = lambda x: time.sleep(x / 1000.0)
def next_colour(pix):
r = pix[0]
g = pix[1]
b = pix[2]
if (r == 255 and g < 255 and b == 0):
g += 1
if (g == 255 and r > 0 and b == 0):
r -= 1
示例15: AstroPi
from astro_pi import AstroPi
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