Compare commits
1 Commits
ebe4350e92
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d9f744381 |
2
.vscode/c_cpp_properties.json
vendored
2
.vscode/c_cpp_properties.json
vendored
@@ -11,7 +11,7 @@
|
|||||||
"${userHome}/.pico-sdk/sdk/2.2.0/src/common/pico_base_headers/include/pico.h"
|
"${userHome}/.pico-sdk/sdk/2.2.0/src/common/pico_base_headers/include/pico.h"
|
||||||
],
|
],
|
||||||
"defines": [],
|
"defines": [],
|
||||||
"compilerPath": "${userHome}/.pico-sdk/toolchain/14_2_Rel1/bin/arm-none-eabi-gcc",
|
"compilerPath": "${userHome}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3/bin/riscv32-unknown-elf-gcc",
|
||||||
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
|
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
|
||||||
"cStandard": "c17",
|
"cStandard": "c17",
|
||||||
"cppStandard": "c++14",
|
"cppStandard": "c++14",
|
||||||
|
|||||||
12
.vscode/settings.json
vendored
12
.vscode/settings.json
vendored
@@ -20,18 +20,18 @@
|
|||||||
"C_Cpp.debugShortcut": false,
|
"C_Cpp.debugShortcut": false,
|
||||||
"terminal.integrated.env.windows": {
|
"terminal.integrated.env.windows": {
|
||||||
"PICO_SDK_PATH": "${env:USERPROFILE}/.pico-sdk/sdk/2.2.0",
|
"PICO_SDK_PATH": "${env:USERPROFILE}/.pico-sdk/sdk/2.2.0",
|
||||||
"PICO_TOOLCHAIN_PATH": "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1",
|
"PICO_TOOLCHAIN_PATH": "${env:USERPROFILE}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3",
|
||||||
"Path": "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1/bin;${env:USERPROFILE}/.pico-sdk/picotool/2.2.0-a4/picotool;${env:USERPROFILE}/.pico-sdk/cmake/v3.31.5/bin;${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1;${env:PATH}"
|
"Path": "${env:USERPROFILE}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3/bin;${env:USERPROFILE}/.pico-sdk/picotool/2.2.0-a4/picotool;${env:USERPROFILE}/.pico-sdk/cmake/v3.31.5/bin;${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1;${env:PATH}"
|
||||||
},
|
},
|
||||||
"terminal.integrated.env.osx": {
|
"terminal.integrated.env.osx": {
|
||||||
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
|
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
|
||||||
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1",
|
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3",
|
||||||
"PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.2.0-a4/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
|
"PATH": "${env:HOME}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3/bin:${env:HOME}/.pico-sdk/picotool/2.2.0-a4/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
|
||||||
},
|
},
|
||||||
"terminal.integrated.env.linux": {
|
"terminal.integrated.env.linux": {
|
||||||
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
|
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
|
||||||
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1",
|
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3",
|
||||||
"PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.2.0-a4/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
|
"PATH": "${env:HOME}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3/bin:${env:HOME}/.pico-sdk/picotool/2.2.0-a4/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
|
||||||
},
|
},
|
||||||
"raspberry-pi-pico.cmakeAutoConfigure": true,
|
"raspberry-pi-pico.cmakeAutoConfigure": true,
|
||||||
"raspberry-pi-pico.useCmakeTools": false,
|
"raspberry-pi-pico.useCmakeTools": false,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ else()
|
|||||||
set(USERHOME $ENV{HOME})
|
set(USERHOME $ENV{HOME})
|
||||||
endif()
|
endif()
|
||||||
set(sdkVersion 2.2.0)
|
set(sdkVersion 2.2.0)
|
||||||
set(toolchainVersion 14_2_Rel1)
|
set(toolchainVersion RISCV_ZCB_RPI_2_2_0_3)
|
||||||
set(picotoolVersion 2.2.0-a4)
|
set(picotoolVersion 2.2.0-a4)
|
||||||
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
|
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
|
||||||
if (EXISTS ${picoVscode})
|
if (EXISTS ${picoVscode})
|
||||||
|
|||||||
94
python_fall_back/main.py
Normal file
94
python_fall_back/main.py
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
import time
|
||||||
|
import network
|
||||||
|
import socket
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
ssid = '5'
|
||||||
|
password = 'nevem123'
|
||||||
|
move = 0
|
||||||
|
dir = 0
|
||||||
|
|
||||||
|
def read_html(filename):
|
||||||
|
try:
|
||||||
|
with open(filename, "r") as file:
|
||||||
|
return file.read()
|
||||||
|
except:
|
||||||
|
return "<html><body><h1>File not found</h1></body></html>"
|
||||||
|
|
||||||
|
def init_wifi(ssid, password):
|
||||||
|
wlan = network.WLAN(network.STA_IF)
|
||||||
|
wlan.active(True)
|
||||||
|
wlan.connect(ssid, password)
|
||||||
|
|
||||||
|
connection_timeout = 10
|
||||||
|
while connection_timeout > 0:
|
||||||
|
if wlan.status() >= 3:
|
||||||
|
break
|
||||||
|
connection_timeout -= 1
|
||||||
|
print('Waiting for Wi-Fi connection...')
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
if wlan.status() != 3:
|
||||||
|
print("Failed to connect.")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
print('Connection successful!')
|
||||||
|
print('IP address:', wlan.ifconfig()[0])
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def handle_client(reader, writer):
|
||||||
|
global move, dir
|
||||||
|
try:
|
||||||
|
request_line = await reader.readline()
|
||||||
|
if not request_line:
|
||||||
|
return
|
||||||
|
request = request_line.decode().strip()
|
||||||
|
if '/up' in request:
|
||||||
|
move += 5
|
||||||
|
elif '/down' in request:
|
||||||
|
move -= 5
|
||||||
|
elif '/right' in request:
|
||||||
|
dir += 5
|
||||||
|
elif '/left' in request:
|
||||||
|
dir -= 5
|
||||||
|
while True:
|
||||||
|
line = await reader.readline()
|
||||||
|
if line == b"\r\n" or line == b"":
|
||||||
|
break
|
||||||
|
|
||||||
|
response_body = read_html("./webpage/index.html")
|
||||||
|
writer.write(b"HTTP/1.0 200 OK\r\n")
|
||||||
|
writer.write(b"Content-type: text/html\r\n")
|
||||||
|
writer.write(b"Connection: close\r\n\r\n")
|
||||||
|
writer.write(response_body.encode("utf-8"))
|
||||||
|
await writer.drain()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("Error handling client:", e)
|
||||||
|
finally:
|
||||||
|
await writer.aclose()
|
||||||
|
async def move_car_loop():
|
||||||
|
global move, dir
|
||||||
|
print("Car control loop started.")
|
||||||
|
while True:
|
||||||
|
print(f"Executing: Speed {move} , Direction {dir}")
|
||||||
|
await asyncio.sleep(0.5)
|
||||||
|
move = move * 0.9
|
||||||
|
dir = dir * 0.9
|
||||||
|
if(abs(move) < 1):
|
||||||
|
move = 0
|
||||||
|
if(abs(dir) < 1):
|
||||||
|
dir = 0
|
||||||
|
async def main():
|
||||||
|
if not init_wifi(ssid, password):
|
||||||
|
return
|
||||||
|
print("Starting async web server...")
|
||||||
|
server = await asyncio.start_server(handle_client, "0.0.0.0", 80)
|
||||||
|
car_task = asyncio.create_task(move_car_loop())
|
||||||
|
while True:
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
asyncio.run(main())
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("Program Interrupted")
|
||||||
@@ -6,20 +6,95 @@
|
|||||||
<title>brum brum</title>
|
<title>brum brum</title>
|
||||||
<link type="text/css" rel="stylesheet" href="./style.css">
|
<link type="text/css" rel="stylesheet" href="./style.css">
|
||||||
</head>
|
</head>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #3a3a3a;
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
position: absolute;
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
border-radius: 25px;
|
||||||
|
font-size: 100px;
|
||||||
|
background-color: #8a0261;
|
||||||
|
border: none;
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
button.button:hover{
|
||||||
|
background-color: #bb0284;
|
||||||
|
}
|
||||||
|
button.button:active{
|
||||||
|
background-color: #d10594;
|
||||||
|
}
|
||||||
|
#dalinec {
|
||||||
|
display: block;
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 100px;
|
||||||
|
background-color: #333;
|
||||||
|
border-radius: 25px;
|
||||||
|
width: 800px;
|
||||||
|
height: 800px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
#levo {
|
||||||
|
left: 25%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
#desno {
|
||||||
|
left: 75%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
#gor {
|
||||||
|
left: 50%;
|
||||||
|
top: 25%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
#dol {
|
||||||
|
left: 50%;
|
||||||
|
top: 75%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
#dalinec {
|
||||||
|
width: 90vw;
|
||||||
|
height: 90vw;
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
width: 20vw;
|
||||||
|
height: 20vw;
|
||||||
|
font-size: 8vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<body>
|
<body>
|
||||||
<div id="dalinec">
|
<div id="dalinec">
|
||||||
<button class="button" id="levo">
|
<form method="get" action="left">
|
||||||
|
<button class="button" id="levo" type="submit" value="left">
|
||||||
←
|
←
|
||||||
</button>
|
</button>
|
||||||
<button class="button" id="gor">
|
</form>
|
||||||
|
<form method="get" action="up">
|
||||||
|
<button class="button" id="gor" type="submit" value="up">
|
||||||
↑
|
↑
|
||||||
</button>
|
</button>
|
||||||
<button class="button" id="dol">
|
</form>
|
||||||
|
<form method="get" action="down">
|
||||||
|
<button class="button" id="dol" type="submit" value="down">
|
||||||
↓
|
↓
|
||||||
</button>
|
</button>
|
||||||
<button class="button" id="desno">
|
</form>
|
||||||
|
<form method="get" action="right">
|
||||||
|
<button class="button" id="desno" type="submit" value="right">
|
||||||
→
|
→
|
||||||
</button>
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
body {
|
|
||||||
background-color: #3a3a3a;
|
|
||||||
}
|
|
||||||
.button {
|
|
||||||
position: absolute;
|
|
||||||
width: 200px;
|
|
||||||
height: 200px;
|
|
||||||
border-radius: 25px;
|
|
||||||
font-size: 100px;
|
|
||||||
background-color: #8a0261;
|
|
||||||
border: none;
|
|
||||||
color: rgba(255, 255, 255, 0.92);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
button.button:hover{
|
|
||||||
background-color: #bb0284;
|
|
||||||
}
|
|
||||||
button.button:active{
|
|
||||||
background-color: #d10594;
|
|
||||||
}
|
|
||||||
#dalinec {
|
|
||||||
display: block;
|
|
||||||
margin: auto;
|
|
||||||
margin-top: 100px;
|
|
||||||
background-color: #333;
|
|
||||||
border-radius: 25px;
|
|
||||||
width: 800px;
|
|
||||||
height: 800px;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
#levo {
|
|
||||||
left: 25%;
|
|
||||||
top: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
#desno {
|
|
||||||
left: 75%;
|
|
||||||
top: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
#gor {
|
|
||||||
left: 50%;
|
|
||||||
top: 25%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
#dol {
|
|
||||||
left: 50%;
|
|
||||||
top: 75%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Responsive: scale down container and button sizes on small screens */
|
|
||||||
@media (max-width: 900px) {
|
|
||||||
#dalinec {
|
|
||||||
width: 90vw;
|
|
||||||
height: 90vw;
|
|
||||||
}
|
|
||||||
.button {
|
|
||||||
width: 20vw;
|
|
||||||
height: 20vw;
|
|
||||||
font-size: 8vw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user