本文整理汇总了Python中sense_hat.SenseHat方法的典型用法代码示例。如果您正苦于以下问题:Python sense_hat.SenseHat方法的具体用法?Python sense_hat.SenseHat怎么用?Python sense_hat.SenseHat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sense_hat
的用法示例。
在下文中一共展示了sense_hat.SenseHat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: old
# 需要导入模块: import sense_hat [as 别名]
# 或者: from sense_hat import SenseHat [as 别名]
def old():
sense = SenseHat()
sense.clear()
acceleration = sense.get_accelerometer_raw()
celsius = round(sense.get_temperature(), 1)
kwargs = dict(
celsius = celsius,
fahrenheit = round(1.8 * celsius + 32, 1),
humidity = round(sense.get_humidity(), 1),
pressure = round(sense.get_pressure(), 1),
x = round(acceleration['x'], 2),
y = round(acceleration['y'], 2),
z = round(acceleration['z'], 2),
)
aqi = get_gov_aqi()
dark_sky = get_dark_sky()
return render_template('weather_old.html', **kwargs, aqi=aqi, dark_sky=dark_sky)
示例2: __init__
# 需要导入模块: import sense_hat [as 别名]
# 或者: from sense_hat import SenseHat [as 别名]
def __init__(self):
self.s = SenseHat()
self.s.low_light = True
self.__displayImage(self.__raspberry())#Flash the raspberry pi logo at initialization
time.sleep(1)
self.s.clear()
示例3: __init__
# 需要导入模块: import sense_hat [as 别名]
# 或者: from sense_hat import SenseHat [as 别名]
def __init__(self):
self.s = SenseHat()
self.s.low_light = True
# Flash the raspberry pi logo at initialization
self.__displayImage(self.__raspberry())
time.sleep(1)
self.s.clear()
示例4: get_sensor_data
# 需要导入模块: import sense_hat [as 别名]
# 或者: from sense_hat import SenseHat [as 别名]
def get_sensor_data():
"""Get sensor data from SenseHAT"""
sense = SenseHat()
sense.clear()
celsius = round(sense.get_temperature(), 1)
fahrenheit = round(1.8 * celsius + 32, 1)
humidity = round(sense.get_humidity(), 1)
pressure = round(sense.get_pressure(), 1)
try:
dewpoint = (round(243.04 * (log(humidity / 100)
+ ((17.625 * celsius) / (243.04 + celsius))) / (17.625 - log(humidity / 100)
- (17.625 * celsius) / (243.04 + celsius)), 1))
except:
dewpoint = 'broken'
return [celsius, fahrenheit, humidity, pressure, dewpoint]
示例5: get_sensor_data
# 需要导入模块: import sense_hat [as 别名]
# 或者: from sense_hat import SenseHat [as 别名]
def get_sensor_data():
"""Get sensor data from SenseHAT"""
sense = SenseHat()
sense.clear()
celsius = round(sense.get_temperature(), 1)
fahrenheit = round(1.8 * celsius + 32, 1)
humidity = round(sense.get_humidity(), 1)
pressure = round(sense.get_pressure(), 1)
dewpoint = (round(243.04 * (log(humidity / 100)
+ ((17.625 * celsius) / (243.04 + celsius))) / (17.625 - log(humidity / 100)
- (17.625 * celsius) / (243.04 + celsius)), 1))
return [celsius, fahrenheit, humidity, pressure, dewpoint]
示例6: get_sensehat
# 需要导入模块: import sense_hat [as 别名]
# 或者: from sense_hat import SenseHat [as 别名]
def get_sensehat():
global _sensehat
if not _sensehat :
_sensehat = sense_hat.SenseHat()
return _sensehat
示例7: main
# 需要导入模块: import sense_hat [as 别名]
# 或者: from sense_hat import SenseHat [as 别名]
def main():
global sense, wu_station_id, wu_station_key
# Setup the basic console logger
format_str = '%(asctime)s %(levelname)s %(message)s'
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(format=format_str, level=logging.INFO, datefmt=date_format)
# When debugging, uncomment the following two lines
# logger = logging.getLogger()
# logger.setLevel(logging.DEBUG)
print('\n' + HASHES)
print(SINGLE_HASH, 'Pi Weather Station (Sense HAT) ', SINGLE_HASH)
print(SINGLE_HASH, 'By John M. Wargo (https://johnwargo.com)', SINGLE_HASH)
print(HASHES)
# make sure we don't have a MEASUREMENT_INTERVAL > 60
if (MEASUREMENT_INTERVAL is None) or (MEASUREMENT_INTERVAL > 60):
logging.info("The application's 'MEASUREMENT_INTERVAL' cannot be empty or greater than 60")
sys.exit(1)
# ============================================================================
# Read Weather Underground Configuration
# ============================================================================
logging.info('Initializing Weather Underground configuration')
wu_station_id = Config.STATION_ID
wu_station_key = Config.STATION_KEY
if (wu_station_id is None) or (wu_station_key is None):
logging.info('Missing values from the Weather Underground configuration file')
sys.exit(1)
# we made it this far, so it must have worked...
logging.info('Successfully read Weather Underground configuration')
logging.info('Station ID: {}'.format(wu_station_id))
logging.debug('Station key: {}'.format(wu_station_key))
# ============================================================================
# initialize the Sense HAT object
# ============================================================================
try:
logging.info('Initializing the Sense HAT client')
sense = SenseHat()
# sense.set_rotation(180)
# then write some text to the Sense HAT
sense.show_message('Init', text_colour=[255, 255, 0], back_colour=[0, 0, 255])
# clear the screen
sense.clear()
except:
logging.info('Unable to initialize the Sense HAT library')
logging.error('Exception type: {}'.format(type(e)))
logging.error('Error: {}'.format(sys.exc_info()[0]))
traceback.print_exc(file=sys.stdout)
sys.exit(1)
logging.info('Initialization complete!')
processing_loop()
# Now see what we're supposed to do next