diff --git a/strongback/src/org/strongback/hardware/Hardware.java b/strongback/src/org/strongback/hardware/Hardware.java
index eb6b681..35169d7 100644
--- a/strongback/src/org/strongback/hardware/Hardware.java
+++ b/strongback/src/org/strongback/hardware/Hardware.java
@@ -58,6 +58,7 @@
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.PowerDistributionPanel;
import edu.wpi.first.wpilibj.SPI;
+import edu.wpi.first.wpilibj.Spark;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Ultrasonic;
import edu.wpi.first.wpilibj.Victor;
@@ -692,6 +693,29 @@ public static TalonSRX talonSRX(int deviceNumber, TalonSRX leader, boolean rever
talon.reverseOutput(reverse);
return talonSRX(talon, 0.0d, 0.0d);
}
+
+ /**
+ * Create a motor driven by a RevRobotics Spark Motor Controller on the
+ * specified channel. The speed output is limited to [-1.0,1.0] inclusive.
+ *
+ * @param channel the channel the controller is connected to
+ * @return a motor on the specified channel
+ */
+ public static Motor spark(int channel) {
+ return spark(channel, SPEED_LIMITER);
+ }
+
+ /**
+ * Create a motor driven by a RevRobotics Spark Motor Controller on the
+ * specified channel, with a custom speed limiting function.
+ *
+ * @param channel the channel the controller is connected to
+ * @param speedLimiter function that will be used to limit the speed (input voltage); may not be null
+ * @return a motor on the specified channel
+ */
+ public static Motor spark(int channel, DoubleToDoubleFunction speedLimiter) {
+ return new HardwareSpark(new Spark(channel), SPEED_LIMITER);
+ }
}
/**
diff --git a/strongback/src/org/strongback/hardware/HardwareMotor.java b/strongback/src/org/strongback/hardware/HardwareMotor.java
index e96f8f2..ebbe6ac 100644
--- a/strongback/src/org/strongback/hardware/HardwareMotor.java
+++ b/strongback/src/org/strongback/hardware/HardwareMotor.java
@@ -30,7 +30,7 @@
* @see Hardware
* @see edu.wpi.first.wpilibj.SpeedController
*/
-final class HardwareMotor implements Motor {
+class HardwareMotor implements Motor {
private final SpeedController controller;
private final DoubleToDoubleFunction speedValidator;
diff --git a/strongback/src/org/strongback/hardware/HardwareSpark.java b/strongback/src/org/strongback/hardware/HardwareSpark.java
new file mode 100644
index 0000000..ef55927
--- /dev/null
+++ b/strongback/src/org/strongback/hardware/HardwareSpark.java
@@ -0,0 +1,35 @@
+/*
+ * Strongback
+ * Copyright 2017, Strongback and individual contributors by the @authors tag.
+ * See the COPYRIGHT.txt in the distribution for a full listing of individual
+ * contributors.
+ *
+ * Licensed under the MIT License; you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://opensource.org/licenses/MIT
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.strongback.hardware;
+
+import org.strongback.annotation.Immutable;
+import org.strongback.function.DoubleToDoubleFunction;
+
+import edu.wpi.first.wpilibj.SpeedController;
+
+/**
+ * RevRobotics Spark motor controller.
+ *
+ * @author Randall Hauch
+ */
+@Immutable
+class HardwareSpark extends HardwareMotor {
+
+ HardwareSpark(SpeedController controller, DoubleToDoubleFunction speedValidator ) {
+ super(controller,speedValidator);
+ }
+}
\ No newline at end of file