From 93085eecb43a6996d7cf06823d3a330c2fb0d939 Mon Sep 17 00:00:00 2001 From: OliE Date: Fri, 1 Jun 2018 09:37:00 +0200 Subject: [PATCH] - change visceral fat from percent to an index value. - evaluate visceral fat - revert cropping time by Exingtech Y1 and fix byte conversion bug --- .../core/bluetooth/BluetoothExingtechY1.java | 10 +++------- .../core/evaluation/EvaluationSheet.java | 10 ++++++++++ .../gui/views/VisceralFatMeasurementView.java | 15 +++------------ 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java index ebd71faf..40f7821c 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java @@ -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); } diff --git a/android_app/app/src/main/java/com/health/openscale/core/evaluation/EvaluationSheet.java b/android_app/app/src/main/java/com/health/openscale/core/evaluation/EvaluationSheet.java index 1a9542d8..e22e20ce 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/evaluation/EvaluationSheet.java +++ b/android_app/app/src/main/java/com/health/openscale/core/evaluation/EvaluationSheet.java @@ -47,6 +47,8 @@ public class EvaluationSheet { private List whrEvaluateSheet_Man; private List whrEvaluateSheet_Woman; + private List 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 sheet) { for (int i=0; i < sheet.size(); i++) { sheetEntry curEntry = sheet.get(i); diff --git a/android_app/app/src/main/java/com/health/openscale/gui/views/VisceralFatMeasurementView.java b/android_app/app/src/main/java/com/health/openscale/gui/views/VisceralFatMeasurementView.java index 2c88e46c..d0b41b33 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/views/VisceralFatMeasurementView.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/views/VisceralFatMeasurementView.java @@ -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); } }