mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Counter: Fix default distance per pulse, add distance and rate to C++ (#5796)
- Default distance per pulse in java was 0; 1 is a more reasonable default - C++ was missing this functionality
This commit is contained in:
@@ -260,6 +260,18 @@ int Counter::GetFPGAIndex() const {
|
||||
return m_index;
|
||||
}
|
||||
|
||||
void Counter::SetDistancePerPulse(double distancePerPulse) {
|
||||
m_distancePerPulse = distancePerPulse;
|
||||
}
|
||||
|
||||
double Counter::GetDistance() const {
|
||||
return Get() * m_distancePerPulse;
|
||||
}
|
||||
|
||||
double Counter::GetRate() const {
|
||||
return m_distancePerPulse / GetPeriod().value();
|
||||
}
|
||||
|
||||
int Counter::Get() const {
|
||||
int32_t status = 0;
|
||||
int value = HAL_GetCounter(m_counter, &status);
|
||||
|
||||
Reference in New Issue
Block a user