Skip to content
Snippets Groups Projects
Commit 85a312d7 authored by jamesimmanuel.magsino@stud.h-da.de's avatar jamesimmanuel.magsino@stud.h-da.de
Browse files

averaged the last three results

parent 90b8ba20
Branches
Tags
No related merge requests found
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#include <unistd.h> #include <unistd.h>
#include <hardware/pwm.h> #include <hardware/pwm.h>
double percentage_1 = 0;
double percentage_2 = 0;
bool flipflop = false;
const uint8_t init[4] = {0x21, 0xa0, 0xef, 0x81}; const uint8_t init[4] = {0x21, 0xa0, 0xef, 0x81};
const uint8_t zeile[8] = {0x00, 0x02, 0x04, 0x06, 0x08, 0x10, 0x12, 0x14}; const uint8_t zeile[8] = {0x00, 0x02, 0x04, 0x06, 0x08, 0x10, 0x12, 0x14};
const uint8_t fill[17] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; const uint8_t fill[17] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
...@@ -144,7 +148,18 @@ void callback(uint gpio, uint32_t events) ...@@ -144,7 +148,18 @@ void callback(uint gpio, uint32_t events)
volatile int percentage = (distance / 10) * 100; volatile int percentage = (distance / 10) * 100;
set_progress(percentage); if (flipflop)
{
percentage_1 = percentage;
flipflop = false;
}
else
{
percentage_2 = percentage;
flipflop = true;
}
set_progress((percentage + percentage_1 + percentage_2) / 3);
} }
else if (events & GPIO_IRQ_EDGE_RISE) else if (events & GPIO_IRQ_EDGE_RISE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment