mirror of
https://github.com/eliasrenman/gardentron.git
synced 2026-03-16 20:46:07 +01:00
feat: added basic picropython
This commit is contained in:
3
pico-w/.gitignore
vendored
Normal file
3
pico-w/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.env
|
||||
env.json
|
||||
config.py
|
||||
3
pico-w/.picowgo
Normal file
3
pico-w/.picowgo
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"info": "This file is just used to identify a project folder."
|
||||
}
|
||||
1
pico-w/.vscode/Pico-W-Stub
vendored
Symbolic link
1
pico-w/.vscode/Pico-W-Stub
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
/home/eliasrenman/.config/Code/User/Pico-W-Stub
|
||||
7
pico-w/.vscode/extensions.json
vendored
Normal file
7
pico-w/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-python.python",
|
||||
"visualstudioexptteam.vscodeintellicode",
|
||||
"ms-python.vscode-pylance"
|
||||
]
|
||||
}
|
||||
16
pico-w/.vscode/settings.json
vendored
Normal file
16
pico-w/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"python.linting.enabled": true,
|
||||
"python.languageServer": "Pylance",
|
||||
"python.analysis.typeCheckingMode": "basic",
|
||||
"picowgo.syncFolder": "",
|
||||
"python.analysis.typeshedPaths": [
|
||||
".vscode/Pico-W-Stub"
|
||||
],
|
||||
"python.analysis.extraPaths": [
|
||||
".vscode/Pico-W-Stub/stubs"
|
||||
],
|
||||
"[python]": {
|
||||
"editor.defaultFormatter": "ms-python.autopep8"
|
||||
},
|
||||
"python.formatting.provider": "none"
|
||||
}
|
||||
4
pico-w/boot.py
Normal file
4
pico-w/boot.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from wireless import enableWireless
|
||||
|
||||
|
||||
enableWireless()
|
||||
2
pico-w/config.py.example
Normal file
2
pico-w/config.py.example
Normal file
@@ -0,0 +1,2 @@
|
||||
ssid = "ssid"
|
||||
password = "password"
|
||||
40
pico-w/wireless.py
Normal file
40
pico-w/wireless.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import time
|
||||
import network
|
||||
from machine import Pin
|
||||
from config import ssid, password
|
||||
|
||||
|
||||
def enableWireless():
|
||||
|
||||
led = Pin("LED", Pin.OUT)
|
||||
led.value(1) # LED On
|
||||
led.value(0) # LED Off
|
||||
|
||||
wlan = network.WLAN(network.STA_IF)
|
||||
wlan.active(True)
|
||||
wlan.connect(ssid, password)
|
||||
|
||||
# Wait for connect or fail
|
||||
max_wait = 10
|
||||
while max_wait > 0:
|
||||
if wlan.status() < 0 or wlan.status() >= 3:
|
||||
break
|
||||
max_wait -= 1
|
||||
print('waiting for connection...')
|
||||
time.sleep(1)
|
||||
|
||||
# Handle connection error
|
||||
if wlan.status() != 3:
|
||||
raise RuntimeError('network connection failed')
|
||||
else:
|
||||
s = 3
|
||||
while s > 0:
|
||||
s -= 1
|
||||
led.value(1)
|
||||
time.sleep(0.5)
|
||||
led.value(0)
|
||||
time.sleep(0.5)
|
||||
|
||||
# print('connected')
|
||||
status = wlan.ifconfig()
|
||||
print('Connected to ' + ssid + '. ' + 'Device IP: ' + status[0])
|
||||
Reference in New Issue
Block a user