mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Replaced const variables with constexpr (#731)
This commit is contained in:
committed by
Peter Johnson
parent
259461aee9
commit
5af0c9c101
@@ -59,10 +59,10 @@ class ADXL345_I2C : public Accelerometer, public LiveWindowSendable {
|
||||
protected:
|
||||
I2C m_i2c;
|
||||
|
||||
static const int kAddress = 0x1D;
|
||||
static const int kPowerCtlRegister = 0x2D;
|
||||
static const int kDataFormatRegister = 0x31;
|
||||
static const int kDataRegister = 0x32;
|
||||
static constexpr int kAddress = 0x1D;
|
||||
static constexpr int kPowerCtlRegister = 0x2D;
|
||||
static constexpr int kDataFormatRegister = 0x31;
|
||||
static constexpr int kDataRegister = 0x32;
|
||||
static constexpr double kGsPerLSB = 0.00390625;
|
||||
|
||||
enum PowerCtlFields {
|
||||
|
||||
@@ -37,7 +37,6 @@ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
|
||||
double ZAxis;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
|
||||
virtual ~ADXL345_SPI() = default;
|
||||
|
||||
@@ -62,9 +61,9 @@ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
|
||||
protected:
|
||||
SPI m_spi;
|
||||
|
||||
static const int kPowerCtlRegister = 0x2D;
|
||||
static const int kDataFormatRegister = 0x31;
|
||||
static const int kDataRegister = 0x32;
|
||||
static constexpr int kPowerCtlRegister = 0x2D;
|
||||
static constexpr int kDataFormatRegister = 0x31;
|
||||
static constexpr int kDataRegister = 0x32;
|
||||
static constexpr double kGsPerLSB = 0.00390625;
|
||||
|
||||
enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 };
|
||||
|
||||
@@ -32,8 +32,8 @@ class AnalogInput;
|
||||
*/
|
||||
class AnalogGyro : public GyroBase {
|
||||
public:
|
||||
static const int kOversampleBits = 10;
|
||||
static const int kAverageBits = 0;
|
||||
static constexpr int kOversampleBits = 10;
|
||||
static constexpr int kAverageBits = 0;
|
||||
static constexpr double kSamplesPerSecond = 50.0;
|
||||
static constexpr double kCalibrationSampleTime = 5.0;
|
||||
static constexpr double kDefaultVoltsPerDegreePerSecond = 0.007;
|
||||
|
||||
@@ -40,9 +40,9 @@ class AnalogInput : public SensorBase,
|
||||
friend class AnalogGyro;
|
||||
|
||||
public:
|
||||
static const int kAccumulatorModuleNumber = 1;
|
||||
static const int kAccumulatorNumChannels = 2;
|
||||
static const int kAccumulatorChannels[kAccumulatorNumChannels];
|
||||
static constexpr int kAccumulatorModuleNumber = 1;
|
||||
static constexpr int kAccumulatorNumChannels = 2;
|
||||
static constexpr int kAccumulatorChannels[kAccumulatorNumChannels] = {0, 1};
|
||||
|
||||
explicit AnalogInput(int channel);
|
||||
virtual ~AnalogInput();
|
||||
|
||||
@@ -40,7 +40,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
static void ReportError(bool is_error, int code, llvm::StringRef error,
|
||||
llvm::StringRef location, llvm::StringRef stack);
|
||||
|
||||
static const int kJoystickPorts = 6;
|
||||
static constexpr int kJoystickPorts = 6;
|
||||
|
||||
bool GetStickButton(int stick, int button);
|
||||
bool GetStickButtonPressed(int stick, int button);
|
||||
|
||||
@@ -113,7 +113,8 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
void Normalize(double* wheelSpeeds);
|
||||
void RotateVector(double& x, double& y, double angle);
|
||||
|
||||
static const int kMaxNumberOfMotors = 4;
|
||||
static constexpr int kMaxNumberOfMotors = 4;
|
||||
|
||||
double m_sensitivity = 0.5;
|
||||
double m_maxOutput = 1.0;
|
||||
|
||||
|
||||
@@ -32,8 +32,10 @@ class SolenoidBase : public SensorBase {
|
||||
|
||||
protected:
|
||||
explicit SolenoidBase(int pcmID);
|
||||
static const int m_maxModules = 63;
|
||||
static const int m_maxPorts = 8;
|
||||
|
||||
static constexpr int m_maxModules = 63;
|
||||
static constexpr int m_maxPorts = 8;
|
||||
|
||||
int m_moduleNumber; // PCM module number
|
||||
};
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class Ultrasonic : public SensorBase,
|
||||
static constexpr double kPingTime = 10 * 1e-6;
|
||||
|
||||
// Priority that the ultrasonic round robin task runs.
|
||||
static const int kPriority = 64;
|
||||
static constexpr int kPriority = 64;
|
||||
|
||||
// Max time (ms) between readings.
|
||||
static constexpr double kMaxUltrasonicTime = 0.1;
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#ifdef WPI_ERRORS_DEFINE_STRINGS
|
||||
#define S(label, offset, message) \
|
||||
const char* wpi_error_s_##label = message; \
|
||||
const int wpi_error_value_##label = offset
|
||||
constexpr int wpi_error_value_##label = offset
|
||||
#else
|
||||
#define S(label, offset, message) \
|
||||
extern const char* wpi_error_s_##label; \
|
||||
const int wpi_error_value_##label = offset
|
||||
constexpr int wpi_error_value_##label = offset
|
||||
#endif
|
||||
|
||||
// Fatal errors
|
||||
|
||||
Reference in New Issue
Block a user