Skip to content

Commit 49ad5be

Browse files
FintasticManRiksu9000
authored andcommitted
motioncontroller: Fix clang-tidy warnings
Also move one-line functions to header.
1 parent 76e79df commit 49ad5be

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/components/motion/MotionController.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps)
2323
this->z = z;
2424

2525
int32_t deltaSteps = nbSteps - this->nbSteps;
26-
this->nbSteps = nbSteps;
2726
if (deltaSteps > 0) {
2827
currentTripSteps += deltaSteps;
2928
}
29+
this->nbSteps = nbSteps;
3030
}
3131

3232
bool MotionController::Should_RaiseWake(bool isSleeping) {
@@ -61,10 +61,6 @@ bool MotionController::ShouldShakeWake(uint16_t thresh) {
6161
return accumulatedSpeed > thresh;
6262
}
6363

64-
void MotionController::IsSensorOk(bool isOk) {
65-
isSensorOk = isOk;
66-
}
67-
6864
void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) {
6965
switch (types) {
7066
case Drivers::Bma421::DeviceTypes::BMA421:
@@ -78,7 +74,3 @@ void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) {
7874
break;
7975
}
8076
}
81-
82-
void MotionController::SetService(Pinetime::Controllers::MotionService* service) {
83-
this->service = service;
84-
}

src/components/motion/MotionController.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ namespace Pinetime {
5050
return accumulatedSpeed;
5151
}
5252

53-
void IsSensorOk(bool isOk);
53+
void IsSensorOk(bool isOk) {
54+
isSensorOk = isOk;
55+
}
5456

5557
bool IsSensorOk() const {
5658
return isSensorOk;
@@ -61,21 +63,24 @@ namespace Pinetime {
6163
}
6264

6365
void Init(Pinetime::Drivers::Bma421::DeviceTypes types);
64-
void SetService(Pinetime::Controllers::MotionService* service);
66+
67+
void SetService(Pinetime::Controllers::MotionService* service) {
68+
this->service = service;
69+
}
6570

6671
private:
67-
uint32_t nbSteps;
72+
uint32_t nbSteps = 0;
6873
uint32_t currentTripSteps = 0;
6974

7075
TickType_t lastTime = 0;
7176
TickType_t time = 0;
7277

73-
int16_t x;
78+
int16_t x = 0;
7479
int16_t lastYForWakeUp = 0;
7580
int16_t lastY = 0;
76-
int16_t y;
81+
int16_t y = 0;
7782
int16_t lastZ = 0;
78-
int16_t z;
83+
int16_t z = 0;
7984
int32_t accumulatedSpeed = 0;
8085

8186
bool isSensorOk = false;

0 commit comments

Comments
 (0)