NerfUS mobile node that manages a target for the Nerf gun firing range
Dependencies: LedController mbed-rtos mbed NerfUSXbee Servomotor TargetManager
Fork of NerfUS by
Diff: source/TargetManager.cpp
- Revision:
- 38:70a1c8bd2877
- Parent:
- 37:8fc7845ae95b
- Child:
- 39:a98413395b20
diff -r 8fc7845ae95b -r 70a1c8bd2877 source/TargetManager.cpp --- a/source/TargetManager.cpp Sat Apr 08 14:08:37 2017 -0400 +++ b/source/TargetManager.cpp Sun Apr 09 13:12:22 2017 -0400 @@ -1,9 +1,9 @@ #include "TargetManager.hpp" TargetManager::TargetManager(std::vector<TargetInterface*>& targets, - NerfusTickerInterface& nerfus_ticker) : + std::vector<NerfusTickerInterface*>& nerfus_tickers) : targets(targets), - nerfus_ticker(nerfus_ticker) + nerfus_tickers(nerfus_tickers) { for(int i=0; i<targets.size(); i++) { @@ -26,7 +26,7 @@ is_active_target[target_info.id] = true; - nerfus_ticker.start(target_info.timeout_ms); + nerfus_tickers[target_info.id]->start(target_info.timeout_ms); } void TargetManager::execute(const std::vector<uint8_t>& target_info_bytes, int *address) @@ -44,8 +44,8 @@ { if(is_active_target[target_number]) { - targets[target_number]->hit(nerfus_ticker.get_time_ms()); - nerfus_ticker.stop(); + targets[target_number]->hit(nerfus_tickers[target_number]->get_time_ms()); + nerfus_tickers[target_number]->stop(); is_active_target[target_number] = false; } } @@ -54,8 +54,8 @@ { if(is_active_target[target_number]) { - targets[target_number]->timeout(nerfus_ticker.get_time_ms()); - nerfus_ticker.stop(); + targets[target_number]->timeout(nerfus_tickers[target_number]->get_time_ms()); + nerfus_tickers[target_number]->stop(); is_active_target[target_number] = false; } }