diff --git a/Production/Firmware/chu_pico.uf2 b/Production/Firmware/chu_pico.uf2 index eff0564..432981b 100644 Binary files a/Production/Firmware/chu_pico.uf2 and b/Production/Firmware/chu_pico.uf2 differ diff --git a/firmware/src/air.c b/firmware/src/air.c index 0015b7c..5a1ba3c 100644 --- a/firmware/src/air.c +++ b/firmware/src/air.c @@ -180,21 +180,20 @@ static void air_update_tof() static void ir_read() { - for (int i = 0; i < count_of(IR_ABC); i++) { - gpio_put(IR_ABC[i], 1); - sleep_us(9); + static int phase = 0; - adc_select_input(IR_SIG[0]); - sleep_us(1); - ir_raw[i * 2] = adc_read(); + gpio_put(IR_ABC[phase], 1); + sleep_us(20); // time for phototransistor to settle down - adc_select_input(IR_SIG[1]); - sleep_us(1); - ir_raw[i * 2 + 1] = adc_read(); - - gpio_put(IR_ABC[i], 0); - sleep_us(1); + for (int i = 0; i < 2; i++) { + adc_select_input(IR_SIG[i]); + sleep_us(2); + ir_raw[phase * 2 + i] = adc_read(); } + + gpio_put(IR_ABC[phase], 0); + + phase = (phase + 1) % count_of(IR_ABC); } static void ir_judge() @@ -207,7 +206,7 @@ static void ir_judge() threshold = threshold * IR_DEBOUNCE_PERCENT / 100; } - ir_blocked[i] = offset >= threshold; + ir_blocked[i] = (offset >= threshold); } } diff --git a/firmware/src/usb_descriptors.c b/firmware/src/usb_descriptors.c index 3e167eb..a0ab948 100644 --- a/firmware/src/usb_descriptors.c +++ b/firmware/src/usb_descriptors.c @@ -23,6 +23,8 @@ * */ +#include + #include "usb_descriptors.h" #include "tusb.h"