Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TargetManager mbed
main.cpp
00001 #include "mbed.h" 00002 #include "Bumper.hpp" 00003 #include "TargetHitCallback.hpp" 00004 #include "TestTargetManager.hpp" 00005 #include "TargetMissedCallback.hpp" 00006 #include "NerfusTicker.hpp" 00007 00008 int main() 00009 { 00010 printf("Start TargetManager manual test\r\n"); 00011 printf("Instruction:\r\n"); 00012 printf("\tNerfusTicker works if target #0 is missed by default and target #1 is always hit\r\n"); 00013 printf("\tBumper works if a target hit is printed when you click the limit switch\r\n"); 00014 printf("\t\tLimit switch connections: C(p5), NO(VCC), NC(GND)\r\n"); 00015 00016 PinName bumper_pin_0 = p5; 00017 PinName bumper_pin_1 = p6; 00018 00019 //Tickers 00020 NerfusTicker target_timeout_ticker_0; 00021 NerfusTicker target_timeout_ticker_1; 00022 std::vector<NerfusTickerInterface*> tickers; 00023 tickers.push_back(&target_timeout_ticker_0); 00024 tickers.push_back(&target_timeout_ticker_1); 00025 00026 TestTargetManager target_manager(tickers); 00027 00028 TargetMissedCallback target_missed_callback_0(target_manager, 0); 00029 TargetMissedCallback target_missed_callback_1(target_manager, 1); 00030 target_timeout_ticker_0.init(&target_missed_callback_0); 00031 target_timeout_ticker_1.init(&target_missed_callback_1); 00032 00033 TargetHitCallback target_hit_callback_0(target_manager, 0); 00034 TargetHitCallback target_hit_callback_1(target_manager, 1); 00035 Bumper bumper_0(bumper_pin_0, target_hit_callback_0); 00036 Bumper bumper_1(bumper_pin_1, target_hit_callback_1); 00037 00038 while(true) 00039 { 00040 target_timeout_ticker_0.start(500); 00041 target_timeout_ticker_1.start(1000); 00042 wait_ms(750); 00043 bumper_1.bumped(); 00044 wait_ms(1500); 00045 } 00046 }
Generated on Thu Jul 21 2022 23:56:01 by
1.7.2