import time
import requests
import pyupm_i2clcd as lcd
# requests モジュールでAPIからGET
r = requests.get('https://d6h35jv1q8.execute-api.us-east-1.amazonaws.com/production/weather').json()
# 天候を取得
weather = r['weather'][0]['main'].encode('utf-8')
# 気温を取得(APIから得られる値はケルビンのため、摂氏に換算)
temp_k = r['main']['temp']
temp_c = temp_k - 273.15
# LCD に表示
my_lcd = lcd.Jhd1313m1(6, 0x3E, 0x62)
my_lcd.setColor(0, 255, 255)
my_lcd.clear()
first_row = "Weather : " + weather
second_row = "Temperature : " + str(temp_c)
my_lcd.setCursor(0, 0)
my_lcd.write(first_row)
my_lcd.setCursor(1, 0)
my_lcd.write(second_row)
# スクロール
while True:
time.sleep(0.7)
my_lcd.scrollDisplayLeft()
Last active
October 9, 2015 06:53
-
-
Save iktakahiro/14c87b54ce18b9bcb26b to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment