diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 0a6cd5a..a0906f3 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -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", diff --git a/.vscode/settings.json b/.vscode/settings.json index 95be83b..20d11be 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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, diff --git a/CMakeLists.txt b/CMakeLists.txt index 75b3196..fb80f77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/python_fall_back/main.py b/python_fall_back/main.py new file mode 100644 index 0000000..e9b37fb --- /dev/null +++ b/python_fall_back/main.py @@ -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 "

File not found

" + +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") diff --git a/website/index.html b/website/index.html index b5e5965..2eaef9e 100644 --- a/website/index.html +++ b/website/index.html @@ -6,20 +6,95 @@ brum brum +
- - - - +
+ +
+
+ +
+
+ +
+
+ +
+
- \ No newline at end of file + diff --git a/website/script.js b/website/script.js deleted file mode 100644 index e69de29..0000000 diff --git a/website/style.css b/website/style.css deleted file mode 100644 index 45f5f7f..0000000 --- a/website/style.css +++ /dev/null @@ -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; - } -} \ No newline at end of file