From ecc8f2fd01db50456ec45b170d20e2aeb7323476 Mon Sep 17 00:00:00 2001 From: oliexdev Date: Tue, 5 Mar 2019 19:12:26 +0100 Subject: [PATCH] fixed female calculation for mi scale v2 --- .../core/bluetooth/lib/MiScaleLib.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/lib/MiScaleLib.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/lib/MiScaleLib.java index e9a4cd2f..47537b9d 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/lib/MiScaleLib.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/lib/MiScaleLib.java @@ -133,27 +133,32 @@ public class MiScaleLib { if (sex == 0 && age <= 49) { lbmSub = 9.25f; - } else if (sex == 1 && age > 49) { + } else if (sex == 0 && age > 49) { lbmSub = 7.25f; } float lbmCoeff = getLBMCoefficient(weight, impedance); + float coeff = 1.0f; - if (sex == 1 && weight < 61) { - bodyFat = (1.0f - (((lbmCoeff - lbmSub) * 0.98f) / weight)) * 100.0f; + if (sex == 1 && weight < 61.0f) { + coeff = 0.98f; } - else if (sex == 0 && weight < 50) { - bodyFat = (1.0f - (((lbmCoeff - lbmSub) * 1.02f) / weight)) * 100.0f; - } - else if (sex == 0 && weight < 60) { - bodyFat = (1.0f - (((lbmCoeff - lbmSub) * 0.96f) / weight)) * 100.0f; - } - else if (sex == 0 && height < 160) { - bodyFat = (1.0f - (((lbmCoeff - lbmSub) * 1.03f) / weight)) * 100.0f; - } else { - bodyFat = (1.0f - ((lbmCoeff - lbmSub) / weight)) * 100.0f; + else if (sex == 0 && weight > 60.0f) { + coeff = 0.96f; + + if (height > 160.0f) { + coeff *= 1.03f; + } + } else if (sex == 0 && weight < 50.0f) { + coeff = 1.02f; + + if (height > 160.0f) { + coeff *= 1.03f; + } } + bodyFat = (1.0f - (((lbmCoeff - lbmSub) * coeff) / weight)) * 100.0f; + if (bodyFat > 63.0f) { bodyFat = 75.0f; }