Skip to content

Commit

Permalink
code style and other cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
martukas committed Jul 4, 2022
1 parent 9f46ada commit 806ee2c
Show file tree
Hide file tree
Showing 7 changed files with 926 additions and 991 deletions.
12 changes: 5 additions & 7 deletions software/controller/lib/core/breath_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ limitations under the License.
#include "breath_detection.h"

/// \TODO: this is only here for loop period for default trigger values. Get rid of this
#include "controller.h"

#include <algorithm>

#include "controller.h"

using DebugFloat = Debug::Variable::Float;

// Note that since BreathDetection is instantiated for each breath, these debugvars are static and
Expand All @@ -25,10 +25,10 @@ using DebugFloat = Debug::Variable::Float;

/// \TODO: This should be configurable from the GUI.
static DebugFloat inhale_trigger{"bd_inhale_trigger", Debug::Variable::Access::ReadWrite, 200,
"mL/s", "Breath detection inhale trigger"};
"mL/s", "Breath detection inhale trigger"};

static DebugFloat exhale_trigger("bd_exhale_trigger", Debug::Variable::Access::ReadWrite, 300,
"mL/s", "Breath detection exhale trigger");
"mL/s", "Breath detection exhale trigger");

// fast_alpha_ and slow_alpha_ were tuned for a control loop that runs at a particular frequency.
// In theory if the control loop gets slower, the alpha terms should get bigger, placing more weight
Expand Down Expand Up @@ -70,8 +70,7 @@ void BreathDetection::update_averages(const BreathDetectionInputs &inputs) {
dbg_fast_flow_avg.set(fast_flow_avg_.ml_per_sec());
}


bool BreathDetection::PatientInspiring(const BreathDetectionInputs &inputs, bool at_dwell) {
bool BreathDetection::PatientInhaling(const BreathDetectionInputs &inputs, bool at_dwell) {
// Calculate averages only once flow is non-negative
if (inputs.net_flow < ml_per_sec(0)) {
return false;
Expand All @@ -92,4 +91,3 @@ bool BreathDetection::PatientExhaling(const BreathDetectionInputs &inputs, bool

return slow_flow_avg_ > fast_flow_avg_ + ml_per_sec(exhale_trigger.get());
}

2 changes: 1 addition & 1 deletion software/controller/lib/core/breath_detection.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BreathDetection {
// - net_flow, to allow inspire detection
// - at_dwell, telling BreathDetection that the dwell plateau has been reached
// TODO: automatically detect dwell plateau from flow
bool PatientInspiring(const BreathDetectionInputs &inputs, bool at_dwell);
bool PatientInhaling(const BreathDetectionInputs &inputs, bool at_dwell);
bool PatientExhaling(const BreathDetectionInputs &inputs, bool at_dwell);

protected:
Expand Down
Loading

0 comments on commit 806ee2c

Please sign in to comment.