Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions strongback/src/org/strongback/hardware/Hardware.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <a href="http://www.revrobotics.com/SPARK">RevRobotics Spark Motor Controller</a> 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 <a href="http://www.revrobotics.com/SPARK">RevRobotics Spark Motor Controller</a> 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);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion strongback/src/org/strongback/hardware/HardwareMotor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 35 additions & 0 deletions strongback/src/org/strongback/hardware/HardwareSpark.java
Original file line number Diff line number Diff line change
@@ -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);
}
}