raisewake: Fix for new raise to wake impl
This commit is contained in:
@@ -6,12 +6,13 @@
|
||||
|
||||
#include "drivers/Bma421.h"
|
||||
//#include "components/ble/MotionService.h"
|
||||
#include "utility/CircularBuffer.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class MotionController {
|
||||
public:
|
||||
enum class DeviceTypes{
|
||||
enum class DeviceTypes {
|
||||
Unknown,
|
||||
BMA421,
|
||||
BMA425,
|
||||
@@ -24,11 +25,11 @@ namespace Pinetime {
|
||||
}
|
||||
|
||||
int16_t Y() const {
|
||||
return y;
|
||||
return yHistory[0];
|
||||
}
|
||||
|
||||
int16_t Z() const {
|
||||
return z;
|
||||
return zHistory[0];
|
||||
}
|
||||
|
||||
uint32_t NbSteps() const {
|
||||
@@ -44,20 +45,12 @@ namespace Pinetime {
|
||||
}
|
||||
|
||||
bool ShouldShakeWake(uint16_t thresh);
|
||||
bool ShouldRaiseWake(bool isSleeping);
|
||||
bool ShouldRaiseWake() const;
|
||||
|
||||
int32_t CurrentShakeSpeed() const {
|
||||
return accumulatedSpeed;
|
||||
}
|
||||
|
||||
void IsSensorOk(bool isOk) {
|
||||
isSensorOk = isOk;
|
||||
}
|
||||
|
||||
bool IsSensorOk() const {
|
||||
return isSensorOk;
|
||||
}
|
||||
|
||||
DeviceTypes DeviceType() const {
|
||||
return deviceType;
|
||||
}
|
||||
@@ -75,15 +68,29 @@ namespace Pinetime {
|
||||
// TickType_t lastTime = 0;
|
||||
// TickType_t time = 0;
|
||||
|
||||
struct AccelStats {
|
||||
static constexpr uint8_t numHistory = 2;
|
||||
|
||||
int16_t yMean = 0;
|
||||
int16_t zMean = 0;
|
||||
int16_t prevYMean = 0;
|
||||
int16_t prevZMean = 0;
|
||||
|
||||
uint32_t yVariance = 0;
|
||||
uint32_t zVariance = 0;
|
||||
};
|
||||
|
||||
AccelStats GetAccelStats() const;
|
||||
|
||||
AccelStats stats = {};
|
||||
|
||||
int16_t lastX = 0;
|
||||
int16_t x = 0;
|
||||
int16_t lastYForRaiseWake = 0;
|
||||
int16_t lastY = 0;
|
||||
int16_t y = 0;
|
||||
int16_t lastZ = 0;
|
||||
int16_t z = 0;
|
||||
static constexpr uint8_t histSize = 8;
|
||||
Utility::CircularBuffer<int16_t, histSize> yHistory = {};
|
||||
Utility::CircularBuffer<int16_t, histSize> zHistory = {};
|
||||
int32_t accumulatedSpeed = 0;
|
||||
|
||||
bool isSensorOk = false;
|
||||
DeviceTypes deviceType = DeviceTypes::Unknown;
|
||||
// Pinetime::Controllers::MotionService* service = nullptr;
|
||||
};
|
||||
|
Reference in New Issue
Block a user