mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-19 06:51:57 +02:00
- change visceral fat from percent to an index value.
- evaluate visceral fat - revert cropping time by Exingtech Y1 and fix byte conversion bug
This commit is contained in:
@@ -86,7 +86,7 @@ public class BluetoothExingtechY1 extends BluetoothCommunication {
|
||||
|
||||
// The first notification only includes weight and all other fields are
|
||||
// either 0x00 (user info) or 0xff (fat, water, etc.)
|
||||
if (data != null && data.length == 20 && data[6] != 0xff) {
|
||||
if (data != null && data.length == 20 && data[6] != (byte)0xff) {
|
||||
parseBytes(data);
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class BluetoothExingtechY1 extends BluetoothCommunication {
|
||||
float water = Converters.fromUnsignedInt16Be(weightBytes, 8) / 10.0f; // %
|
||||
float bone = Converters.fromUnsignedInt16Be(weightBytes, 10) / 10.0f; // kg
|
||||
float muscle = Converters.fromUnsignedInt16Be(weightBytes, 12) / 10.0f; // %
|
||||
float visc_fat = weightBytes[14] & 0xFF; // %
|
||||
float visc_fat = weightBytes[14] & 0xFF; // index
|
||||
float calorie = Converters.fromUnsignedInt16Be(weightBytes, 15);
|
||||
float bmi = Converters.fromUnsignedInt16Be(weightBytes, 17) / 10.0f;
|
||||
|
||||
@@ -115,11 +115,7 @@ public class BluetoothExingtechY1 extends BluetoothCommunication {
|
||||
scaleBtData.setWater(water);
|
||||
scaleBtData.setBone(bone);
|
||||
scaleBtData.setVisceralFat(visc_fat);
|
||||
|
||||
Calendar dateTime = Calendar.getInstance();
|
||||
dateTime.set(Calendar.MILLISECOND, 0);
|
||||
dateTime.set(Calendar.SECOND, 0);
|
||||
scaleBtData.setDateTime(dateTime.getTime());
|
||||
scaleBtData.setDateTime(new Date());
|
||||
|
||||
addScaleData(scaleBtData);
|
||||
}
|
||||
|
@@ -47,6 +47,8 @@ public class EvaluationSheet {
|
||||
private List<sheetEntry> whrEvaluateSheet_Man;
|
||||
private List<sheetEntry> whrEvaluateSheet_Woman;
|
||||
|
||||
private List<sheetEntry> visceralFatEvaluateSheet;
|
||||
|
||||
private class sheetEntry {
|
||||
public sheetEntry(int lowAge, int maxAge, float lowLimit, float highLimit)
|
||||
{
|
||||
@@ -87,6 +89,8 @@ public class EvaluationSheet {
|
||||
whrEvaluateSheet_Man = new ArrayList<>();
|
||||
whrEvaluateSheet_Woman = new ArrayList<>();
|
||||
|
||||
visceralFatEvaluateSheet = new ArrayList<>();
|
||||
|
||||
initEvaluationSheets();
|
||||
}
|
||||
|
||||
@@ -163,6 +167,8 @@ public class EvaluationSheet {
|
||||
|
||||
whrEvaluateSheet_Man.add(new sheetEntry(18, 90, 0.8f, 0.9f));
|
||||
whrEvaluateSheet_Woman.add(new sheetEntry(18, 90, 0.7f, 0.8f));
|
||||
|
||||
visceralFatEvaluateSheet.add(new sheetEntry(18, 90, -1, 12));
|
||||
}
|
||||
|
||||
|
||||
@@ -267,6 +273,10 @@ public class EvaluationSheet {
|
||||
return evaluateSheet(whr, bodyEvaluateSheet);
|
||||
}
|
||||
|
||||
public EvaluationResult evaluateVisceralFat(float visceralFat) {
|
||||
return evaluateSheet(visceralFat, visceralFatEvaluateSheet);
|
||||
}
|
||||
|
||||
private EvaluationResult evaluateSheet(float value, List<sheetEntry> sheet) {
|
||||
for (int i=0; i < sheet.size(); i++) {
|
||||
sheetEntry curEntry = sheet.get(i);
|
||||
|
@@ -36,11 +36,6 @@ public class VisceralFatMeasurementView extends FloatMeasurementView {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportsPercentageToAbsoluteWeightConversion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
||||
return measurement.getVisceralFat();
|
||||
@@ -53,16 +48,12 @@ public class VisceralFatMeasurementView extends FloatMeasurementView {
|
||||
|
||||
@Override
|
||||
public String getUnit() {
|
||||
if (shouldConvertPercentageToAbsoluteWeight()) {
|
||||
return getScaleUser().getScaleUnit().toString();
|
||||
}
|
||||
|
||||
return "%";
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getMaxValue() {
|
||||
return maybeConvertPercentageToAbsoluteWeight(80);
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,6 +63,6 @@ public class VisceralFatMeasurementView extends FloatMeasurementView {
|
||||
|
||||
@Override
|
||||
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
|
||||
return null;
|
||||
return evalSheet.evaluateVisceralFat(value);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user