Skip to content

Commit bdd755c

Browse files
committed
改造firmwareとweatherFinderを追加
1 parent 43c70ce commit bdd755c

File tree

5 files changed

+56
-157
lines changed

5 files changed

+56
-157
lines changed

firmware.bin

624 KB
Binary file not shown.

lib/metadata.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/uurequest.py

Lines changed: 0 additions & 152 deletions
This file was deleted.

sample/weatherFinder/main.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from machine import Pin
2+
from time import sleep
3+
4+
def do_connect():
5+
import network
6+
sta_if = network.WLAN(network.STA_IF)
7+
if not sta_if.isconnected():
8+
print('connecting to network...')
9+
sta_if.active(True)
10+
sta_if.connect('ssid', 'password')
11+
while not sta_if.isconnected():
12+
pass
13+
print('network config:', sta_if.ifconfig())
14+
15+
do_connect()
16+
17+
import urequests
18+
19+
sunny = Pin(12, Pin.OUT)
20+
cloudy = Pin(13, Pin.OUT)
21+
rainy = Pin(14, Pin.OUT)
22+
23+
while True:
24+
r = urequests.get('https://weather.tsukumijima.net/api/forecast?city=140010')
25+
j = r.json()
26+
tomorrow = j['forecasts'][1]['telop']
27+
28+
if "雨" in tomorrow:
29+
sunny.value(0)
30+
cloudy.value(0)
31+
rainy.value(1)
32+
print("rainy")
33+
elif "曇" in tomorrow:
34+
sunny.value(0)
35+
cloudy.value(1)
36+
rainy.value(0)
37+
print("cloudy")
38+
else:
39+
sunny.value(1)
40+
cloudy.value(0)
41+
rainy.value(0)
42+
print("sunny")
43+
44+
sleep(1000)

sample/wifi/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def do_connect():
2+
import network
3+
sta_if = network.WLAN(network.STA_IF)
4+
if not sta_if.isconnected():
5+
print('connecting to network...')
6+
sta_if.active(True)
7+
sta_if.connect('ssid', 'password')
8+
while not sta_if.isconnected():
9+
pass
10+
print('network config:', sta_if.ifconfig())
11+
12+
do_connect()

0 commit comments

Comments
 (0)