Check that subsystem range is within pot voltage range

This checks that the subsystem range is within the potentiometer
voltage range, ensuring that the potentiometer won't break, even
at range extremes. The range that the potentiometer can handle
is 0 to 5 volts or -5 to 0 volts, so the subsystem positional
limits should be within these bounds.

Signed-off-by: Nathan Leong <100028864@mvla.net>
Change-Id: I3c7f06595541408111b4c393c6610acb635d4b07
diff --git a/frc971/wpilib/wpilib_utils.h b/frc971/wpilib/wpilib_utils.h
new file mode 100644
index 0000000..78dd262
--- /dev/null
+++ b/frc971/wpilib/wpilib_utils.h
@@ -0,0 +1,28 @@
+#ifndef FRC971_WPILIB_WPILIB_UTILS_H_
+#define FRC971_WPILIB_WPILIB_UTILS_H_
+
+#include <functional>
+
+#include "frc971/constants.h"
+
+namespace frc971 {
+namespace wpilib {
+
+// Convert min and max angle positions from range to voltage and compare to
+// min and max potentiometer voltage to check if in range.
+
+// subsystem_range is a ::frc971::constants::Range that defines the pot limits
+// potentiometer_offset is a constant that is the initial offset of the pot
+// pot_translate_inverse is a function that translates an angle to voltage
+// reverse is a boolean that sets the pot voltage range as -5 to 0 when true
+// limit_buffer is a constant that is the buffer for the maximum voltage values
+
+bool SafePotVoltageRange(::frc971::constants::Range subsystem_range,
+                         double potentiometer_offset,
+                         ::std::function<double(double)> pot_translate_inverse,
+                         bool reverse, double limit_buffer = 0.05);
+
+}  // namespace wpilib
+}  // namespace frc971
+
+#endif  // FRC971_WPILIB_WPILIB_UTILS_H_
\ No newline at end of file