mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
Inverted the circular dependency of MotionService and MotionController
This commit is contained in:
parent
d030982902
commit
a083358b98
|
@ -62,9 +62,9 @@ void MotionService::Init() {
|
|||
int MotionService::OnStepCountRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context) {
|
||||
if (attributeHandle == stepCountHandle) {
|
||||
NRF_LOG_INFO("Motion-stepcount : handle = %d", stepCountHandle);
|
||||
uint32_t buffer = motionController.NbSteps();
|
||||
MotionController::step_t buffer = motionController.NbSteps();
|
||||
|
||||
int res = os_mbuf_append(context->om, &buffer, 4);
|
||||
int res = os_mbuf_append(context->om, &buffer, sizeof(buffer));
|
||||
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
|
||||
} else if (attributeHandle == motionValuesHandle) {
|
||||
int16_t buffer[3] = {motionController.X(), motionController.Y(), motionController.Z()};
|
||||
|
@ -75,12 +75,12 @@ int MotionService::OnStepCountRequested(uint16_t attributeHandle, ble_gatt_acces
|
|||
return 0;
|
||||
}
|
||||
|
||||
void MotionService::OnNewStepCountValue(uint32_t stepCount) {
|
||||
void MotionService::OnNewStepCountValue(MotionController::step_t stepCount) {
|
||||
if (!stepCountNoficationEnabled)
|
||||
return;
|
||||
|
||||
uint32_t buffer = stepCount;
|
||||
auto* om = ble_hs_mbuf_from_flat(&buffer, 4);
|
||||
MotionController::step_t buffer = stepCount;
|
||||
auto* om = ble_hs_mbuf_from_flat(&buffer, sizeof(buffer));
|
||||
|
||||
uint16_t connectionHandle = nimble.connHandle();
|
||||
|
||||
|
|
|
@ -6,17 +6,18 @@
|
|||
#undef max
|
||||
#undef min
|
||||
|
||||
#include "components/motion/MotionController.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class NimbleController;
|
||||
class MotionController;
|
||||
|
||||
class MotionService {
|
||||
public:
|
||||
MotionService(NimbleController& nimble, Controllers::MotionController& motionController);
|
||||
void Init();
|
||||
int OnStepCountRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context);
|
||||
void OnNewStepCountValue(uint32_t stepCount);
|
||||
void OnNewStepCountValue(MotionController::step_t stepCount);
|
||||
void OnNewMotionValues(int16_t x, int16_t y, int16_t z);
|
||||
|
||||
void SubscribeNotification(uint16_t attributeHandle);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <task.h>
|
||||
|
||||
#include "components/ble/MotionService.h"
|
||||
#include "utility/Math.h"
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
#include <FreeRTOS.h>
|
||||
|
||||
#include "drivers/Bma421.h"
|
||||
#include "components/ble/MotionService.h"
|
||||
#include "utility/CircularBuffer.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class MotionService;
|
||||
|
||||
class MotionController {
|
||||
public:
|
||||
enum class DeviceTypes {
|
||||
|
|
Loading…
Reference in a new issue