mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[hal] Rename SimDevice constants to all caps
Also use enum class for SimDevice C++ wrapper.
This commit is contained in:
@@ -16,11 +16,14 @@ ADXL345_I2C::ADXL345_I2C(I2C::Port port, Range range, int deviceAddress)
|
||||
m_simDevice("Accel:ADXL345_I2C", static_cast<int>(port), deviceAddress) {
|
||||
if (m_simDevice) {
|
||||
m_simRange = m_simDevice.CreateEnumDouble(
|
||||
"range", wpi::hal::SimDevice::kOutput, {"2G", "4G", "8G", "16G"},
|
||||
{2.0, 4.0, 8.0, 16.0}, 0);
|
||||
m_simX = m_simDevice.CreateDouble("x", wpi::hal::SimDevice::kInput, 0.0);
|
||||
m_simY = m_simDevice.CreateDouble("y", wpi::hal::SimDevice::kInput, 0.0);
|
||||
m_simZ = m_simDevice.CreateDouble("z", wpi::hal::SimDevice::kInput, 0.0);
|
||||
"range", wpi::hal::SimDevice::Direction::OUTPUT,
|
||||
{"2G", "4G", "8G", "16G"}, {2.0, 4.0, 8.0, 16.0}, 0);
|
||||
m_simX = m_simDevice.CreateDouble(
|
||||
"x", wpi::hal::SimDevice::Direction::INPUT, 0.0);
|
||||
m_simY = m_simDevice.CreateDouble(
|
||||
"y", wpi::hal::SimDevice::Direction::INPUT, 0.0);
|
||||
m_simZ = m_simDevice.CreateDouble(
|
||||
"z", wpi::hal::SimDevice::Direction::INPUT, 0.0);
|
||||
}
|
||||
// Turn on the measurements
|
||||
m_i2c.Write(kPowerCtlRegister, kPowerCtl_Measure);
|
||||
|
||||
@@ -89,7 +89,8 @@ PWMMotorController::PWMMotorController(std::string_view name, int channel)
|
||||
|
||||
m_simDevice = wpi::hal::SimDevice{"PWMMotorController", channel};
|
||||
if (m_simDevice) {
|
||||
m_simDutyCycle = m_simDevice.CreateDouble("DutyCycle", true, 0.0);
|
||||
m_simDutyCycle = m_simDevice.CreateDouble(
|
||||
"DutyCycle", wpi::hal::SimDevice::Direction::OUTPUT, 0.0);
|
||||
m_pwm.SetSimDevice(m_simDevice);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ SharpIR::SharpIR(int channel, double a, double b, wpi::units::meter_t min,
|
||||
|
||||
m_simDevice = wpi::hal::SimDevice("SharpIR", m_sensor.GetChannel());
|
||||
if (m_simDevice) {
|
||||
m_simRange = m_simDevice.CreateDouble("Range (m)", false, 0.0);
|
||||
m_simRange = m_simDevice.CreateDouble(
|
||||
"Range (m)", wpi::hal::SimDevice::Direction::INPUT, 0.0);
|
||||
m_sensor.SetSimDevice(m_simDevice);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ void AnalogEncoder::Init(double fullRange, double expectedZero) {
|
||||
wpi::hal::SimDevice{"AnalogEncoder", m_analogInput->GetChannel()};
|
||||
|
||||
if (m_simDevice) {
|
||||
m_simPosition = m_simDevice.CreateDouble("Position", false, 0.0);
|
||||
m_simPosition = m_simDevice.CreateDouble(
|
||||
"Position", wpi::hal::SimDevice::Direction::INPUT, 0.0);
|
||||
}
|
||||
|
||||
m_fullRange = fullRange;
|
||||
|
||||
@@ -64,9 +64,10 @@ void DutyCycleEncoder::Init(double fullRange, double expectedZero) {
|
||||
m_dutyCycle->GetSourceChannel()};
|
||||
|
||||
if (m_simDevice) {
|
||||
m_simPosition = m_simDevice.CreateDouble("Position", false, 0.0);
|
||||
m_simPosition = m_simDevice.CreateDouble(
|
||||
"Position", wpi::hal::SimDevice::Direction::INPUT, 0.0);
|
||||
m_simIsConnected = m_simDevice.CreateBoolean(
|
||||
"Connected", wpi::hal::SimDevice::kInput, true);
|
||||
"Connected", wpi::hal::SimDevice::Direction::INPUT, true);
|
||||
}
|
||||
|
||||
m_fullRange = fullRange;
|
||||
|
||||
Reference in New Issue
Block a user