mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-14 20:54:33 +02:00
@@ -96,7 +96,7 @@ public class BluetoothFactory {
|
|||||||
if (name.startsWith("SANITAS SBF70".toLowerCase(Locale.US)) || name.startsWith("sbf75")) {
|
if (name.startsWith("SANITAS SBF70".toLowerCase(Locale.US)) || name.startsWith("sbf75")) {
|
||||||
return new BluetoothBeurerSanitas(context, BluetoothBeurerSanitas.DeviceType.SANITAS_SBF70_70);
|
return new BluetoothBeurerSanitas(context, BluetoothBeurerSanitas.DeviceType.SANITAS_SBF70_70);
|
||||||
}
|
}
|
||||||
if (deviceName.startsWith("YUNMAI-SIGNAL-") || deviceName.startsWith("YUNMAI-ISM")) {
|
if (deviceName.startsWith("YUNMAI-SIGNAL") || deviceName.startsWith("YUNMAI-ISM")) {
|
||||||
return new BluetoothYunmaiSE_Mini(context, true);
|
return new BluetoothYunmaiSE_Mini(context, true);
|
||||||
}
|
}
|
||||||
if (deviceName.startsWith("YUNMAI-ISSE")) {
|
if (deviceName.startsWith("YUNMAI-ISSE")) {
|
||||||
|
@@ -130,8 +130,15 @@ public class BluetoothYunmaiSE_Mini extends BluetoothCommunication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
YunmaiLib yunmaiLib = new YunmaiLib(sex, scaleUser.getBodyHeight());
|
YunmaiLib yunmaiLib = new YunmaiLib(sex, scaleUser.getBodyHeight());
|
||||||
float bodyFat = Converters.fromUnsignedInt16Be(weightBytes, 17) / 100.0f;
|
float bodyFat;
|
||||||
int resistance = Converters.fromUnsignedInt16Be(weightBytes, 15);
|
int resistance = Converters.fromUnsignedInt16Be(weightBytes, 15);
|
||||||
|
if (weightBytes[1] >= (byte)0x1E) {
|
||||||
|
Timber.d("Extract the fat value from received bytes");
|
||||||
|
bodyFat = Converters.fromUnsignedInt16Be(weightBytes, 17) / 100.0f;
|
||||||
|
} else {
|
||||||
|
Timber.d("Calculate the fat value using the Yunmai lib");
|
||||||
|
bodyFat = yunmaiLib.getFat(scaleUser.getAge(), weight, resistance);
|
||||||
|
}
|
||||||
|
|
||||||
if (bodyFat != 0) {
|
if (bodyFat != 0) {
|
||||||
scaleBtData.setFat(bodyFat);
|
scaleBtData.setFat(bodyFat);
|
||||||
|
@@ -29,6 +29,24 @@ public class YunmaiLib {
|
|||||||
return ((100.0f - bodyFat) * 0.726f * 100.0f + 0.5f) / 100.0f;
|
return ((100.0f - bodyFat) * 0.726f * 100.0f + 0.5f) / 100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getFat(int age, float weight, int resistance) {
|
||||||
|
// for < 0x1e version devices
|
||||||
|
float fat;
|
||||||
|
|
||||||
|
float r = (resistance - 100.0f) / 100.0f;
|
||||||
|
float h = height / 100.0f;
|
||||||
|
|
||||||
|
if (this.sex == 1) {
|
||||||
|
fat = (weight * 1.5f / h / h) + (age * 0.08f) - 10.8f;
|
||||||
|
} else {
|
||||||
|
fat = (weight * 1.5f / h / h) + (age * 0.08f);
|
||||||
|
}
|
||||||
|
|
||||||
|
fat = (fat - 7.4f) + r;
|
||||||
|
|
||||||
|
return fat;
|
||||||
|
}
|
||||||
|
|
||||||
public float getMuscle(float bodyFat) {
|
public float getMuscle(float bodyFat) {
|
||||||
float muscle;
|
float muscle;
|
||||||
muscle = (100.0f - bodyFat) * 0.67f;
|
muscle = (100.0f - bodyFat) * 0.67f;
|
||||||
|
Reference in New Issue
Block a user