mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Remove PWM.Period enum
Replace it with just numeric values.
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class {{ name }} extends PWMMotorController {
|
||||
super("{{ name }}", channel);
|
||||
|
||||
setBoundsMicroseconds({{ (pulse_width_ms.max * 1000) | int }}, {{ (pulse_width_ms.deadbandMax * 1000) | int }}, {{ (pulse_width_ms.center * 1000) | int }}, {{ (pulse_width_ms.deadbandMin * 1000) | int }}, {{ (pulse_width_ms.min * 1000) | int }});
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k{{ OutputPeriod | default("5", true)}}Ms);
|
||||
m_pwm.setOutputPeriod({{ OutputPeriod | default("5", true)}});
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "{{ ResourceName }}");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class Koors40 extends PWMMotorController {
|
||||
super("Koors40", channel);
|
||||
|
||||
setBoundsMicroseconds(2004, 1520, 1500, 1480, 997);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k20Ms);
|
||||
m_pwm.setOutputPeriod(20);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "Koors40");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class PWMSparkFlex extends PWMMotorController {
|
||||
super("PWMSparkFlex", channel);
|
||||
|
||||
setBoundsMicroseconds(2003, 1550, 1500, 1460, 999);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "RevSparkFlexPWM");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class PWMSparkMax extends PWMMotorController {
|
||||
super("PWMSparkMax", channel);
|
||||
|
||||
setBoundsMicroseconds(2003, 1550, 1500, 1460, 999);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "RevSparkMaxPWM");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class PWMTalonFX extends PWMMotorController {
|
||||
super("PWMTalonFX", channel);
|
||||
|
||||
setBoundsMicroseconds(2004, 1520, 1500, 1480, 997);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "TalonFX");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class PWMTalonSRX extends PWMMotorController {
|
||||
super("PWMTalonSRX", channel);
|
||||
|
||||
setBoundsMicroseconds(2004, 1520, 1500, 1480, 997);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "PWMTalonSRX");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class PWMVenom extends PWMMotorController {
|
||||
super("PWMVenom", channel);
|
||||
|
||||
setBoundsMicroseconds(2004, 1520, 1500, 1480, 997);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "FusionVenom");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class PWMVictorSPX extends PWMMotorController {
|
||||
super("PWMVictorSPX", channel);
|
||||
|
||||
setBoundsMicroseconds(2004, 1520, 1500, 1480, 997);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "PWMVictorSPX");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class Spark extends PWMMotorController {
|
||||
super("Spark", channel);
|
||||
|
||||
setBoundsMicroseconds(2003, 1550, 1500, 1460, 999);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "RevSPARK");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class SparkMini extends PWMMotorController {
|
||||
super("SparkMini", channel);
|
||||
|
||||
setBoundsMicroseconds(2500, 1510, 1500, 1490, 500);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "RevSPARK");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class Talon extends PWMMotorController {
|
||||
super("Talon", channel);
|
||||
|
||||
setBoundsMicroseconds(2037, 1539, 1513, 1487, 989);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "Talon");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package org.wpilib.hardware.motor;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.hal.HAL;
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ public class VictorSP extends PWMMotorController {
|
||||
super("VictorSP", channel);
|
||||
|
||||
setBoundsMicroseconds(2004, 1520, 1500, 1480, 997);
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
|
||||
HAL.reportUsage("IO", getChannel(), "VictorSP");
|
||||
|
||||
@@ -20,16 +20,6 @@ import org.wpilib.util.sendable.SendableRegistry;
|
||||
* sent to the FPGA, and the update occurs at the next FPGA cycle (5.05ms). There is no delay.
|
||||
*/
|
||||
public class PWM implements Sendable, AutoCloseable {
|
||||
/** Represents the output period in microseconds. */
|
||||
public enum OutputPeriod {
|
||||
/** Pulse every 5ms. */
|
||||
k5Ms,
|
||||
/** Pulse every 10ms. */
|
||||
k10Ms,
|
||||
/** Pulse every 20ms. */
|
||||
k20Ms
|
||||
}
|
||||
|
||||
private final int m_channel;
|
||||
|
||||
private int m_handle;
|
||||
@@ -120,14 +110,16 @@ public class PWM implements Sendable, AutoCloseable {
|
||||
/**
|
||||
* Sets the PWM output period.
|
||||
*
|
||||
* @param mult The output period to apply to this channel
|
||||
* @param millisecondPeriod The output period to apply to this channel, in milliseconds. Valid
|
||||
* values are 5ms, 10ms, and 20ms. Default is 20 ms.
|
||||
*/
|
||||
public void setOutputPeriod(OutputPeriod mult) {
|
||||
public void setOutputPeriod(int millisecondPeriod) {
|
||||
int scale =
|
||||
switch (mult) {
|
||||
case k20Ms -> 3;
|
||||
case k10Ms -> 1;
|
||||
case k5Ms -> 0;
|
||||
switch (millisecondPeriod) {
|
||||
case 5 -> 0;
|
||||
case 10 -> 1;
|
||||
case 20 -> 3;
|
||||
default -> 3; // default to 20ms if invalid value is given
|
||||
};
|
||||
|
||||
PWMJNI.setPWMOutputPeriod(m_handle, scale);
|
||||
|
||||
Reference in New Issue
Block a user