feat: added basic picropython

This commit is contained in:
Elias Renman
2023-05-21 17:51:55 +02:00
parent a3e32e76c1
commit a9a1915a5e
8 changed files with 76 additions and 0 deletions

3
pico-w/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
.env
env.json
config.py

3
pico-w/.picowgo Normal file
View 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
View File

@@ -0,0 +1 @@
/home/eliasrenman/.config/Code/User/Pico-W-Stub

7
pico-w/.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"recommendations": [
"ms-python.python",
"visualstudioexptteam.vscodeintellicode",
"ms-python.vscode-pylance"
]
}

16
pico-w/.vscode/settings.json vendored Normal file
View 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
View File

@@ -0,0 +1,4 @@
from wireless import enableWireless
enableWireless()

2
pico-w/config.py.example Normal file
View File

@@ -0,0 +1,2 @@
ssid = "ssid"
password = "password"

40
pico-w/wireless.py Normal file
View 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])