TargetManager manual test

Dependencies:   TargetManager mbed

Files at this revision

API Documentation at this revision

Comitter:
GaiSensei
Date:
Sun Apr 09 23:46:10 2017 +0000
Parent:
10:766bb1c03153
Commit message:
Make sure a bumper hit doesn't mess with the ticker

Changed in this revision

TargetManager.lib Show annotated file Show diff for this revision Revisions of this file
TestTargetManager.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 766bb1c03153 -r d07c9f451088 TargetManager.lib
--- a/TargetManager.lib	Sun Apr 09 17:20:27 2017 +0000
+++ b/TargetManager.lib	Sun Apr 09 23:46:10 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/NerfUS/code/TargetManager/#c8f69a35a9a9
+https://developer.mbed.org/teams/NerfUS/code/TargetManager/#1069bd8c9472
diff -r 766bb1c03153 -r d07c9f451088 TestTargetManager.cpp
--- a/TestTargetManager.cpp	Sun Apr 09 17:20:27 2017 +0000
+++ b/TestTargetManager.cpp	Sun Apr 09 23:46:10 2017 +0000
@@ -15,6 +15,7 @@
 
 void TestTargetManager::target_hit(int target_number)
 {
+    target_timeout_tickers[target_number]->stop();
     std::printf("Target #%d hit after %d ms\r\n", target_number, target_timeout_tickers[target_number]->get_time_ms());
 }
 
diff -r 766bb1c03153 -r d07c9f451088 main.cpp
--- a/main.cpp	Sun Apr 09 17:20:27 2017 +0000
+++ b/main.cpp	Sun Apr 09 23:46:10 2017 +0000
@@ -9,11 +9,12 @@
 {
     printf("Start TargetManager manual test\r\n");
     printf("Instruction:\r\n");
-    printf("\tNerfusTicker works if target #0 is missed before target #1\r\n");
+    printf("\tNerfusTicker works if target #0 is missed by default and target #1 is always hit\r\n");
     printf("\tBumper works if a target hit is printed when you click the limit switch\r\n");
     printf("\t\tLimit switch connections: C(p5), NO(VCC), NC(GND)\r\n");
     
-    PinName bumper_pin = p5;
+    PinName bumper_pin_0 = p5;
+    PinName bumper_pin_1 = p6;
     
     //Tickers
     NerfusTicker target_timeout_ticker_0;
@@ -29,13 +30,17 @@
     target_timeout_ticker_0.init(&target_missed_callback_0);
     target_timeout_ticker_1.init(&target_missed_callback_1);
     
-    TargetHitCallback target_hit_callback(target_manager, 0);
-    Bumper bumper(bumper_pin, target_hit_callback);
+    TargetHitCallback target_hit_callback_0(target_manager, 0);
+    TargetHitCallback target_hit_callback_1(target_manager, 1);
+    Bumper bumper_0(bumper_pin_0, target_hit_callback_0);
+    Bumper bumper_1(bumper_pin_1, target_hit_callback_1);
     
     while(true)
     {
         target_timeout_ticker_0.start(500);
         target_timeout_ticker_1.start(1000);
+        wait_ms(750);
+        bumper_1.bumped();
         wait_ms(1500);
     }
 }