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


Python SenseHat.rotation方法代码示例

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


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

示例1: main

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

	#initialize Pygame which handles joystick inputs on SenseHat
	pygame.init()
	pygame.display.set_mode((640, 480))

	subprocess.call(["mpc","clear"])
	subprocess.call(["mpc","load","playlist1"])
	subprocess.call(["mpc","enable","1"])


	# SenseHat initialization and configuration
	sense = SenseHat()
	sense.low_light = True
	sense.rotation = 90

	#initialize last weather update time
	last_update_time = 0

	#Main loop

	while True:  

		#Handle Senshat Joystick inputs
		for event in pygame.event.get():
			#if event.type == KEYDOWN:
				#radio_commands(event)
				#print('DN')
			if event.type == KEYUP:
				radio_commands(event)
				print('SenseHat Input')
开发者ID:amonsain,项目名称:Raspberry,代码行数:33,代码来源:SenseRadio.py

示例2: menu

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import rotation [as 别名]
        return minecraftOP
    
anotherGo = True

while anotherGo:
    choice = menu()

    if choice == 1:
        temp = sense.get_temperature()
        print("Temperature: %s C" % temp)

    elif choice == 2:
        degreesMenu()
        degrees = degreesMenu()
        if degrees == 1:
            sense.rotation = 90
            degreesMenu()

        elif degrees == 2:
            sense.rotation = 180
            degreesMenu()

        elif degrees == 3:
            sense.rotation = 270
            degreesMenu()

        elif degrees == 4:
            menu()

    if choice == 3:
        minecraftMenu()
开发者ID:AungWinnHtut,项目名称:Minecraft-Pi--Sense-Hat-Projects,代码行数:33,代码来源:hat_API.py

示例3: SenseHat

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import rotation [as 别名]
from sense_hat import SenseHat
from time import sleep
import icon_mapper
import os
import sys

sense = SenseHat()
sense.clear()
sense.rotation = 180

import json
import requests

try:
  forecast_key = os.environ['FORECAST_KEY']
except KeyError as e:
  print 'FORECAST_KEY not set'
  sys.exit(1)

latitude = os.getenv('FORECAST_LATITUDE', 53.4667)
longitude = os.getenv('FORECAST_LONGITUDE', -2.2333)

url = 'https://api.darksky.net/forecast/%s/%s,%s' % (forecast_key, latitude, longitude)

while True:
  response = requests.get(url)

  if(response.ok):
    jData = json.loads(response.content)

    current = jData['currently']['icon']
开发者ID:foxy1982,项目名称:RaspberryPi,代码行数:33,代码来源:main.py

示例4: main

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

	sense = SenseHat()
	sense.low_light = True
	last_update_time = 0
	sense.rotation = 90

	SunPictos = [1,2,3,4,5,6,13,14,15]
	SunCloudPictos = [7,8,9,10,11,12,31,32]
	CloudPictos = [16,17,18,19,20,21,22,23]
	RainPictos = [23,25,33,35]
	SnowPictos = [24,26,29,34]
	StormPictos = [27,28,30]

	while True:  

		# Fetch weather data every update period
		if time.time()-last_update_time > update_period*60:
			Weather = get_weather(url)
			last_update_time = time.time()
			Baro = get_press(AltitudeAboveSeaLevel)
			Humidity = sense.get_humidity()
			print('Current, Max, Min temp, Picto:',Weather.CurrentTemp,Weather.ForecastMaxTemp,Weather.ForecastMinTemp,Weather.Picto)
			print('Weather info updated at:', strftime("%a, %d %b %Y %H:%M:%S", localtime()))
			print('Local Pressure',Baro)


 
		# display Time & Weather info on SenseHat

		if ShowTime:
			sense.show_message('{} {}'.format('Heure:',strftime("%H:%M",localtime())),text_colour=(180,180,180))

		if ShowTemperature:
			sense.show_message('{} {}{}'.format('T:', str(Weather.CurrentTemp),' '), text_colour=Weather.CurrentColor,scroll_speed=0.15)
			sense.show_message('{} {}'.format('Max:', str(Weather.ForecastMaxTemp)), text_colour=Weather.MaxColor,scroll_speed=0.15)
			sense.show_message('{} {}'.format('Min:', str(Weather.ForecastMinTemp)), text_colour=Weather.MinColor,scroll_speed=0.15)

		if ShowWeatherPicto:

			if Weather.Picto in SunPictos:
				for i in range (0,10):
					sense.load_image("/home/pi/SenseHat/WeatherMonitor/Images/soleil.png")
					time.sleep(0.3)
					sense.load_image("/home/pi/SenseHat/WeatherMonitor/Images/soleil2.png")
					time.sleep(0.3)
			elif Weather.Picto in SunCloudPictos:
				sense.load_image("/home/pi/SenseHat/WeatherMonitor/Images/soleil&nuage.png")
				time.sleep(5)
			elif Weather.Picto in CloudPictos:
				sense.load_image("/home/pi/SenseHat/WeatherMonitor/Images/nuage.png")
				time.sleep(5)
			elif Weather.Picto in RainPictos:
				sense.load_image("/home/pi/SenseHat/WeatherMonitor/Images/nuage&pluie.png")
				time.sleep(5)
			elif Weather.Picto in SnowPictos:
				sense.load_image("/home/pi/SenseHat/WeatherMonitor/Images/nuage&neige.png")
				time.sleep(5)
			elif Weather.Picto in StormPictos:
				sense.load_image("/home/pi/SenseHat/WeatherMonitor/Images/nuages&eclairs.png")
				time.sleep(5)												
		
		if ShowPressure:
			sense.show_message('{} {}'.format(format(Baro, '.1f'),'hPa'), text_colour=Weather.CurrentColor,scroll_speed=0.15)
			#print(format(Baro, '.1f'),'hPa')

		if ShowHumidity:
			sense.show_message('{} {} {}'.format(format(Humidity, '.1f'),'%','Hum.'), text_colour=Weather.CurrentColor,scroll_speed=0.15)
			#print(format(Humidity, '.1f'),'%','Hum.')


		time.sleep(1)
开发者ID:amonsain,项目名称:Raspberry,代码行数:74,代码来源:WeatherStation.py

示例5: main

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

	#parameters
	last_update_time = 0



	#Initialize Sense Hat

	sense = SenseHat()
	sense.low_light = True
	sense.rotation = 90

	#Initialize Google Calendar

	credentials = get_credentials()
	http = credentials.authorize(httplib2.Http())
	service = discovery.build('calendar', 'v3', http=http)


		# Main Loop

	while True:  

		# Fetch weather & calendar data every update period
		if time.time()-last_update_time > update_period*60:
			Weather = get_weather(url)
			last_update_time = time.time()
			Baro = get_press(AltitudeAboveSeaLevel)
			Humidity = sense.get_humidity()
			print('Current, Max, Min temp:',Weather.CurrentTemp,Weather.ForecastMaxTemp,Weather.ForecastMinTemp)
			print('Weather info updated at:', strftime("%a, %d %b %Y %H:%M:%S", localtime()))
			print('Local Pressure',Baro)

			now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
			print('Getting the upcoming 10 events')
			eventsResult = service.events().list(
				calendarId='primary', timeMin='2011-06-03T10:00:00-07:00', maxResults=2, singleEvents=True,
				orderBy='startTime').execute()
			events = eventsResult.get('items', [])

			print(events)

			if not events:
				print('No upcoming events found.')
			for event in events:
				start = event['start'].get('dateTime', event['start'].get('date'))
				print(start, event['summary'])




		# Fetch Calendar data

		
 
		# display Weather info on SenseHat
		for event in events:
			eventtime=dateutil.parser.parse(event['start'].get('dateTime'))
			print(eventtime.strftime('%I:%M'))
			sense.show_message(eventtime.strftime('%I:%M'))
			sense.show_message(event['summary'])

		# if ShowTemperature:
		# 	sense.show_message('{} {}{}'.format('T:', str(Weather.CurrentTemp),' '), text_colour=Weather.CurrentColor,scroll_speed=0.15)
		# 	sense.show_message('{} {}'.format('Max:', str(Weather.ForecastMaxTemp)), text_colour=Weather.MaxColor,scroll_speed=0.15)
		# 	sense.show_message('{} {}'.format('Min:', str(Weather.ForecastMinTemp)), text_colour=Weather.MinColor,scroll_speed=0.15)
		
		# if ShowTime:
		# 	sense.show_message('{} {}'.format('Heure:',strftime("%H:%M",localtime())))

		# if ShowWeatherPicto:

		# 	if Weather.Picto > 0:
		# 		sense.load_image("Soleil.png")
		# 		time.sleep(3)
		
		# if ShowPressure:
		# 	sense.show_message('{} {}'.format(format(Baro, '.1f'),'hPa'), text_colour=Weather.CurrentColor,scroll_speed=0.15)
		# 	#print(format(Baro, '.1f'),'hPa')

		# if ShowHumidity:
		# 	sense.show_message('{} {} {}'.format(format(Humidity, '.1f'),'%','Hum.'), text_colour=Weather.CurrentColor,scroll_speed=0.15)
		# 	#print(format(Humidity, '.1f'),'%','Hum.')


		time.sleep(1)
开发者ID:amonsain,项目名称:Raspberry,代码行数:89,代码来源:WeatherCalendarStation.py

示例6: show_frame

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import rotation [as 别名]
        [255, 255, 0],
        [255, 255, 0],
        [255, 255, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [255, 255, 0],
        [255, 255, 0],
        [255, 255, 0],
        [255, 255, 0],
        [0, 0, 0],
        [0, 0, 0],
    ]
]

sh.rotation = 180


def show_frame():
    for x in FRAMES:
        sh.set_pixels(x)
        time.sleep(0.5)


def main():
    try:
        while True:
            show_frame()
    except (KeyboardInterrupt, SystemExit):
        sys.exit()
开发者ID:emawind84,项目名称:sensehat-discotest,代码行数:32,代码来源:ciao.py

示例7: SenseHat

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import rotation [as 别名]
from sense_hat import SenseHat
from time import sleep

sense = SenseHat()
sense.set_imu_config(True, True, True)
sense.rotation = 270

while True:
    try:
        temp = sense.get_temperature_from_humidity()
        humidity = sense.get_humidity()
        print("Humidity: %s %%rH" % humidity)
     #   orientation = sense.get_orientation_degrees()
     #   print("p: {pitch}, r: {roll}, y: {yaw}".format(**orientation))     
       # print(sense.accelerometer_raw)
       # print(sense.gyroscope_raw)
       # print(sense.compass_raw)        
        sense.show_message(str(round(temp, 2)), text_colour=[0, 255, 224])
       # sleep()
    except KeyboardInterrupt:
        sense.clear()
        break
开发者ID:mpawlowski7,项目名称:QtSenseHatFun,代码行数:24,代码来源:sense_hat_testr.py


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