Skip to content
Snippets Groups Projects
Commit d9f56847 authored by Pascal Koch's avatar Pascal Koch
Browse files

AUTOOOO!!!

parent df5e567f
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"miDebuggerPath": "gdb-multiarch",
"miDebuggerServerAddress": "localhost:3333",
"miDebuggerServerAddress": "10.42.0.1:3333",
"preLaunchTask": "build",
"internalConsoleOptions": "neverOpen",
"postRemoteConnectCommands": [
......
......@@ -3,6 +3,7 @@
#include <stdio.h>
#include <unistd.h>
#include <hardware/pwm.h>
#include <math.h>
double rollingperc[4] = {0, 0, 0, 0};
int pos = 0;
......@@ -155,14 +156,14 @@ void callback(uint gpio, uint32_t events)
{
distance = 0;
}
if (distance > 20)
if (distance > 40)
{
distance = 20;
distance = 40;
}
distance = 20 - distance;
distance = 40 - distance;
volatile int percentage = (distance / 10) * 100;
volatile int percentage = (distance / 20) * 100;
rollingperc[pos] = percentage;
pos++;
......@@ -173,8 +174,13 @@ 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)) + 2000;
speed = speed + ((1.8 * avg) - 180);
double speed = 0.9 * ((avg - 100) * (avg - 100)) + 1500; // 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)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment