當前位置: 首頁>>代碼示例>>Python>>正文


Python AstroPi.get_temperature方法代碼示例

本文整理匯總了Python中astro_pi.AstroPi.get_temperature方法的典型用法代碼示例。如果您正苦於以下問題:Python AstroPi.get_temperature方法的具體用法?Python AstroPi.get_temperature怎麽用?Python AstroPi.get_temperature使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在astro_pi.AstroPi的用法示例。


在下文中一共展示了AstroPi.get_temperature方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: updated

# 需要導入模塊: from astro_pi import AstroPi [as 別名]
# 或者: from astro_pi.AstroPi import get_temperature [as 別名]
dataDisplayInterval = 0.5                         # how often the displayed value is updated (seconds)

tmstmp = time.strftime("%Y%m%d-%H%M%S")           # Set timestamp format for the logging filename
logging.basicConfig(format='%(asctime)s %(message)s',filename='readings'+str(tmstmp)
+'.log',level=logging.DEBUG)                      # set up logging

hum_prev = 0                                      # set previous humidity and temp values to zero
temp_prev = 0
sec_count = 0

while True:                                       # Main program loop

	x, y, z = ap.get_accelerometer_raw().values() #Get raw accelerometer values and round them
	x = round(x, 0)
	y = round(y, 0)
	temp_f = ap.get_temperature()                 # Get temperature from astro-pi
	hum_f = ap.get_humidity()                     # Get humidity from astro-pi
	hum_int = int(hum_f)                          # convert to integers
	temp_int = int(temp_f)

	if (sec_count >= dataWriteInterval/dataDisplayInterval) or (sec_count == 0): 
		logging.info('humidity: ' + str(hum_f) + ' temperature: ' + str(temp_f))
		sec_count = 0

	if x == -1 and y != -1:                        # humidity display if HDMI port pointing upwards
		ap.set_rotation(270)
		if hum_int > hum_prev:                     # Is the latest reading higher than the last?
			r = [0,255,0]                          # green if higher
		elif hum_int == hum_prev:
			r = [0,0,255]                          # blue if the same
		else:
開發者ID:topshed,項目名稱:HTLogger,代碼行數:33,代碼來源:HTLogger.py

示例2: AstroPi

# 需要導入模塊: from astro_pi import AstroPi [as 別名]
# 或者: from astro_pi.AstroPi import get_temperature [as 別名]
from astro_pi import AstroPi
ap = AstroPi()

while True:
    t = ap.get_temperature()
    p = ap.get_pressure()
    h = ap.get_humidity()

    t = round(t,1)
    p = round(p,1)
    h = round(h,1)

    msg = "Temperature = %s, Pressure=%s, Humidity=%s" % (t,p,h)

    ap.show_message(msg,scroll_speed=0.05)
開發者ID:LornaLynch,項目名稱:getting-started-with-astro-pi,代碼行數:17,代碼來源:env.py

示例3: countdown

# 需要導入模塊: from astro_pi import AstroPi [as 別名]
# 或者: from astro_pi.AstroPi import get_temperature [as 別名]
name = "ISS (ZARYA)";            
#line1 = "1 25544U 98067A   15178.42973832  .00011523  00000-0  17276-3 0  9998"
#line2 = "2 25544  51.6456  32.8760 0003760  98.7829 323.8559 15.55421066949635"

line1 = "1 25544U 98067A   15185.95963984  .00006354  00000-0  98170-4 0  9990"
line2 = "2 25544  51.6454 355.2696 0003202 121.3230  14.1346 15.55509232950800"

def countdown():
    for i in reversed(range(0, 6)):
        ap.show_letter(str(i))
        time.sleep(1)

countdown()        
ap.clear()
while True:
    temp = str(ap.get_temperature())
    pressure =  str(ap.get_pressure())
    orientation =  ap.get_orientation_degrees()

    time.sleep(0.5)
    tle_rec = ephem.readtle(name, line1, line2)
    tle_rec.compute()
    
    #convert to strings#
    lat2string = str(tle_rec.sublat)
    long2string = str(tle_rec.sublong)

    lati = lat2string.split(":")
    longt = long2string.split(":")

    ###Convert to floats to check the rangess
開發者ID:TeCoEd,項目名稱:iss-tracker,代碼行數:33,代碼來源:ISS_Tracker.py


注:本文中的astro_pi.AstroPi.get_temperature方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。