From 8a62b92a15441936bf4b5cf0f5690723e5600389 Mon Sep 17 00:00:00 2001 From: James Immanuel Magsino <stjamagsi@mi-2023-9.fbi.h-da.de> Date: Fri, 10 Jan 2025 11:15:47 +0100 Subject: [PATCH] testing --- .vscode/settings.json | 3 ++- src/main.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2c8b73a0..ca576085 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -35,5 +35,6 @@ "*.cpp": "cpp", "*.h": "c", "*.c": "c" - } + }, + "task.allowAutomaticTasks": "on" } \ No newline at end of file diff --git a/src/main.c b/src/main.c index 0e6c2cd9..c8b52dca 100644 --- a/src/main.c +++ b/src/main.c @@ -156,14 +156,14 @@ void callback(uint gpio, uint32_t events) { distance = 0; } - if (distance > 40) + if (distance > 20) { - distance = 40; + distance = 20; } - distance = 40 - distance; + distance = 20 - distance; - volatile int percentage = (distance / 20) * 100; + volatile int percentage = (distance / 10) * 100; rollingperc[pos] = percentage; pos++; @@ -175,23 +175,23 @@ void callback(uint gpio, uint32_t events) int avg = (rollingperc[0] + rollingperc[1] + rollingperc[2] + rollingperc[3]) / 4; // if zwischen 90, 110, stop - double speed = 0.9 * ((avg - 100) * (avg - 100)) + 1500; // quadratisch + double speed = 0.5 * ((avg - 100) * (avg - 100)) + 1000; // quadratisch speed = speed + 10 * ((1.8 * avg) - 180); // double speed = abs(70 * avg) + 2000; // linear // speed += 70; set_speed(speed); - if (avg > 90 && avg < 110) + if (avg == 100) { gpio_put(20, 0); gpio_put(21, 0); } - else if (avg < 90) + if (avg < 100) { motor_forward(); } - else if (avg > 110) + else if (avg > 100) { motor_backward(); } -- GitLab