Compare commits

...

3 Commits

9 changed files with 211 additions and 87 deletions

View File

@@ -11,7 +11,7 @@
"${userHome}/.pico-sdk/sdk/2.2.0/src/common/pico_base_headers/include/pico.h"
],
"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",
"cStandard": "c17",
"cppStandard": "c++14",

12
.vscode/settings.json vendored
View File

@@ -20,18 +20,18 @@
"C_Cpp.debugShortcut": false,
"terminal.integrated.env.windows": {
"PICO_SDK_PATH": "${env:USERPROFILE}/.pico-sdk/sdk/2.2.0",
"PICO_TOOLCHAIN_PATH": "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1",
"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}"
"PICO_TOOLCHAIN_PATH": "${env:USERPROFILE}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3",
"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": {
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1",
"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}"
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3",
"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": {
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1",
"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}"
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/RISCV_ZCB_RPI_2_2_0_3",
"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.useCmakeTools": false,

View File

@@ -20,7 +20,7 @@ else()
set(USERHOME $ENV{HOME})
endif()
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(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
if (EXISTS ${picoVscode})

18
LICENSE Normal file
View File

@@ -0,0 +1,18 @@
Copyright (c) 2026 Jonas Korene Novak and Matic Flegar
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# l3iot-fin
Končni projekt pri IOT za 3. Letnik.

94
python_fall_back/main.py Normal file
View 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")

View File

@@ -6,20 +6,95 @@
<title>brum brum</title>
<link type="text/css" rel="stylesheet" href="./style.css">
</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>
<div id="dalinec">
<button class="button" id="levo">
</button>
<button class="button" id="gor">
</button>
<button class="button" id="dol">
</button>
<button class="button" id="desno">
</button>
<form method="get" action="left">
<button class="button" id="levo" type="submit" value="left">
</button>
</form>
<form method="get" action="up">
<button class="button" id="gor" type="submit" value="up">
</button>
</form>
<form method="get" action="down">
<button class="button" id="dol" type="submit" value="down">
</button>
</form>
<form method="get" action="right">
<button class="button" id="desno" type="submit" value="right">
</button>
</form>
</div>
</body>
</html>

View File

View File

@@ -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;
}
}