Merge "adjusted the scoring positions"
diff --git a/y2019/jevois/teensy.cc b/y2019/jevois/teensy.cc
index a3b93d2..539d7b6 100644
--- a/y2019/jevois/teensy.cc
+++ b/y2019/jevois/teensy.cc
@@ -333,6 +333,44 @@
   return SpiPackToRoborio(message);
 }
 
+// Manages turning the debug light on and off periodically.
+//
+// It blinks at 1Hz with a variable duty cycle.
+class DebugLight {
+ public:
+  static constexpr aos::monotonic_clock::duration period() {
+    return std::chrono::seconds(1);
+  }
+
+  void set_next_off_time(aos::monotonic_clock::duration next_off_time) {
+    next_off_time_ = next_off_time;
+  }
+
+  void Tick() {
+    const auto now = aos::monotonic_clock::now();
+    if (last_cycle_start_ == aos::monotonic_clock::min_time) {
+      last_cycle_start_ = now;
+      current_off_point_ = last_cycle_start_ + next_off_time_;
+    } else if (now > last_cycle_start_ + period()) {
+      last_cycle_start_ += period();
+      current_off_point_ = last_cycle_start_ + next_off_time_;
+    }
+    if (now > current_off_point_) {
+      GPIOC_PCOR = 1 << 5;
+    } else {
+      GPIOC_PSOR = 1 << 5;
+    }
+  }
+
+ private:
+  aos::monotonic_clock::time_point last_cycle_start_ =
+      aos::monotonic_clock::min_time;
+
+  aos::monotonic_clock::duration next_off_time_ = std::chrono::milliseconds(100);
+  aos::monotonic_clock::time_point current_off_point_ =
+      aos::monotonic_clock::min_time;
+};
+
 extern "C" {
 
 void *__stack_chk_guard = (void *)0x67111971;
@@ -588,9 +626,12 @@
       aos::monotonic_clock::min_time;
   CameraCommand stdin_camera_command = CameraCommand::kNormal;
   CameraCommand last_roborio_camera_command = CameraCommand::kNormal;
+  DebugLight debug_light;
 
   bool first = true;
   while (true) {
+    debug_light.Tick();
+
     {
       const auto received_transfer = SpiQueue::global_instance->Tick();
       if (received_transfer) {
@@ -650,6 +691,14 @@
         } else {
           calibration.camera_command = stdin_camera_command;
         }
+        if (calibration.camera_command == CameraCommand::kUsb) {
+          debug_light.set_next_off_time(std::chrono::milliseconds(900));
+        } else if (calibration.camera_command ==
+                   CameraCommand::kCameraPassthrough) {
+          debug_light.set_next_off_time(std::chrono::milliseconds(500));
+        } else {
+          debug_light.set_next_off_time(std::chrono::milliseconds(100));
+        }
         // TODO(Brian): Actually fill out the calibration field.
         transmit_buffers[0].MaybeWritePacket(calibration);
         transmit_buffers[1].MaybeWritePacket(calibration);
diff --git a/y2019/vision/tools/deploy.sh b/y2019/vision/tools/deploy.sh
index 4ad926f..ff3ee01 100755
--- a/y2019/vision/tools/deploy.sh
+++ b/y2019/vision/tools/deploy.sh
@@ -1,4 +1,12 @@
 #!/bin/sh
+echo "Building executables"
+readonly BAZEL_OPTIONS="-c opt --cpu=armhf-debian"
+readonly BAZEL_BIN="$(bazel info ${BAZEL_OPTIONS} bazel-bin)"
+
+bazel build ${BAZEL_OPTIONS} \
+    //y2019/vision:target_sender \
+    //y2019/vision:serial_waiter
+
 echo "Mount jevois ..."
 ./jevois-cmd usbsd
 
@@ -11,6 +19,11 @@
 
 echo "Copying files ..."
 cp ./austin_cam.sh /media/$USER/JEVOIS/
+cp ./launch.sh /media/$USER/JEVOIS/deploy/
+
+cp "${BAZEL_BIN}/y2019/vision/target_sender" \
+  "${BAZEL_BIN}/y2019/vision/serial_waiter" \
+  /media/$USER/JEVOIS/deploy/
 
 echo "Unmount sd card ..."
 umount /media/$USER/JEVOIS
diff --git a/y2019/vision/tools/launch.sh b/y2019/vision/tools/launch.sh
index f2bd68d..b23fe2c 100755
--- a/y2019/vision/tools/launch.sh
+++ b/y2019/vision/tools/launch.sh
@@ -1 +1,5 @@
+if /jevois/deploy/serial_waiter; then
+  /jevois/deploy/target_sender &> /jevois/log.log
+fi
+
 touch /tmp/do_not_export_sd_card