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

HPlus: Fix bug related to steps and heart rate

This commit is contained in:
João Paulo Barraca 2017-01-22 23:33:30 +00:00
parent 5222cf99a2
commit c4a0c60b8c
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) {