Skip to content

Commit

Permalink
invoking the measurements speed once
Browse files Browse the repository at this point in the history
  • Loading branch information
Zer0-bit committed Aug 5, 2023
1 parent 2a2d68f commit a9d71b8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/gaggiuino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ static void sensorsReadWeight(void) {
const auto weight = handleTaringAndReadWeight();
weightMeasurements.add(weight);
currentState.weight = weightMeasurements.getLatest().value;
float weightFlow = weightMeasurements.getMeasurementChange().speed();

if (brewActive && !currentState.steamSwitchState) {
// If there's a sudden jump in weight
bool isChangeRateHigh = weightMeasurements.getMeasurementChange().speed() > weightRateThreshold;
bool isChangeRateHigh = weightFlow > weightRateThreshold;
bool isCupPlaced = currentState.weight - initialWeight >= weightIncreaseThreshold;
if (!systemState.tarePending && (isChangeRateHigh || isCupPlaced)) {
// Ignore accidental weight bumps
Expand All @@ -183,7 +184,7 @@ static void sensorsReadWeight(void) {
// Only take flow measurements when tare is not pending.
currentState.weightFlow = systemState.tarePending
? currentState.weightFlow
: fmax(0.f, weightMeasurements.getMeasurementChange().speed());
: fmax(0.f, weightFlow);
currentState.smoothedWeightFlow = smoothScalesFlow.updateEstimate(currentState.weightFlow);
}
}
Expand Down

0 comments on commit a9d71b8

Please sign in to comment.