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 NerfUS

Revision:
19:377887760869
Parent:
18:353fb432c03c
Child:
20:05e2c4941285
diff -r 353fb432c03c -r 377887760869 source/Target.cpp
--- a/source/Target.cpp	Wed Mar 08 12:24:17 2017 -0500
+++ b/source/Target.cpp	Wed Mar 08 13:56:18 2017 -0500
@@ -1,9 +1,10 @@
 #include "Target.hpp"
 
 
-Target::Target(ServomotorInterface& servomotor, LedControllerInterface& led_controller):
+Target::Target(ServomotorInterface& servomotor, LedControllerInterface& led_controller, XbeeTransmitterInterface& xbee_transmitter):
     servomotor(servomotor),
-    led_controller(led_controller)
+    led_controller(led_controller),
+    xbee_transmitter(xbee_transmitter)
 {
 }
 
@@ -31,3 +32,17 @@
     servomotor.set_position_up();
 }
 
+std::vector<uint8_t> Target::generate_message(uint8_t target_number, Result result, uint16_t timeout_ms) const
+{
+    const uint8_t target_number_and_result = (target_number << 3) + result;
+    const uint8_t timeout_ms_msb = timeout_ms >> 8;
+    const uint8_t timeout_ms_lsb = (timeout_ms << 8) >> 8;
+
+    std::vector<uint8_t> message;
+
+    message.push_back(target_number_and_result);
+    message.push_back(timeout_ms_msb);
+    message.push_back(timeout_ms_lsb);
+
+    return message;
+}