mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-19 23:12:12 +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
|
// The first notification only includes weight and all other fields are
|
||||||
// either 0x00 (user info) or 0xff (fat, water, etc.)
|
// 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);
|
parseBytes(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ public class BluetoothExingtechY1 extends BluetoothCommunication {
|
|||||||
float water = Converters.fromUnsignedInt16Be(weightBytes, 8) / 10.0f; // %
|
float water = Converters.fromUnsignedInt16Be(weightBytes, 8) / 10.0f; // %
|
||||||
float bone = Converters.fromUnsignedInt16Be(weightBytes, 10) / 10.0f; // kg
|
float bone = Converters.fromUnsignedInt16Be(weightBytes, 10) / 10.0f; // kg
|
||||||
float muscle = Converters.fromUnsignedInt16Be(weightBytes, 12) / 10.0f; // %
|
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 calorie = Converters.fromUnsignedInt16Be(weightBytes, 15);
|
||||||
float bmi = Converters.fromUnsignedInt16Be(weightBytes, 17) / 10.0f;
|
float bmi = Converters.fromUnsignedInt16Be(weightBytes, 17) / 10.0f;
|
||||||
|
|
||||||
@@ -115,11 +115,7 @@ public class BluetoothExingtechY1 extends BluetoothCommunication {
|
|||||||
scaleBtData.setWater(water);
|
scaleBtData.setWater(water);
|
||||||
scaleBtData.setBone(bone);
|
scaleBtData.setBone(bone);
|
||||||
scaleBtData.setVisceralFat(visc_fat);
|
scaleBtData.setVisceralFat(visc_fat);
|
||||||
|
scaleBtData.setDateTime(new Date());
|
||||||
Calendar dateTime = Calendar.getInstance();
|
|
||||||
dateTime.set(Calendar.MILLISECOND, 0);
|
|
||||||
dateTime.set(Calendar.SECOND, 0);
|
|
||||||
scaleBtData.setDateTime(dateTime.getTime());
|
|
||||||
|
|
||||||
addScaleData(scaleBtData);
|
addScaleData(scaleBtData);
|
||||||
}
|
}
|
||||||
|
@@ -47,6 +47,8 @@ public class EvaluationSheet {
|
|||||||
private List<sheetEntry> whrEvaluateSheet_Man;
|
private List<sheetEntry> whrEvaluateSheet_Man;
|
||||||
private List<sheetEntry> whrEvaluateSheet_Woman;
|
private List<sheetEntry> whrEvaluateSheet_Woman;
|
||||||
|
|
||||||
|
private List<sheetEntry> visceralFatEvaluateSheet;
|
||||||
|
|
||||||
private class sheetEntry {
|
private class sheetEntry {
|
||||||
public sheetEntry(int lowAge, int maxAge, float lowLimit, float highLimit)
|
public sheetEntry(int lowAge, int maxAge, float lowLimit, float highLimit)
|
||||||
{
|
{
|
||||||
@@ -87,6 +89,8 @@ public class EvaluationSheet {
|
|||||||
whrEvaluateSheet_Man = new ArrayList<>();
|
whrEvaluateSheet_Man = new ArrayList<>();
|
||||||
whrEvaluateSheet_Woman = new ArrayList<>();
|
whrEvaluateSheet_Woman = new ArrayList<>();
|
||||||
|
|
||||||
|
visceralFatEvaluateSheet = new ArrayList<>();
|
||||||
|
|
||||||
initEvaluationSheets();
|
initEvaluationSheets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,6 +167,8 @@ public class EvaluationSheet {
|
|||||||
|
|
||||||
whrEvaluateSheet_Man.add(new sheetEntry(18, 90, 0.8f, 0.9f));
|
whrEvaluateSheet_Man.add(new sheetEntry(18, 90, 0.8f, 0.9f));
|
||||||
whrEvaluateSheet_Woman.add(new sheetEntry(18, 90, 0.7f, 0.8f));
|
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);
|
return evaluateSheet(whr, bodyEvaluateSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EvaluationResult evaluateVisceralFat(float visceralFat) {
|
||||||
|
return evaluateSheet(visceralFat, visceralFatEvaluateSheet);
|
||||||
|
}
|
||||||
|
|
||||||
private EvaluationResult evaluateSheet(float value, List<sheetEntry> sheet) {
|
private EvaluationResult evaluateSheet(float value, List<sheetEntry> sheet) {
|
||||||
for (int i=0; i < sheet.size(); i++) {
|
for (int i=0; i < sheet.size(); i++) {
|
||||||
sheetEntry curEntry = sheet.get(i);
|
sheetEntry curEntry = sheet.get(i);
|
||||||
|
@@ -36,11 +36,6 @@ public class VisceralFatMeasurementView extends FloatMeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean supportsPercentageToAbsoluteWeightConversion() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
||||||
return measurement.getVisceralFat();
|
return measurement.getVisceralFat();
|
||||||
@@ -53,16 +48,12 @@ public class VisceralFatMeasurementView extends FloatMeasurementView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUnit() {
|
public String getUnit() {
|
||||||
if (shouldConvertPercentageToAbsoluteWeight()) {
|
return "";
|
||||||
return getScaleUser().getScaleUnit().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "%";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getMaxValue() {
|
protected float getMaxValue() {
|
||||||
return maybeConvertPercentageToAbsoluteWeight(80);
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,6 +63,6 @@ public class VisceralFatMeasurementView extends FloatMeasurementView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
|
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
|
||||||
return null;
|
return evalSheet.evaluateVisceralFat(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user