1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 19:06:53 +01:00

Merge pull request #515 from jpbarraca/hplus-fix-2

HPlus: Fix bug related to steps and heart rate
This commit is contained in:
Andreas Shimokawa 2017-01-24 08:21:07 +01:00 committed by GitHub
commit 378d285b1a
3 changed files with 5 additions and 2 deletions

View File

@ -46,7 +46,7 @@ public class HPlusDataRecordDaySlot extends HPlusDataRecord {
slot = a;
heartRate = data[1] & 0xFF;
if(heartRate == 255)
if(heartRate == 255 || heartRate == 0)
heartRate = ActivityKind.TYPE_NOT_MEASURED;
steps = (data[2] & 0xFF) * 256 + data[3] & 0xFF;

View File

@ -9,6 +9,7 @@ import java.util.GregorianCalendar;
import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
class HPlusDataRecordRealtime extends HPlusDataRecord {
@ -71,6 +72,7 @@ class HPlusDataRecordRealtime extends HPlusDataRecord {
if(heartRate == 255) {
intensity = 0;
activityKind = ActivityKind.TYPE_NOT_MEASURED;
heartRate = ActivitySample.NOT_MEASURED;
}
else {
intensity = (int) (100 * Math.max(0, Math.min((heartRate - 60) / 120.0, 1))); // TODO: Calculate a proper value

View File

@ -391,6 +391,8 @@ class HPlusHandlerThread extends GBDeviceIoThread {
sample.setRawHPlusHealthData(record.getRawData());
sample.setProvider(provider);
provider.addGBActivitySample(sample);
sample.setSteps(sample.getSteps() - prevRealTimeRecord.steps);
Intent intent = new Intent(DeviceService.ACTION_REALTIME_SAMPLES)
@ -398,7 +400,6 @@ class HPlusHandlerThread extends GBDeviceIoThread {
.putExtra(DeviceService.EXTRA_TIMESTAMP, System.currentTimeMillis());
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
provider.addGBActivitySample(sample);
//TODO: Handle Active Time. With Overlay?
} catch (GBException ex) {