diff --git a/examples/stairs/Makefile b/examples/stairs/Makefile index 09812e87e450c8a46963b900c89f66dffa151365..0bde160cb53b3eeb8e312a88736910df6ecb48f3 100644 --- a/examples/stairs/Makefile +++ b/examples/stairs/Makefile @@ -2,7 +2,7 @@ PROJECT=stairs ######################################################## # afegir tots els fitxers que s'han de compilar aquà ######################################################## -SOURCES=stairs.c ../mtn_library.c +SOURCES=stairs.c OBJS=$(SOURCES:.c=.o) SRC_DIR=./ diff --git a/examples/stairs/stairs.c b/examples/stairs/stairs.c index c9587e44ac09815874df175d3f7eb4eaf61517fd..f847f9dbb0741cf6d152df242120c5d1a27525fa 100644 --- a/examples/stairs/stairs.c +++ b/examples/stairs/stairs.c @@ -6,162 +6,6 @@ #include "mtn_library.h" typedef enum {wait_start,wait_ready,walk_to_stairs1,wait_stop1,up_stairs1} main_states; -typedef enum {up_idle,up_wait_stop,up_wait_step1,up_delay1,up_wait_step2,up_wait_step3,up_wait_step4,wait_ready_up} stairs_up_states; -typedef enum {down_idle,down_wait_stop,down_wait_step1,down_wait_step2,down_wait_step3,wait_ready_down} stairs_down_states; - -uint8_t stairs_up_process(void) -{ - static stairs_up_states state=up_idle; - uint8_t done=0x00; - - switch(state) - { - case up_idle: if(is_action_running()) - { - action_stop_page(); - state = up_wait_stop; - } - else - { - action_set_page(227); - action_start_page(); - state = up_wait_step1; - } - break; - case up_wait_stop: if(is_action_running()) - state = up_wait_stop; - else - { - action_set_page(227); - action_start_page(); - state = up_wait_step1; - } - break; - case up_wait_step1: if(is_action_running()) - state = up_wait_step1; - else - { - user_time_set_one_time(1500); - state = up_delay1; - } - break; - case up_delay1: if(user_time_is_done()) - { - action_set_page(224); - action_start_page(); - state = up_wait_step2; - } - else - state = up_delay1; - break; - case up_wait_step2: if(is_action_running()) - state = up_wait_step2; - else - { - action_set_page(225); - action_start_page(); - state = up_wait_step3; - } - break; - case up_wait_step3: if(is_action_running()) - state = up_wait_step3; - else - { - action_set_page(226); - action_start_page(); - state = up_wait_step4; - } - break; - case up_wait_step4: if(is_action_running()) - state = up_wait_step4; - else - { - action_set_page(31); - action_start_page(); - state = wait_ready_up; - } - break; - case wait_ready_up: if(is_action_running()) - state = wait_ready_up; - else - { - state=up_idle; - done=0x01; - } - break; - } - - return done; -} - - -uint8_t stairs_down_process(void) -{ - static stairs_down_states state=down_idle; - uint8_t done=0x00; - - switch(state) - { - case down_idle: if(is_action_running()) - { - action_stop_page(); - state = down_wait_stop; - } - else - { - action_set_page(228); - action_start_page(); - state = down_wait_step1; - } - break; - case down_wait_stop: if(is_action_running()) - state = down_wait_stop; - else - { - action_set_page(228); - action_start_page(); - state = down_wait_step1; - } - break; - case down_wait_step1: if(is_action_running()) - state = down_wait_step1; - else - { - action_set_page(229); - action_start_page(); - state = down_wait_step2; - } - break; - case down_wait_step2: if(is_action_running()) - state = down_wait_step2; - else - { - action_set_page(230); - action_start_page(); - state = down_wait_step3; - } - break; - case down_wait_step3: if(is_action_running()) - state = down_wait_step3; - else - { - action_set_page(31); - action_start_page(); - state = wait_ready_down; - } - break; - case wait_ready_down: if(is_action_running()) - state = wait_ready_down; - else - { - state=down_idle; - done=0x01; - } - break; - } - - return done; -} void user_init(void) { @@ -170,7 +14,6 @@ void user_init(void) balance_calibrate_gyro(); balance_enable_gyro(); user_time_set_period(100); - mtn_lib_init(); } void user_loop(void) @@ -196,7 +39,7 @@ void user_loop(void) state=walk_to_stairs1; } break; - case walk_to_stairs1: if(exp_gpio_get_value(GPIO0) || exp_gpio_get_value(GPIO3)) + case walk_to_stairs1: if(exp_gpio_get_value(GPIO1)==0x00 || exp_gpio_get_value(GPIO18)==0x00) { mtn_lib_stop_mtn(); state=wait_stop1; @@ -210,7 +53,7 @@ void user_loop(void) else state=wait_stop1; break; - case up_stairs1: if(stairs_up_process()) + case up_stairs1: if(stairs_up_process(robot_standing)) state=wait_start; else state=up_stairs1;