1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-17 22:11:35 +02:00

Add YUNMAI LBM & visceral fat value. (#522)

* Add YUNMAI LBM value

this scale machine just use `weight - fat` formula

* Initial implement YunmaiLib.getVisceralFat

a return value range is 1 to 30
an original app use `floor` calculation to last value and return the integer value.
it's a different part.
This commit is contained in:
Sunguk Lee
2019-12-04 23:35:49 +09:00
committed by OliE
parent bb374495e0
commit 6d0e2d1855
2 changed files with 46 additions and 0 deletions

View File

@@ -145,6 +145,8 @@ public class BluetoothYunmaiSE_Mini extends BluetoothCommunication {
scaleBtData.setMuscle(yunmaiLib.getMuscle(bodyFat));
scaleBtData.setWater(yunmaiLib.getWater(bodyFat));
scaleBtData.setBone(yunmaiLib.getBoneMass(scaleBtData.getMuscle(), weight));
scaleBtData.setLbm(yunmaiLib.getLeanBodyMass(weight, bodyFat));
scaleBtData.setVisceralFat(yunmaiLib.getVisceralFat(bodyFat, scaleUser.getAge()));
} else {
Timber.e("body fat is zero");
}

View File

@@ -79,4 +79,48 @@ public class YunmaiLib {
return boneMass;
}
public float getLeanBodyMass(float weight, float bodyFat) {
if (bodyFat < 5.0f || bodyFat > 75.0f) {
return 0.0f;
}
return weight * (100.0f - bodyFat) / 100.0f;
}
public float getVisceralFat(float bodyFat, int age) {
float f = (bodyFat < 5.0f || bodyFat > 75.0f) ? 0.0f : bodyFat;
int a = (age < 18 || age > 120) ? 18 : age;
if (sex == 1) {
if (a < 40) {
f -= 21.0f;
} else if (a < 60) {
f -= 22.0f;
} else {
f -= 24.0f;
}
} else {
if (a < 40) {
f -= 34.0f;
} else if (a < 60) {
f -= 35.0f;
} else {
f -= 36.0f;
}
}
float d = sex == 1 ? 1.4f : 1.8f;
if (f > 0.0f) {
d = 1.1f;
}
float vf = (f / d) + 9.5f;
if (vf < 1.0f) {
return 1.0f;
}
if (vf > 30.0f) {
return 30.0f;
}
return vf;
}
}