![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Teacher version
Dependencies: mbed lib_workshop_2019
main.cpp@2:8153195b1672, 2019-10-23 (annotated)
- Committer:
- gvaquette
- Date:
- Wed Oct 23 13:56:30 2019 +0000
- Revision:
- 2:8153195b1672
- Parent:
- 1:7a8764e627b5
- Child:
- 3:a0e37b8918ac
cny testing analog input
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 | 1:7a8764e627b5 | 7 | |
gvaquette | 1:7a8764e627b5 | 8 | #include "pin_connexions.h" |
gvaquette | 1:7a8764e627b5 | 9 | |
gvaquette | 1:7a8764e627b5 | 10 | |
gvaquette | 0:0a75a79d6b77 | 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 | 1:7a8764e627b5 | 19 | while(1) |
gvaquette | 1:7a8764e627b5 | 20 | { |
gvaquette | 1:7a8764e627b5 | 21 | switch (user_choice) |
gvaquette | 1:7a8764e627b5 | 22 | { |
gvaquette | 1:7a8764e627b5 | 23 | case ULTRASONIC : |
gvaquette | 1:7a8764e627b5 | 24 | do |
gvaquette | 1:7a8764e627b5 | 25 | { |
gvaquette | 1:7a8764e627b5 | 26 | ft_print_all_values_US(ultra_sonic, pc); |
gvaquette | 1:7a8764e627b5 | 27 | } while (!pc.readable()); |
gvaquette | 1:7a8764e627b5 | 28 | user_choice = ft_get_user_choice(pc); |
gvaquette | 1:7a8764e627b5 | 29 | pc.printf("\n"); |
gvaquette | 1:7a8764e627b5 | 30 | break; |
gvaquette | 1:7a8764e627b5 | 31 | |
gvaquette | 1:7a8764e627b5 | 32 | case COMPASS : |
gvaquette | 1:7a8764e627b5 | 33 | do |
gvaquette | 1:7a8764e627b5 | 34 | { |
gvaquette | 1:7a8764e627b5 | 35 | ft_print_compass_values(compass, pc); |
gvaquette | 1:7a8764e627b5 | 36 | } while (!pc.readable()); |
gvaquette | 1:7a8764e627b5 | 37 | pc.printf("\n"); |
gvaquette | 1:7a8764e627b5 | 38 | user_choice = ft_get_user_choice(pc); |
gvaquette | 1:7a8764e627b5 | 39 | break; |
gvaquette | 2:8153195b1672 | 40 | |
gvaquette | 2:8153195b1672 | 41 | case CNY70 : |
gvaquette | 2:8153195b1672 | 42 | do |
gvaquette | 2:8153195b1672 | 43 | { |
gvaquette | 2:8153195b1672 | 44 | pc.printf("\r CNY_1"); |
gvaquette | 2:8153195b1672 | 45 | ft_print_cny_analog_voltage(CNY1, pc); |
gvaquette | 2:8153195b1672 | 46 | pc.printf("\t CNY_2"); |
gvaquette | 2:8153195b1672 | 47 | ft_print_cny_analog_voltage(CNY2, pc); |
gvaquette | 2:8153195b1672 | 48 | pc.printf("\t CNY_3"); |
gvaquette | 2:8153195b1672 | 49 | ft_print_cny_analog_voltage(CNY3, pc); |
gvaquette | 2:8153195b1672 | 50 | } while (!pc.readable()); |
gvaquette | 2:8153195b1672 | 51 | pc.printf("\n"); |
gvaquette | 2:8153195b1672 | 52 | user_choice = ft_get_user_choice(pc); |
gvaquette | 2:8153195b1672 | 53 | break; |
gvaquette | 2:8153195b1672 | 54 | |
gvaquette | 2:8153195b1672 | 55 | |
gvaquette | 1:7a8764e627b5 | 56 | default : |
gvaquette | 1:7a8764e627b5 | 57 | ft_print_test_menu(pc); |
gvaquette | 1:7a8764e627b5 | 58 | user_choice = ft_get_user_choice(pc); |
gvaquette | 1:7a8764e627b5 | 59 | break; |
gvaquette | 1:7a8764e627b5 | 60 | } |
gvaquette | 1:7a8764e627b5 | 61 | } |
gvaquette | 1:7a8764e627b5 | 62 | |
gvaquette | 0:0a75a79d6b77 | 63 | } |