From f4aa96104f6eecfdf32af2e0f04ce61185537502 Mon Sep 17 00:00:00 2001 From: PoliEcho Date: Fri, 24 Apr 2026 15:22:37 +0200 Subject: [PATCH] mutiplexors done --- mux.c | 14 ++++++++++---- mux.h | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 mux.h diff --git a/mux.c b/mux.c index d0f9d6f..b9a1086 100644 --- a/mux.c +++ b/mux.c @@ -1,4 +1,7 @@ #include "const.h" +#include "state.h" +#include +#include #include #include @@ -8,12 +11,15 @@ void set_mux_addr(uint8_t addr) { gpio_put(MUX_S2, (addr >> 2) & 1); } -float read_value_from_mux() { - return 0.0f; -} + void update_inputs() { for(uint8_t i = 0; i < 2; i++) { - + adc_select_input(i); + for(uint8_t j = 0; j < 8;j++) { + set_mux_addr(j); + sleep_ms(1); // let multiplexor multiplex + state.array[(i+1)*j]= adc_read(); + } } } diff --git a/mux.h b/mux.h new file mode 100644 index 0000000..4f035fd --- /dev/null +++ b/mux.h @@ -0,0 +1,5 @@ +#pragma once +#include + +void set_mux_addr(uint8_t addr); +void update_inputs(); \ No newline at end of file