diff --git a/controllers/src/examples/Makefile b/controllers/src/examples/Makefile index db83592ea8c4d3501365f3b0ed1bd8bc74b83a87..7c7088841ea4c814e6c9be041459741a658ea512 100644 --- a/controllers/src/examples/Makefile +++ b/controllers/src/examples/Makefile @@ -36,7 +36,7 @@ $(PROJECT).elf: $(OBJS) $(CC) -c $(CFLAGS) $(INCLUDE_DIRS) -o $@ $< download: $(MAIN_OUT_HEX) - fw_downloader -d /dev/ttyUSB0 -f ./src/examples/comm_ex.hex -p new + fw_downloader -d /dev/ttyUSB0 -f $(PROJECT).hex -p new clean: -rm $(PROJECT).* diff --git a/controllers/src/examples/main.c b/controllers/src/examples/main.c index fa6923951b9dc0c57f42948db90fbaedee7b255d..a1d62161825f6ddd3735b991735363977c2d59ac 100755 --- a/controllers/src/examples/main.c +++ b/controllers/src/examples/main.c @@ -29,8 +29,8 @@ void user_loop(void) { if(user_time_is_period_done()) { - printf("Gyro X: %d\n",get_adc_avg_channel(ADC_PORT_3)); - printf("Gyro Y: %d\n",get_adc_avg_channel(ADC_PORT_4)); + printf("Gyro X: %d\n",get_adc_channel(ADC_PORT_3)); + printf("Gyro Y: %d\n",get_adc_channel(ADC_PORT_4)); } if(is_button_pressed(BTN_START)) turn_led_on(LED_AUX); diff --git a/motion/src/balance.c b/motion/src/balance.c index 9caf2a9ac9ec07f72e98e58e398c3662c58d4fdc..dd5290656c969e42b5efdf6b78a373b6926fc2b8 100644 --- a/motion/src/balance.c +++ b/motion/src/balance.c @@ -6,11 +6,15 @@ #include "balance.h" #include "adc.h" #include "buzzer.h" +#include "user_time.h" // external functions extern void buzzer_start_alarm(note_t note,uint16_t on_time_100ms,uint16_t off_time_100ms); extern void buzzer_stop_alarm(void); +extern void adc_loop(void); +extern void user_time_loop(void); + // private variables uint16_t balance_x_gyro_center; uint16_t balance_y_gyro_center; @@ -98,14 +102,20 @@ uint8_t balance_calibrate_gyro(void) balance_x_gyro_center=0; balance_y_gyro_center=0; + user_time_set_period(50); for(i=0;i<BALANCE_GYRO_CAL_NUM_SAMPLES;i++) { - _delay_ms(50); + while(!user_time_is_period_done()) + { + user_time_loop(); + adc_loop(); + } x_gyro_values[i]=get_adc_channel(BALANCE_GYRO_X_CHANNEL); y_gyro_values[i]=get_adc_channel(BALANCE_GYRO_Y_CHANNEL); x_gyro_average+=x_gyro_values[i]; y_gyro_average+=y_gyro_values[i]; } + user_time_stop(); x_gyro_average/=(float)BALANCE_GYRO_CAL_NUM_SAMPLES; y_gyro_average/=(float)BALANCE_GYRO_CAL_NUM_SAMPLES; // compute the standard deviation diff --git a/motion/src/examples/Makefile b/motion/src/examples/Makefile index 4dacfd579d67cd85c8f4976d3b57b62fe2925409..686382b1015b6fa6ee484b4dadb4cdd575aaa1e7 100644 --- a/motion/src/examples/Makefile +++ b/motion/src/examples/Makefile @@ -2,7 +2,7 @@ PROJECT=manager_ex ######################################################## # afegir tots els fitxers que s'han de compilar aquà ######################################################## -SOURCES=walk_straight.c +SOURCES=get_up.c#walk_straight.c OBJS=$(SOURCES:.c=.o) SRC_DIR=./src/