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:
@@ -4,7 +4,6 @@
|
||||
|
||||
package org.wpilib.romi;
|
||||
|
||||
import org.wpilib.hardware.discrete.PWM;
|
||||
import org.wpilib.hardware.motor.PWMMotorController;
|
||||
|
||||
/**
|
||||
@@ -15,7 +14,7 @@ import org.wpilib.hardware.motor.PWMMotorController;
|
||||
public class RomiMotor extends PWMMotorController {
|
||||
/** Common initialization code called by all constructors. */
|
||||
protected final void initRomiMotor() {
|
||||
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
|
||||
m_pwm.setOutputPeriod(5);
|
||||
setDutyCycle(0.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
using namespace wpi::romi;
|
||||
|
||||
RomiMotor::RomiMotor(int channel) : PWMMotorController("Romi Motor", channel) {
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
{{ name }}::{{ name }}(int channel) : PWMMotorController("{{ name }}", channel) {
|
||||
SetBounds({{ pulse_width_ms.max }}_ms, {{ pulse_width_ms.deadbandMax }}_ms, {{ pulse_width_ms.center }}_ms, {{ pulse_width_ms.deadbandMin }}_ms, {{ pulse_width_ms.min }}_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_{{ OutputPeriod | default("5", true)}}Ms);
|
||||
m_pwm.SetOutputPeriod({{ OutputPeriod | default("5", true)}}_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "{{ ResourceName }}");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
Koors40::Koors40(int channel) : PWMMotorController("Koors40", channel) {
|
||||
SetBounds(2.004_ms, 1.52_ms, 1.5_ms, 1.48_ms, 0.997_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_20Ms);
|
||||
m_pwm.SetOutputPeriod(20_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "Koors40");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
PWMSparkFlex::PWMSparkFlex(int channel) : PWMMotorController("PWMSparkFlex", channel) {
|
||||
SetBounds(2.003_ms, 1.55_ms, 1.5_ms, 1.46_ms, 0.999_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "RevSparkFlexPWM");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
PWMSparkMax::PWMSparkMax(int channel) : PWMMotorController("PWMSparkMax", channel) {
|
||||
SetBounds(2.003_ms, 1.55_ms, 1.5_ms, 1.46_ms, 0.999_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "RevSparkMaxPWM");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
PWMTalonFX::PWMTalonFX(int channel) : PWMMotorController("PWMTalonFX", channel) {
|
||||
SetBounds(2.004_ms, 1.52_ms, 1.5_ms, 1.48_ms, 0.997_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "TalonFX");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
PWMTalonSRX::PWMTalonSRX(int channel) : PWMMotorController("PWMTalonSRX", channel) {
|
||||
SetBounds(2.004_ms, 1.52_ms, 1.5_ms, 1.48_ms, 0.997_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "PWMTalonSRX");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
PWMVenom::PWMVenom(int channel) : PWMMotorController("PWMVenom", channel) {
|
||||
SetBounds(2.004_ms, 1.52_ms, 1.5_ms, 1.48_ms, 0.997_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "FusionVenom");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
PWMVictorSPX::PWMVictorSPX(int channel) : PWMMotorController("PWMVictorSPX", channel) {
|
||||
SetBounds(2.004_ms, 1.52_ms, 1.5_ms, 1.48_ms, 0.997_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "PWMVictorSPX");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
Spark::Spark(int channel) : PWMMotorController("Spark", channel) {
|
||||
SetBounds(2.003_ms, 1.55_ms, 1.5_ms, 1.46_ms, 0.999_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "RevSPARK");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
SparkMini::SparkMini(int channel) : PWMMotorController("SparkMini", channel) {
|
||||
SetBounds(2.5_ms, 1.51_ms, 1.5_ms, 1.49_ms, 0.5_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "RevSPARK");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
Talon::Talon(int channel) : PWMMotorController("Talon", channel) {
|
||||
SetBounds(2.037_ms, 1.539_ms, 1.513_ms, 1.487_ms, 0.989_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "Talon");
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace wpi;
|
||||
|
||||
VictorSP::VictorSP(int channel) : PWMMotorController("VictorSP", channel) {
|
||||
SetBounds(2.004_ms, 1.52_ms, 1.5_ms, 1.48_ms, 0.997_ms);
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
m_pwm.SetOutputPeriod(5_ms);
|
||||
SetDutyCycle(0.0);
|
||||
|
||||
HAL_ReportUsage("IO", GetChannel(), "VictorSP");
|
||||
|
||||
@@ -60,25 +60,23 @@ void PWM::SetDisabled() {
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
void PWM::SetOutputPeriod(OutputPeriod mult) {
|
||||
void PWM::SetOutputPeriod(wpi::units::millisecond_t period) {
|
||||
int32_t status = 0;
|
||||
|
||||
switch (mult) {
|
||||
case kOutputPeriod_20Ms:
|
||||
HAL_SetPWMOutputPeriod(m_handle, 3,
|
||||
&status); // Squelch 3 out of 4 outputs
|
||||
switch (static_cast<int>(period.value())) {
|
||||
case 5:
|
||||
// Don't squelch any outputs
|
||||
HAL_SetPWMOutputPeriod(m_handle, 0, &status);
|
||||
break;
|
||||
case kOutputPeriod_10Ms:
|
||||
HAL_SetPWMOutputPeriod(m_handle, 1,
|
||||
&status); // Squelch 1 out of 2 outputs
|
||||
case 10:
|
||||
// Squelch 1 out of 2 outputs
|
||||
HAL_SetPWMOutputPeriod(m_handle, 1, &status);
|
||||
break;
|
||||
case kOutputPeriod_5Ms:
|
||||
HAL_SetPWMOutputPeriod(m_handle, 0,
|
||||
&status); // Don't squelch any outputs
|
||||
case 20:
|
||||
default: // default to 20ms if invalid value is given
|
||||
// Squelch 3 out of 4 outputs
|
||||
HAL_SetPWMOutputPeriod(m_handle, 3, &status);
|
||||
break;
|
||||
default:
|
||||
throw WPILIB_MakeError(err::InvalidParameter, "OutputPeriod value {}",
|
||||
static_cast<int>(mult));
|
||||
}
|
||||
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
|
||||
@@ -26,23 +26,6 @@ class AddressableLED;
|
||||
class PWM : public wpi::util::Sendable, public wpi::util::SendableHelper<PWM> {
|
||||
public:
|
||||
friend class AddressableLED;
|
||||
/**
|
||||
* Represents the output period in microseconds.
|
||||
*/
|
||||
enum OutputPeriod {
|
||||
/**
|
||||
* PWM pulses occur every 5 ms
|
||||
*/
|
||||
kOutputPeriod_5Ms = 1,
|
||||
/**
|
||||
* PWM pulses occur every 10 ms
|
||||
*/
|
||||
kOutputPeriod_10Ms = 2,
|
||||
/**
|
||||
* PWM pulses occur every 20 ms
|
||||
*/
|
||||
kOutputPeriod_20Ms = 4
|
||||
};
|
||||
|
||||
/**
|
||||
* Allocate a PWM given a channel number.
|
||||
@@ -71,7 +54,7 @@ class PWM : public wpi::util::Sendable, public wpi::util::SendableHelper<PWM> {
|
||||
*
|
||||
* Write a microsecond value to a PWM channel.
|
||||
*
|
||||
* @param time Microsecond PWM value.
|
||||
* @param time Microsecond PWM value. Range 0 - 4096.
|
||||
*/
|
||||
void SetPulseTime(wpi::units::microsecond_t time);
|
||||
|
||||
@@ -80,7 +63,7 @@ class PWM : public wpi::util::Sendable, public wpi::util::SendableHelper<PWM> {
|
||||
*
|
||||
* Read a microsecond value from a PWM channel.
|
||||
*
|
||||
* @return Microsecond PWM control value.
|
||||
* @return Microsecond PWM control value. Range 0 - 4096.
|
||||
*/
|
||||
wpi::units::microsecond_t GetPulseTime() const;
|
||||
|
||||
@@ -93,9 +76,10 @@ class PWM : public wpi::util::Sendable, public wpi::util::SendableHelper<PWM> {
|
||||
/**
|
||||
* Sets the PWM output period.
|
||||
*
|
||||
* @param mult The output period to apply to this channel
|
||||
* @param period The output period to apply to this channel, in milliseconds.
|
||||
* Valid values are 5ms, 10ms, and 20ms. Default is 20 ms.
|
||||
*/
|
||||
void SetOutputPeriod(OutputPeriod mult);
|
||||
void SetOutputPeriod(wpi::units::millisecond_t period);
|
||||
|
||||
int GetChannel() const;
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ classes:
|
||||
wpi::PWM:
|
||||
ignored_bases:
|
||||
- wpi::util::SendableHelper<PWM>
|
||||
enums:
|
||||
OutputPeriod:
|
||||
methods:
|
||||
PWM:
|
||||
SetPulseTime:
|
||||
|
||||
@@ -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