mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Major formatting changes (breaks diffs). No code changes.
The changes made in this commit do not affect any actual code,
they are purely aesthetic. I ran clang-format with google style
over all .h/.cpp files in wpilibc that weren't in wpilibC++Sim
or gtest, and the eclipse formatter over all of the Java files
using the Google eclipse formatting configuration.
Change-Id: I9627bca0bc103c398ecc1c5ba17467193291ae63
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008. All Rights Reserved. */
|
||||
/* Copyright (c) FIRST 2008. All Rights Reserved.
|
||||
*/
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -14,27 +15,24 @@
|
||||
/**
|
||||
* Initialize an analog trigger from a channel.
|
||||
*/
|
||||
void AnalogTrigger::InitTrigger(uint32_t channel)
|
||||
{
|
||||
void* port = getPort(channel);
|
||||
int32_t status = 0;
|
||||
uint32_t index = 0;
|
||||
m_trigger = initializeAnalogTrigger(port, &index, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_index = index;
|
||||
void AnalogTrigger::InitTrigger(uint32_t channel) {
|
||||
void *port = getPort(channel);
|
||||
int32_t status = 0;
|
||||
uint32_t index = 0;
|
||||
m_trigger = initializeAnalogTrigger(port, &index, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
m_index = index;
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_AnalogTrigger, channel);
|
||||
HALReport(HALUsageReporting::kResourceType_AnalogTrigger, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for an analog trigger given a channel number.
|
||||
*
|
||||
* @param channel The channel number on the roboRIO to represent. 0-3 are on-board 4-7 are on the MXP port.
|
||||
* @param channel The channel number on the roboRIO to represent. 0-3 are
|
||||
* on-board 4-7 are on the MXP port.
|
||||
*/
|
||||
AnalogTrigger::AnalogTrigger(int32_t channel)
|
||||
{
|
||||
InitTrigger(channel);
|
||||
}
|
||||
AnalogTrigger::AnalogTrigger(int32_t channel) { InitTrigger(channel); }
|
||||
|
||||
/**
|
||||
* Construct an analog trigger given an analog input.
|
||||
@@ -42,31 +40,29 @@ AnalogTrigger::AnalogTrigger(int32_t channel)
|
||||
* trigger and an analog input object.
|
||||
* @param channel The pointer to the existing AnalogInput object
|
||||
*/
|
||||
AnalogTrigger::AnalogTrigger(AnalogInput *input)
|
||||
{
|
||||
InitTrigger(input->GetChannel());
|
||||
AnalogTrigger::AnalogTrigger(AnalogInput *input) {
|
||||
InitTrigger(input->GetChannel());
|
||||
}
|
||||
|
||||
AnalogTrigger::~AnalogTrigger()
|
||||
{
|
||||
int32_t status = 0;
|
||||
cleanAnalogTrigger(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
AnalogTrigger::~AnalogTrigger() {
|
||||
int32_t status = 0;
|
||||
cleanAnalogTrigger(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the upper and lower limits of the analog trigger.
|
||||
* The limits are given in ADC codes. If oversampling is used, the units must be scaled
|
||||
* The limits are given in ADC codes. If oversampling is used, the units must
|
||||
* be scaled
|
||||
* appropriately.
|
||||
* @param lower The lower limit of the trigger in ADC codes (12-bit values).
|
||||
* @param upper The upper limit of the trigger in ADC codes (12-bit values).
|
||||
*/
|
||||
void AnalogTrigger::SetLimitsRaw(int32_t lower, int32_t upper)
|
||||
{
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerLimitsRaw(m_trigger, lower, upper, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
void AnalogTrigger::SetLimitsRaw(int32_t lower, int32_t upper) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerLimitsRaw(m_trigger, lower, upper, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,40 +71,42 @@ void AnalogTrigger::SetLimitsRaw(int32_t lower, int32_t upper)
|
||||
* @param lower The lower limit of the trigger in Volts.
|
||||
* @param upper The upper limit of the trigger in Volts.
|
||||
*/
|
||||
void AnalogTrigger::SetLimitsVoltage(float lower, float upper)
|
||||
{
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerLimitsVoltage(m_trigger, lower, upper, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
void AnalogTrigger::SetLimitsVoltage(float lower, float upper) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerLimitsVoltage(m_trigger, lower, upper, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the analog trigger to use the averaged vs. raw values.
|
||||
* If the value is true, then the averaged value is selected for the analog trigger, otherwise
|
||||
* If the value is true, then the averaged value is selected for the analog
|
||||
* trigger, otherwise
|
||||
* the immediate value is used.
|
||||
* @param useAveragedValue If true, use the Averaged value, otherwise use the instantaneous reading
|
||||
* @param useAveragedValue If true, use the Averaged value, otherwise use the
|
||||
* instantaneous reading
|
||||
*/
|
||||
void AnalogTrigger::SetAveraged(bool useAveragedValue)
|
||||
{
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerAveraged(m_trigger, useAveragedValue, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
void AnalogTrigger::SetAveraged(bool useAveragedValue) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerAveraged(m_trigger, useAveragedValue, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the analog trigger to use a filtered value.
|
||||
* The analog trigger will operate with a 3 point average rejection filter. This is designed to
|
||||
* help with 360 degree pot applications for the period where the pot crosses through zero.
|
||||
* @param useFilteredValue If true, use the 3 point rejection filter, otherwise use the unfiltered value
|
||||
* The analog trigger will operate with a 3 point average rejection filter. This
|
||||
* is designed to
|
||||
* help with 360 degree pot applications for the period where the pot crosses
|
||||
* through zero.
|
||||
* @param useFilteredValue If true, use the 3 point rejection filter, otherwise
|
||||
* use the unfiltered value
|
||||
*/
|
||||
void AnalogTrigger::SetFiltered(bool useFilteredValue)
|
||||
{
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerFiltered(m_trigger, useFilteredValue, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
void AnalogTrigger::SetFiltered(bool useFilteredValue) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
setAnalogTriggerFiltered(m_trigger, useFilteredValue, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,10 +114,9 @@ void AnalogTrigger::SetFiltered(bool useFilteredValue)
|
||||
* This is the FPGA index of this analog trigger instance.
|
||||
* @return The index of the analog trigger.
|
||||
*/
|
||||
uint32_t AnalogTrigger::GetIndex()
|
||||
{
|
||||
if (StatusIsFatal()) return ~0ul;
|
||||
return m_index;
|
||||
uint32_t AnalogTrigger::GetIndex() {
|
||||
if (StatusIsFatal()) return ~0ul;
|
||||
return m_index;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,13 +124,12 @@ uint32_t AnalogTrigger::GetIndex()
|
||||
* True if the analog input is between the upper and lower limits.
|
||||
* @return True if the analog input is between the upper and lower limits.
|
||||
*/
|
||||
bool AnalogTrigger::GetInWindow()
|
||||
{
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool result = getAnalogTriggerInWindow(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
return result;
|
||||
bool AnalogTrigger::GetInWindow() {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool result = getAnalogTriggerInWindow(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,15 +137,15 @@ bool AnalogTrigger::GetInWindow()
|
||||
* True if above upper limit.
|
||||
* False if below lower limit.
|
||||
* If in Hysteresis, maintain previous state.
|
||||
* @return True if above upper limit. False if below lower limit. If in Hysteresis, maintain previous state.
|
||||
* @return True if above upper limit. False if below lower limit. If in
|
||||
* Hysteresis, maintain previous state.
|
||||
*/
|
||||
bool AnalogTrigger::GetTriggerState()
|
||||
{
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool result = getAnalogTriggerTriggerState(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
return result;
|
||||
bool AnalogTrigger::GetTriggerState() {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
bool result = getAnalogTriggerTriggerState(m_trigger, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,8 +155,7 @@ bool AnalogTrigger::GetTriggerState()
|
||||
* @param type An enum of the type of output object to create.
|
||||
* @return A pointer to a new AnalogTriggerOutput object.
|
||||
*/
|
||||
AnalogTriggerOutput *AnalogTrigger::CreateOutput(AnalogTriggerType type)
|
||||
{
|
||||
if (StatusIsFatal()) return NULL;
|
||||
return new AnalogTriggerOutput(this, type);
|
||||
AnalogTriggerOutput *AnalogTrigger::CreateOutput(AnalogTriggerType type) {
|
||||
if (StatusIsFatal()) return NULL;
|
||||
return new AnalogTriggerOutput(this, type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user