Add an option to send 'a' repeatedly
Change-Id: I81239d802035ecfb760c483b8b0d83c66a643f5d
diff --git a/y2019/jevois/structures.h b/y2019/jevois/structures.h
index b6db24e..676b46c 100644
--- a/y2019/jevois/structures.h
+++ b/y2019/jevois/structures.h
@@ -141,6 +141,9 @@
kCameraPassthrough,
// Go to being a useful USB device.
kUsb,
+ // Send As, which triggers the bootstrap script to drop directly into USB
+ // mode.
+ kAs,
};
// This is all the information sent from the Teensy to each camera.
diff --git a/y2019/jevois/teensy.cc b/y2019/jevois/teensy.cc
index 84b98b0..7fd7b15 100644
--- a/y2019/jevois/teensy.cc
+++ b/y2019/jevois/teensy.cc
@@ -87,6 +87,12 @@
buffer.PushSingle(0);
}
}
+
+ void FillAs() {
+ while (!buffer.full()) {
+ buffer.PushSingle('a');
+ }
+ }
};
InterruptBufferedSpi *global_spi_instance = nullptr;
@@ -368,7 +374,8 @@
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::duration next_off_time_ =
+ std::chrono::milliseconds(100);
aos::monotonic_clock::time_point current_off_point_ =
aos::monotonic_clock::min_time;
};
@@ -682,30 +689,38 @@
}
{
const auto now = aos::monotonic_clock::now();
- if (last_camera_send + std::chrono::milliseconds(1000) < now) {
- last_camera_send = now;
- CameraCalibration calibration{};
- calibration.teensy_now = aos::monotonic_clock::now();
- calibration.realtime_now = aos::realtime_clock::min_time;
- if (last_roborio_camera_command != CameraCommand::kNormal) {
- calibration.camera_command = last_roborio_camera_command;
- } else {
- calibration.camera_command = stdin_camera_command;
+ CameraCommand current_camera_command = CameraCommand::kNormal;
+ if (last_roborio_camera_command != CameraCommand::kNormal) {
+ current_camera_command = last_roborio_camera_command;
+ } else {
+ current_camera_command = stdin_camera_command;
+ }
+ if (current_camera_command == CameraCommand::kUsb) {
+ debug_light.set_next_off_time(std::chrono::milliseconds(900));
+ } else if (current_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));
+ }
+
+ if (current_camera_command == CameraCommand::kAs) {
+ for (size_t i = 0; i < transmit_buffers.size(); ++i) {
+ transmit_buffers[i].FillAs();
}
- 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));
+ } else {
+ if (last_camera_send + std::chrono::milliseconds(1000) < now) {
+ last_camera_send = now;
+ CameraCalibration calibration{};
+ calibration.teensy_now = aos::monotonic_clock::now();
+ calibration.realtime_now = aos::realtime_clock::min_time;
+ calibration.camera_command = current_camera_command;
+ // TODO(Brian): Actually fill out the calibration field.
+ transmit_buffers[0].MaybeWritePacket(calibration);
+ transmit_buffers[1].MaybeWritePacket(calibration);
+ transmit_buffers[2].MaybeWritePacket(calibration);
+ transmit_buffers[3].MaybeWritePacket(calibration);
+ transmit_buffers[4].MaybeWritePacket(calibration);
}
- // TODO(Brian): Actually fill out the calibration field.
- transmit_buffers[0].MaybeWritePacket(calibration);
- transmit_buffers[1].MaybeWritePacket(calibration);
- transmit_buffers[2].MaybeWritePacket(calibration);
- transmit_buffers[3].MaybeWritePacket(calibration);
- transmit_buffers[4].MaybeWritePacket(calibration);
}
for (TransmitBuffer &transmit_buffer : transmit_buffers) {
transmit_buffer.Tick(now);
@@ -728,6 +743,10 @@
printf("Entering normal mode\n");
stdin_camera_command = CameraCommand::kNormal;
break;
+ case 'a':
+ printf("Entering all-A mode\n");
+ stdin_camera_command = CameraCommand::kAs;
+ break;
default:
printf("Unrecognized character\n");
break;
diff --git a/y2019/vision/target_sender.cc b/y2019/vision/target_sender.cc
index 4c14969..2801c61 100644
--- a/y2019/vision/target_sender.cc
+++ b/y2019/vision/target_sender.cc
@@ -390,6 +390,7 @@
switch (calibration.camera_command) {
case CameraCommand::kNormal:
+ case CameraCommand::kAs:
break;
case CameraCommand::kUsb:
return 0;