diff --git a/wpilibc/src/main/native/cpp/motorcontrol/NidecBrushless.cpp b/wpilibc/src/main/native/cpp/motorcontrol/NidecBrushless.cpp deleted file mode 100644 index f0bf06c463..0000000000 --- a/wpilibc/src/main/native/cpp/motorcontrol/NidecBrushless.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "frc/motorcontrol/NidecBrushless.h" - -#include - -#include -#include -#include -#include - -using namespace frc; - -WPI_IGNORE_DEPRECATED - -NidecBrushless::NidecBrushless(int pwmChannel, int dioChannel) - : m_dio(dioChannel), m_pwm(pwmChannel) { - wpi::SendableRegistry::AddChild(this, &m_dio); - wpi::SendableRegistry::AddChild(this, &m_pwm); - SetExpiration(0_s); - SetSafetyEnabled(false); - - // the dio controls the output (in PWM mode) - m_dio.SetPWMRate(15625); - m_dio.EnablePWM(0.5); - - HAL_ReportUsage(fmt::format("IO[{},{}]", pwmChannel, dioChannel), - "NidecBrushless"); - wpi::SendableRegistry::Add(this, "Nidec Brushless", pwmChannel); -} - -WPI_UNIGNORE_DEPRECATED - -void NidecBrushless::Set(double speed) { - if (!m_disabled) { - m_speed = speed; - m_dio.UpdateDutyCycle(0.5 + 0.5 * (m_isInverted ? -speed : speed)); - m_pwm.SetAlwaysHighMode(); - } - Feed(); -} - -double NidecBrushless::Get() const { - return m_speed; -} - -void NidecBrushless::SetInverted(bool isInverted) { - m_isInverted = isInverted; -} - -bool NidecBrushless::GetInverted() const { - return m_isInverted; -} - -void NidecBrushless::Disable() { - m_disabled = true; - m_dio.UpdateDutyCycle(0.5); - m_pwm.SetDisabled(); -} - -void NidecBrushless::Enable() { - m_disabled = false; -} - -void NidecBrushless::StopMotor() { - m_dio.UpdateDutyCycle(0.5); - m_pwm.SetDisabled(); -} - -std::string NidecBrushless::GetDescription() const { - return fmt::format("Nidec {}", GetChannel()); -} - -int NidecBrushless::GetChannel() const { - return m_pwm.GetChannel(); -} - -void NidecBrushless::InitSendable(wpi::SendableBuilder& builder) { - builder.SetSmartDashboardType("Nidec Brushless"); - builder.SetActuator(true); - builder.AddDoubleProperty( - "Value", [=, this] { return Get(); }, - [=, this](double value) { Set(value); }); -} diff --git a/wpilibc/src/main/native/include/frc/motorcontrol/NidecBrushless.h b/wpilibc/src/main/native/include/frc/motorcontrol/NidecBrushless.h deleted file mode 100644 index d50c836170..0000000000 --- a/wpilibc/src/main/native/include/frc/motorcontrol/NidecBrushless.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include - -#include -#include -#include - -#include "frc/DigitalOutput.h" -#include "frc/MotorSafety.h" -#include "frc/PWM.h" -#include "frc/motorcontrol/MotorController.h" - -namespace frc { - -WPI_IGNORE_DEPRECATED - -/** - * Nidec Brushless Motor. - */ -class NidecBrushless : public MotorController, - public MotorSafety, - public wpi::Sendable, - public wpi::SendableHelper { - public: - /** - * Constructor. - * - * @param pwmChannel The PWM channel that the Nidec Brushless controller is - * attached to. 0-9 are on-board, 10-19 are on the MXP port. - * @param dioChannel The DIO channel that the Nidec Brushless controller is - * attached to. 0-9 are on-board, 10-25 are on the MXP port. - */ - NidecBrushless(int pwmChannel, int dioChannel); - - ~NidecBrushless() override = default; - - NidecBrushless(NidecBrushless&&) = default; - NidecBrushless& operator=(NidecBrushless&&) = default; - - // MotorController interface - /** - * Set the PWM value. - * - * The PWM value is set using a range of -1.0 to 1.0, appropriately scaling - * the value for the FPGA. - * - * @param speed The speed value between -1.0 and 1.0 to set. - */ - void Set(double speed) override; - - /** - * Get the recently set value of the PWM. - * - * @return The most recently set value for the PWM between -1.0 and 1.0. - */ - double Get() const override; - - void SetInverted(bool isInverted) override; - - bool GetInverted() const override; - - /** - * Disable the motor. The Enable() function must be called to re-enable the - * motor. - */ - void Disable() override; - - /** - * Re-enable the motor after Disable() has been called. The Set() function - * must be called to set a new motor speed. - */ - void Enable(); - - // MotorSafety interface - void StopMotor() override; - std::string GetDescription() const override; - - /** - * Gets the channel number associated with the object. - * - * @return The channel number. - */ - int GetChannel() const; - - // Sendable interface - void InitSendable(wpi::SendableBuilder& builder) override; - - private: - bool m_isInverted = false; - bool m_disabled = false; - DigitalOutput m_dio; - PWM m_pwm; - double m_speed = 0.0; -}; - -WPI_UNIGNORE_DEPRECATED - -} // namespace frc diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/NidecBrushless.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/NidecBrushless.java deleted file mode 100644 index 86a777d73a..0000000000 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/NidecBrushless.java +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.motorcontrol; - -import edu.wpi.first.hal.HAL; -import edu.wpi.first.util.sendable.Sendable; -import edu.wpi.first.util.sendable.SendableBuilder; -import edu.wpi.first.util.sendable.SendableRegistry; -import edu.wpi.first.wpilibj.DigitalOutput; -import edu.wpi.first.wpilibj.MotorSafety; -import edu.wpi.first.wpilibj.PWM; - -/** Nidec Brushless Motor. */ -@SuppressWarnings("removal") -public class NidecBrushless extends MotorSafety - implements MotorController, Sendable, AutoCloseable { - private boolean m_isInverted; - private final DigitalOutput m_dio; - private final PWM m_pwm; - private volatile double m_speed; - private volatile boolean m_disabled; - - /** - * Constructor. - * - * @param pwmChannel The PWM channel that the Nidec Brushless controller is attached to. 0-9 are - * on-board, 10-19 are on the MXP port - * @param dioChannel The DIO channel that the Nidec Brushless controller is attached to. 0-9 are - * on-board, 10-25 are on the MXP port - */ - @SuppressWarnings("this-escape") - public NidecBrushless(final int pwmChannel, final int dioChannel) { - setSafetyEnabled(false); - - // the dio controls the output (in PWM mode) - m_dio = new DigitalOutput(dioChannel); - SendableRegistry.addChild(this, m_dio); - m_dio.setPWMRate(15625); - m_dio.enablePWM(0.5); - - // the pwm enables the controller - m_pwm = new PWM(pwmChannel); - SendableRegistry.addChild(this, m_pwm); - - HAL.reportUsage("IO[" + pwmChannel + "," + dioChannel + "]", "NidecBrushless"); - SendableRegistry.add(this, "Nidec Brushless", pwmChannel); - } - - @Override - public void close() { - SendableRegistry.remove(this); - m_dio.close(); - m_pwm.close(); - } - - /** - * Set the PWM value. - * - *

The PWM value is set using a range of -1.0 to 1.0, appropriately scaling the value for the - * FPGA. - * - * @param speed The speed value between -1.0 and 1.0 to set. - */ - @Override - public void set(double speed) { - if (!m_disabled) { - m_speed = speed; - m_dio.updateDutyCycle(0.5 + 0.5 * (m_isInverted ? -speed : speed)); - m_pwm.setAlwaysHighMode(); - } - - feed(); - } - - /** - * Get the recently set value of the PWM. - * - * @return The most recently set value for the PWM between -1.0 and 1.0. - */ - @Override - public double get() { - return m_speed; - } - - @Override - public void setInverted(boolean isInverted) { - m_isInverted = isInverted; - } - - @Override - public boolean getInverted() { - return m_isInverted; - } - - /** - * Stop the motor. This is called by the MotorSafety object when it has a timeout for this PWM and - * needs to stop it from running. Calling set() will re-enable the motor. - */ - @Override - public void stopMotor() { - m_dio.updateDutyCycle(0.5); - m_pwm.setDisabled(); - } - - @Override - public String getDescription() { - return "Nidec " + getChannel(); - } - - /** Disable the motor. The enable() function must be called to re-enable the motor. */ - @Override - public void disable() { - m_disabled = true; - m_dio.updateDutyCycle(0.5); - m_pwm.setDisabled(); - } - - /** - * Re-enable the motor after disable() has been called. The set() function must be called to set a - * new motor speed. - */ - public void enable() { - m_disabled = false; - } - - /** - * Gets the channel number associated with the object. - * - * @return The channel number. - */ - public int getChannel() { - return m_pwm.getChannel(); - } - - @Override - public void initSendable(SendableBuilder builder) { - builder.setSmartDashboardType("Nidec Brushless"); - builder.setActuator(true); - builder.addDoubleProperty("Value", this::get, this::set); - } -}