Initialize SystemTask, DisplayApp and HeartRateTask as global static variable instead of variables on the heap. We don't need them on the heap as we know their size at build time, it'll reduce memory fragmentation and it'll make memory analysis easier.
This commit is contained in:
@@ -4,9 +4,6 @@
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
HeartRateController::HeartRateController(Pinetime::System::SystemTask& systemTask) : systemTask {systemTask} {
|
||||
}
|
||||
|
||||
void HeartRateController::Update(HeartRateController::States newState, uint8_t heartRate) {
|
||||
this->state = newState;
|
||||
if (this->heartRate != heartRate) {
|
||||
|
@@ -15,8 +15,7 @@ namespace Pinetime {
|
||||
public:
|
||||
enum class States { Stopped, NotEnoughData, NoTouch, Running };
|
||||
|
||||
explicit HeartRateController(System::SystemTask& systemTask);
|
||||
|
||||
HeartRateController() = default;
|
||||
void Start();
|
||||
void Stop();
|
||||
void Update(States newState, uint8_t heartRate);
|
||||
@@ -32,7 +31,6 @@ namespace Pinetime {
|
||||
void SetService(Pinetime::Controllers::HeartRateService* service);
|
||||
|
||||
private:
|
||||
System::SystemTask& systemTask;
|
||||
Applications::HeartRateTask* task = nullptr;
|
||||
States state = States::Stopped;
|
||||
uint8_t heartRate = 0;
|
||||
|
@@ -38,9 +38,8 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
Ppg::Ppg(float spl)
|
||||
: offset {spl},
|
||||
hpf {0.87033078, -1.74066156, 0.87033078, -1.72377617, 0.75754694},
|
||||
Ppg::Ppg()
|
||||
: hpf {0.87033078, -1.74066156, 0.87033078, -1.72377617, 0.75754694},
|
||||
agc {20, 0.971, 2},
|
||||
lpf {0.11595249, 0.23190498, 0.11595249, -0.72168143, 0.18549138} {
|
||||
}
|
||||
@@ -67,13 +66,7 @@ float Ppg::HeartRate() {
|
||||
dataIndex = 0;
|
||||
return hr;
|
||||
}
|
||||
|
||||
int cccount = 0;
|
||||
float Ppg::ProcessHeartRate() {
|
||||
|
||||
if (cccount > 2)
|
||||
asm("nop");
|
||||
cccount++;
|
||||
auto t0 = Trough(data.data(), dataIndex, 7, 48);
|
||||
if (t0 < 0)
|
||||
return 0;
|
||||
|
@@ -8,8 +8,7 @@ namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class Ppg {
|
||||
public:
|
||||
explicit Ppg(float spl);
|
||||
|
||||
Ppg();
|
||||
int8_t Preprocess(float spl);
|
||||
float HeartRate();
|
||||
|
||||
|
Reference in New Issue
Block a user