Skip to content

Commit 7f6ea30

Browse files
committed
Moved scale factors out of class and into anonymous namespace
1 parent 89deb19 commit 7f6ea30

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/drivers/Bma421.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@ namespace {
2222
void user_delay(uint32_t period_us, void* /*intf_ptr*/) {
2323
nrf_delay_us(period_us);
2424
}
25-
}
26-
27-
// Scale factors to convert accelerometer counts to milli-g
28-
// from datasheet: https://files.pine64.org/doc/datasheet/pinetime/BST-BMA421-FL000.pdf
29-
// The array index to use is stored in accel_conf.range
30-
constexpr int16_t accelScaleFactors[] = {
31-
[BMA4_ACCEL_RANGE_2G] = 1024, // LSB/g +/- 2g range
32-
[BMA4_ACCEL_RANGE_4G] = 512, // LSB/g +/- 4g range
33-
[BMA4_ACCEL_RANGE_8G] = 256, // LSB/g +/- 8g range
34-
[BMA4_ACCEL_RANGE_16G] = 128 // LSB/g +/- 16g range
35-
};
3625

26+
// Scale factors to convert accelerometer counts to milli-g
27+
// from datasheet: https://files.pine64.org/doc/datasheet/pinetime/BST-BMA421-FL000.pdf
28+
// The array index to use is stored in accel_conf.range
29+
constexpr int16_t accelScaleFactors[] = {
30+
[BMA4_ACCEL_RANGE_2G] = 1024, // LSB/g +/- 2g range
31+
[BMA4_ACCEL_RANGE_4G] = 512, // LSB/g +/- 4g range
32+
[BMA4_ACCEL_RANGE_8G] = 256, // LSB/g +/- 8g range
33+
[BMA4_ACCEL_RANGE_16G] = 128 // LSB/g +/- 16g range
34+
};
35+
}
3736

3837
Bma421::Bma421(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaster}, deviceAddress {twiAddress} {
3938
bma.intf = BMA4_I2C_INTF;

src/drivers/Bma421.h

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ namespace Pinetime {
99
public:
1010
enum class DeviceTypes : uint8_t { Unknown, BMA421, BMA425 };
1111

12-
// Scale factors to convert accelerometer counts to milli-g
13-
// The array values are initialised in Bma421.cpp
14-
static const short accelScaleFactors[];
15-
1612
struct Values {
1713
uint32_t steps;
1814
int16_t x;

0 commit comments

Comments
 (0)