![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
TUK Workshop
Dependencies: mbed lib_workshop_2019
main.cpp@4:bf5caf4c0c88, 2019-10-23 (annotated)
- Committer:
- gvaquette
- Date:
- Wed Oct 23 19:25:12 2019 +0000
- Revision:
- 4:bf5caf4c0c88
- Parent:
- 3:a0e37b8918ac
- Child:
- 5:d99659a45cab
testing motors and add comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gvaquette | 0:0a75a79d6b77 | 1 | #include "mbed.h" |
gvaquette | 1:7a8764e627b5 | 2 | |
gvaquette | 0:0a75a79d6b77 | 3 | #include "console_output.h" |
gvaquette | 1:7a8764e627b5 | 4 | #include "test_us.h" |
gvaquette | 1:7a8764e627b5 | 5 | #include "test_compass.h" |
gvaquette | 2:8153195b1672 | 6 | #include "test_cny.h" |
gvaquette | 4:bf5caf4c0c88 | 7 | #include "test_motor.h" |
gvaquette | 1:7a8764e627b5 | 8 | |
gvaquette | 1:7a8764e627b5 | 9 | #include "pin_connexions.h" |
gvaquette | 1:7a8764e627b5 | 10 | |
gvaquette | 1:7a8764e627b5 | 11 | |
gvaquette | 0:0a75a79d6b77 | 12 | Serial pc (PA_2, PA_3, 115200); |
gvaquette | 0:0a75a79d6b77 | 13 | |
gvaquette | 0:0a75a79d6b77 | 14 | int main() { |
gvaquette | 1:7a8764e627b5 | 15 | e_test user_choice ; |
gvaquette | 0:0a75a79d6b77 | 16 | ft_print_test_menu(pc); |
gvaquette | 1:7a8764e627b5 | 17 | user_choice = ft_get_user_choice(pc); |
gvaquette | 1:7a8764e627b5 | 18 | |
gvaquette | 4:bf5caf4c0c88 | 19 | |
gvaquette | 4:bf5caf4c0c88 | 20 | /* Main loop */ |
gvaquette | 1:7a8764e627b5 | 21 | while(1) |
gvaquette | 1:7a8764e627b5 | 22 | { |
gvaquette | 4:bf5caf4c0c88 | 23 | /* Which component to test ? */ |
gvaquette | 1:7a8764e627b5 | 24 | switch (user_choice) |
gvaquette | 1:7a8764e627b5 | 25 | { |
gvaquette | 1:7a8764e627b5 | 26 | case ULTRASONIC : |
gvaquette | 1:7a8764e627b5 | 27 | do |
gvaquette | 1:7a8764e627b5 | 28 | { |
gvaquette | 1:7a8764e627b5 | 29 | ft_print_all_values_US(ultra_sonic, pc); |
gvaquette | 1:7a8764e627b5 | 30 | } while (!pc.readable()); |
gvaquette | 1:7a8764e627b5 | 31 | user_choice = ft_get_user_choice(pc); |
gvaquette | 1:7a8764e627b5 | 32 | pc.printf("\n"); |
gvaquette | 1:7a8764e627b5 | 33 | break; |
gvaquette | 1:7a8764e627b5 | 34 | |
gvaquette | 1:7a8764e627b5 | 35 | case COMPASS : |
gvaquette | 1:7a8764e627b5 | 36 | do |
gvaquette | 1:7a8764e627b5 | 37 | { |
gvaquette | 1:7a8764e627b5 | 38 | ft_print_compass_values(compass, pc); |
gvaquette | 1:7a8764e627b5 | 39 | } while (!pc.readable()); |
gvaquette | 1:7a8764e627b5 | 40 | pc.printf("\n"); |
gvaquette | 1:7a8764e627b5 | 41 | user_choice = ft_get_user_choice(pc); |
gvaquette | 1:7a8764e627b5 | 42 | break; |
gvaquette | 2:8153195b1672 | 43 | |
gvaquette | 2:8153195b1672 | 44 | case CNY70 : |
gvaquette | 2:8153195b1672 | 45 | do |
gvaquette | 2:8153195b1672 | 46 | { |
gvaquette | 2:8153195b1672 | 47 | pc.printf("\r CNY_1"); |
gvaquette | 2:8153195b1672 | 48 | ft_print_cny_analog_voltage(CNY1, pc); |
gvaquette | 2:8153195b1672 | 49 | pc.printf("\t CNY_2"); |
gvaquette | 2:8153195b1672 | 50 | ft_print_cny_analog_voltage(CNY2, pc); |
gvaquette | 2:8153195b1672 | 51 | pc.printf("\t CNY_3"); |
gvaquette | 2:8153195b1672 | 52 | ft_print_cny_analog_voltage(CNY3, pc); |
gvaquette | 2:8153195b1672 | 53 | } while (!pc.readable()); |
gvaquette | 2:8153195b1672 | 54 | pc.printf("\n"); |
gvaquette | 2:8153195b1672 | 55 | user_choice = ft_get_user_choice(pc); |
gvaquette | 2:8153195b1672 | 56 | break; |
gvaquette | 3:a0e37b8918ac | 57 | |
gvaquette | 3:a0e37b8918ac | 58 | case VBAT : |
gvaquette | 3:a0e37b8918ac | 59 | do |
gvaquette | 3:a0e37b8918ac | 60 | { |
gvaquette | 3:a0e37b8918ac | 61 | ft_print_to_be_imp(pc); |
gvaquette | 3:a0e37b8918ac | 62 | } while (!pc.readable()); |
gvaquette | 3:a0e37b8918ac | 63 | pc.printf("\n"); |
gvaquette | 3:a0e37b8918ac | 64 | user_choice = ft_get_user_choice(pc); |
gvaquette | 3:a0e37b8918ac | 65 | break; |
gvaquette | 3:a0e37b8918ac | 66 | |
gvaquette | 3:a0e37b8918ac | 67 | case LEFT_MOTOR : |
gvaquette | 4:bf5caf4c0c88 | 68 | ft_test_motor(Pwm_MG,DIR_1G,DIR_2G,pc); |
gvaquette | 3:a0e37b8918ac | 69 | user_choice = ft_get_user_choice(pc); |
gvaquette | 3:a0e37b8918ac | 70 | break; |
gvaquette | 3:a0e37b8918ac | 71 | |
gvaquette | 3:a0e37b8918ac | 72 | case RIGHT_MOTOR: |
gvaquette | 4:bf5caf4c0c88 | 73 | ft_test_motor(Pwm_MD,DIR_1D,DIR_2D,pc); |
gvaquette | 3:a0e37b8918ac | 74 | user_choice = ft_get_user_choice(pc); |
gvaquette | 3:a0e37b8918ac | 75 | break; |
gvaquette | 3:a0e37b8918ac | 76 | |
gvaquette | 2:8153195b1672 | 77 | |
gvaquette | 1:7a8764e627b5 | 78 | default : |
gvaquette | 1:7a8764e627b5 | 79 | ft_print_test_menu(pc); |
gvaquette | 1:7a8764e627b5 | 80 | user_choice = ft_get_user_choice(pc); |
gvaquette | 1:7a8764e627b5 | 81 | break; |
gvaquette | 1:7a8764e627b5 | 82 | } |
gvaquette | 1:7a8764e627b5 | 83 | } |
gvaquette | 1:7a8764e627b5 | 84 | |
gvaquette | 0:0a75a79d6b77 | 85 | } |