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


Python AstroPi.get_accelerometer_raw方法代码示例

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


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

示例1: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import get_accelerometer_raw [as 别名]
# read all astro pi sensors
# a test to see how quick it is

from time import time, sleep
from astro_pi import AstroPi

ap = AstroPi()
ap.get_humidity()
ap.get_pressure()
ap.get_orientation()

while True:
    starttime = time()

    hum = ap.get_humidity()
    pres = ap.get_pressure()
    temp1 = ap.get_temperature_from_humidity()
    temp1 = ap.get_temperature_from_pressure()
    rads = ap.get_orientation_radians()
    degs = ap.get_orientation_degrees()
    rawcomp = ap.get_compass_raw()
    rawgyro = ap.get_gyroscope_raw()
    rawaccel = ap.get_accelerometer_raw()

    endtime = time()

    print(endtime - starttime)
    sleep(1)
开发者ID:astro-pi,项目名称:SpaceCRAFT,代码行数:30,代码来源:readsensors.py

示例2: print

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import get_accelerometer_raw [as 别名]
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:
      ap.set_pixels(arrow_green)
      score = score + 1
    elif y == -1 and angle == 90:
      ap.set_pixels(arrow_green)
开发者ID:LornaLynch,项目名称:getting-started-with-astro-pi,代码行数:33,代码来源:reaction_game.py

示例3: AstroPi

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

dataWriteInterval = 120                           # how often data is written to file (seconds)
dataDisplayInterval = 0.5                         # how often the displayed value is updated (seconds)

tmstmp = time.strftime("%Y%m%d-%H%M%S")           # Set timestamp format for the logging filename
logging.basicConfig(format='%(asctime)s %(message)s',filename='readings'+str(tmstmp)
+'.log',level=logging.DEBUG)                      # set up logging

hum_prev = 0                                      # set previous humidity and temp values to zero
temp_prev = 0
sec_count = 0

while True:                                       # Main program loop

	x, y, z = ap.get_accelerometer_raw().values() #Get raw accelerometer values and round them
	x = round(x, 0)
	y = round(y, 0)
	temp_f = ap.get_temperature()                 # Get temperature from astro-pi
	hum_f = ap.get_humidity()                     # Get humidity from astro-pi
	hum_int = int(hum_f)                          # convert to integers
	temp_int = int(temp_f)

	if (sec_count >= dataWriteInterval/dataDisplayInterval) or (sec_count == 0): 
		logging.info('humidity: ' + str(hum_f) + ' temperature: ' + str(temp_f))
		sec_count = 0

	if x == -1 and y != -1:                        # humidity display if HDMI port pointing upwards
		ap.set_rotation(270)
		if hum_int > hum_prev:                     # Is the latest reading higher than the last?
			r = [0,255,0]                          # green if higher
开发者ID:topshed,项目名称:HTLogger,代码行数:33,代码来源:HTLogger.py


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