Skip to content

Commit fb0cb36

Browse files
committed
Revert bluetooth weight check
1 parent c064124 commit fb0cb36

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/display/plugins/ShotHistoryPlugin.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,14 @@ void ShotHistoryPlugin::setup(Controller *c, PluginManager *pm) {
1717
pm->on("controller:volumetric-measurement:bluetooth:change", [this](Event const &event) {
1818
const float weight = event.getFloat("value");
1919
const unsigned long now = millis();
20-
// Explicit check: Only process if weight is a valid number (not NaN or Inf)
21-
if (!isnan(weight) && isfinite(weight)) {
22-
if (lastVolumeSample != 0) {
23-
const unsigned long timeDiff = now - lastVolumeSample;
24-
const float volumeDiff = weight - currentBluetoothWeight;
25-
currentBluetoothFlow = volumeDiff / static_cast<float>(timeDiff) * 1000.0f;
26-
}
27-
lastVolumeSample = now;
28-
currentBluetoothWeight = weight;
29-
} else {
30-
// If weight data is invalid, ignore this update
31-
// This prevents crashes if BLE data is corrupted or connection is unstable
20+
if (lastVolumeSample != 0) {
21+
const unsigned long timeDiff = now - lastVolumeSample;
22+
const float volumeDiff = weight - currentBluetoothWeight;
23+
const float volumeFlow = volumeDiff / static_cast<float>(timeDiff) * 1000.0f;
24+
currentBluetoothFlow = currentBluetoothFlow * 0.9f + volumeFlow * 0.1f;
3225
}
26+
lastVolumeSample = now;
27+
currentBluetoothWeight = weight;
3328
});
3429
pm->on("boiler:currentTemperature:change", [this](Event const &event) { currentTemperature = event.getFloat("value"); });
3530
pm->on("pump:puck-resistance:change", [this](Event const &event) { currentPuckResistance = event.getFloat("value"); });

0 commit comments

Comments
 (0)