1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 10:05:49 +01:00

HPlus: set not worn when charging

This commit is contained in:
João Paulo Barraca 2017-05-31 15:20:20 +01:00
parent 9b5c1b91c0
commit e97f4d3909
3 changed files with 18 additions and 21 deletions

View File

@ -167,6 +167,8 @@ public class HPlusHealthSampleProvider extends AbstractSampleProvider<HPlusHealt
long nonSleepTimeEnd = 0;
for (HPlusHealthActivitySample sample : samples) {
if (sample.getRawKind() == ActivityKind.TYPE_NOT_WORN)
continue;
if (sample.getTimestamp() >= overlay.getTimestampFrom() && sample.getTimestamp() < overlay.getTimestampTo()) {
if (overlay.getRawKind() == ActivityKind.TYPE_NOT_WORN || overlay.getRawKind() == ActivityKind.TYPE_LIGHT_SLEEP || overlay.getRawKind() == ActivityKind.TYPE_DEEP_SLEEP) {

View File

@ -24,6 +24,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.hplus;
import java.util.GregorianCalendar;
import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityAmount;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
@ -80,19 +81,24 @@ class HPlusDataRecordRealtime extends HPlusDataRecord {
int y = (data[8] & 0xFF) * 256 + (data[7] & 0xFF);
battery = data[9];
calories = x + y; // KCal
heartRate = data[11] & 0xFF; // BPM
activeTime = (data[14] & 0xFF * 256) + (data[13] & 0xFF);
if(heartRate == 255) {
intensity = 0;
activityKind = ActivityKind.TYPE_NOT_MEASURED;
if (battery == 255) {
battery = ActivitySample.NOT_MEASURED;
heartRate = ActivitySample.NOT_MEASURED;
}
else {
intensity = (int) ((100*heartRate)/(208-0.7*age));
activityKind = ActivityKind.TYPE_UNKNOWN;
intensity = 0;
activityKind = ActivityKind.TYPE_NOT_WORN;
} else {
heartRate = data[11] & 0xFF; // BPM
if (heartRate == 255) {
intensity = 0;
activityKind = ActivityKind.TYPE_NOT_MEASURED;
heartRate = ActivitySample.NOT_MEASURED;
} else {
intensity = (int) ((100 * heartRate) / (208 - 0.7 * age));
activityKind = HPlusDataRecord.TYPE_REALTIME;
}
}
}

View File

@ -443,17 +443,6 @@ class HPlusHandlerThread extends GBDeviceIoThread {
getDevice().setBatteryLevel(record.battery);
//Skip when measuring heart rate
//Calories and Distance are updated and these values will be lost.
//Because a message with a valid Heart Rate will be provided, this loss very limited
if (record.heartRate == ActivityKind.TYPE_NOT_MEASURED) {
getDevice().setFirmwareVersion2("---");
getDevice().sendDeviceUpdateIntent(getContext());
} else {
getDevice().setFirmwareVersion2("" + record.heartRate);
getDevice().sendDeviceUpdateIntent(getContext());
}
try (DBHandler dbHandler = GBApplication.acquireDB()) {
HPlusHealthSampleProvider provider = new HPlusHealthSampleProvider(getDevice(), dbHandler.getDaoSession());