本文整理汇总了Python中sense_hat.SenseHat.low_light方法的典型用法代码示例。如果您正苦于以下问题:Python SenseHat.low_light方法的具体用法?Python SenseHat.low_light怎么用?Python SenseHat.low_light使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sense_hat.SenseHat
的用法示例。
在下文中一共展示了SenseHat.low_light方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
def main():
# Initialization stuff
sense = SenseHat()
sense.low_light = True
# Display a random pixel matrix
pixelValues = [ [ random.randint( 0, 255 ) for j in range( 3 ) ] for i in range( 64 ) ]
sense.set_pixels( pixelValues )
time.sleep( 3 )
# Create a colour 'beat'
for i in range( 3 ):
sense.clear( 255, 0, 0 )
time.sleep ( 0.333 )
sense.clear( 0, 255, 0 )
time.sleep ( 0.333 )
sense.clear( 0, 0, 255 )
time.sleep ( 0.333 )
# Toy around with text display
message = "Einfach Mensch..."
sense.show_message( message, 0.05 )
rotation = 0
for letter in message:
sense.set_rotation( rotation, False )
rotation += 90
if rotation == 270:
rotation = 0
sense.show_letter( letter )
time.sleep( 0.24 )
sense.clear()
示例2: main
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [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')
示例3: main
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
def main():
sense = SenseHat()
sense.low_light = True
print( "<---- ImageDisplay ---->\n" )
if len( sys.argv ) != 2:
print( "There must be exactly one argument, the path of the to be displayed image" )
return 0
else:
print( "Displaying \'{0}\'".format( sys.argv[ 1 ] ) )
onOffMatrix = senseSuppLib.LoadPixelStatusFromBIDF( sys.argv[ 1 ] )
senseSuppLib.UpdateScreen( [ 255, 255, 255 ], onOffMatrix, sense )
time.sleep( 3 )
sense.clear()
return 0
示例4: main
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
def main():
sense = SenseHat()
sense.low_light = True
print( "<---- SinusGraph ---->\n" )
pixelStatuses = [ [ 0, 0, 0 ] for i in range( 64 ) ]
for i in range( 150 ):
assert len( pixelStatuses ) == 64
del pixelStatuses[ : 8 ]
pixelStatuses.extend( [ [ 0, 0, 0 ] for i in range( 8 ) ] )
pixelStatuses[ 60 + round( cos( i / 1.5 ) * 3 ) ] = [ 0, 255, 0 ]
pixelStatuses[ 60 + round( sin( i / 2 ) * 3 ) ] = [ 255, 255, 255 ]
sense.set_pixels( pixelStatuses )
pixelStatuses = sense.get_pixels()
print( pixelStatuses )
sleep( 0.096 )
sense.clear()
示例5: Flask
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
wind_speed = 0.0
sunrise = datetime.now()
sunset = datetime.now()
temp_interior = 0.0
temp_interior_alt = 0.0
pressure_interior = 0.0
humidity_interior = 0.0
# initialisiere Flask server
app = Flask(__name__)
# initialisiere SenseHat-Erweiterung
sense = SenseHat()
sense.low_light = True
def get_location():
"""Ermittelt die Stadt zur eigenen IP-Adresse."""
url = "https://ipinfo.io/"
try:
r = requests.get(url)
except:
print("error while querying info...")
data = json.loads(r.text)
return data['city']
def get_weather_for_city(city):
"""Fragt das aktuelle Wetter bei openweathermap.org ab und gibt Temperatur,
示例6: SenseHat
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
from sense_hat import SenseHat
import random
import time
s = SenseHat()
screen = []
for i in range(64):
n = i * 4
screen.append((n,n,n))
while True:
s.set_pixels(screen)
s.low_light = not s.low_light
time.sleep(1)
示例7: range
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
pixelOffset = 0
index = 0
for indexLoop in range(0, 4):
for counterLoop in range(0, 4):
if (hour >= 10):
clockImage[index] = number[int(hour/10)*16+pixelOffset]
clockImage[index+4] = number[int(hour%10)*16+pixelOffset]
clockImage[index+32] = number[int(minute/10)*16+pixelOffset]
clockImage[index+36] = number[int(minute%10)*16+pixelOffset]
pixelOffset = pixelOffset + 1
index = index + 1
index = index + 4
# Colour the hours and minutes
for index in range(0, 64):
if (clockImage[index]):
if index < 32:
clockImage[index] = hourColour
else:
clockImage[index] = minuteColour
else:
clockImage[index] = empty
# Display the time
sense.set_rotation(90) # Optional
sense.low_light = True # Optional
sense.set_pixels(clockImage)
示例8: SenseHat
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
#!/usr/bin/python
import sys
import time
import datetime
import clock_digits
from sense_hat import SenseHat
sense = SenseHat() # create sense object
sense.set_rotation(180) # better when USB cable sticks out the top
sense.low_light = True # don't hurt my eyes
sense.clear() # always start with a clean slate
charWidth = 4
charHeight = 4
# returns the specified row of the digit
def digitrow(digit, row):
return digit[row * charWidth : (row * charWidth) + charWidth]
# main display routine
# takes a list of 4 digits and displays them on the LED-matrix
def display(digits):
if len(digits) > 4:
return
x = [0, 0, 0] # off
screen = [
x, x, x, x, x, x, x, x,
x, x, x, x, x, x, x, x,
x, x, x, x, x, x, x, x,
示例9: print
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
print("Time out of range, setting to default.")
t = [23, 8]
break
else:
t = [23, 8]
rotation = 0
#Setup the rotation if it was provided
if args.rotation:
rotation = int(((round(args.rotation[0]/90, 0) % 4) * 90))
sense = SenseHat()
#Set the LED matrix to bright if the argument was provided
if args.bright:
sense.low_light = False
else:
sense.low_light = True
groupings = generateNumberGroupings(numbers, 2, (5, 8), (5, 4))
now = datetime.now()
target = datetime.now()
#[time, [avgT, minT, maxT], [avgP, minP, maxP], [avgH, minH, maxH]]
metric = [0, [[20, 0, 0], [1000, 0, 0], [50, 0, 0]]]
while True:
data = []
#From t 0 to 59
for i in range(60):
start = datetime.now()
示例10: SenseHat
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
from sense_hat import SenseHat
sense = SenseHat()
sense.load_image("/home/pi/testit1/CoffeeCup.gif")
sense.low_light = False
示例11: main
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [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)
示例12: SenseHat
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
#!/usr/bin/python
import sys
import math
import colorsys
from random import randint
import time
from sys import exit
import pygame
from sense_hat import SenseHat
sense = SenseHat()
sense.low_light = False # Makes sure the SenseHat isn't in low light mode. This screws with the RGB values.
sense.clear() # Clear the SenseHat screen
''' -----------------------------
Spirit Level for Raspberry Pi
For use with the Sense Hat
And using the pygame library.
Remember to run with sudo: "sudo python3 spirit-level-plus.py"
DISCLAIMER:
I am not by any reach of the imagination a professional programmer.
My code is very messy and there are very likely much better ways to do this.
If you have any recommendations about how to clean up my code, or just any
questions in general, feel free to reach out to me via my github account at
https://github.com/dansushi/
Authored by Dan Schneider (2015), along with some
helpful coding techniques borrowed from
示例13: main
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [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)
示例14: SenseHat
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import low_light [as 别名]
from sense_hat import SenseHat
import time
s = SenseHat()
s.low_light = True
green = (0, 255, 0)
yellow = (255, 255, 0)
blue = (0, 0, 255)
red = (255, 0, 0)
white = (255,255,255)
nothing = (0,0,0)
pink = (255,105, 180)
def trinket_logo():
G = green
Y = yellow
B = blue
O = nothing
logo = [
O, O, O, O, O, O, O, O,
O, Y, Y, Y, B, G, O, O,
Y, Y, Y, Y, Y, B, G, O,
Y, Y, Y, Y, Y, B, G, O,
Y, Y, Y, Y, Y, B, G, O,
Y, Y, Y, Y, Y, B, G, O,
O, Y, Y, Y, B, G, O, O,
O, O, O, O, O, O, O, O,
]
return logo