Skip to content

Commit 0f0d411

Browse files
committed
Merge branch 'p8-acc-hfble' into p8b
2 parents b2f7f25 + 0df4648 commit 0f0d411

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

src/components/ble/MotionService.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,22 @@ void MotionService::OnNewStepCountValue(uint32_t stepCount) {
9090

9191
ble_gattc_notify_custom(connectionHandle, stepCountHandle, om);
9292
}
93-
void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
93+
94+
void MotionService::OnNewMotionValues(int16_t* samples, uint16_t samples_length) {
9495
if (!motionValuesNoficationEnabled)
9596
return;
9697

97-
int16_t buffer[3] = {motionController.X(), motionController.Y(), motionController.Z()};
98-
auto* om = ble_hs_mbuf_from_flat(buffer, 3 * sizeof(int16_t));
98+
if (samples_length > 0 && samples != nullptr) {
99+
auto* om = ble_hs_mbuf_from_flat(samples, samples_length * 3 * sizeof(int16_t));
99100

100-
uint16_t connectionHandle = system.nimble().connHandle();
101+
uint16_t connectionHandle = system.nimble().connHandle();
101102

102-
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
103-
return;
104-
}
103+
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
104+
return;
105+
}
105106

106-
ble_gattc_notify_custom(connectionHandle, motionValuesHandle, om);
107+
ble_gattc_notify_custom(connectionHandle, motionValuesHandle, om);
108+
}
107109
}
108110

109111
void MotionService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {

src/components/ble/MotionService.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Pinetime {
1818
void Init();
1919
int OnStepCountRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context);
2020
void OnNewStepCountValue(uint32_t stepCount);
21-
void OnNewMotionValues(int16_t x, int16_t y, int16_t z);
21+
void OnNewMotionValues(int16_t* samples, uint16_t samples_length);
2222

2323
void SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle);
2424
void UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle);

src/components/motion/MotionController.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
#include "os/os_cputime.h"
33
using namespace Pinetime::Controllers;
44

5-
void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) {
5+
void MotionController::Update(uint32_t nbSteps, int16_t x, int16_t y, int16_t z, int16_t* samples, uint16_t samples_length) {
66
if (this->nbSteps != nbSteps && service != nullptr) {
77
service->OnNewStepCountValue(nbSteps);
88
}
99

1010
if (service != nullptr && (this->x != x || this->y != y || this->z != z)) {
11-
service->OnNewMotionValues(x, y, z);
11+
service->OnNewMotionValues(samples, samples_length);
1212
}
1313

1414
this->x = x;

src/components/motion/MotionController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Pinetime {
88
namespace Controllers {
99
class MotionController {
1010
public:
11-
void Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps);
11+
void Update(uint32_t nbSteps, int16_t x, int16_t y, int16_t z, int16_t* samples, uint16_t samples_length);
1212

1313
int16_t X() const {
1414
return x;

src/systemtask/SystemTask.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,6 @@ void SystemTask::UpdateMotion() {
474474
return;
475475
}
476476

477-
if (state == SystemTaskState::Sleeping && !(settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) ||
478-
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake))) {
479-
return;
480-
}
481-
482477
if (stepCounterMustBeReset) {
483478
motionSensor.ResetStepCounter();
484479
stepCounterMustBeReset = false;
@@ -487,7 +482,8 @@ void SystemTask::UpdateMotion() {
487482
auto motionValues = motionSensor.Process();
488483

489484
motionController.IsSensorOk(motionSensor.IsInitialized());
490-
motionController.Update(motionValues.x, motionValues.y, motionValues.z, motionValues.steps);
485+
motionController
486+
.Update(motionValues.steps, motionValues.x, motionValues.y, motionValues.z, motionValues.samples, motionValues.samples_length);
491487

492488
if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) &&
493489
motionController.Should_RaiseWake(state == SystemTaskState::Sleeping)) {

0 commit comments

Comments
 (0)