Skip to content

Commit

Permalink
[hal, wpilib] Remove analog accumulator and analog gyro (#7697)
Browse files Browse the repository at this point in the history
The 2 high level classes were temporarily kept to keep the examples compiling. We will remove those when we have the interface into the built in IMU.
  • Loading branch information
ThadHouse authored Jan 17, 2025
1 parent 92f0a3c commit f80874d
Show file tree
Hide file tree
Showing 76 changed files with 33 additions and 3,886 deletions.
41 changes: 0 additions & 41 deletions glass/src/lib/native/cpp/hardware/AnalogGyro.cpp

This file was deleted.

6 changes: 1 addition & 5 deletions glass/src/lib/native/cpp/hardware/AnalogInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ void glass::DisplayAnalogInput(AnalogInputModel* model, int index) {
wpi::format_to_n_c_str(label, sizeof(label), "In[{}]###name", index);
}

if (model->IsGyro()) {
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(96, 96, 96, 255));
ImGui::LabelText(label, "AnalogGyro[%d]", index);
ImGui::PopStyleColor();
} else if (auto simDevice = model->GetSimDevice()) {
if (auto simDevice = model->GetSimDevice()) {
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(96, 96, 96, 255));
ImGui::LabelText(label, "%s", simDevice);
ImGui::PopStyleColor();
Expand Down
33 changes: 0 additions & 33 deletions glass/src/lib/native/include/glass/hardware/AnalogGyro.h

This file was deleted.

1 change: 0 additions & 1 deletion glass/src/lib/native/include/glass/hardware/AnalogInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class DoubleSource;

class AnalogInputModel : public Model {
public:
virtual bool IsGyro() const = 0;
virtual const char* GetSimDevice() const = 0;

virtual DoubleSource* GetVoltageData() = 0;
Expand Down
29 changes: 0 additions & 29 deletions hal/src/main/java/edu/wpi/first/hal/AccumulatorResult.java

This file was deleted.

132 changes: 0 additions & 132 deletions hal/src/main/java/edu/wpi/first/hal/AnalogGyroJNI.java

This file was deleted.

89 changes: 1 addition & 88 deletions hal/src/main/java/edu/wpi/first/hal/AnalogJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
package edu.wpi.first.hal;

/**
* Analog Input / Output / Accumulator / Trigger JNI Functions.
* Analog Input / Output / Trigger JNI Functions.
*
* @see "hal/AnalogInput.h"
* @see "hal/AnalogAccumulator.h"
* @see "hal/AnalogTrigger.h"
*/
public class AnalogJNI extends JNIWrapper {
Expand Down Expand Up @@ -249,92 +248,6 @@ public interface AnalogTriggerType {
*/
public static native int getAnalogOffset(int analogPortHandle);

/**
* Is the channel attached to an accumulator.
*
* @param analogPortHandle Handle to the analog port.
* @return The analog channel is attached to an accumulator.
* @see "HAL_IsAccumulatorChannel"
*/
public static native boolean isAccumulatorChannel(int analogPortHandle);

/**
* Initialize the accumulator.
*
* @param analogPortHandle Handle to the analog port.
* @see "HAL_InitAccumulator"
*/
public static native void initAccumulator(int analogPortHandle);

/**
* Resets the accumulator to the initial value.
*
* @param analogPortHandle Handle to the analog port.
* @see "HAL_ResetAccumulator"
*/
public static native void resetAccumulator(int analogPortHandle);

/**
* Set the center value of the accumulator.
*
* <p>The center value is subtracted from each A/D value before it is added to the accumulator.
* This is used for the center value of devices like gyros and accelerometers to make integration
* work and to take the device offset into account when integrating.
*
* <p>This center value is based on the output of the oversampled and averaged source from channel
* 1. Because of this, any non-zero oversample bits will affect the size of the value for this
* field.
*
* @param analogPortHandle Handle to the analog port.
* @param center The center value of the accumulator.
* @see "HAL_SetAccumulatorCenter"
*/
public static native void setAccumulatorCenter(int analogPortHandle, int center);

/**
* Set the accumulator's deadband.
*
* @param analogPortHandle Handle to the analog port.
* @param deadband The deadband of the accumulator.
* @see "HAL_SetAccumulatorDeadband"
*/
public static native void setAccumulatorDeadband(int analogPortHandle, int deadband);

/**
* Read the accumulated value.
*
* <p>Read the value that has been accumulating on channel 1. The accumulator is attached after
* the oversample and average engine.
*
* @param analogPortHandle Handle to the analog port.
* @return The 64-bit value accumulated since the last Reset().
* @see "HAL_GetAccumulatorValue"
*/
public static native long getAccumulatorValue(int analogPortHandle);

/**
* Read the number of accumulated values.
*
* <p>Read the count of the accumulated values since the accumulator was last Reset().
*
* @param analogPortHandle Handle to the analog port.
* @return The number of times samples from the channel were accumulated.
* @see "HAL_GetAccumulatorCount"
*/
public static native int getAccumulatorCount(int analogPortHandle);

/**
* Read the accumulated value and the number of accumulated values atomically.
*
* <p>This function reads the value and count from the FPGA atomically. This can be used for
* averaging.
*
* @param analogPortHandle Handle to the analog port.
* @param result Accumulator result.
* @see "HAL_GetAccumulatorOutput"
*/
public static native void getAccumulatorOutput(int analogPortHandle, AccumulatorResult result);

/**
* Initializes an analog trigger.
*
Expand Down
23 changes: 0 additions & 23 deletions hal/src/main/java/edu/wpi/first/hal/DMAJNISample.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,29 +137,6 @@ public int getAnalogInputAveraged(int analogInputHandle) {
return readValue(data.m_valueType + 2, data.m_index);
}

public void getAnalogAccumulator(int analogInputHandle, AccumulatorResult result) {
BaseStore data = m_propertyMap.get(analogInputHandle);
if (data == null) {
data = addSensorInternal(analogInputHandle);
}

if (data.m_index == 0) {
int val0 = readValue(kEnable_Accumulator0, 0);
int val1 = readValue(kEnable_Accumulator0, 1);
int val2 = readValue(kEnable_Accumulator0, 2);
result.count = val2;
result.value = ((long) val1 << 32) | val0;
} else if (data.m_index == 1) {
int val0 = readValue(kEnable_Accumulator1, 0);
int val1 = readValue(kEnable_Accumulator1, 1);
int val2 = readValue(kEnable_Accumulator1, 2);
result.count = val2;
result.value = ((long) val1 << 32) | val0;
} else {
throw new RuntimeException("Resource not found in DMA capture");
}
}

public int getDutyCycleOutput(int dutyCycleHandle) {
BaseStore data = m_propertyMap.get(dutyCycleHandle);
if (data == null) {
Expand Down
Loading

0 comments on commit f80874d

Please sign in to comment.