diff --git a/glass/src/lib/native/cpp/hardware/RoboRio.cpp b/glass/src/lib/native/cpp/hardware/RoboRio.cpp index d0667d9bef..f382082421 100644 --- a/glass/src/lib/native/cpp/hardware/RoboRio.cpp +++ b/glass/src/lib/native/cpp/hardware/RoboRio.cpp @@ -47,9 +47,6 @@ static void DisplayRail(RoboRioRailModel& rail, const char* name) { } void glass::DisplayRoboRio(RoboRioModel* model) { - ImGui::Button("User Button"); - model->SetUserButton(ImGui::IsItemActive()); - ImGui::PushItemWidth(ImGui::GetFontSize() * 8); if (CollapsingHeader("RoboRIO Input")) { @@ -60,22 +57,9 @@ void glass::DisplayRoboRio(RoboRioModel* model) { model->SetVInVoltage(val); } } - - if (auto data = model->GetVInCurrentData()) { - double val = data->GetValue(); - if (data->InputDouble("Current (A)", &val)) { - model->SetVInCurrent(val); - } - } ImGui::PopID(); } - if (auto rail = model->GetUser6VRail()) { - DisplayRail(*rail, "6V Rail"); - } - if (auto rail = model->GetUser5VRail()) { - DisplayRail(*rail, "5V Rail"); - } if (auto rail = model->GetUser3V3Rail()) { DisplayRail(*rail, "3.3V Rail"); } diff --git a/glass/src/lib/native/include/glass/hardware/RoboRio.h b/glass/src/lib/native/include/glass/hardware/RoboRio.h index 063d0cf056..17ff92e5a0 100644 --- a/glass/src/lib/native/include/glass/hardware/RoboRio.h +++ b/glass/src/lib/native/include/glass/hardware/RoboRio.h @@ -27,18 +27,12 @@ class RoboRioRailModel : public Model { class RoboRioModel : public Model { public: - virtual RoboRioRailModel* GetUser6VRail() = 0; - virtual RoboRioRailModel* GetUser5VRail() = 0; virtual RoboRioRailModel* GetUser3V3Rail() = 0; - virtual BooleanSource* GetUserButton() = 0; virtual DoubleSource* GetVInVoltageData() = 0; - virtual DoubleSource* GetVInCurrentData() = 0; virtual DoubleSource* GetBrownoutVoltage() = 0; - virtual void SetUserButton(bool val) = 0; virtual void SetVInVoltage(double val) = 0; - virtual void SetVInCurrent(double val) = 0; virtual void SetBrownoutVoltage(double val) = 0; }; diff --git a/hal/src/main/java/edu/wpi/first/hal/HALUtil.java b/hal/src/main/java/edu/wpi/first/hal/HALUtil.java index 0ff306f839..55ad83f131 100644 --- a/hal/src/main/java/edu/wpi/first/hal/HALUtil.java +++ b/hal/src/main/java/edu/wpi/first/hal/HALUtil.java @@ -107,18 +107,6 @@ public final class HALUtil extends JNIWrapper { */ public static native int getHALRuntimeType(); - /** - * Gets the state of the "USER" button on the roboRIO. - * - *

Warning: the User Button is used to stop user programs from automatically loading if it is - * held for more then 5 seconds. Because of this, it's not recommended to be used by teams for any - * other purpose. - * - * @return true if the button is currently pressed down - * @see "HAL_GetFPGAButton" - */ - public static native boolean getFPGAButton(); - /** * Gets the error message for a specific status code. * diff --git a/hal/src/main/java/edu/wpi/first/hal/LEDJNI.java b/hal/src/main/java/edu/wpi/first/hal/LEDJNI.java deleted file mode 100644 index 64a71de55c..0000000000 --- a/hal/src/main/java/edu/wpi/first/hal/LEDJNI.java +++ /dev/null @@ -1,43 +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.hal; - -/** - * LED JNI Functions. - * - * @see "hal/LEDs.h" - */ -public class LEDJNI extends JNIWrapper { - /** LED Off state. */ - public static final int RADIO_LED_STATE_OFF = 0; - - /** LED Green state. */ - public static final int RADIO_LED_STATE_GREEN = 1; - - /** LED Red state. */ - public static final int RADIO_LED_STATE_RED = 2; - - /** LED Orange state. */ - public static final int RADIO_LED_STATE_ORANGE = 3; - - /** - * Set the state of the "Radio" LED. - * - * @param state The state to set the LED to. - * @see "HAL_SetRadioLEDState" - */ - public static native void setRadioLEDState(int state); - - /** - * Get the state of the "Radio" LED. - * - * @return The state of the LED. - * @see "HAL_GetRadioLEDState" - */ - public static native int getRadioLEDState(); - - /** Utility class. */ - private LEDJNI() {} -} diff --git a/hal/src/main/java/edu/wpi/first/hal/PowerJNI.java b/hal/src/main/java/edu/wpi/first/hal/PowerJNI.java index 60c86c5d01..78ae1c6970 100644 --- a/hal/src/main/java/edu/wpi/first/hal/PowerJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/PowerJNI.java @@ -18,92 +18,6 @@ public class PowerJNI extends JNIWrapper { */ public static native double getVinVoltage(); - /** - * Gets the roboRIO input current. - * - * @return the input current (amps) - * @see "HAL_GetVinCurrent" - */ - public static native double getVinCurrent(); - - /** - * Gets the 6V rail voltage. - * - * @return the 6V rail voltage (volts) - * @see "HAL_GetUserVoltage6V" - */ - public static native double getUserVoltage6V(); - - /** - * Gets the 6V rail current. - * - * @return the 6V rail current (amps) - * @see "HAL_GetUserCurrent6V" - */ - public static native double getUserCurrent6V(); - - /** - * Enables or disables the 6V rail. - * - * @param enabled whether the rail should be enabled - */ - public static native void setUserEnabled6V(boolean enabled); - - /** - * Gets the active state of the 6V rail. - * - * @return true if the rail is active, otherwise false - * @see "HAL_GetUserActive6V" - */ - public static native boolean getUserActive6V(); - - /** - * Gets the fault count for the 6V rail. - * - * @return the number of 6V fault counts - * @see "HAL_GetUserCurrentFaults6V" - */ - public static native int getUserCurrentFaults6V(); - - /** - * Gets the 5V rail voltage. - * - * @return the 5V rail voltage (volts) - * @see "HAL_GetUserVoltage5V" - */ - public static native double getUserVoltage5V(); - - /** - * Gets the 5V rail current. - * - * @return the 5V rail current (amps) - * @see "HAL_GetUserCurrent5V" - */ - public static native double getUserCurrent5V(); - - /** - * Enables or disables the 5V rail. - * - * @param enabled whether the rail should be enabled - */ - public static native void setUserEnabled5V(boolean enabled); - - /** - * Gets the active state of the 5V rail. - * - * @return true if the rail is active, otherwise false - * @see "HAL_GetUserActive5V" - */ - public static native boolean getUserActive5V(); - - /** - * Gets the fault count for the 5V rail. - * - * @return the number of 5V fault counts - * @see "HAL_GetUserCurrentFaults5V" - */ - public static native int getUserCurrentFaults5V(); - /** * Gets the 3V3 rail voltage. * diff --git a/hal/src/main/java/edu/wpi/first/hal/simulation/RoboRioDataJNI.java b/hal/src/main/java/edu/wpi/first/hal/simulation/RoboRioDataJNI.java index 83d599db2f..caef4c7d89 100644 --- a/hal/src/main/java/edu/wpi/first/hal/simulation/RoboRioDataJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/simulation/RoboRioDataJNI.java @@ -8,15 +8,6 @@ import edu.wpi.first.hal.JNIWrapper; /** JNI for roboRIO data. */ public class RoboRioDataJNI extends JNIWrapper { - public static native int registerFPGAButtonCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelFPGAButtonCallback(int uid); - - public static native boolean getFPGAButton(); - - public static native void setFPGAButton(boolean fPGAButton); - public static native int registerVInVoltageCallback( NotifyCallback callback, boolean initialNotify); @@ -26,69 +17,6 @@ public class RoboRioDataJNI extends JNIWrapper { public static native void setVInVoltage(double vInVoltage); - public static native int registerVInCurrentCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelVInCurrentCallback(int uid); - - public static native double getVInCurrent(); - - public static native void setVInCurrent(double vInCurrent); - - public static native int registerUserVoltage6VCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelUserVoltage6VCallback(int uid); - - public static native double getUserVoltage6V(); - - public static native void setUserVoltage6V(double userVoltage6V); - - public static native int registerUserCurrent6VCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelUserCurrent6VCallback(int uid); - - public static native double getUserCurrent6V(); - - public static native void setUserCurrent6V(double userCurrent6V); - - public static native int registerUserActive6VCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelUserActive6VCallback(int uid); - - public static native boolean getUserActive6V(); - - public static native void setUserActive6V(boolean userActive6V); - - public static native int registerUserVoltage5VCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelUserVoltage5VCallback(int uid); - - public static native double getUserVoltage5V(); - - public static native void setUserVoltage5V(double userVoltage5V); - - public static native int registerUserCurrent5VCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelUserCurrent5VCallback(int uid); - - public static native double getUserCurrent5V(); - - public static native void setUserCurrent5V(double userCurrent5V); - - public static native int registerUserActive5VCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelUserActive5VCallback(int uid); - - public static native boolean getUserActive5V(); - - public static native void setUserActive5V(boolean userActive5V); - public static native int registerUserVoltage3V3Callback( NotifyCallback callback, boolean initialNotify); @@ -116,24 +44,6 @@ public class RoboRioDataJNI extends JNIWrapper { public static native void setUserActive3V3(boolean userActive3V3); - public static native int registerUserFaults6VCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelUserFaults6VCallback(int uid); - - public static native int getUserFaults6V(); - - public static native void setUserFaults6V(int userFaults6V); - - public static native int registerUserFaults5VCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelUserFaults5VCallback(int uid); - - public static native int getUserFaults5V(); - - public static native void setUserFaults5V(int userFaults5V); - public static native int registerUserFaults3V3Callback( NotifyCallback callback, boolean initialNotify); @@ -177,15 +87,6 @@ public class RoboRioDataJNI extends JNIWrapper { public static native void setComments(String comments); - public static native int registerRadioLEDStateCallback( - NotifyCallback callback, boolean initialNotify); - - public static native void cancelRadioLEDStateCallback(int uid); - - public static native int getRadioLEDState(); - - public static native void setRadioLEDState(int state); - public static native void resetData(); /** Utility class. */ diff --git a/hal/src/main/native/cpp/jni/HALUtil.cpp b/hal/src/main/native/cpp/jni/HALUtil.cpp index f33333b919..47ff07d1af 100644 --- a/hal/src/main/native/cpp/jni/HALUtil.cpp +++ b/hal/src/main/native/cpp/jni/HALUtil.cpp @@ -469,21 +469,6 @@ Java_edu_wpi_first_hal_HALUtil_getHALRuntimeType return returnValue; } -/* - * Class: edu_wpi_first_hal_HALUtil - * Method: getFPGAButton - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_hal_HALUtil_getFPGAButton - (JNIEnv* env, jclass) -{ - int32_t status = 0; - jboolean returnValue = HAL_GetFPGAButton(&status); - CheckStatus(env, status); - return returnValue; -} - /* * Class: edu_wpi_first_hal_HALUtil * Method: getHALErrorMessage diff --git a/hal/src/main/native/cpp/jni/LEDJNI.cpp b/hal/src/main/native/cpp/jni/LEDJNI.cpp deleted file mode 100644 index 06c95a709e..0000000000 --- a/hal/src/main/native/cpp/jni/LEDJNI.cpp +++ /dev/null @@ -1,49 +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 "HALUtil.h" -#include "edu_wpi_first_hal_LEDJNI.h" -#include "hal/LEDs.h" - -static_assert(edu_wpi_first_hal_LEDJNI_RADIO_LED_STATE_OFF == - HAL_RadioLEDState::HAL_RadioLED_kOff); -static_assert(edu_wpi_first_hal_LEDJNI_RADIO_LED_STATE_GREEN == - HAL_RadioLEDState::HAL_RadioLED_kGreen); -static_assert(edu_wpi_first_hal_LEDJNI_RADIO_LED_STATE_RED == - HAL_RadioLEDState::HAL_RadioLED_kRed); -static_assert(edu_wpi_first_hal_LEDJNI_RADIO_LED_STATE_ORANGE == - HAL_RadioLEDState::HAL_RadioLED_kOrange); - -using namespace hal; - -extern "C" { -/* - * Class: edu_wpi_first_hal_LEDJNI - * Method: setRadioLEDState - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_LEDJNI_setRadioLEDState - (JNIEnv* env, jclass, jint state) -{ - int32_t status = 0; - HAL_SetRadioLEDState(static_cast(state), &status); - CheckStatus(env, status); -} - -/* - * Class: edu_wpi_first_hal_LEDJNI - * Method: getRadioLEDState - * Signature: ()I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_LEDJNI_getRadioLEDState - (JNIEnv* env, jclass) -{ - int32_t status = 0; - auto retVal = HAL_GetRadioLEDState(&status); - CheckStatus(env, status); - return retVal; -} -} // extern "C" diff --git a/hal/src/main/native/cpp/jni/PowerJNI.cpp b/hal/src/main/native/cpp/jni/PowerJNI.cpp index f21d50f474..192b29d89d 100644 --- a/hal/src/main/native/cpp/jni/PowerJNI.cpp +++ b/hal/src/main/native/cpp/jni/PowerJNI.cpp @@ -27,169 +27,6 @@ Java_edu_wpi_first_hal_PowerJNI_getVinVoltage return val; } -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: getVinCurrent - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_PowerJNI_getVinCurrent - (JNIEnv* env, jclass) -{ - int32_t status = 0; - double val = HAL_GetVinCurrent(&status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: getUserVoltage6V - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_PowerJNI_getUserVoltage6V - (JNIEnv* env, jclass) -{ - int32_t status = 0; - double val = HAL_GetUserVoltage6V(&status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: getUserCurrent6V - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_PowerJNI_getUserCurrent6V - (JNIEnv* env, jclass) -{ - int32_t status = 0; - double val = HAL_GetUserCurrent6V(&status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: setUserEnabled6V - * Signature: (Z)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_PowerJNI_setUserEnabled6V - (JNIEnv* env, jclass, jboolean enabled) -{ - int32_t status = 0; - HAL_SetUserRailEnabled6V(enabled, &status); - CheckStatus(env, status); -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: getUserActive6V - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_hal_PowerJNI_getUserActive6V - (JNIEnv* env, jclass) -{ - int32_t status = 0; - bool val = HAL_GetUserActive6V(&status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: getUserCurrentFaults6V - * Signature: ()I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_PowerJNI_getUserCurrentFaults6V - (JNIEnv* env, jclass) -{ - int32_t status = 0; - int32_t val = HAL_GetUserCurrentFaults6V(&status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: getUserVoltage5V - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_PowerJNI_getUserVoltage5V - (JNIEnv* env, jclass) -{ - int32_t status = 0; - double val = HAL_GetUserVoltage5V(&status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: getUserCurrent5V - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_PowerJNI_getUserCurrent5V - (JNIEnv* env, jclass) -{ - int32_t status = 0; - double val = HAL_GetUserCurrent5V(&status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: setUserEnabled5V - * Signature: (Z)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_PowerJNI_setUserEnabled5V - (JNIEnv* env, jclass, jboolean enabled) -{ - int32_t status = 0; - HAL_SetUserRailEnabled5V(enabled, &status); - CheckStatus(env, status); -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: getUserActive5V - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_hal_PowerJNI_getUserActive5V - (JNIEnv* env, jclass) -{ - int32_t status = 0; - bool val = HAL_GetUserActive5V(&status); - CheckStatus(env, status); - return val; -} - -/* - * Class: edu_wpi_first_hal_PowerJNI - * Method: getUserCurrentFaults5V - * Signature: ()I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_PowerJNI_getUserCurrentFaults5V - (JNIEnv* env, jclass) -{ - int32_t status = 0; - int32_t val = HAL_GetUserCurrentFaults5V(&status); - CheckStatus(env, status); - return val; -} - /* * Class: edu_wpi_first_hal_PowerJNI * Method: getUserVoltage3V3 diff --git a/hal/src/main/native/cpp/jni/simulation/RoboRioDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/RoboRioDataJNI.cpp index 3c9d4422d4..5436f8ef70 100644 --- a/hal/src/main/native/cpp/jni/simulation/RoboRioDataJNI.cpp +++ b/hal/src/main/native/cpp/jni/simulation/RoboRioDataJNI.cpp @@ -15,56 +15,6 @@ using namespace wpi::java; extern "C" { -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerFPGAButtonCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerFPGAButtonCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, &HALSIM_RegisterRoboRioFPGAButtonCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelFPGAButtonCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelFPGAButtonCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioFPGAButtonCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getFPGAButton - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getFPGAButton - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioFPGAButton(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setFPGAButton - * Signature: (Z)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setFPGAButton - (JNIEnv*, jclass, jboolean value) -{ - HALSIM_SetRoboRioFPGAButton(value); -} - /* * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI * Method: registerVInVoltageCallback @@ -115,362 +65,6 @@ Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setVInVoltage HALSIM_SetRoboRioVInVoltage(value); } -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerVInCurrentCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerVInCurrentCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, &HALSIM_RegisterRoboRioVInCurrentCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelVInCurrentCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelVInCurrentCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioVInCurrentCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getVInCurrent - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getVInCurrent - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioVInCurrent(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setVInCurrent - * Signature: (D)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setVInCurrent - (JNIEnv*, jclass, jdouble value) -{ - HALSIM_SetRoboRioVInCurrent(value); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerUserVoltage6VCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserVoltage6VCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, - &HALSIM_RegisterRoboRioUserVoltage6VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelUserVoltage6VCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserVoltage6VCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioUserVoltage6VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getUserVoltage6V - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserVoltage6V - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioUserVoltage6V(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setUserVoltage6V - * Signature: (D)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserVoltage6V - (JNIEnv*, jclass, jdouble value) -{ - HALSIM_SetRoboRioUserVoltage6V(value); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerUserCurrent6VCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserCurrent6VCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, - &HALSIM_RegisterRoboRioUserCurrent6VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelUserCurrent6VCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserCurrent6VCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioUserCurrent6VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getUserCurrent6V - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserCurrent6V - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioUserCurrent6V(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setUserCurrent6V - * Signature: (D)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserCurrent6V - (JNIEnv*, jclass, jdouble value) -{ - HALSIM_SetRoboRioUserCurrent6V(value); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerUserActive6VCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserActive6VCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, - &HALSIM_RegisterRoboRioUserActive6VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelUserActive6VCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserActive6VCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioUserActive6VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getUserActive6V - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserActive6V - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioUserActive6V(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setUserActive6V - * Signature: (Z)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserActive6V - (JNIEnv*, jclass, jboolean value) -{ - HALSIM_SetRoboRioUserActive6V(value); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerUserVoltage5VCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserVoltage5VCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, - &HALSIM_RegisterRoboRioUserVoltage5VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelUserVoltage5VCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserVoltage5VCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioUserVoltage5VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getUserVoltage5V - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserVoltage5V - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioUserVoltage5V(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setUserVoltage5V - * Signature: (D)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserVoltage5V - (JNIEnv*, jclass, jdouble value) -{ - HALSIM_SetRoboRioUserVoltage5V(value); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerUserCurrent5VCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserCurrent5VCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, - &HALSIM_RegisterRoboRioUserCurrent5VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelUserCurrent5VCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserCurrent5VCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioUserCurrent5VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getUserCurrent5V - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserCurrent5V - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioUserCurrent5V(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setUserCurrent5V - * Signature: (D)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserCurrent5V - (JNIEnv*, jclass, jdouble value) -{ - HALSIM_SetRoboRioUserCurrent5V(value); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerUserActive5VCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserActive5VCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, - &HALSIM_RegisterRoboRioUserActive5VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelUserActive5VCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserActive5VCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioUserActive5VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getUserActive5V - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserActive5V - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioUserActive5V(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setUserActive5V - * Signature: (Z)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserActive5V - (JNIEnv*, jclass, jboolean value) -{ - HALSIM_SetRoboRioUserActive5V(value); -} - /* * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI * Method: registerUserVoltage3V3Callback @@ -624,108 +218,6 @@ Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserActive3V3 HALSIM_SetRoboRioUserActive3V3(value); } -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerUserFaults6VCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserFaults6VCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, - &HALSIM_RegisterRoboRioUserFaults6VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelUserFaults6VCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserFaults6VCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioUserFaults6VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getUserFaults6V - * Signature: ()I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserFaults6V - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioUserFaults6V(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setUserFaults6V - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserFaults6V - (JNIEnv*, jclass, jint value) -{ - HALSIM_SetRoboRioUserFaults6V(value); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerUserFaults5VCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserFaults5VCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, - &HALSIM_RegisterRoboRioUserFaults5VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelUserFaults5VCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserFaults5VCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioUserFaults5VCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getUserFaults5V - * Signature: ()I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserFaults5V - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioUserFaults5V(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setUserFaults5V - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserFaults5V - (JNIEnv*, jclass, jint value) -{ - HALSIM_SetRoboRioUserFaults5V(value); -} - /* * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI * Method: registerUserFaults3V3Callback @@ -988,57 +480,6 @@ Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setComments HALSIM_SetRoboRioComments(&str); } -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: registerRadioLEDStateCallback - * Signature: (Ljava/lang/Object;Z)I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerRadioLEDStateCallback - (JNIEnv* env, jclass, jobject callback, jboolean initialNotify) -{ - return sim::AllocateCallbackNoIndex( - env, callback, initialNotify, - &HALSIM_RegisterRoboRioRadioLEDStateCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: cancelRadioLEDStateCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelRadioLEDStateCallback - (JNIEnv* env, jclass, jint handle) -{ - return sim::FreeCallbackNoIndex(env, handle, - &HALSIM_CancelRoboRioRadioLEDStateCallback); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: getRadioLEDState - * Signature: ()I - */ -JNIEXPORT jint JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getRadioLEDState - (JNIEnv*, jclass) -{ - return HALSIM_GetRoboRioRadioLEDState(); -} - -/* - * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI - * Method: setRadioLEDState - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setRadioLEDState - (JNIEnv*, jclass, jint value) -{ - HALSIM_SetRoboRioRadioLEDState(static_cast(value)); -} - /* * Class: edu_wpi_first_hal_simulation_RoboRioDataJNI * Method: resetData diff --git a/hal/src/main/native/include/hal/HAL.h b/hal/src/main/native/include/hal/HAL.h index afadadbbc4..eeb9db6998 100644 --- a/hal/src/main/native/include/hal/HAL.h +++ b/hal/src/main/native/include/hal/HAL.h @@ -18,7 +18,6 @@ #include "hal/Errors.h" #include "hal/HALBase.h" #include "hal/I2C.h" -#include "hal/LEDs.h" #include "hal/Main.h" #include "hal/Notifier.h" #include "hal/PWM.h" diff --git a/hal/src/main/native/include/hal/HALBase.h b/hal/src/main/native/include/hal/HALBase.h index 95e3a5f28e..7d128c0b3f 100644 --- a/hal/src/main/native/include/hal/HALBase.h +++ b/hal/src/main/native/include/hal/HALBase.h @@ -113,18 +113,6 @@ int32_t HAL_GetTeamNumber(void); */ HAL_RuntimeType HAL_GetRuntimeType(void); -/** - * Gets the state of the "USER" button on the roboRIO. - * - * @warning the User Button is used to stop user programs from automatically - * loading if it is held for more then 5 seconds. Because of this, it's not - * recommended to be used by teams for any other purpose. - * - * @param[out] status the error code, or 0 for success - * @return true if the button is currently pressed down - */ -HAL_Bool HAL_GetFPGAButton(int32_t* status); - /** * Gets if the system outputs are currently active. * diff --git a/hal/src/main/native/include/hal/LEDs.h b/hal/src/main/native/include/hal/LEDs.h deleted file mode 100644 index d7ee716868..0000000000 --- a/hal/src/main/native/include/hal/LEDs.h +++ /dev/null @@ -1,34 +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 "hal/Types.h" - -HAL_ENUM(HAL_RadioLEDState) { - HAL_RadioLED_kOff = 0, - HAL_RadioLED_kGreen = 1, - HAL_RadioLED_kRed = 2, - HAL_RadioLED_kOrange = 3 -}; - -#ifdef __cplusplus -extern "C" { -#endif -/** - * Set the state of the "Radio" LED. - * @param state The state to set the LED to. - * @param[out] status the error code, or 0 for success - */ -void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status); - -/** - * Get the state of the "Radio" LED. - * - * @param[out] status the error code, or 0 for success - * @return The state of the LED. - */ -HAL_RadioLEDState HAL_GetRadioLEDState(int32_t* status); -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/hal/src/main/native/include/hal/Power.h b/hal/src/main/native/include/hal/Power.h index b6dd4b6952..2988df58e5 100644 --- a/hal/src/main/native/include/hal/Power.h +++ b/hal/src/main/native/include/hal/Power.h @@ -26,94 +26,6 @@ extern "C" { */ double HAL_GetVinVoltage(int32_t* status); -/** - * Gets the roboRIO input current. - * - * @param[out] status the error code, or 0 for success - * @return the input current (amps) - */ -double HAL_GetVinCurrent(int32_t* status); - -/** - * Gets the 6V rail voltage. - * - * @param[out] status the error code, or 0 for success - * @return the 6V rail voltage (volts) - */ -double HAL_GetUserVoltage6V(int32_t* status); - -/** - * Gets the 6V rail current. - * - * @param[out] status the error code, or 0 for success - * @return the 6V rail current (amps) - */ -double HAL_GetUserCurrent6V(int32_t* status); - -/** - * Gets the active state of the 6V rail. - * - * @param[out] status the error code, or 0 for success - * @return true if the rail is active, otherwise false - */ -HAL_Bool HAL_GetUserActive6V(int32_t* status); - -/** - * Gets the fault count for the 6V rail. Capped at 255. - * - * @param[out] status the error code, or 0 for success - * @return the number of 6V fault counts - */ -int32_t HAL_GetUserCurrentFaults6V(int32_t* status); - -/** - * Enables or disables the 6V rail. - * - * @param enabled whether the rail should be enabled - * @param[out] status the error code, or 0 for success - */ -void HAL_SetUserRailEnabled6V(HAL_Bool enabled, int32_t* status); - -/** - * Gets the 5V rail voltage. - * - * @param[out] status the error code, or 0 for success - * @return the 5V rail voltage (volts) - */ -double HAL_GetUserVoltage5V(int32_t* status); - -/** - * Gets the 5V rail current. - * - * @param[out] status the error code, or 0 for success - * @return the 5V rail current (amps) - */ -double HAL_GetUserCurrent5V(int32_t* status); - -/** - * Gets the active state of the 5V rail. - * - * @param[out] status the error code, or 0 for success - * @return true if the rail is active, otherwise false - */ -HAL_Bool HAL_GetUserActive5V(int32_t* status); - -/** - * Gets the fault count for the 5V rail. Capped at 255. - * - * @param[out] status the error code, or 0 for success - * @return the number of 5V fault counts - */ -int32_t HAL_GetUserCurrentFaults5V(int32_t* status); - -/** - * Enables or disables the 5V rail. - * - * @param enabled whether the rail should be enabled - * @param[out] status the error code, or 0 for success - */ -void HAL_SetUserRailEnabled5V(HAL_Bool enabled, int32_t* status); - /** * Gets the 3V3 rail voltage. * diff --git a/hal/src/main/native/include/hal/simulation/RoboRioData.h b/hal/src/main/native/include/hal/simulation/RoboRioData.h index 0c87b07e5c..1bab98908a 100644 --- a/hal/src/main/native/include/hal/simulation/RoboRioData.h +++ b/hal/src/main/native/include/hal/simulation/RoboRioData.h @@ -8,7 +8,6 @@ #include -#include "hal/LEDs.h" #include "hal/Types.h" #include "hal/simulation/NotifyListener.h" @@ -34,55 +33,6 @@ void HALSIM_CancelRoboRioVInVoltageCallback(int32_t uid); double HALSIM_GetRoboRioVInVoltage(void); void HALSIM_SetRoboRioVInVoltage(double vInVoltage); -int32_t HALSIM_RegisterRoboRioVInCurrentCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioVInCurrentCallback(int32_t uid); -double HALSIM_GetRoboRioVInCurrent(void); -void HALSIM_SetRoboRioVInCurrent(double vInCurrent); - -int32_t HALSIM_RegisterRoboRioUserVoltage6VCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioUserVoltage6VCallback(int32_t uid); -double HALSIM_GetRoboRioUserVoltage6V(void); -void HALSIM_SetRoboRioUserVoltage6V(double userVoltage6V); - -int32_t HALSIM_RegisterRoboRioUserCurrent6VCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioUserCurrent6VCallback(int32_t uid); -double HALSIM_GetRoboRioUserCurrent6V(void); -void HALSIM_SetRoboRioUserCurrent6V(double userCurrent6V); - -int32_t HALSIM_RegisterRoboRioUserActive6VCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioUserActive6VCallback(int32_t uid); -HAL_Bool HALSIM_GetRoboRioUserActive6V(void); -void HALSIM_SetRoboRioUserActive6V(HAL_Bool userActive6V); - -int32_t HALSIM_RegisterRoboRioUserVoltage5VCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioUserVoltage5VCallback(int32_t uid); -double HALSIM_GetRoboRioUserVoltage5V(void); -void HALSIM_SetRoboRioUserVoltage5V(double userVoltage5V); - -int32_t HALSIM_RegisterRoboRioUserCurrent5VCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioUserCurrent5VCallback(int32_t uid); -double HALSIM_GetRoboRioUserCurrent5V(void); -void HALSIM_SetRoboRioUserCurrent5V(double userCurrent5V); - -int32_t HALSIM_RegisterRoboRioUserActive5VCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioUserActive5VCallback(int32_t uid); -HAL_Bool HALSIM_GetRoboRioUserActive5V(void); -void HALSIM_SetRoboRioUserActive5V(HAL_Bool userActive5V); - int32_t HALSIM_RegisterRoboRioUserVoltage3V3Callback( HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify); void HALSIM_CancelRoboRioUserVoltage3V3Callback(int32_t uid); @@ -102,20 +52,6 @@ void HALSIM_CancelRoboRioUserActive3V3Callback(int32_t uid); HAL_Bool HALSIM_GetRoboRioUserActive3V3(void); void HALSIM_SetRoboRioUserActive3V3(HAL_Bool userActive3V3); -int32_t HALSIM_RegisterRoboRioUserFaults6VCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioUserFaults6VCallback(int32_t uid); -int32_t HALSIM_GetRoboRioUserFaults6V(void); -void HALSIM_SetRoboRioUserFaults6V(int32_t userFaults6V); - -int32_t HALSIM_RegisterRoboRioUserFaults5VCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioUserFaults5VCallback(int32_t uid); -int32_t HALSIM_GetRoboRioUserFaults5V(void); -void HALSIM_SetRoboRioUserFaults5V(int32_t userFaults5V); - int32_t HALSIM_RegisterRoboRioUserFaults3V3Callback(HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify); @@ -155,13 +91,6 @@ void HALSIM_CancelRoboRioCPUTempCallback(int32_t uid); double HALSIM_GetRoboRioCPUTemp(void); void HALSIM_SetRoboRioCPUTemp(double cpuTemp); -int32_t HALSIM_RegisterRoboRioRadioLEDStateCallback(HAL_NotifyCallback callback, - void* param, - HAL_Bool initialNotify); -void HALSIM_CancelRoboRioRadioLEDStateCallback(int32_t uid); -HAL_RadioLEDState HALSIM_GetRoboRioRadioLEDState(void); -void HALSIM_SetRoboRioRadioLEDState(HAL_RadioLEDState state); - void HALSIM_RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify); #ifdef __cplusplus diff --git a/hal/src/main/native/sim/HAL.cpp b/hal/src/main/native/sim/HAL.cpp index df9368803a..63a9e25c25 100644 --- a/hal/src/main/native/sim/HAL.cpp +++ b/hal/src/main/native/sim/HAL.cpp @@ -289,10 +289,6 @@ uint64_t HAL_ExpandFPGATime(uint32_t unexpandedLower, int32_t* status) { return (upper << 32) + static_cast(unexpandedLower); } -HAL_Bool HAL_GetFPGAButton(int32_t* status) { - return SimRoboRioData[0].fpgaButton; -} - HAL_Bool HAL_GetSystemActive(int32_t* status) { return HALSIM_GetDriverStationEnabled(); } diff --git a/hal/src/main/native/sim/LEDs.cpp b/hal/src/main/native/sim/LEDs.cpp deleted file mode 100644 index e7d45aa7f7..0000000000 --- a/hal/src/main/native/sim/LEDs.cpp +++ /dev/null @@ -1,21 +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 "hal/LEDs.h" - -#include "hal/simulation/RoboRioData.h" - -namespace hal::init { -void InitializeLEDs() {} -} // namespace hal::init - -extern "C" { - -void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status) { - HALSIM_SetRoboRioRadioLEDState(state); -} -HAL_RadioLEDState HAL_GetRadioLEDState(int32_t* status) { - return HALSIM_GetRoboRioRadioLEDState(); -} -} // extern "C" diff --git a/hal/src/main/native/sim/Power.cpp b/hal/src/main/native/sim/Power.cpp index ce7a462bdd..076d9c5d44 100644 --- a/hal/src/main/native/sim/Power.cpp +++ b/hal/src/main/native/sim/Power.cpp @@ -17,34 +17,6 @@ extern "C" { double HAL_GetVinVoltage(int32_t* status) { return SimRoboRioData->vInVoltage; } -double HAL_GetVinCurrent(int32_t* status) { - return SimRoboRioData->vInCurrent; -} -double HAL_GetUserVoltage6V(int32_t* status) { - return SimRoboRioData->userVoltage6V; -} -double HAL_GetUserCurrent6V(int32_t* status) { - return SimRoboRioData->userCurrent6V; -} -HAL_Bool HAL_GetUserActive6V(int32_t* status) { - return SimRoboRioData->userActive6V; -} -int32_t HAL_GetUserCurrentFaults6V(int32_t* status) { - return SimRoboRioData->userFaults6V; -} -void HAL_SetUserRailEnabled6V(HAL_Bool enabled, int32_t* status) {} -double HAL_GetUserVoltage5V(int32_t* status) { - return SimRoboRioData->userVoltage5V; -} -double HAL_GetUserCurrent5V(int32_t* status) { - return SimRoboRioData->userCurrent5V; -} -HAL_Bool HAL_GetUserActive5V(int32_t* status) { - return SimRoboRioData->userActive5V; -} -int32_t HAL_GetUserCurrentFaults5V(int32_t* status) { - return SimRoboRioData->userFaults5V; -} void HAL_SetUserRailEnabled5V(HAL_Bool enabled, int32_t* status) {} double HAL_GetUserVoltage3V3(int32_t* status) { return SimRoboRioData->userVoltage3V3; @@ -61,8 +33,6 @@ int32_t HAL_GetUserCurrentFaults3V3(int32_t* status) { void HAL_SetUserRailEnabled3V3(HAL_Bool enabled, int32_t* status) {} void HAL_ResetUserCurrentFaults(int32_t* status) { SimRoboRioData->userFaults3V3 = 0; - SimRoboRioData->userFaults5V = 0; - SimRoboRioData->userFaults6V = 0; } void HAL_SetBrownoutVoltage(double voltage, int32_t* status) { SimRoboRioData->brownoutVoltage = voltage; diff --git a/hal/src/main/native/sim/mockdata/RoboRioData.cpp b/hal/src/main/native/sim/mockdata/RoboRioData.cpp index 613d89d4fd..ba772a8add 100644 --- a/hal/src/main/native/sim/mockdata/RoboRioData.cpp +++ b/hal/src/main/native/sim/mockdata/RoboRioData.cpp @@ -17,20 +17,10 @@ void InitializeRoboRioData() { RoboRioData* hal::SimRoboRioData; void RoboRioData::ResetData() { - fpgaButton.Reset(false); vInVoltage.Reset(12.0); - vInCurrent.Reset(0.0); - userVoltage6V.Reset(6.0); - userCurrent6V.Reset(0.0); - userActive6V.Reset(true); - userVoltage5V.Reset(5.0); - userCurrent5V.Reset(0.0); - userActive5V.Reset(true); userVoltage3V3.Reset(3.3); userCurrent3V3.Reset(0.0); userActive3V3.Reset(true); - userFaults6V.Reset(0); - userFaults5V.Reset(0); userFaults3V3.Reset(0); brownoutVoltage.Reset(6.75); cpuTemp.Reset(45.0); @@ -110,25 +100,14 @@ void HALSIM_ResetRoboRioData(void) { HAL_SIMDATAVALUE_DEFINE_CAPI_NOINDEX(TYPE, HALSIM, RoboRio##CAPINAME, \ SimRoboRioData, LOWERNAME) -DEFINE_CAPI(HAL_Bool, FPGAButton, fpgaButton) DEFINE_CAPI(double, VInVoltage, vInVoltage) -DEFINE_CAPI(double, VInCurrent, vInCurrent) -DEFINE_CAPI(double, UserVoltage6V, userVoltage6V) -DEFINE_CAPI(double, UserCurrent6V, userCurrent6V) -DEFINE_CAPI(HAL_Bool, UserActive6V, userActive6V) -DEFINE_CAPI(double, UserVoltage5V, userVoltage5V) -DEFINE_CAPI(double, UserCurrent5V, userCurrent5V) -DEFINE_CAPI(HAL_Bool, UserActive5V, userActive5V) DEFINE_CAPI(double, UserVoltage3V3, userVoltage3V3) DEFINE_CAPI(double, UserCurrent3V3, userCurrent3V3) DEFINE_CAPI(HAL_Bool, UserActive3V3, userActive3V3) -DEFINE_CAPI(int32_t, UserFaults6V, userFaults6V) -DEFINE_CAPI(int32_t, UserFaults5V, userFaults5V) DEFINE_CAPI(int32_t, UserFaults3V3, userFaults3V3) DEFINE_CAPI(double, BrownoutVoltage, brownoutVoltage) DEFINE_CAPI(double, CPUTemp, cpuTemp) DEFINE_CAPI(int32_t, TeamNumber, teamNumber) -DEFINE_CAPI(HAL_RadioLEDState, RadioLEDState, radioLedState) int32_t HALSIM_RegisterRoboRioSerialNumberCallback( HAL_RoboRioStringCallback callback, void* param, HAL_Bool initialNotify) { @@ -168,23 +147,12 @@ void HALSIM_RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback, void HALSIM_RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify) { - REGISTER(fpgaButton); REGISTER(vInVoltage); - REGISTER(vInCurrent); - REGISTER(userVoltage6V); - REGISTER(userCurrent6V); - REGISTER(userActive6V); - REGISTER(userVoltage5V); - REGISTER(userCurrent5V); - REGISTER(userActive5V); REGISTER(userVoltage3V3); REGISTER(userCurrent3V3); REGISTER(userActive3V3); - REGISTER(userFaults6V); - REGISTER(userFaults5V); REGISTER(userFaults3V3); REGISTER(brownoutVoltage); REGISTER(cpuTemp); - REGISTER(radioLedState); } } // extern "C" diff --git a/hal/src/main/native/sim/mockdata/RoboRioDataInternal.h b/hal/src/main/native/sim/mockdata/RoboRioDataInternal.h index 6ef523e182..378537ff0a 100644 --- a/hal/src/main/native/sim/mockdata/RoboRioDataInternal.h +++ b/hal/src/main/native/sim/mockdata/RoboRioDataInternal.h @@ -14,60 +14,31 @@ namespace hal { class RoboRioData { - HAL_SIMDATAVALUE_DEFINE_NAME(FPGAButton) HAL_SIMDATAVALUE_DEFINE_NAME(VInVoltage) - HAL_SIMDATAVALUE_DEFINE_NAME(VInCurrent) - HAL_SIMDATAVALUE_DEFINE_NAME(UserVoltage6V) - HAL_SIMDATAVALUE_DEFINE_NAME(UserCurrent6V) - HAL_SIMDATAVALUE_DEFINE_NAME(UserActive6V) - HAL_SIMDATAVALUE_DEFINE_NAME(UserVoltage5V) - HAL_SIMDATAVALUE_DEFINE_NAME(UserCurrent5V) - HAL_SIMDATAVALUE_DEFINE_NAME(UserActive5V) HAL_SIMDATAVALUE_DEFINE_NAME(UserVoltage3V3) HAL_SIMDATAVALUE_DEFINE_NAME(UserCurrent3V3) HAL_SIMDATAVALUE_DEFINE_NAME(UserActive3V3) - HAL_SIMDATAVALUE_DEFINE_NAME(UserFaults6V) - HAL_SIMDATAVALUE_DEFINE_NAME(UserFaults5V) HAL_SIMDATAVALUE_DEFINE_NAME(UserFaults3V3) HAL_SIMDATAVALUE_DEFINE_NAME(BrownoutVoltage) HAL_SIMDATAVALUE_DEFINE_NAME(CPUTemp) HAL_SIMDATAVALUE_DEFINE_NAME(TeamNumber) - HAL_SIMDATAVALUE_DEFINE_NAME(RadioLEDState) HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(SerialNumber) HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(Comments); - static inline HAL_Value MakeRadioLEDStateValue(HAL_RadioLEDState value) { - return HAL_MakeEnum(value); - } - public: - SimDataValue fpgaButton{false}; SimDataValue vInVoltage{12.0}; - SimDataValue vInCurrent{0.0}; - SimDataValue userVoltage6V{6.0}; - SimDataValue userCurrent6V{0.0}; - SimDataValue userActive6V{ - true}; - SimDataValue userVoltage5V{5.0}; - SimDataValue userCurrent5V{0.0}; - SimDataValue userActive5V{ - true}; SimDataValue userVoltage3V3{ 3.3}; SimDataValue userCurrent3V3{ 0.0}; SimDataValue userActive3V3{ true}; - SimDataValue userFaults6V{0}; - SimDataValue userFaults5V{0}; SimDataValue userFaults3V3{0}; SimDataValue brownoutVoltage{ 6.75}; SimDataValue cpuTemp{45.0}; SimDataValue teamNumber{0}; - SimDataValue - radioLedState{HAL_RadioLED_kOff}; int32_t RegisterSerialNumberCallback(HAL_RoboRioStringCallback callback, void* param, HAL_Bool initialNotify); diff --git a/hal/src/main/native/systemcore/HAL.cpp b/hal/src/main/native/systemcore/HAL.cpp index 887ae0823d..27a0f4a729 100644 --- a/hal/src/main/native/systemcore/HAL.cpp +++ b/hal/src/main/native/systemcore/HAL.cpp @@ -59,7 +59,6 @@ void InitializeHAL() { InitializeEncoder(); InitializeFRCDriverStation(); InitializeI2C(); - InitializeLEDs(); InitializeMain(); InitializeNotifier(); InitializeCTREPDP(); @@ -252,12 +251,6 @@ uint64_t HAL_ExpandFPGATime(uint32_t unexpandedLower, int32_t* status) { return (upper << 32) + static_cast(unexpandedLower); } -HAL_Bool HAL_GetFPGAButton(int32_t* status) { - hal::init::CheckInit(); - *status = HAL_HANDLE_ERROR; - return false; -} - HAL_Bool HAL_GetSystemActive(int32_t* status) { hal::init::CheckInit(); *status = HAL_HANDLE_ERROR; diff --git a/hal/src/main/native/systemcore/HALInitializer.h b/hal/src/main/native/systemcore/HALInitializer.h index bee47fd29b..8199ea6f3f 100644 --- a/hal/src/main/native/systemcore/HALInitializer.h +++ b/hal/src/main/native/systemcore/HALInitializer.h @@ -32,7 +32,6 @@ extern void InitializeEncoder(); extern void InitializeFRCDriverStation(); extern void InitializeHAL(); extern void InitializeI2C(); -extern void InitializeLEDs(); extern void InitializeMain(); extern void InitializeNotifier(); extern void InitializeCTREPDP(); diff --git a/hal/src/main/native/systemcore/LEDs.cpp b/hal/src/main/native/systemcore/LEDs.cpp deleted file mode 100644 index c7d7b5bea2..0000000000 --- a/hal/src/main/native/systemcore/LEDs.cpp +++ /dev/null @@ -1,34 +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 "hal/LEDs.h" - -#include - -#include -#include - -#include -#include -#include - -#include "HALInternal.h" -#include "hal/Errors.h" - -namespace hal::init { - -void InitializeLEDs() {} -} // namespace hal::init - -extern "C" { -void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status) { - *status = HAL_HANDLE_ERROR; - return; -} - -HAL_RadioLEDState HAL_GetRadioLEDState(int32_t* status) { - *status = HAL_HANDLE_ERROR; - return HAL_RadioLED_kOff; -} -} // extern "C" diff --git a/hal/src/main/native/systemcore/Power.cpp b/hal/src/main/native/systemcore/Power.cpp index 907167382e..4c8c2df51f 100644 --- a/hal/src/main/native/systemcore/Power.cpp +++ b/hal/src/main/native/systemcore/Power.cpp @@ -31,72 +31,6 @@ double HAL_GetVinVoltage(int32_t* status) { return 0; } -double HAL_GetVinCurrent(int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return 0; -} - -double HAL_GetUserVoltage6V(int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return 0; -} - -double HAL_GetUserCurrent6V(int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return 0; -} - -HAL_Bool HAL_GetUserActive6V(int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return 0; -} - -int32_t HAL_GetUserCurrentFaults6V(int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return 0; -} - -void HAL_SetUserRailEnabled6V(HAL_Bool enabled, int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return; -} - -double HAL_GetUserVoltage5V(int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return 0; -} - -double HAL_GetUserCurrent5V(int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return 0; -} - -HAL_Bool HAL_GetUserActive5V(int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return 0; -} - -int32_t HAL_GetUserCurrentFaults5V(int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return 0; -} - -void HAL_SetUserRailEnabled5V(HAL_Bool enabled, int32_t* status) { - initializePower(status); - *status = HAL_HANDLE_ERROR; - return; -} - double HAL_GetUserVoltage3V3(int32_t* status) { initializePower(status); *status = HAL_HANDLE_ERROR; diff --git a/hal/src/main/native/systemcore/mockdata/RoboRioData.cpp b/hal/src/main/native/systemcore/mockdata/RoboRioData.cpp index b1ba26026d..8e1b503eaa 100644 --- a/hal/src/main/native/systemcore/mockdata/RoboRioData.cpp +++ b/hal/src/main/native/systemcore/mockdata/RoboRioData.cpp @@ -12,25 +12,14 @@ void HALSIM_ResetRoboRioData(void) {} #define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ HAL_SIMDATAVALUE_STUB_CAPI_NOINDEX(TYPE, HALSIM, RoboRio##CAPINAME, RETURN) -DEFINE_CAPI(HAL_Bool, FPGAButton, false) DEFINE_CAPI(double, VInVoltage, 0) -DEFINE_CAPI(double, VInCurrent, 0) -DEFINE_CAPI(double, UserVoltage6V, 0) -DEFINE_CAPI(double, UserCurrent6V, 0) -DEFINE_CAPI(HAL_Bool, UserActive6V, false) -DEFINE_CAPI(double, UserVoltage5V, 0) -DEFINE_CAPI(double, UserCurrent5V, 0) -DEFINE_CAPI(HAL_Bool, UserActive5V, false) DEFINE_CAPI(double, UserVoltage3V3, 0) DEFINE_CAPI(double, UserCurrent3V3, 0) DEFINE_CAPI(HAL_Bool, UserActive3V3, false) -DEFINE_CAPI(int32_t, UserFaults6V, 0) -DEFINE_CAPI(int32_t, UserFaults5V, 0) DEFINE_CAPI(int32_t, UserFaults3V3, 0) DEFINE_CAPI(double, BrownoutVoltage, 6.75) DEFINE_CAPI(double, CPUTemp, 45.0) DEFINE_CAPI(int32_t, TeamNumber, 0) -DEFINE_CAPI(HAL_RadioLEDState, RadioLEDState, HAL_RadioLED_kOff); int32_t HALSIM_RegisterRoboRioSerialNumberCallback( HAL_RoboRioStringCallback callback, void* param, HAL_Bool initialNotify) { diff --git a/simulation/halsim_gui/src/main/native/cpp/RoboRioSimGui.cpp b/simulation/halsim_gui/src/main/native/cpp/RoboRioSimGui.cpp index d0689478c7..9e6a45edde 100644 --- a/simulation/halsim_gui/src/main/native/cpp/RoboRioSimGui.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/RoboRioSimGui.cpp @@ -15,65 +15,13 @@ using namespace halsimgui; namespace { -HALSIMGUI_DATASOURCE_BOOLEAN(RoboRioFPGAButton, "Rio User Button"); HALSIMGUI_DATASOURCE_DOUBLE(RoboRioVInVoltage, "Rio Input Voltage"); -HALSIMGUI_DATASOURCE_DOUBLE(RoboRioVInCurrent, "Rio Input Current"); -HALSIMGUI_DATASOURCE_DOUBLE(RoboRioUserVoltage6V, "Rio 6V Voltage"); -HALSIMGUI_DATASOURCE_DOUBLE(RoboRioUserCurrent6V, "Rio 6V Current"); -HALSIMGUI_DATASOURCE_BOOLEAN(RoboRioUserActive6V, "Rio 6V Active"); -HALSIMGUI_DATASOURCE_INT(RoboRioUserFaults6V, "Rio 6V Faults"); -HALSIMGUI_DATASOURCE_DOUBLE(RoboRioUserVoltage5V, "Rio 5V Voltage"); -HALSIMGUI_DATASOURCE_DOUBLE(RoboRioUserCurrent5V, "Rio 5V Current"); -HALSIMGUI_DATASOURCE_BOOLEAN(RoboRioUserActive5V, "Rio 5V Active"); -HALSIMGUI_DATASOURCE_INT(RoboRioUserFaults5V, "Rio 5V Faults"); HALSIMGUI_DATASOURCE_DOUBLE(RoboRioUserVoltage3V3, "Rio 3.3V Voltage"); HALSIMGUI_DATASOURCE_DOUBLE(RoboRioUserCurrent3V3, "Rio 3.3V Current"); HALSIMGUI_DATASOURCE_BOOLEAN(RoboRioUserActive3V3, "Rio 3.3V Active"); HALSIMGUI_DATASOURCE_INT(RoboRioUserFaults3V3, "Rio 3.3V Faults"); HALSIMGUI_DATASOURCE_DOUBLE(RoboRioBrownoutVoltage, "Rio Brownout Voltage"); -class RoboRioUser6VRailSimModel : public glass::RoboRioRailModel { - public: - void Update() override {} - bool Exists() override { return true; } - glass::DoubleSource* GetVoltageData() override { return &m_voltage; } - glass::DoubleSource* GetCurrentData() override { return &m_current; } - glass::BooleanSource* GetActiveData() override { return &m_active; } - glass::IntegerSource* GetFaultsData() override { return &m_faults; } - - void SetVoltage(double val) override { HALSIM_SetRoboRioUserVoltage6V(val); } - void SetCurrent(double val) override { HALSIM_SetRoboRioUserCurrent6V(val); } - void SetActive(bool val) override { HALSIM_SetRoboRioUserActive6V(val); } - void SetFaults(int val) override { HALSIM_SetRoboRioUserFaults6V(val); } - - private: - RoboRioUserVoltage6VSource m_voltage; - RoboRioUserCurrent6VSource m_current; - RoboRioUserActive6VSource m_active; - RoboRioUserFaults6VSource m_faults; -}; - -class RoboRioUser5VRailSimModel : public glass::RoboRioRailModel { - public: - void Update() override {} - bool Exists() override { return true; } - glass::DoubleSource* GetVoltageData() override { return &m_voltage; } - glass::DoubleSource* GetCurrentData() override { return &m_current; } - glass::BooleanSource* GetActiveData() override { return &m_active; } - glass::IntegerSource* GetFaultsData() override { return &m_faults; } - - void SetVoltage(double val) override { HALSIM_SetRoboRioUserVoltage5V(val); } - void SetCurrent(double val) override { HALSIM_SetRoboRioUserCurrent5V(val); } - void SetActive(bool val) override { HALSIM_SetRoboRioUserActive5V(val); } - void SetFaults(int val) override { HALSIM_SetRoboRioUserFaults5V(val); } - - private: - RoboRioUserVoltage5VSource m_voltage; - RoboRioUserCurrent5VSource m_current; - RoboRioUserActive5VSource m_active; - RoboRioUserFaults5VSource m_faults; -}; - class RoboRioUser3V3RailSimModel : public glass::RoboRioRailModel { public: void Update() override {} @@ -101,30 +49,20 @@ class RoboRioSimModel : public glass::RoboRioModel { bool Exists() override { return true; } - glass::RoboRioRailModel* GetUser6VRail() override { return &m_user6VRail; } - glass::RoboRioRailModel* GetUser5VRail() override { return &m_user5VRail; } glass::RoboRioRailModel* GetUser3V3Rail() override { return &m_user3V3Rail; } - glass::BooleanSource* GetUserButton() override { return &m_userButton; } glass::DoubleSource* GetVInVoltageData() override { return &m_vInVoltage; } - glass::DoubleSource* GetVInCurrentData() override { return &m_vInCurrent; } glass::DoubleSource* GetBrownoutVoltage() override { return &m_brownoutVoltage; } - void SetUserButton(bool val) override { HALSIM_SetRoboRioFPGAButton(val); } void SetVInVoltage(double val) override { HALSIM_SetRoboRioVInVoltage(val); } - void SetVInCurrent(double val) override { HALSIM_SetRoboRioVInCurrent(val); } void SetBrownoutVoltage(double val) override { HALSIM_SetRoboRioBrownoutVoltage(val); } private: - RoboRioFPGAButtonSource m_userButton; RoboRioVInVoltageSource m_vInVoltage; - RoboRioVInCurrentSource m_vInCurrent; - RoboRioUser6VRailSimModel m_user6VRail; - RoboRioUser5VRailSimModel m_user5VRail; RoboRioUser3V3RailSimModel m_user3V3Rail; RoboRioBrownoutVoltageSource m_brownoutVoltage; }; diff --git a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_RoboRIO.cpp b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_RoboRIO.cpp index c2998cb739..ebb272b01d 100644 --- a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_RoboRIO.cpp +++ b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_RoboRIO.cpp @@ -26,19 +26,7 @@ HALSimWSProviderRoboRIO::~HALSimWSProviderRoboRIO() { } void HALSimWSProviderRoboRIO::RegisterCallbacks() { - m_fpgaCbKey = REGISTER(FPGAButton, ">fpga_button", bool, boolean); m_vinVoltageCbKey = REGISTER(VInVoltage, ">vin_voltage", double, double); - m_vinCurrentCbKey = REGISTER(VInCurrent, ">vin_current", double, double); - - m_6vVoltageCbKey = REGISTER(UserVoltage6V, ">6v_voltage", double, double); - m_6vCurrentCbKey = REGISTER(UserCurrent6V, ">6v_current", double, double); - m_6vActiveCbKey = REGISTER(UserActive6V, ">6v_active", bool, boolean); - m_6vFaultsCbKey = REGISTER(UserFaults6V, ">6v_faults", int32_t, int); - - m_5vVoltageCbKey = REGISTER(UserVoltage5V, ">5v_voltage", double, double); - m_5vCurrentCbKey = REGISTER(UserCurrent5V, ">5v_current", double, double); - m_5vActiveCbKey = REGISTER(UserActive5V, ">5v_active", bool, boolean); - m_5vFaultsCbKey = REGISTER(UserFaults5V, ">5v_faults", int32_t, int); m_3v3VoltageCbKey = REGISTER(UserVoltage3V3, ">3v3_voltage", double, double); m_3v3CurrentCbKey = REGISTER(UserCurrent3V3, ">3v3_current", double, double); @@ -51,36 +39,14 @@ void HALSimWSProviderRoboRIO::CancelCallbacks() { } void HALSimWSProviderRoboRIO::DoCancelCallbacks() { - HALSIM_CancelRoboRioFPGAButtonCallback(m_fpgaCbKey); HALSIM_CancelRoboRioVInVoltageCallback(m_vinVoltageCbKey); - HALSIM_CancelRoboRioVInCurrentCallback(m_vinCurrentCbKey); - - HALSIM_CancelRoboRioUserVoltage6VCallback(m_6vVoltageCbKey); - HALSIM_CancelRoboRioUserCurrent6VCallback(m_6vCurrentCbKey); - HALSIM_CancelRoboRioUserActive6VCallback(m_6vActiveCbKey); - HALSIM_CancelRoboRioUserFaults6VCallback(m_6vFaultsCbKey); - - HALSIM_CancelRoboRioUserVoltage5VCallback(m_5vVoltageCbKey); - HALSIM_CancelRoboRioUserCurrent5VCallback(m_5vCurrentCbKey); - HALSIM_CancelRoboRioUserActive5VCallback(m_5vActiveCbKey); - HALSIM_CancelRoboRioUserFaults5VCallback(m_5vFaultsCbKey); HALSIM_CancelRoboRioUserVoltage3V3Callback(m_3v3VoltageCbKey); HALSIM_CancelRoboRioUserCurrent3V3Callback(m_3v3CurrentCbKey); HALSIM_CancelRoboRioUserActive3V3Callback(m_3v3ActiveCbKey); HALSIM_CancelRoboRioUserFaults3V3Callback(m_3v3FaultsCbKey); - m_fpgaCbKey = 0; m_vinVoltageCbKey = 0; - m_vinCurrentCbKey = 0; - m_6vActiveCbKey = 0; - m_6vCurrentCbKey = 0; - m_6vFaultsCbKey = 0; - m_6vVoltageCbKey = 0; - m_5vActiveCbKey = 0; - m_5vCurrentCbKey = 0; - m_5vFaultsCbKey = 0; - m_5vVoltageCbKey = 0; m_3v3ActiveCbKey = 0; m_3v3CurrentCbKey = 0; m_3v3FaultsCbKey = 0; @@ -89,42 +55,9 @@ void HALSimWSProviderRoboRIO::DoCancelCallbacks() { void HALSimWSProviderRoboRIO::OnNetValueChanged(const wpi::json& json) { wpi::json::const_iterator it; - if ((it = json.find(">fpga_button")) != json.end()) { - HALSIM_SetRoboRioFPGAButton(static_cast(it.value())); - } - if ((it = json.find(">vin_voltage")) != json.end()) { HALSIM_SetRoboRioVInVoltage(it.value()); } - if ((it = json.find(">vin_current")) != json.end()) { - HALSIM_SetRoboRioVInCurrent(it.value()); - } - - if ((it = json.find(">6v_voltage")) != json.end()) { - HALSIM_SetRoboRioUserVoltage6V(it.value()); - } - if ((it = json.find(">6v_current")) != json.end()) { - HALSIM_SetRoboRioUserCurrent6V(it.value()); - } - if ((it = json.find(">6v_active")) != json.end()) { - HALSIM_SetRoboRioUserActive6V(static_cast(it.value())); - } - if ((it = json.find(">6v_faults")) != json.end()) { - HALSIM_SetRoboRioUserFaults6V(it.value()); - } - - if ((it = json.find(">5v_voltage")) != json.end()) { - HALSIM_SetRoboRioUserVoltage5V(it.value()); - } - if ((it = json.find(">5v_current")) != json.end()) { - HALSIM_SetRoboRioUserCurrent5V(it.value()); - } - if ((it = json.find(">5v_active")) != json.end()) { - HALSIM_SetRoboRioUserActive5V(static_cast(it.value())); - } - if ((it = json.find(">5v_faults")) != json.end()) { - HALSIM_SetRoboRioUserFaults5V(it.value()); - } if ((it = json.find(">3v3_voltage")) != json.end()) { HALSIM_SetRoboRioUserVoltage3V3(it.value()); diff --git a/simulation/halsim_ws_core/src/main/native/include/WSProvider_RoboRIO.h b/simulation/halsim_ws_core/src/main/native/include/WSProvider_RoboRIO.h index 0b8e44ee94..55aa592932 100644 --- a/simulation/halsim_ws_core/src/main/native/include/WSProvider_RoboRIO.h +++ b/simulation/halsim_ws_core/src/main/native/include/WSProvider_RoboRIO.h @@ -25,17 +25,7 @@ class HALSimWSProviderRoboRIO : public HALSimWSHalProvider { void DoCancelCallbacks(); private: - int32_t m_fpgaCbKey = 0; int32_t m_vinVoltageCbKey = 0; - int32_t m_vinCurrentCbKey = 0; - int32_t m_6vVoltageCbKey = 0; - int32_t m_6vCurrentCbKey = 0; - int32_t m_6vActiveCbKey = 0; - int32_t m_6vFaultsCbKey = 0; - int32_t m_5vVoltageCbKey = 0; - int32_t m_5vCurrentCbKey = 0; - int32_t m_5vActiveCbKey = 0; - int32_t m_5vFaultsCbKey = 0; int32_t m_3v3VoltageCbKey = 0; int32_t m_3v3CurrentCbKey = 0; int32_t m_3v3ActiveCbKey = 0; diff --git a/wpilibc/src/main/native/cpp/AnalogEncoder.cpp b/wpilibc/src/main/native/cpp/AnalogEncoder.cpp index 31548e9425..f9263b0826 100644 --- a/wpilibc/src/main/native/cpp/AnalogEncoder.cpp +++ b/wpilibc/src/main/native/cpp/AnalogEncoder.cpp @@ -80,7 +80,7 @@ double AnalogEncoder::Get() const { } double analog = m_analogInput->GetVoltage(); - double pos = analog / RobotController::GetVoltage5V(); + double pos = analog / RobotController::GetVoltage3V3(); // Map sensor range if range isn't full pos = MapSensorRange(pos); diff --git a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp index 2855464bd6..b4d911297a 100644 --- a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp +++ b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp @@ -39,7 +39,7 @@ AnalogPotentiometer::AnalogPotentiometer(std::shared_ptr input, double AnalogPotentiometer::Get() const { return (m_analog_input->GetAverageVoltage() / - RobotController::GetVoltage5V()) * + RobotController::GetVoltage3V3()) * m_fullRange + m_offset; } diff --git a/wpilibc/src/main/native/cpp/RobotController.cpp b/wpilibc/src/main/native/cpp/RobotController.cpp index 57200d30e8..a676d3248c 100644 --- a/wpilibc/src/main/native/cpp/RobotController.cpp +++ b/wpilibc/src/main/native/cpp/RobotController.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include "frc/Errors.h" @@ -69,13 +68,6 @@ uint64_t RobotController::GetFPGATime() { return time; } -bool RobotController::GetUserButton() { - int32_t status = 0; - bool value = HAL_GetFPGAButton(&status); - FRC_CheckErrorStatus(status, "GetUserButton"); - return value; -} - units::volt_t RobotController::GetBatteryVoltage() { int32_t status = 0; double retVal = HAL_GetVinVoltage(&status); @@ -125,13 +117,6 @@ double RobotController::GetInputVoltage() { return retVal; } -double RobotController::GetInputCurrent() { - int32_t status = 0; - double retVal = HAL_GetVinCurrent(&status); - FRC_CheckErrorStatus(status, "GetInputCurrent"); - return retVal; -} - double RobotController::GetVoltage3V3() { int32_t status = 0; double retVal = HAL_GetUserVoltage3V3(&status); @@ -166,74 +151,6 @@ int RobotController::GetFaultCount3V3() { return retVal; } -double RobotController::GetVoltage5V() { - int32_t status = 0; - double retVal = HAL_GetUserVoltage5V(&status); - FRC_CheckErrorStatus(status, "GetVoltage5V"); - return retVal; -} - -double RobotController::GetCurrent5V() { - int32_t status = 0; - double retVal = HAL_GetUserCurrent5V(&status); - FRC_CheckErrorStatus(status, "GetCurrent5V"); - return retVal; -} - -void RobotController::SetEnabled5V(bool enabled) { - int32_t status = 0; - HAL_SetUserRailEnabled5V(enabled, &status); - FRC_CheckErrorStatus(status, "SetEnabled5V"); -} - -bool RobotController::GetEnabled5V() { - int32_t status = 0; - bool retVal = HAL_GetUserActive5V(&status); - FRC_CheckErrorStatus(status, "GetEnabled5V"); - return retVal; -} - -int RobotController::GetFaultCount5V() { - int32_t status = 0; - int retVal = HAL_GetUserCurrentFaults5V(&status); - FRC_CheckErrorStatus(status, "GetFaultCount5V"); - return retVal; -} - -double RobotController::GetVoltage6V() { - int32_t status = 0; - double retVal = HAL_GetUserVoltage6V(&status); - FRC_CheckErrorStatus(status, "GetVoltage6V"); - return retVal; -} - -double RobotController::GetCurrent6V() { - int32_t status = 0; - double retVal = HAL_GetUserCurrent6V(&status); - FRC_CheckErrorStatus(status, "GetCurrent6V"); - return retVal; -} - -void RobotController::SetEnabled6V(bool enabled) { - int32_t status = 0; - HAL_SetUserRailEnabled6V(enabled, &status); - FRC_CheckErrorStatus(status, "SetEnabled6V"); -} - -bool RobotController::GetEnabled6V() { - int32_t status = 0; - bool retVal = HAL_GetUserActive6V(&status); - FRC_CheckErrorStatus(status, "GetEnabled6V"); - return retVal; -} - -int RobotController::GetFaultCount6V() { - int32_t status = 0; - int retVal = HAL_GetUserCurrentFaults6V(&status); - FRC_CheckErrorStatus(status, "GetFaultCount6V"); - return retVal; -} - void RobotController::ResetRailFaultCounts() { int32_t status = 0; HAL_ResetUserCurrentFaults(&status); @@ -260,30 +177,6 @@ units::celsius_t RobotController::GetCPUTemp() { return units::celsius_t{retVal}; } -static_assert(RadioLEDState::kOff == - static_cast(HAL_RadioLEDState::HAL_RadioLED_kOff)); -static_assert( - RadioLEDState::kGreen == - static_cast(HAL_RadioLEDState::HAL_RadioLED_kGreen)); -static_assert(RadioLEDState::kRed == - static_cast(HAL_RadioLEDState::HAL_RadioLED_kRed)); -static_assert( - RadioLEDState::kOrange == - static_cast(HAL_RadioLEDState::HAL_RadioLED_kOrange)); - -void RobotController::SetRadioLEDState(RadioLEDState state) { - int32_t status = 0; - HAL_SetRadioLEDState(static_cast(state), &status); - FRC_CheckErrorStatus(status, "SetRadioLEDState"); -} - -RadioLEDState RobotController::GetRadioLEDState() { - int32_t status = 0; - auto retVal = static_cast(HAL_GetRadioLEDState(&status)); - FRC_CheckErrorStatus(status, "GetRadioLEDState"); - return retVal; -} - CANStatus RobotController::GetCANStatus(int busId) { int32_t status = 0; float percentBusUtilization = 0; diff --git a/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp b/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp index 4973080b54..c7fa8ded79 100644 --- a/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp +++ b/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp @@ -12,23 +12,6 @@ using namespace frc; using namespace frc::sim; -std::unique_ptr RoboRioSim::RegisterFPGAButtonCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioFPGAButtonCallback); - store->SetUid(HALSIM_RegisterRoboRioFPGAButtonCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -bool RoboRioSim::GetFPGAButton() { - return HALSIM_GetRoboRioFPGAButton(); -} - -void RoboRioSim::SetFPGAButton(bool fPGAButton) { - HALSIM_SetRoboRioFPGAButton(fPGAButton); -} - std::unique_ptr RoboRioSim::RegisterVInVoltageCallback( NotifyCallback callback, bool initialNotify) { auto store = std::make_unique( @@ -46,125 +29,6 @@ void RoboRioSim::SetVInVoltage(units::volt_t vInVoltage) { HALSIM_SetRoboRioVInVoltage(vInVoltage.value()); } -std::unique_ptr RoboRioSim::RegisterVInCurrentCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioVInCurrentCallback); - store->SetUid(HALSIM_RegisterRoboRioVInCurrentCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -units::ampere_t RoboRioSim::GetVInCurrent() { - return units::ampere_t{HALSIM_GetRoboRioVInCurrent()}; -} - -void RoboRioSim::SetVInCurrent(units::ampere_t vInCurrent) { - HALSIM_SetRoboRioVInCurrent(vInCurrent.value()); -} - -std::unique_ptr RoboRioSim::RegisterUserVoltage6VCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback); - store->SetUid(HALSIM_RegisterRoboRioUserVoltage6VCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -units::volt_t RoboRioSim::GetUserVoltage6V() { - return units::volt_t{HALSIM_GetRoboRioUserVoltage6V()}; -} - -void RoboRioSim::SetUserVoltage6V(units::volt_t userVoltage6V) { - HALSIM_SetRoboRioUserVoltage6V(userVoltage6V.value()); -} - -std::unique_ptr RoboRioSim::RegisterUserCurrent6VCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback); - store->SetUid(HALSIM_RegisterRoboRioUserCurrent6VCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -units::ampere_t RoboRioSim::GetUserCurrent6V() { - return units::ampere_t{HALSIM_GetRoboRioUserCurrent6V()}; -} - -void RoboRioSim::SetUserCurrent6V(units::ampere_t userCurrent6V) { - HALSIM_SetRoboRioUserCurrent6V(userCurrent6V.value()); -} - -std::unique_ptr RoboRioSim::RegisterUserActive6VCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioUserActive6VCallback); - store->SetUid(HALSIM_RegisterRoboRioUserActive6VCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -bool RoboRioSim::GetUserActive6V() { - return HALSIM_GetRoboRioUserActive6V(); -} - -void RoboRioSim::SetUserActive6V(bool userActive6V) { - HALSIM_SetRoboRioUserActive6V(userActive6V); -} - -std::unique_ptr RoboRioSim::RegisterUserVoltage5VCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback); - store->SetUid(HALSIM_RegisterRoboRioUserVoltage5VCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -units::volt_t RoboRioSim::GetUserVoltage5V() { - return units::volt_t{HALSIM_GetRoboRioUserVoltage5V()}; -} - -void RoboRioSim::SetUserVoltage5V(units::volt_t userVoltage5V) { - HALSIM_SetRoboRioUserVoltage5V(userVoltage5V.value()); -} - -std::unique_ptr RoboRioSim::RegisterUserCurrent5VCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback); - store->SetUid(HALSIM_RegisterRoboRioUserCurrent5VCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -units::ampere_t RoboRioSim::GetUserCurrent5V() { - return units::ampere_t{HALSIM_GetRoboRioUserCurrent5V()}; -} - -void RoboRioSim::SetUserCurrent5V(units::ampere_t userCurrent5V) { - HALSIM_SetRoboRioUserCurrent5V(userCurrent5V.value()); -} - -std::unique_ptr RoboRioSim::RegisterUserActive5VCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioUserActive5VCallback); - store->SetUid(HALSIM_RegisterRoboRioUserActive5VCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -bool RoboRioSim::GetUserActive5V() { - return HALSIM_GetRoboRioUserActive5V(); -} - -void RoboRioSim::SetUserActive5V(bool userActive5V) { - HALSIM_SetRoboRioUserActive5V(userActive5V); -} - std::unique_ptr RoboRioSim::RegisterUserVoltage3V3Callback( NotifyCallback callback, bool initialNotify) { auto store = std::make_unique( @@ -216,40 +80,6 @@ void RoboRioSim::SetUserActive3V3(bool userActive3V3) { HALSIM_SetRoboRioUserActive3V3(userActive3V3); } -std::unique_ptr RoboRioSim::RegisterUserFaults6VCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback); - store->SetUid(HALSIM_RegisterRoboRioUserFaults6VCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -int RoboRioSim::GetUserFaults6V() { - return HALSIM_GetRoboRioUserFaults6V(); -} - -void RoboRioSim::SetUserFaults6V(int userFaults6V) { - HALSIM_SetRoboRioUserFaults6V(userFaults6V); -} - -std::unique_ptr RoboRioSim::RegisterUserFaults5VCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback); - store->SetUid(HALSIM_RegisterRoboRioUserFaults5VCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -int RoboRioSim::GetUserFaults5V() { - return HALSIM_GetRoboRioUserFaults5V(); -} - -void RoboRioSim::SetUserFaults5V(int userFaults5V) { - HALSIM_SetRoboRioUserFaults5V(userFaults5V); -} - std::unique_ptr RoboRioSim::RegisterUserFaults3V3Callback( NotifyCallback callback, bool initialNotify) { auto store = std::make_unique( @@ -344,23 +174,6 @@ void RoboRioSim::SetComments(std::string_view comments) { HALSIM_SetRoboRioComments(&str); } -std::unique_ptr RoboRioSim::RegisterRadioLEDStateCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - -1, callback, &HALSIM_CancelRoboRioRadioLEDStateCallback); - store->SetUid(HALSIM_RegisterRoboRioRadioLEDStateCallback( - &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -RadioLEDState RoboRioSim::GetRadioLEDState() { - return static_cast(HALSIM_GetRoboRioRadioLEDState()); -} - -void RoboRioSim::SetRadioLEDState(RadioLEDState state) { - HALSIM_SetRoboRioRadioLEDState(static_cast(state)); -} - void RoboRioSim::ResetData() { HALSIM_ResetRoboRioData(); } diff --git a/wpilibc/src/main/native/include/frc/RobotController.h b/wpilibc/src/main/native/include/frc/RobotController.h index d696f1f171..6d10b51b09 100644 --- a/wpilibc/src/main/native/include/frc/RobotController.h +++ b/wpilibc/src/main/native/include/frc/RobotController.h @@ -22,14 +22,6 @@ struct CANStatus { int transmitErrorCount; }; -/** State for the radio led. */ -enum RadioLEDState { - kOff = 0, ///< Off. - kGreen = 1, ///< Green. - kRed = 2, ///< Red. - kOrange = 3 ///< Orange. -}; - class RobotController { public: RobotController() = delete; @@ -105,17 +97,6 @@ class RobotController { */ static uint64_t GetFPGATime(); - /** - * Get the state of the "USER" button on the roboRIO. - * - * @warning the User Button is used to stop user programs from automatically - * loading if it is held for more then 5 seconds. Because of this, it's not - * recommended to be used by teams for any other purpose. - * - * @return True if the button is currently pressed down - */ - static bool GetUserButton(); - /** * Read the battery voltage. * @@ -168,13 +149,6 @@ class RobotController { */ static double GetInputVoltage(); - /** - * Get the input current to the robot controller. - * - * @return The controller input current value in Amps - */ - static double GetInputCurrent(); - /** * Get the voltage of the 3.3V rail. * @@ -213,82 +187,6 @@ class RobotController { */ static int GetFaultCount3V3(); - /** - * Get the voltage of the 5V rail. - * - * @return The controller 5V rail voltage value in Volts - */ - static double GetVoltage5V(); - - /** - * Get the current output of the 5V rail. - * - * @return The controller 5V rail output current value in Amps - */ - static double GetCurrent5V(); - - /** - * Enables or disables the 5V rail. - * - * @param enabled whether to enable the 5V rail. - */ - static void SetEnabled5V(bool enabled); - - /** - * Get the enabled state of the 5V rail. The rail may be disabled due to - * calling SetEnabled5V(), a controller brownout, a short circuit on the rail, - * or controller over-voltage. - * - * @return The controller 5V rail enabled value. True for enabled. - */ - static bool GetEnabled5V(); - - /** - * Get the count of the total current faults on the 5V rail since the - * code started. - * - * @return The number of faults - */ - static int GetFaultCount5V(); - - /** - * Get the voltage of the 6V rail. - * - * @return The controller 6V rail voltage value in Volts - */ - static double GetVoltage6V(); - - /** - * Get the current output of the 6V rail. - * - * @return The controller 6V rail output current value in Amps - */ - static double GetCurrent6V(); - - /** - * Enables or disables the 6V rail. - * - * @param enabled whether to enable the 6V rail. - */ - static void SetEnabled6V(bool enabled); - - /** - * Get the enabled state of the 6V rail. The rail may be disabled due to - * calling SetEnabled6V(), a controller brownout, a short circuit on the rail, - * or controller over-voltage. - * - * @return The controller 6V rail enabled value. True for enabled. - */ - static bool GetEnabled6V(); - - /** - * Get the count of the total current faults on the 6V rail since the - * code started. - * - * @return The number of faults. - */ - static int GetFaultCount6V(); - /** Reset the overcurrent fault counters for all user rails to 0. */ static void ResetRailFaultCounts(); @@ -316,23 +214,6 @@ class RobotController { */ static units::celsius_t GetCPUTemp(); - /** - * Set the state of the "Radio" LED. On the RoboRIO, this writes to sysfs, so - * this function should not be called multiple times per loop cycle to avoid - * overruns. - * @param state The state to set the LED to. - */ - static void SetRadioLEDState(RadioLEDState state); - - /** - * Get the state of the "Radio" LED. On the RoboRIO, this reads from sysfs, so - * this function should not be called multiple times per loop cycle to avoid - * overruns. - * - * @return The state of the LED. - */ - static RadioLEDState GetRadioLEDState(); - /** * Get the current status of the CAN bus. * diff --git a/wpilibc/src/main/native/include/frc/simulation/RoboRioSim.h b/wpilibc/src/main/native/include/frc/simulation/RoboRioSim.h index 64713473a9..341b2f0c10 100644 --- a/wpilibc/src/main/native/include/frc/simulation/RoboRioSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/RoboRioSim.h @@ -21,31 +21,6 @@ namespace frc::sim { */ class RoboRioSim { public: - /** - * Register a callback to be run when the FPGA button state changes. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterFPGAButtonCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Query the state of the FPGA button. - * - * @return the FPGA button state - */ - static bool GetFPGAButton(); - - /** - * Define the state of the FPGA button. - * - * @param fPGAButton the new state - */ - static void SetFPGAButton(bool fPGAButton); - /** * Register a callback to be run whenever the Vin voltage changes. * @@ -71,188 +46,6 @@ class RoboRioSim { */ static void SetVInVoltage(units::volt_t vInVoltage); - /** - * Register a callback to be run whenever the Vin current changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial value - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterVInCurrentCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Measure the Vin current. - * - * @return the Vin current - */ - static units::ampere_t GetVInCurrent(); - - /** - * Define the Vin current. - * - * @param vInCurrent the new current - */ - static void SetVInCurrent(units::ampere_t vInCurrent); - - /** - * Register a callback to be run whenever the 6V rail voltage changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial value - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterUserVoltage6VCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Measure the 6V rail voltage. - * - * @return the 6V rail voltage - */ - static units::volt_t GetUserVoltage6V(); - - /** - * Define the 6V rail voltage. - * - * @param userVoltage6V the new voltage - */ - static void SetUserVoltage6V(units::volt_t userVoltage6V); - - /** - * Register a callback to be run whenever the 6V rail current changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial value - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterUserCurrent6VCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Measure the 6V rail current. - * - * @return the 6V rail current - */ - static units::ampere_t GetUserCurrent6V(); - - /** - * Define the 6V rail current. - * - * @param userCurrent6V the new current - */ - static void SetUserCurrent6V(units::ampere_t userCurrent6V); - - /** - * Register a callback to be run whenever the 6V rail active state changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial state - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterUserActive6VCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Get the 6V rail active state. - * - * @return true if the 6V rail is active - */ - static bool GetUserActive6V(); - - /** - * Set the 6V rail active state. - * - * @param userActive6V true to make rail active - */ - static void SetUserActive6V(bool userActive6V); - - /** - * Register a callback to be run whenever the 5V rail voltage changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial value - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterUserVoltage5VCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Measure the 5V rail voltage. - * - * @return the 5V rail voltage - */ - static units::volt_t GetUserVoltage5V(); - - /** - * Define the 5V rail voltage. - * - * @param userVoltage5V the new voltage - */ - static void SetUserVoltage5V(units::volt_t userVoltage5V); - - /** - * Register a callback to be run whenever the 5V rail current changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial value - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterUserCurrent5VCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Measure the 5V rail current. - * - * @return the 5V rail current - */ - static units::ampere_t GetUserCurrent5V(); - - /** - * Define the 5V rail current. - * - * @param userCurrent5V the new current - */ - static void SetUserCurrent5V(units::ampere_t userCurrent5V); - - /** - * Register a callback to be run whenever the 5V rail active state changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial state - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterUserActive5VCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Get the 5V rail active state. - * - * @return true if the 5V rail is active - */ - static bool GetUserActive5V(); - - /** - * Set the 5V rail active state. - * - * @param userActive5V true to make rail active - */ - static void SetUserActive5V(bool userActive5V); - /** * Register a callback to be run whenever the 3.3V rail voltage changes. * @@ -331,60 +124,6 @@ class RoboRioSim { */ static void SetUserActive3V3(bool userActive3V3); - /** - * Register a callback to be run whenever the 6V rail number of faults - * changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial value - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterUserFaults6VCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Get the 6V rail number of faults. - * - * @return number of faults - */ - static int GetUserFaults6V(); - - /** - * Set the 6V rail number of faults. - * - * @param userFaults6V number of faults - */ - static void SetUserFaults6V(int userFaults6V); - - /** - * Register a callback to be run whenever the 5V rail number of faults - * changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial value - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterUserFaults5VCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Get the 5V rail number of faults. - * - * @return number of faults - */ - static int GetUserFaults5V(); - - /** - * Set the 5V rail number of faults. - * - * @param userFaults5V number of faults - */ - static void SetUserFaults5V(int userFaults5V); - /** * Register a callback to be run whenever the 3.3V rail number of faults * changes. @@ -515,32 +254,6 @@ class RoboRioSim { */ static void SetComments(std::string_view comments); - /** - * Register a callback to be run whenever the Radio led state changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the - * initial value - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - static std::unique_ptr RegisterRadioLEDStateCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Get the state of the radio led. - * - * @return The state of the radio led. - */ - static RadioLEDState GetRadioLEDState(); - - /** - * Set the state of the radio led. - * - * @param state The state of the radio led. - */ - static void SetRadioLEDState(RadioLEDState state); - /** * Reset all simulation data. */ diff --git a/wpilibc/src/test/native/cpp/AnalogPotentiometerTest.cpp b/wpilibc/src/test/native/cpp/AnalogPotentiometerTest.cpp index c8d3068307..b42425f206 100644 --- a/wpilibc/src/test/native/cpp/AnalogPotentiometerTest.cpp +++ b/wpilibc/src/test/native/cpp/AnalogPotentiometerTest.cpp @@ -19,8 +19,8 @@ TEST(AnalogPotentiometerTest, InitializeWithAnalogInput) { AnalogInputSim sim{ai}; RoboRioSim::ResetData(); - sim.SetVoltage(4.0); - EXPECT_EQ(0.8, pot.Get()); + sim.SetVoltage(2.8); + EXPECT_EQ(2.8 / 3.3, pot.Get()); } TEST(AnalogPotentiometerTest, InitializeWithAnalogInputAndScale) { @@ -31,11 +31,11 @@ TEST(AnalogPotentiometerTest, InitializeWithAnalogInputAndScale) { RoboRioSim::ResetData(); AnalogInputSim sim{ai}; - sim.SetVoltage(5.0); + sim.SetVoltage(3.3); EXPECT_EQ(270.0, pot.Get()); sim.SetVoltage(2.5); - EXPECT_EQ(135, pot.Get()); + EXPECT_EQ((2.5 / 3.3) * 270.0, pot.Get()); sim.SetVoltage(0.0); EXPECT_EQ(0.0, pot.Get()); @@ -47,7 +47,7 @@ TEST(AnalogPotentiometerTest, InitializeWithChannel) { AnalogPotentiometer pot{1}; AnalogInputSim sim{1}; - sim.SetVoltage(5.0); + sim.SetVoltage(3.3); EXPECT_EQ(1.0, pot.Get()); } @@ -58,7 +58,7 @@ TEST(AnalogPotentiometerTest, InitializeWithChannelAndScale) { RoboRioSim::ResetData(); AnalogInputSim sim{1}; - sim.SetVoltage(5.0); + sim.SetVoltage(3.3); EXPECT_EQ(180.0, pot.Get()); sim.SetVoltage(0.0); @@ -70,23 +70,23 @@ TEST(AnalogPotentiometerTest, WithModifiedBatteryVoltage) { RoboRioSim::ResetData(); AnalogInputSim sim{1}; - // Test at 5v - sim.SetVoltage(5.0); + // Test at 3.3v + sim.SetVoltage(3.3); EXPECT_EQ(270, pot.Get()); sim.SetVoltage(0.0); EXPECT_EQ(90, pot.Get()); // Simulate a lower battery voltage - RoboRioSim::SetUserVoltage5V(units::volt_t{2.5}); + RoboRioSim::SetUserVoltage3V3(units::volt_t{2.5}); sim.SetVoltage(2.5); - EXPECT_EQ(270, pot.Get()); + EXPECT_EQ(270.0, pot.Get()); sim.SetVoltage(2.0); - EXPECT_EQ(234, pot.Get()); + EXPECT_EQ(234.0, pot.Get()); sim.SetVoltage(0.0); - EXPECT_EQ(90, pot.Get()); + EXPECT_EQ(90.0, pot.Get()); } } // namespace frc diff --git a/wpilibc/src/test/native/cpp/simulation/RoboRioSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/RoboRioSimTest.cpp index c713005659..45ccc9689a 100644 --- a/wpilibc/src/test/native/cpp/simulation/RoboRioSimTest.cpp +++ b/wpilibc/src/test/native/cpp/simulation/RoboRioSimTest.cpp @@ -15,51 +15,19 @@ namespace frc::sim { -TEST(RoboRioSimTest, FPGAButton) { - RoboRioSim::ResetData(); - - int dummyStatus = 0; - - BooleanCallback callback; - auto cb = - RoboRioSim::RegisterFPGAButtonCallback(callback.GetCallback(), false); - RoboRioSim::SetFPGAButton(true); - EXPECT_TRUE(RoboRioSim::GetFPGAButton()); - EXPECT_TRUE(HAL_GetFPGAButton(&dummyStatus)); - EXPECT_TRUE(callback.WasTriggered()); - EXPECT_TRUE(callback.GetLastValue()); - - callback.Reset(); - RoboRioSim::SetFPGAButton(false); - EXPECT_FALSE(RoboRioSim::GetFPGAButton()); - EXPECT_FALSE(HAL_GetFPGAButton(&dummyStatus)); - EXPECT_TRUE(callback.WasTriggered()); - EXPECT_FALSE(callback.GetLastValue()); -} - TEST(RoboRioSimTest, SetVin) { RoboRioSim::ResetData(); DoubleCallback voltageCallback; - DoubleCallback currentCallback; auto voltageCb = RoboRioSim::RegisterVInVoltageCallback( voltageCallback.GetCallback(), false); - auto currentCb = RoboRioSim::RegisterVInCurrentCallback( - currentCallback.GetCallback(), false); constexpr double kTestVoltage = 1.91; - constexpr double kTestCurrent = 35.04; RoboRioSim::SetVInVoltage(units::volt_t{kTestVoltage}); EXPECT_TRUE(voltageCallback.WasTriggered()); EXPECT_EQ(kTestVoltage, voltageCallback.GetLastValue()); EXPECT_EQ(kTestVoltage, RoboRioSim::GetVInVoltage().value()); EXPECT_EQ(kTestVoltage, RobotController::GetInputVoltage()); - - RoboRioSim::SetVInCurrent(units::ampere_t{kTestCurrent}); - EXPECT_TRUE(currentCallback.WasTriggered()); - EXPECT_EQ(kTestCurrent, currentCallback.GetLastValue()); - EXPECT_EQ(kTestCurrent, RoboRioSim::GetVInCurrent().value()); - EXPECT_EQ(kTestCurrent, RobotController::GetInputCurrent()); } TEST(RoboRioSimTest, SetBrownout) { @@ -77,94 +45,6 @@ TEST(RoboRioSimTest, SetBrownout) { EXPECT_EQ(kTestVoltage, RobotController::GetBrownoutVoltage().value()); } -TEST(RoboRioSimTest, Set6V) { - RoboRioSim::ResetData(); - - DoubleCallback voltageCallback; - DoubleCallback currentCallback; - BooleanCallback activeCallback; - IntCallback faultCallback; - auto voltageCb = RoboRioSim::RegisterUserVoltage6VCallback( - voltageCallback.GetCallback(), false); - auto currentCb = RoboRioSim::RegisterUserCurrent6VCallback( - currentCallback.GetCallback(), false); - auto activeCb = RoboRioSim::RegisterUserActive6VCallback( - activeCallback.GetCallback(), false); - auto faultsCb = RoboRioSim::RegisterUserFaults6VCallback( - faultCallback.GetCallback(), false); - constexpr double kTestVoltage = 22.9; - constexpr double kTestCurrent = 174; - constexpr int kTestFaults = 229; - - RoboRioSim::SetUserVoltage6V(units::volt_t{kTestVoltage}); - EXPECT_TRUE(voltageCallback.WasTriggered()); - EXPECT_EQ(kTestVoltage, voltageCallback.GetLastValue()); - EXPECT_EQ(kTestVoltage, RoboRioSim::GetUserVoltage6V().value()); - EXPECT_EQ(kTestVoltage, RobotController::GetVoltage6V()); - - RoboRioSim::SetUserCurrent6V(units::ampere_t{kTestCurrent}); - EXPECT_TRUE(currentCallback.WasTriggered()); - EXPECT_EQ(kTestCurrent, currentCallback.GetLastValue()); - EXPECT_EQ(kTestCurrent, RoboRioSim::GetUserCurrent6V().value()); - EXPECT_EQ(kTestCurrent, RobotController::GetCurrent6V()); - - RoboRioSim::SetUserActive6V(false); - EXPECT_TRUE(activeCallback.WasTriggered()); - EXPECT_FALSE(activeCallback.GetLastValue()); - EXPECT_FALSE(RoboRioSim::GetUserActive6V()); - EXPECT_FALSE(RobotController::GetEnabled6V()); - - RoboRioSim::SetUserFaults6V(kTestFaults); - EXPECT_TRUE(faultCallback.WasTriggered()); - EXPECT_EQ(kTestFaults, faultCallback.GetLastValue()); - EXPECT_EQ(kTestFaults, RoboRioSim::GetUserFaults6V()); - EXPECT_EQ(kTestFaults, RobotController::GetFaultCount6V()); -} - -TEST(RoboRioSimTest, Set5V) { - RoboRioSim::ResetData(); - - DoubleCallback voltageCallback; - DoubleCallback currentCallback; - BooleanCallback activeCallback; - IntCallback faultCallback; - auto voltageCb = RoboRioSim::RegisterUserVoltage5VCallback( - voltageCallback.GetCallback(), false); - auto currentCb = RoboRioSim::RegisterUserCurrent5VCallback( - currentCallback.GetCallback(), false); - auto activeCb = RoboRioSim::RegisterUserActive5VCallback( - activeCallback.GetCallback(), false); - auto faultsCb = RoboRioSim::RegisterUserFaults5VCallback( - faultCallback.GetCallback(), false); - constexpr double kTestVoltage = 22.9; - constexpr double kTestCurrent = 174; - constexpr int kTestFaults = 229; - - RoboRioSim::SetUserVoltage5V(units::volt_t{kTestVoltage}); - EXPECT_TRUE(voltageCallback.WasTriggered()); - EXPECT_EQ(kTestVoltage, voltageCallback.GetLastValue()); - EXPECT_EQ(kTestVoltage, RoboRioSim::GetUserVoltage5V().value()); - EXPECT_EQ(kTestVoltage, RobotController::GetVoltage5V()); - - RoboRioSim::SetUserCurrent5V(units::ampere_t{kTestCurrent}); - EXPECT_TRUE(currentCallback.WasTriggered()); - EXPECT_EQ(kTestCurrent, currentCallback.GetLastValue()); - EXPECT_EQ(kTestCurrent, RoboRioSim::GetUserCurrent5V().value()); - EXPECT_EQ(kTestCurrent, RobotController::GetCurrent5V()); - - RoboRioSim::SetUserActive5V(false); - EXPECT_TRUE(activeCallback.WasTriggered()); - EXPECT_FALSE(activeCallback.GetLastValue()); - EXPECT_FALSE(RoboRioSim::GetUserActive5V()); - EXPECT_FALSE(RobotController::GetEnabled5V()); - - RoboRioSim::SetUserFaults5V(kTestFaults); - EXPECT_TRUE(faultCallback.WasTriggered()); - EXPECT_EQ(kTestFaults, faultCallback.GetLastValue()); - EXPECT_EQ(kTestFaults, RoboRioSim::GetUserFaults5V()); - EXPECT_EQ(kTestFaults, RobotController::GetFaultCount5V()); -} - TEST(RoboRioSimTest, Set3V3) { RoboRioSim::ResetData(); @@ -276,26 +156,4 @@ TEST(RoboRioSimTest, SetComments) { EXPECT_EQ(kCommentsTruncated, RobotController::GetComments()); } -TEST(RoboRioSimTest, SetRadioLEDState) { - RoboRioSim::ResetData(); - - EnumCallback callback; - auto cbHandle = - RoboRioSim::RegisterRadioLEDStateCallback(callback.GetCallback(), false); - - RobotController::SetRadioLEDState(RadioLEDState::kGreen); - EXPECT_TRUE(callback.WasTriggered()); - EXPECT_EQ(RadioLEDState::kGreen, callback.GetLastValue()); - EXPECT_EQ(RadioLEDState::kGreen, RoboRioSim::GetRadioLEDState()); - EXPECT_EQ(RadioLEDState::kGreen, RobotController::GetRadioLEDState()); - - callback.Reset(); - - RoboRioSim::SetRadioLEDState(RadioLEDState::kOrange); - EXPECT_TRUE(callback.WasTriggered()); - EXPECT_EQ(RadioLEDState::kOrange, callback.GetLastValue()); - EXPECT_EQ(RadioLEDState::kOrange, RoboRioSim::GetRadioLEDState()); - EXPECT_EQ(RadioLEDState::kOrange, RobotController::GetRadioLEDState()); -} - } // namespace frc::sim diff --git a/wpilibcExamples/src/test/cpp/examples/PotentiometerPID/cpp/PotentiometerPIDTest.cpp b/wpilibcExamples/src/test/cpp/examples/PotentiometerPID/cpp/PotentiometerPIDTest.cpp index 9d2691c1d0..417ba6418e 100644 --- a/wpilibcExamples/src/test/cpp/examples/PotentiometerPID/cpp/PotentiometerPIDTest.cpp +++ b/wpilibcExamples/src/test/cpp/examples/PotentiometerPID/cpp/PotentiometerPIDTest.cpp @@ -57,7 +57,7 @@ class PotentiometerPIDTest : public testing::Test { 5v * (meters / range) = v */ m_analogSim.SetVoltage( - (frc::RobotController::GetVoltage5V() * + (frc::RobotController::GetVoltage3V3() * (m_elevatorSim.GetPosition().value() / Robot::kFullHeight)) .value()); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogEncoder.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogEncoder.java index d76f4d63da..b57370cfc5 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogEncoder.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogEncoder.java @@ -112,7 +112,7 @@ public class AnalogEncoder implements Sendable, AutoCloseable { } double analog = m_analogInput.getVoltage(); - double pos = analog / RobotController.getVoltage5V(); + double pos = analog / RobotController.getVoltage3V3(); // Map sensor range if range isn't full pos = mapSensorRange(pos); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java index b7c32b2390..7e9bc3007b 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java @@ -125,7 +125,7 @@ public class AnalogPotentiometer implements Sendable, AutoCloseable { if (m_analogInput == null) { return m_offset; } - return (m_analogInput.getAverageVoltage() / RobotController.getVoltage5V()) * m_fullRange + return (m_analogInput.getAverageVoltage() / RobotController.getVoltage3V3()) * m_fullRange + m_offset; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java index e54038e921..93aa5c5107 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java @@ -11,7 +11,6 @@ import static edu.wpi.first.units.Units.Volts; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.HALUtil; -import edu.wpi.first.hal.LEDJNI; import edu.wpi.first.hal.PowerJNI; import edu.wpi.first.hal.can.CANJNI; import edu.wpi.first.hal.can.CANStatus; @@ -129,19 +128,6 @@ public final class RobotController { return Microseconds.of(HALUtil.getFPGATime()); } - /** - * Get the state of the "USER" button on the roboRIO. - * - *

Warning: the User Button is used to stop user programs from automatically loading if it is - * held for more then 5 seconds. Because of this, it's not recommended to be used by teams for any - * other purpose. - * - * @return true if the button is currently pressed down - */ - public static boolean getUserButton() { - return HALUtil.getFPGAButton(); - } - /** * Read the battery voltage. * @@ -225,24 +211,6 @@ public final class RobotController { return Volts.of(PowerJNI.getVinVoltage()); } - /** - * Get the input current to the robot controller. - * - * @return The controller input current value in Amps - */ - public static double getInputCurrent() { - return PowerJNI.getVinCurrent(); - } - - /** - * Get the input current to the robot controller in a measure. - * - * @return The controller input current value in a measure. - */ - public static Current getMeasureInputCurrent() { - return Amps.of(PowerJNI.getVinCurrent()); - } - /** * Get the voltage of the 3.3V rail. * @@ -307,134 +275,6 @@ public final class RobotController { return PowerJNI.getUserCurrentFaults3V3(); } - /** - * Get the voltage of the 5V rail. - * - * @return The controller 5V rail voltage value in Volts - */ - public static double getVoltage5V() { - return PowerJNI.getUserVoltage5V(); - } - - /** - * Get the voltage in a measure of the 5V rail. - * - * @return The controller 5V rail voltage value in a measure. - */ - public static Voltage getMeasureVoltage5V() { - return Volts.of(PowerJNI.getUserVoltage5V()); - } - - /** - * Get the current output of the 5V rail. - * - * @return The controller 5V rail output current value in Amps - */ - public static double getCurrent5V() { - return PowerJNI.getUserCurrent5V(); - } - - /** - * Get the current output in a measure of the 5V rail. - * - * @return The controller 5V rail output current value in a measure. - */ - public static Current getMeasureCurrent5V() { - return Amps.of(PowerJNI.getUserCurrent5V()); - } - - /** - * Enables or disables the 5V rail. - * - * @param enabled whether to enable the 5V rail. - */ - public static void setEnabled5V(boolean enabled) { - PowerJNI.setUserEnabled5V(enabled); - } - - /** - * Get the enabled state of the 5V rail. The rail may be disabled due to a controller brownout, a - * short circuit on the rail, or controller over-voltage. - * - * @return The controller 5V rail enabled value - */ - public static boolean getEnabled5V() { - return PowerJNI.getUserActive5V(); - } - - /** - * Get the count of the total current faults on the 5V rail since the code started. - * - * @return The number of faults - */ - public static int getFaultCount5V() { - return PowerJNI.getUserCurrentFaults5V(); - } - - /** - * Get the voltage of the 6V rail. - * - * @return The controller 6V rail voltage value in Volts - */ - public static double getVoltage6V() { - return PowerJNI.getUserVoltage6V(); - } - - /** - * Get the voltage in a measure of the 6V rail. - * - * @return The controller 6V rail voltage value in a measure. - */ - public static Voltage getMeasureVoltage6V() { - return Volts.of(PowerJNI.getUserVoltage6V()); - } - - /** - * Get the current output of the 6V rail. - * - * @return The controller 6V rail output current value in Amps - */ - public static double getCurrent6V() { - return PowerJNI.getUserCurrent6V(); - } - - /** - * Get the current output in a measure of the 6V rail. - * - * @return The controller 6V rail output current value in a measure. - */ - public static Current getMeasureCurrent6V() { - return Amps.of(PowerJNI.getUserCurrent6V()); - } - - /** - * Enables or disables the 6V rail. - * - * @param enabled whether to enable the 6V rail. - */ - public static void setEnabled6V(boolean enabled) { - PowerJNI.setUserEnabled6V(enabled); - } - - /** - * Get the enabled state of the 6V rail. The rail may be disabled due to a controller brownout, a - * short circuit on the rail, or controller over-voltage. - * - * @return The controller 6V rail enabled value - */ - public static boolean getEnabled6V() { - return PowerJNI.getUserActive6V(); - } - - /** - * Get the count of the total current faults on the 6V rail since the code started. - * - * @return The number of faults - */ - public static int getFaultCount6V() { - return PowerJNI.getUserCurrentFaults6V(); - } - /** Reset the overcurrent fault counters for all user rails to 0. */ public static void resetRailFaultCounts() { PowerJNI.resetUserCurrentFaults(); @@ -498,61 +338,6 @@ public final class RobotController { return Celsius.of(PowerJNI.getCPUTemp()); } - /** State for the radio led. */ - public enum RadioLEDState { - /** Off. */ - kOff(LEDJNI.RADIO_LED_STATE_OFF), - /** Green. */ - kGreen(LEDJNI.RADIO_LED_STATE_GREEN), - /** Red. */ - kRed(LEDJNI.RADIO_LED_STATE_RED), - /** Orange. */ - kOrange(LEDJNI.RADIO_LED_STATE_ORANGE); - - /** The native value for this state. */ - public final int value; - - RadioLEDState(int value) { - this.value = value; - } - - /** - * Gets a state from an int value. - * - * @param value int value - * @return state - */ - public static RadioLEDState fromValue(int value) { - return switch (value) { - case LEDJNI.RADIO_LED_STATE_OFF -> RadioLEDState.kOff; - case LEDJNI.RADIO_LED_STATE_GREEN -> RadioLEDState.kGreen; - case LEDJNI.RADIO_LED_STATE_RED -> RadioLEDState.kRed; - case LEDJNI.RADIO_LED_STATE_ORANGE -> RadioLEDState.kOrange; - default -> RadioLEDState.kOff; - }; - } - } - - /** - * Set the state of the "Radio" LED. On the RoboRIO, this writes to sysfs, so this function should - * not be called multiple times per loop cycle to avoid overruns. - * - * @param state The state to set the LED to. - */ - public static void setRadioLEDState(RadioLEDState state) { - LEDJNI.setRadioLEDState(state.value); - } - - /** - * Get the state of the "Radio" LED. On the RoboRIO, this reads from sysfs, so this function - * should not be called multiple times per loop cycle to avoid overruns. - * - * @return The state of the LED. - */ - public static RadioLEDState getRadioLEDState() { - return RadioLEDState.fromValue(LEDJNI.getRadioLEDState()); - } - /** * Get the current status of the CAN bus. * diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/RoboRioSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/RoboRioSim.java index d347999cee..f5475a8733 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/RoboRioSim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/RoboRioSim.java @@ -6,8 +6,6 @@ package edu.wpi.first.wpilibj.simulation; import edu.wpi.first.hal.simulation.NotifyCallback; import edu.wpi.first.hal.simulation.RoboRioDataJNI; -import edu.wpi.first.wpilibj.RobotController; -import edu.wpi.first.wpilibj.RobotController.RadioLEDState; /** A utility class to control a simulated RoboRIO. */ public final class RoboRioSim { @@ -15,37 +13,6 @@ public final class RoboRioSim { // Utility class } - /** - * Register a callback to be run when the FPGA button state changes. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerFPGAButtonCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerFPGAButtonCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelFPGAButtonCallback); - } - - /** - * Query the state of the FPGA button. - * - * @return the FPGA button state - */ - public static boolean getFPGAButton() { - return RoboRioDataJNI.getFPGAButton(); - } - - /** - * Define the state of the FPGA button. - * - * @param fpgaButton the new state - */ - public static void setFPGAButton(boolean fpgaButton) { - RoboRioDataJNI.setFPGAButton(fpgaButton); - } - /** * Register a callback to be run whenever the Vin voltage changes. * @@ -77,223 +44,6 @@ public final class RoboRioSim { RoboRioDataJNI.setVInVoltage(vInVoltage); } - /** - * Register a callback to be run whenever the Vin current changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the initial value - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerVInCurrentCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerVInCurrentCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelVInCurrentCallback); - } - - /** - * Measure the Vin current. - * - * @return the Vin current - */ - public static double getVInCurrent() { - return RoboRioDataJNI.getVInCurrent(); - } - - /** - * Define the Vin current. - * - * @param vInCurrent the new current - */ - public static void setVInCurrent(double vInCurrent) { - RoboRioDataJNI.setVInCurrent(vInCurrent); - } - - /** - * Register a callback to be run whenever the 6V rail voltage changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the initial value - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerUserVoltage6VCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerUserVoltage6VCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelUserVoltage6VCallback); - } - - /** - * Measure the 6V rail voltage. - * - * @return the 6V rail voltage - */ - public static double getUserVoltage6V() { - return RoboRioDataJNI.getUserVoltage6V(); - } - - /** - * Define the 6V rail voltage. - * - * @param userVoltage6V the new voltage - */ - public static void setUserVoltage6V(double userVoltage6V) { - RoboRioDataJNI.setUserVoltage6V(userVoltage6V); - } - - /** - * Register a callback to be run whenever the 6V rail current changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the initial value - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerUserCurrent6VCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerUserCurrent6VCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelUserCurrent6VCallback); - } - - /** - * Measure the 6V rail current. - * - * @return the 6V rail current - */ - public static double getUserCurrent6V() { - return RoboRioDataJNI.getUserCurrent6V(); - } - - /** - * Define the 6V rail current. - * - * @param userCurrent6V the new current - */ - public static void setUserCurrent6V(double userCurrent6V) { - RoboRioDataJNI.setUserCurrent6V(userCurrent6V); - } - - /** - * Register a callback to be run whenever the 6V rail active state changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the initial state - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerUserActive6VCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerUserActive6VCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelUserActive6VCallback); - } - - /** - * Get the 6V rail active state. - * - * @return true if the 6V rail is active - */ - public static boolean getUserActive6V() { - return RoboRioDataJNI.getUserActive6V(); - } - - /** - * Set the 6V rail active state. - * - * @param userActive6V true to make rail active - */ - public static void setUserActive6V(boolean userActive6V) { - RoboRioDataJNI.setUserActive6V(userActive6V); - } - - /** - * Register a callback to be run whenever the 5V rail voltage changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the initial value - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerUserVoltage5VCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerUserVoltage5VCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelUserVoltage5VCallback); - } - - /** - * Measure the 5V rail voltage. - * - * @return the 5V rail voltage - */ - public static double getUserVoltage5V() { - return RoboRioDataJNI.getUserVoltage5V(); - } - - /** - * Define the 5V rail voltage. - * - * @param userVoltage5V the new voltage - */ - public static void setUserVoltage5V(double userVoltage5V) { - RoboRioDataJNI.setUserVoltage5V(userVoltage5V); - } - - /** - * Register a callback to be run whenever the 5V rail current changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the initial value - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerUserCurrent5VCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerUserCurrent5VCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelUserCurrent5VCallback); - } - - /** - * Measure the 5V rail current. - * - * @return the 5V rail current - */ - public static double getUserCurrent5V() { - return RoboRioDataJNI.getUserCurrent5V(); - } - - /** - * Define the 5V rail current. - * - * @param userCurrent5V the new current - */ - public static void setUserCurrent5V(double userCurrent5V) { - RoboRioDataJNI.setUserCurrent5V(userCurrent5V); - } - - /** - * Register a callback to be run whenever the 5V rail active state changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the initial state - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerUserActive5VCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerUserActive5VCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelUserActive5VCallback); - } - - /** - * Get the 5V rail active state. - * - * @return true if the 5V rail is active - */ - public static boolean getUserActive5V() { - return RoboRioDataJNI.getUserActive5V(); - } - - /** - * Set the 5V rail active state. - * - * @param userActive5V true to make rail active - */ - public static void setUserActive5V(boolean userActive5V) { - RoboRioDataJNI.setUserActive5V(userActive5V); - } - /** * Register a callback to be run whenever the 3.3V rail voltage changes. * @@ -387,68 +137,6 @@ public final class RoboRioSim { RoboRioDataJNI.setUserActive3V3(userActive3V3); } - /** - * Register a callback to be run whenever the 6V rail number of faults changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the initial value - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerUserFaults6VCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerUserFaults6VCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelUserFaults6VCallback); - } - - /** - * Get the 6V rail number of faults. - * - * @return number of faults - */ - public static int getUserFaults6V() { - return RoboRioDataJNI.getUserFaults6V(); - } - - /** - * Set the 6V rail number of faults. - * - * @param userFaults6V number of faults - */ - public static void setUserFaults6V(int userFaults6V) { - RoboRioDataJNI.setUserFaults6V(userFaults6V); - } - - /** - * Register a callback to be run whenever the 5V rail number of faults changes. - * - * @param callback the callback - * @param initialNotify whether the callback should be called with the initial value - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerUserFaults5VCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerUserFaults5VCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelUserFaults5VCallback); - } - - /** - * Get the 5V rail number of faults. - * - * @return number of faults - */ - public static int getUserFaults5V() { - return RoboRioDataJNI.getUserFaults5V(); - } - - /** - * Set the 5V rail number of faults. - * - * @param userFaults5V number of faults - */ - public static void setUserFaults5V(int userFaults5V) { - RoboRioDataJNI.setUserFaults5V(userFaults5V); - } - /** * Register a callback to be run whenever the 3.3V rail number of faults changes. * @@ -609,37 +297,6 @@ public final class RoboRioSim { RoboRioDataJNI.setComments(comments); } - /** - * Register a callback to be run whenever the Radio led state changes. - * - * @param callback the callback - * @param initialNotify whether to call the callback with the initial state - * @return the {@link CallbackStore} object associated with this callback. - */ - public static CallbackStore registerRadioLEDStateCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RoboRioDataJNI.registerRadioLEDStateCallback(callback, initialNotify); - return new CallbackStore(uid, RoboRioDataJNI::cancelRadioLEDStateCallback); - } - - /** - * Get the state of the radio led. - * - * @return The state of the radio led. - */ - public static RadioLEDState getRadioLEDState() { - return RadioLEDState.fromValue(RoboRioDataJNI.getRadioLEDState()); - } - - /** - * Set the state of the radio led. - * - * @param state The state of the radio led. - */ - public static void setRadioLEDState(RobotController.RadioLEDState state) { - RoboRioDataJNI.setRadioLEDState(state.value); - } - /** Reset all simulation data. */ public static void resetData() { RoboRioDataJNI.resetData(); diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java index 7c6536e123..928332ddc1 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java @@ -21,8 +21,8 @@ class AnalogPotentiometerTest { AnalogInputSim sim = new AnalogInputSim(ai); RoboRioSim.resetData(); - sim.setVoltage(4.0); - assertEquals(0.8, pot.get()); + sim.setVoltage(2.8); + assertEquals(2.8 / 3.3, pot.get()); } } @@ -35,11 +35,11 @@ class AnalogPotentiometerTest { RoboRioSim.resetData(); AnalogInputSim sim = new AnalogInputSim(ai); - sim.setVoltage(5.0); + sim.setVoltage(3.3); assertEquals(270.0, pot.get()); sim.setVoltage(2.5); - assertEquals(135, pot.get()); + assertEquals((2.5 / 3.3) * 270.0, pot.get()); sim.setVoltage(0.0); assertEquals(0.0, pot.get()); @@ -54,7 +54,7 @@ class AnalogPotentiometerTest { RoboRioSim.resetData(); AnalogInputSim sim = new AnalogInputSim(1); - sim.setVoltage(5.0); + sim.setVoltage(3.3); assertEquals(1.0, pot.get()); } } @@ -67,7 +67,7 @@ class AnalogPotentiometerTest { RoboRioSim.resetData(); AnalogInputSim sim = new AnalogInputSim(1); - sim.setVoltage(5.0); + sim.setVoltage(3.3); assertEquals(180.0, pot.get()); sim.setVoltage(0.0); @@ -82,14 +82,14 @@ class AnalogPotentiometerTest { AnalogInputSim sim = new AnalogInputSim(1); // Test at 5v - sim.setVoltage(5.0); + sim.setVoltage(3.3); assertEquals(270, pot.get()); sim.setVoltage(0.0); assertEquals(90, pot.get()); // Simulate a lower battery voltage - RoboRioSim.setUserVoltage5V(2.5); + RoboRioSim.setUserVoltage3V3(2.5); sim.setVoltage(2.5); assertEquals(270, pot.get()); diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/RoboRioSimTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/RoboRioSimTest.java index 01029cd793..ecd52faf2a 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/RoboRioSimTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/RoboRioSimTest.java @@ -8,59 +8,26 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import edu.wpi.first.hal.HALUtil; import edu.wpi.first.wpilibj.RobotController; -import edu.wpi.first.wpilibj.RobotController.RadioLEDState; import edu.wpi.first.wpilibj.simulation.testutils.BooleanCallback; import edu.wpi.first.wpilibj.simulation.testutils.DoubleCallback; -import edu.wpi.first.wpilibj.simulation.testutils.EnumCallback; import edu.wpi.first.wpilibj.simulation.testutils.IntCallback; import org.junit.jupiter.api.Test; class RoboRioSimTest { - @Test - void testFPGAButton() { - RoboRioSim.resetData(); - - BooleanCallback callback = new BooleanCallback(); - try (CallbackStore cb = RoboRioSim.registerFPGAButtonCallback(callback, false)) { - RoboRioSim.setFPGAButton(true); - assertTrue(RoboRioSim.getFPGAButton()); - assertTrue(HALUtil.getFPGAButton()); - assertTrue(callback.wasTriggered()); - assertTrue(callback.getSetValue()); - - callback.reset(); - RoboRioSim.setFPGAButton(false); - assertFalse(RoboRioSim.getFPGAButton()); - assertFalse(HALUtil.getFPGAButton()); - assertTrue(callback.wasTriggered()); - assertFalse(callback.getSetValue()); - } - } - @Test void testSetVin() { RoboRioSim.resetData(); DoubleCallback voltageCallback = new DoubleCallback(); - DoubleCallback currentCallback = new DoubleCallback(); - try (CallbackStore voltageCb = RoboRioSim.registerVInVoltageCallback(voltageCallback, false); - CallbackStore currentCb = RoboRioSim.registerVInCurrentCallback(currentCallback, false)) { + try (CallbackStore voltageCb = RoboRioSim.registerVInVoltageCallback(voltageCallback, false)) { final double kTestVoltage = 1.91; - final double kTestCurrent = 35.04; RoboRioSim.setVInVoltage(kTestVoltage); assertTrue(voltageCallback.wasTriggered()); assertEquals(kTestVoltage, voltageCallback.getSetValue()); assertEquals(kTestVoltage, RoboRioSim.getVInVoltage()); assertEquals(kTestVoltage, RobotController.getInputVoltage()); - - RoboRioSim.setVInCurrent(kTestCurrent); - assertTrue(currentCallback.wasTriggered()); - assertEquals(kTestCurrent, currentCallback.getSetValue()); - assertEquals(kTestCurrent, RoboRioSim.getVInCurrent()); - assertEquals(kTestCurrent, RobotController.getInputCurrent()); } } @@ -81,92 +48,6 @@ class RoboRioSimTest { } } - @Test - void test6V() { - RoboRioSim.resetData(); - - DoubleCallback voltageCallback = new DoubleCallback(); - DoubleCallback currentCallback = new DoubleCallback(); - BooleanCallback activeCallback = new BooleanCallback(); - IntCallback faultCallback = new IntCallback(); - try (CallbackStore voltageCb = - RoboRioSim.registerUserVoltage6VCallback(voltageCallback, false); - CallbackStore currentCb = RoboRioSim.registerUserCurrent6VCallback(currentCallback, false); - CallbackStore activeCb = RoboRioSim.registerUserActive6VCallback(activeCallback, false); - CallbackStore faultsCb = RoboRioSim.registerUserFaults6VCallback(faultCallback, false)) { - final double kTestVoltage = 22.9; - final double kTestCurrent = 174; - final int kTestFaults = 229; - - RoboRioSim.setUserVoltage6V(kTestVoltage); - assertTrue(voltageCallback.wasTriggered()); - assertEquals(kTestVoltage, voltageCallback.getSetValue()); - assertEquals(kTestVoltage, RoboRioSim.getUserVoltage6V()); - assertEquals(kTestVoltage, RobotController.getVoltage6V()); - - RoboRioSim.setUserCurrent6V(kTestCurrent); - assertTrue(currentCallback.wasTriggered()); - assertEquals(kTestCurrent, currentCallback.getSetValue()); - assertEquals(kTestCurrent, RoboRioSim.getUserCurrent6V()); - assertEquals(kTestCurrent, RobotController.getCurrent6V()); - - RoboRioSim.setUserActive6V(false); - assertTrue(activeCallback.wasTriggered()); - assertFalse(activeCallback.getSetValue()); - assertFalse(RoboRioSim.getUserActive6V()); - assertFalse(RobotController.getEnabled6V()); - - RoboRioSim.setUserFaults6V(kTestFaults); - assertTrue(faultCallback.wasTriggered()); - assertEquals(kTestFaults, faultCallback.getSetValue()); - assertEquals(kTestFaults, RoboRioSim.getUserFaults6V()); - assertEquals(kTestFaults, RobotController.getFaultCount6V()); - } - } - - @Test - void test5V() { - RoboRioSim.resetData(); - - DoubleCallback voltageCallback = new DoubleCallback(); - DoubleCallback currentCallback = new DoubleCallback(); - BooleanCallback activeCallback = new BooleanCallback(); - IntCallback faultCallback = new IntCallback(); - try (CallbackStore voltageCb = - RoboRioSim.registerUserVoltage5VCallback(voltageCallback, false); - CallbackStore currentCb = RoboRioSim.registerUserCurrent5VCallback(currentCallback, false); - CallbackStore activeCb = RoboRioSim.registerUserActive5VCallback(activeCallback, false); - CallbackStore faultsCb = RoboRioSim.registerUserFaults5VCallback(faultCallback, false)) { - final double kTestVoltage = 22.9; - final double kTestCurrent = 174; - final int kTestFaults = 229; - - RoboRioSim.setUserVoltage5V(kTestVoltage); - assertTrue(voltageCallback.wasTriggered()); - assertEquals(kTestVoltage, voltageCallback.getSetValue()); - assertEquals(kTestVoltage, RoboRioSim.getUserVoltage5V()); - assertEquals(kTestVoltage, RobotController.getVoltage5V()); - - RoboRioSim.setUserCurrent5V(kTestCurrent); - assertTrue(currentCallback.wasTriggered()); - assertEquals(kTestCurrent, currentCallback.getSetValue()); - assertEquals(kTestCurrent, RoboRioSim.getUserCurrent5V()); - assertEquals(kTestCurrent, RobotController.getCurrent5V()); - - RoboRioSim.setUserActive5V(false); - assertTrue(activeCallback.wasTriggered()); - assertFalse(activeCallback.getSetValue()); - assertFalse(RoboRioSim.getUserActive5V()); - assertFalse(RobotController.getEnabled5V()); - - RoboRioSim.setUserFaults5V(kTestFaults); - assertTrue(faultCallback.wasTriggered()); - assertEquals(kTestFaults, faultCallback.getSetValue()); - assertEquals(kTestFaults, RoboRioSim.getUserFaults5V()); - assertEquals(kTestFaults, RobotController.getFaultCount5V()); - } - } - @Test void test3V3() { RoboRioSim.resetData(); @@ -281,26 +162,4 @@ class RoboRioSimTest { assertEquals(kCommentsTruncated, RoboRioSim.getComments()); assertEquals(kCommentsTruncated, RobotController.getComments()); } - - @Test - void testRadioLEDState() { - RoboRioSim.resetData(); - - EnumCallback callback = new EnumCallback(); - try (CallbackStore cb = RoboRioSim.registerRadioLEDStateCallback(callback, false)) { - RobotController.setRadioLEDState(RadioLEDState.kGreen); - assertTrue(callback.wasTriggered()); - assertEquals(RadioLEDState.kGreen.value, callback.getSetValue()); - assertEquals(RadioLEDState.kGreen, RoboRioSim.getRadioLEDState()); - assertEquals(RadioLEDState.kGreen, RobotController.getRadioLEDState()); - - callback.reset(); - - RoboRioSim.setRadioLEDState(RadioLEDState.kOrange); - assertTrue(callback.wasTriggered()); - assertEquals(RadioLEDState.kOrange.value, callback.getSetValue()); - assertEquals(RadioLEDState.kOrange, RoboRioSim.getRadioLEDState()); - assertEquals(RadioLEDState.kOrange, RobotController.getRadioLEDState()); - } - } } diff --git a/wpilibjExamples/src/test/java/edu/wpi/first/wpilibj/examples/potentiometerpid/PotentiometerPIDTest.java b/wpilibjExamples/src/test/java/edu/wpi/first/wpilibj/examples/potentiometerpid/PotentiometerPIDTest.java index 6fe3cc413e..a329adf2aa 100644 --- a/wpilibjExamples/src/test/java/edu/wpi/first/wpilibj/examples/potentiometerpid/PotentiometerPIDTest.java +++ b/wpilibjExamples/src/test/java/edu/wpi/first/wpilibj/examples/potentiometerpid/PotentiometerPIDTest.java @@ -73,7 +73,7 @@ class PotentiometerPIDTest { 5v * (meters / range) = v */ m_analogSim.setVoltage( - RobotController.getVoltage5V() + RobotController.getVoltage3V3() * (m_elevatorSim.getPosition() / Robot.kFullHeight)); });