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


Python sense_hat.SenseHat方法代码示例

本文整理汇总了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) 
开发者ID:joshsisto,项目名称:Pi_Weather_Station,代码行数:19,代码来源:web_app.py

示例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() 
开发者ID:jamesbannan,项目名称:pluralsight,代码行数:8,代码来源:DisplayManager.py

示例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() 
开发者ID:Azure-Samples,项目名称:Custom-vision-service-iot-edge-raspberry-pi,代码行数:9,代码来源:DisplayManager.py

示例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] 
开发者ID:joshsisto,项目名称:Pi_Weather_Station,代码行数:17,代码来源:weather_logger.py

示例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] 
开发者ID:joshsisto,项目名称:Pi_Weather_Station,代码行数:14,代码来源:weather.py

示例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 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:7,代码来源:sensehat.py

示例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 
开发者ID:johnwargo,项目名称:pi_weather_station,代码行数:61,代码来源:weather_station.py


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