Pebble: Initial try to interpret sleep
This commit is contained in:
parent
ebbb71ae9d
commit
1734e58f70
|
@ -69,25 +69,39 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
||||||
Date endDate = new Date((long) (timestamp + samples * 60) * 1000L);
|
Date endDate = new Date((long) (timestamp + samples * 60) * 1000L);
|
||||||
LOG.info("got data from " + startDate + " to " + endDate);
|
LOG.info("got data from " + startDate + " to " + endDate);
|
||||||
|
|
||||||
int steps = 0;
|
|
||||||
int totalSteps = 0;
|
int totalSteps = 0;
|
||||||
GBActivitySample[] activitySamples = new GBActivitySample[samples];
|
GBActivitySample[] activitySamples = new GBActivitySample[samples];
|
||||||
for (int i = 0; i < samples; i++) {
|
for (int i = 0; i < samples; i++) {
|
||||||
short sample = buf.getShort();
|
short sample = buf.getShort();
|
||||||
if ((sample & 0x0001) == 0) { // 16-??? steps encoded in bits 1-7
|
int steps = 0;
|
||||||
steps = (sample & 0x00fe);
|
int intensity = 0;
|
||||||
} else { // 0-14 steps encoded in bits 1-3, most of the time fc71 bits are set in that case
|
byte activityKind = ActivityKind.TYPE_UNKNOWN;
|
||||||
// 0040 also set always?
|
|
||||||
steps = (sample & 0x000e);
|
if (((sample & 0x83ff) == 0x0001) && ((sample & 0xff00) <= 0x4800)) {
|
||||||
|
// sleep seems to be from 0x2401 to 0x4801 (0b0IIIII0000000001) where I = intensity ?
|
||||||
|
intensity = (sample & 0x7c00) >>> 10;
|
||||||
|
// 9-18 decimal after shift
|
||||||
|
if (intensity <= 13) {
|
||||||
|
activityKind = ActivityKind.TYPE_DEEP_SLEEP;
|
||||||
|
} else {
|
||||||
|
// FIXME: this leads to too much false positives, ignore for now
|
||||||
|
//activityKind = ActivityKind.TYPE_LIGHT_SLEEP;
|
||||||
|
//intensity *= 2; // better visual distinction
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((sample & 0x0001) == 0) { // 16-??? steps encoded in bits 1-7
|
||||||
|
steps = (sample & 0x00fe);
|
||||||
|
} else { // 0-14 steps encoded in bits 1-3, most of the time fc71 bits are set in that case
|
||||||
|
steps = (sample & 0x000e);
|
||||||
|
}
|
||||||
|
intensity = steps;
|
||||||
|
activityKind = ActivityKind.TYPE_ACTIVITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
totalSteps += steps;
|
totalSteps += steps;
|
||||||
LOG.info("got steps for sample " + i + " : " + steps + "(" + Integer.toHexString(sample & 0xffff) + ")");
|
LOG.info("got steps for sample " + i + " : " + steps + "(" + Integer.toHexString(sample & 0xffff) + ")");
|
||||||
byte activityKind = ActivityKind.TYPE_UNKNOWN;
|
|
||||||
if (steps > 0) {
|
activitySamples[i] = new GBActivitySample(sampleProvider, timestamp + i * 60, (short) intensity, (short) steps, activityKind);
|
||||||
activityKind = ActivityKind.TYPE_ACTIVITY;
|
|
||||||
}
|
|
||||||
activitySamples[i] = new GBActivitySample(sampleProvider, timestamp + i * 60, (short) steps, (short) steps, activityKind);
|
|
||||||
}
|
}
|
||||||
LOG.info("total steps for above period: " + totalSteps);
|
LOG.info("total steps for above period: " + totalSteps);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue