![]() |
WPILibC++ 2027.0.0-alpha-2
|
Functions | |
HAL_CounterHandle | HAL_InitializeCounter (int channel, HAL_Bool risingEdge, const char *allocationLocation, int32_t *status) |
Initializes a counter. | |
void | HAL_FreeCounter (HAL_CounterHandle counterHandle) |
Frees a counter. | |
void | HAL_SetCounterEdgeConfiguration (HAL_CounterHandle counterHandle, HAL_Bool risingEdge, int32_t *status) |
Sets the up source to either detect rising edges or falling edges. | |
void | HAL_ResetCounter (HAL_CounterHandle counterHandle, int32_t *status) |
Resets the Counter to zero. | |
int32_t | HAL_GetCounter (HAL_CounterHandle counterHandle, int32_t *status) |
Reads the current counter value. | |
double | HAL_GetCounterPeriod (HAL_CounterHandle counterHandle, int32_t *status) |
Gets the Period of the most recent count. | |
void | HAL_SetCounterMaxPeriod (HAL_CounterHandle counterHandle, double maxPeriod, int32_t *status) |
Sets the maximum period where the device is still considered "moving". | |
HAL_Bool | HAL_GetCounterStopped (HAL_CounterHandle counterHandle, int32_t *status) |
Determines if the clock is stopped. | |
void HAL_FreeCounter | ( | HAL_CounterHandle | counterHandle | ) |
Frees a counter.
[in] | counterHandle | the counter handle |
int32_t HAL_GetCounter | ( | HAL_CounterHandle | counterHandle, |
int32_t * | status ) |
Reads the current counter value.
Reads the value at this instant. It may still be running, so it reflects the current value. Next time it is read, it might have a different value.
[in] | counterHandle | the counter handle |
[out] | status | Error status variable. 0 on success. |
double HAL_GetCounterPeriod | ( | HAL_CounterHandle | counterHandle, |
int32_t * | status ) |
Gets the Period of the most recent count.
Returns the time interval of the most recent count. This can be used for velocity calculations to determine shaft speed.
[in] | counterHandle | the counter handle |
[out] | status | Error status variable. 0 on success. |
HAL_Bool HAL_GetCounterStopped | ( | HAL_CounterHandle | counterHandle, |
int32_t * | status ) |
Determines if the clock is stopped.
Determine if the clocked input is stopped based on the MaxPeriod value set using the SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the device (and counter) are assumed to be stopped and it returns true.
[in] | counterHandle | the counter handle |
[out] | status | Error status variable. 0 on success. |
HAL_CounterHandle HAL_InitializeCounter | ( | int | channel, |
HAL_Bool | risingEdge, | ||
const char * | allocationLocation, | ||
int32_t * | status ) |
Initializes a counter.
[in] | channel | the dio channel |
[in] | risingEdge | true to count on rising edge, false for falling |
[in] | allocationLocation | the location where the allocation is occurring (can be null) |
[out] | status | Error status variable. 0 on success. |
void HAL_ResetCounter | ( | HAL_CounterHandle | counterHandle, |
int32_t * | status ) |
Resets the Counter to zero.
Sets the counter value to zero. This does not effect the running state of the counter, just sets the current value to zero.
[in] | counterHandle | the counter handle |
[out] | status | Error status variable. 0 on success. |
void HAL_SetCounterEdgeConfiguration | ( | HAL_CounterHandle | counterHandle, |
HAL_Bool | risingEdge, | ||
int32_t * | status ) |
Sets the up source to either detect rising edges or falling edges.
Note that both are allowed to be set true at the same time without issues.
[in] | counterHandle | the counter handle |
[in] | risingEdge | true to trigger on rising |
[out] | status | Error status variable. 0 on success. |
void HAL_SetCounterMaxPeriod | ( | HAL_CounterHandle | counterHandle, |
double | maxPeriod, | ||
int32_t * | status ) |
Sets the maximum period where the device is still considered "moving".
Sets the maximum period where the device is considered moving. This value is used to determine the "stopped" state of the counter using the HAL_GetCounterStopped method.
[in] | counterHandle | the counter handle |
[in] | maxPeriod | the maximum period where the counted device is considered moving in seconds |
[out] | status | Error status variable. 0 on success. |