當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。