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

edge trigger stuff

parent 9a263c7d
No related branches found
No related tags found
No related merge requests found
...@@ -122,19 +122,29 @@ void callback(uint gpio, uint32_t events) ...@@ -122,19 +122,29 @@ void callback(uint gpio, uint32_t events)
{ {
volatile uint slice_num = pwm_gpio_to_slice_num(27); volatile uint slice_num = pwm_gpio_to_slice_num(27);
volatile duration = pwm_get_counter(slice_num) * 42;
/* volatile uint another_slice_num = pwm_gpio_to_slice_num(27);
if (events & GPIO_IRQ_LEVEL_HIGH) if (events & GPIO_IRQ_EDGE_FALL)
{ {
volatile uint16_t test = pwm_get_counter(another_slice_num); volatile uint16_t duration = pwm_get_counter(slice_num) * 42;
volatile uint16_t test = pwm_get_counter(slice_num);
volatile float distance = (test * 314) / (20000);
if (distance > 20)
{
distance = 20;
}
distance = 20 - distance;
volatile int percentage = (distance / 10) * 100;
set_progress(percentage);
} }
else if (events & GPIO_IRQ_LEVEL_LOW) else if (events & GPIO_IRQ_EDGE_RISE)
{ {
pwm_set_counter(another_slice_num, 0); pwm_set_counter(slice_num, 0);
} }
*/
// volatile uint16_t test = pwm_get_counter(another_slice_num); // volatile uint16_t test = pwm_get_counter(another_slice_num);
// volatile float distance = (test * 314) / (20000); // volatile float distance = (test * 314) / (20000);
// if (distance > 20) // if (distance > 20)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment