mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-31 20:11:58 +02:00
ADd getAge() method overload not taking a Date
This commit is contained in:
@@ -97,7 +97,7 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication {
|
||||
//The weight is stabilized, now we want to measure all available values
|
||||
byte gender = selectedUser.getGender().isMale() ? (byte)0x00: (byte)0x01;
|
||||
byte height = (byte) (selectedUser.getBodyHeight() & 0xFF);
|
||||
byte age = (byte)(selectedUser.getAge(new Date()) & 0xff);
|
||||
byte age = (byte)(selectedUser.getAge() & 0xff);
|
||||
byte unit = 0x01; // kg
|
||||
switch (selectedUser.getScaleUnit()) {
|
||||
case LB:
|
||||
|
@@ -58,7 +58,7 @@ public class BluetoothExcelvanCF369BLE extends BluetoothCommunication {
|
||||
|
||||
byte sex = selectedUser.getGender().isMale() ? (byte)0x01 : (byte)0x00; // 01 - male; 00 - female
|
||||
byte height = (byte)(selectedUser.getBodyHeight() & 0xff); // cm
|
||||
byte age = (byte)(selectedUser.getAge(new Date()) & 0xff);
|
||||
byte age = (byte)(selectedUser.getAge() & 0xff);
|
||||
byte unit = 0x01; // kg
|
||||
|
||||
switch (selectedUser.getScaleUnit()) {
|
||||
|
@@ -53,7 +53,7 @@ public class BluetoothExingtechY1 extends BluetoothCommunication {
|
||||
|
||||
byte gender = selectedUser.getGender().isMale() ? (byte)0x00 : (byte)0x01; // 00 - male; 01 - female
|
||||
byte height = (byte)(selectedUser.getBodyHeight() & 0xff); // cm
|
||||
byte age = (byte)(selectedUser.getAge(new Date()) & 0xff);
|
||||
byte age = (byte)(selectedUser.getAge() & 0xff);
|
||||
|
||||
int userId = selectedUser.getId();
|
||||
|
||||
|
@@ -101,7 +101,7 @@ public class BluetoothMGB extends BluetoothCommunication {
|
||||
break;
|
||||
|
||||
case 3:
|
||||
writeCfg(0xFB, (user.getGender().isMale() ? 1 : 2), user.getAge(new Date()), user.getBodyHeight());
|
||||
writeCfg(0xFB, (user.getGender().isMale() ? 1 : 2), user.getAge(), user.getBodyHeight());
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
@@ -64,7 +64,7 @@ public class BluetoothYunmaiSE_Mini extends BluetoothCommunication {
|
||||
byte[] user_add_or_query = new byte[]{
|
||||
(byte) 0x0d, (byte) 0x12, (byte) 0x10, (byte) 0x01, (byte) 0x00, (byte) 0x00,
|
||||
userId[0], userId[1], (byte) selectedUser.getBodyHeight(), sex,
|
||||
(byte) selectedUser.getAge(new Date()), (byte) 0x55, (byte) 0x5a, (byte) 0x00,
|
||||
(byte) selectedUser.getAge(), (byte) 0x55, (byte) 0x5a, (byte) 0x00,
|
||||
(byte)0x00, display_unit, (byte) 0x03, (byte) 0x00};
|
||||
user_add_or_query[17] = xor_checksum(user_add_or_query);
|
||||
writeBytes(WEIGHT_CMD_SERVICE, WEIGHT_CMD_CHARACTERISTIC, user_add_or_query);
|
||||
|
@@ -128,7 +128,9 @@ public class ScaleUser {
|
||||
|
||||
public int getAge(Date todayDate) {
|
||||
Calendar calToday = Calendar.getInstance();
|
||||
if (todayDate != null) {
|
||||
calToday.setTime(todayDate);
|
||||
}
|
||||
|
||||
Calendar calBirthday = Calendar.getInstance();
|
||||
calBirthday.setTime(birthday);
|
||||
@@ -136,6 +138,10 @@ public class ScaleUser {
|
||||
return DateTimeHelpers.yearsBetween(calBirthday, calToday);
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return getAge(null);
|
||||
}
|
||||
|
||||
public void setInitialWeight(float weight) {
|
||||
this.initialWeight = weight;
|
||||
}
|
||||
|
Reference in New Issue
Block a user