Turn the red LED on and off
Not sure which is which on green vs blue, so just turn those off for
now.
Change-Id: I305d896d9c23da32b1c3699b58dce67e07b606f1
diff --git a/third_party/Phoenix-frc-lib/BUILD b/third_party/Phoenix-frc-lib/BUILD
index 555cfea..7a1934a 100644
--- a/third_party/Phoenix-frc-lib/BUILD
+++ b/third_party/Phoenix-frc-lib/BUILD
@@ -13,7 +13,9 @@
"cpp/src/RCRadio3Ch.cpp",
"cpp/src/CompileTest.cpp",
],
- ),
+ ) + [
+ "libraries/driver/lib/libCTRE_PhoenixCCI.a",
+ ],
hdrs = glob(
include = [
"cpp/include/**/*.h",
@@ -29,6 +31,7 @@
"libraries/driver/include",
],
restricted_to = ["//tools:roborio"],
+ visibility = ["//visibility:public"],
deps = [
"//third_party:wpilib",
],
diff --git a/y2018/BUILD b/y2018/BUILD
index 89e2581..1ff531c 100644
--- a/y2018/BUILD
+++ b/y2018/BUILD
@@ -1,4 +1,5 @@
load("//aos/downloader:downloader.bzl", "aos_downloader")
+load("//aos/build:queues.bzl", "queue_library")
aos_downloader(
name = "download",
@@ -80,6 +81,7 @@
],
restricted_to = ["//tools:roborio"],
deps = [
+ ":status_light",
"//aos/common:math",
"//aos/common:stl_mutex",
"//aos/common:time",
@@ -107,7 +109,15 @@
"//frc971/wpilib:wpilib_interface",
"//frc971/wpilib:wpilib_robot_base",
"//third_party:wpilib",
+ "//third_party/Phoenix-frc-lib:phoenix",
"//y2018:constants",
"//y2018/control_loops/superstructure:superstructure_queue",
],
)
+
+queue_library(
+ name = "status_light",
+ srcs = [
+ "status_light.q",
+ ],
+)
diff --git a/y2018/status_light.q b/y2018/status_light.q
new file mode 100644
index 0000000..246744c
--- /dev/null
+++ b/y2018/status_light.q
@@ -0,0 +1,10 @@
+package y2018;
+
+message StatusLight {
+ // How bright to make each one. 0 is off, 1 is full on.
+ float red;
+ float green;
+ float blue;
+};
+
+queue StatusLight status_light;
diff --git a/y2018/wpilib_interface.cc b/y2018/wpilib_interface.cc
index b43f421..0426444 100644
--- a/y2018/wpilib_interface.cc
+++ b/y2018/wpilib_interface.cc
@@ -18,6 +18,7 @@
#include "Relay.h"
#include "Servo.h"
#include "VictorSP.h"
+#include "ctre/phoenix/CANifier.h"
#undef ERROR
#include "aos/common/commonmath.h"
@@ -50,6 +51,7 @@
#include "frc971/wpilib/wpilib_robot_base.h"
#include "y2018/constants.h"
#include "y2018/control_loops/superstructure/superstructure.q.h"
+#include "y2018/status_light.q.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
@@ -645,6 +647,19 @@
to_log.read_solenoids = pcm_->GetAll();
LOG_STRUCT(DEBUG, "pneumatics info", to_log);
}
+
+ status_light.FetchLatest();
+ if (status_light.get()) {
+ LOG_STRUCT(DEBUG, "writing", *status_light);
+ // Not sure which of these is red vs green. We're not ready to use
+ // either,
+ // so just turn them off.
+ canifier_.SetLEDOutput(1.0, ::ctre::phoenix::CANifier::LEDChannelA);
+ canifier_.SetLEDOutput(1.0, ::ctre::phoenix::CANifier::LEDChannelB);
+ // Red
+ canifier_.SetLEDOutput(1 - status_light->red,
+ ::ctre::phoenix::CANifier::LEDChannelC);
+ }
}
}
@@ -661,6 +676,8 @@
::aos::Queue<::y2018::control_loops::SuperstructureQueue::Output>
superstructure_;
+ ::ctre::phoenix::CANifier canifier_{0};
+
::std::atomic<bool> run_{true};
};