1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-30 11:40:23 +02:00

BluetoothStandardWeightProfile: Calculate lean body mass and bone mass;

Thanks to Adam Serbinski <adam@serbinski.com> for providing formulas!
This commit is contained in:
Krisjans Blukis
2021-07-27 19:28:04 +03:00
parent 05816ce0cf
commit cb08486731

View File

@@ -434,8 +434,9 @@ public class BluetoothStandardWeightProfile extends BluetoothCommunication {
} }
// Read softleanMass if present // Read softleanMass if present
float softLeanMass = 0.0f;
if (softLeanMassPresent) { if (softLeanMassPresent) {
float softLeanMass = parser.getIntValue(BluetoothBytesParser.FORMAT_UINT16) * massMultiplier; softLeanMass = parser.getIntValue(BluetoothBytesParser.FORMAT_UINT16) * massMultiplier;
Timber.d(prefix + "softLeanMass: " + softLeanMass); Timber.d(prefix + "softLeanMass: " + softLeanMass);
} }
@@ -453,11 +454,29 @@ public class BluetoothStandardWeightProfile extends BluetoothCommunication {
} }
// Read weight if present // Read weight if present
float weightValue = 0.0f;
if (weightPresent) { if (weightPresent) {
float weightValue = parser.getIntValue(BluetoothBytesParser.FORMAT_UINT16) * massMultiplier; weightValue = parser.getIntValue(BluetoothBytesParser.FORMAT_UINT16) * massMultiplier;
Timber.d(prefix + "weightValue: " + weightValue); Timber.d(prefix + "weightValue: " + weightValue);
scaleMeasurement.setWeight(weightValue); scaleMeasurement.setWeight(weightValue);
} }
else {
if (previousMeasurement != null) {
weightValue = previousMeasurement.getWeight();
if (weightValue > 0) {
weightPresent = true;
}
}
}
// calculate lean body mass and bone mass
if (weightPresent && softLeanMassPresent) {
float fatMass = weightValue * bodyFatPercentage / 100.0f;
float leanBodyMass = weightValue - fatMass;
float boneMass = leanBodyMass - softLeanMass;
scaleMeasurement.setLbm(leanBodyMass);
scaleMeasurement.setBone(boneMass);
}
// Read height if present // Read height if present
if (heightPresent) { if (heightPresent) {