Skip to content

Commit

Permalink
Unit-HEART Correction due to changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GOB52 committed Oct 16, 2024
1 parent 1e56bbc commit 8862df8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/demo/MultipleUnits/main/MultipleUnits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void prepare()
tvocSmallUI.construct();
vmeterSmallUI.construct();
env3SmallUI.construct();
heartSmallUI.heartRate().setSampleRate(m5::max30100::HeartRate::getSampleRate(unitHeart.config().sample_rate));
heartSmallUI.monitor().setSamplingRate(m5::unit::max30100::getSamplingRate(unitHeart.config().sampling_rate));
}

// task for Vmeter
Expand Down
14 changes: 9 additions & 5 deletions examples/demo/MultipleUnits/src/ui/ui_UnitHEART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ void UnitHEARTSmallUI::update()

lock();
for (auto&& e : _intermediateBuffer) {
beat(_heartRate.push_back(e.ir, e.red));
_bpm = _heartRate.calculate();
_monitor.push_back(e.ir, e.red);
_monitor.update();

_irPlotter->push_back(e.ir);
_spO2Plotter->push_back(_heartRate.SpO2());
beat(_monitor.isBeat());
_bpm = _monitor.bpm();

// _irPlotter->push_back(e.ir);
_irPlotter->push_back(_monitor.latestIR());
_spO2Plotter->push_back(_monitor.SpO2());
}
_intermediateBuffer.clear();
unlock();
Expand Down Expand Up @@ -94,7 +98,7 @@ void UnitHEARTSmallUI::push(LovyanGFX* dst, const int32_t x, const int32_t y)
dst->drawString(s.c_str(), left + GAP * 2, top + GAP * 2 + _irPlotter->height());

dst->setTextDatum(textdatum_t::bottom_right);
s = m5::utility::formatString("SpO2:%3.2f%%", _heartRate.SpO2());
s = m5::utility::formatString("SpO2:%3.2f%%", _monitor.SpO2());
dst->drawString(s.c_str(), right - GAP, bottom - _spO2Plotter->height() - GAP);

constexpr int32_t radius{4};
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/MultipleUnits/src/ui/ui_UnitHEART.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class UnitHEARTSmallUI : public UnitUIBase {
{
}

inline m5::max30100::HeartRate& heartRate()
inline m5::heart::PulseMonitor& monitor()
{
return _heartRate;
return _monitor;
}

inline void beat(bool beated)
Expand All @@ -42,7 +42,7 @@ class UnitHEARTSmallUI : public UnitUIBase {
private:
std::unique_ptr<m5::ui::Plotter> _irPlotter{};
std::unique_ptr<m5::ui::Plotter> _spO2Plotter{};
m5::max30100::HeartRate _heartRate{};
m5::heart::PulseMonitor _monitor{100.0f};
int32_t _beatCounter{}, _bpm{};

struct Data {
Expand Down

0 comments on commit 8862df8

Please sign in to comment.