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
source/Target.cpp@18:353fb432c03c, 2017-03-08 (annotated)
- Committer:
- Maxime Dupuis
- Date:
- Wed Mar 08 12:24:17 2017 -0500
- Revision:
- 18:353fb432c03c
- Child:
- 19:377887760869
Implement 1st draft of Target execute_command
Raise servomotor and turn on LED if necessary
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Maxime Dupuis |
18:353fb432c03c | 1 | #include "Target.hpp" |
Maxime Dupuis |
18:353fb432c03c | 2 | |
Maxime Dupuis |
18:353fb432c03c | 3 | |
Maxime Dupuis |
18:353fb432c03c | 4 | Target::Target(ServomotorInterface& servomotor, LedControllerInterface& led_controller): |
Maxime Dupuis |
18:353fb432c03c | 5 | servomotor(servomotor), |
Maxime Dupuis |
18:353fb432c03c | 6 | led_controller(led_controller) |
Maxime Dupuis |
18:353fb432c03c | 7 | { |
Maxime Dupuis |
18:353fb432c03c | 8 | } |
Maxime Dupuis |
18:353fb432c03c | 9 | |
Maxime Dupuis |
18:353fb432c03c | 10 | void Target::execute_command(Mode mode, int timeout_ms) |
Maxime Dupuis |
18:353fb432c03c | 11 | { |
Maxime Dupuis |
18:353fb432c03c | 12 | if(mode == Ally) |
Maxime Dupuis |
18:353fb432c03c | 13 | { |
Maxime Dupuis |
18:353fb432c03c | 14 | ally_command(); |
Maxime Dupuis |
18:353fb432c03c | 15 | } |
Maxime Dupuis |
18:353fb432c03c | 16 | else |
Maxime Dupuis |
18:353fb432c03c | 17 | { |
Maxime Dupuis |
18:353fb432c03c | 18 | enemy_command(); |
Maxime Dupuis |
18:353fb432c03c | 19 | } |
Maxime Dupuis |
18:353fb432c03c | 20 | } |
Maxime Dupuis |
18:353fb432c03c | 21 | |
Maxime Dupuis |
18:353fb432c03c | 22 | |
Maxime Dupuis |
18:353fb432c03c | 23 | void Target::ally_command() |
Maxime Dupuis |
18:353fb432c03c | 24 | { |
Maxime Dupuis |
18:353fb432c03c | 25 | servomotor.set_position_up(); |
Maxime Dupuis |
18:353fb432c03c | 26 | } |
Maxime Dupuis |
18:353fb432c03c | 27 | |
Maxime Dupuis |
18:353fb432c03c | 28 | void Target::enemy_command() |
Maxime Dupuis |
18:353fb432c03c | 29 | { |
Maxime Dupuis |
18:353fb432c03c | 30 | led_controller.turn_on(); |
Maxime Dupuis |
18:353fb432c03c | 31 | servomotor.set_position_up(); |
Maxime Dupuis |
18:353fb432c03c | 32 | } |
Maxime Dupuis |
18:353fb432c03c | 33 |