1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 02:46:50 +01:00

Colmi R0x: Support REM sleep and awake samples

This commit is contained in:
Arjan Schrijver 2024-09-29 21:27:46 +02:00
parent eb2b7fef41
commit c8c9772ac8
3 changed files with 13 additions and 1 deletions

View File

@ -149,6 +149,16 @@ public abstract class AbstractColmiR0xCoordinator extends AbstractBLEDeviceCoord
return true;
}
@Override
public boolean supportsRemSleep() {
return true;
}
@Override
public boolean supportsAwakeSleep() {
return true;
}
@Override
public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
return new ColmiActivitySampleProvider(device, session);

View File

@ -59,5 +59,6 @@ public class ColmiR0xConstants {
public static final byte SLEEP_TYPE_LIGHT = 0x02;
public static final byte SLEEP_TYPE_DEEP = 0x03;
public static final byte SLEEP_TYPE_REM = 0x04;
public static final byte SLEEP_TYPE_AWAKE = 0x05;
}

View File

@ -157,7 +157,6 @@ public class ColmiActivitySampleProvider extends AbstractSampleProvider<ColmiAct
for (final ColmiSleepStageSample sleepStageSample : sleepStageSamples) {
final ActivityKind sleepRawKind = sleepStageToActivityKind(sleepStageSample.getStage());
if (sleepRawKind == ActivityKind.AWAKE_SLEEP) continue;
// round to the nearest minute, we don't need per-second granularity
final int tsSeconds = (int) ((sleepStageSample.getTimestamp() / 1000) / 60) * 60;
for (int i = tsSeconds; i < tsSeconds + sleepStageSample.getDuration() * 60; i += 60) {
@ -181,6 +180,8 @@ public class ColmiActivitySampleProvider extends AbstractSampleProvider<ColmiAct
return ActivityKind.LIGHT_SLEEP;
case ColmiR0xConstants.SLEEP_TYPE_DEEP:
return ActivityKind.DEEP_SLEEP;
case ColmiR0xConstants.SLEEP_TYPE_REM:
return ActivityKind.REM_SLEEP;
case ColmiR0xConstants.SLEEP_TYPE_AWAKE:
return ActivityKind.AWAKE_SLEEP;
default: