From f9e5ab5fc1a8c5fd0dba8f1b37446d857b08d230 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Fri, 19 Jun 2015 00:20:38 +0200 Subject: [PATCH] Some more refinements to sleep display (#45): - display the recorded level of deep sleep rather than a constant (I hope this works for morpheuz, too!?) - give light sleep a minimum value, because it's sometimes 0 for Mi Band --- .../activities/SleepChartActivity.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SleepChartActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SleepChartActivity.java index 571d0cb9..c46f6a1e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SleepChartActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SleepChartActivity.java @@ -37,6 +37,9 @@ import nodomain.freeyourgadget.gadgetbridge.R; public class SleepChartActivity extends Activity { + private static final float Y_VALUE_DEEP_SLEEP = 0.01f; + private static final float Y_VALUE_LIGHT_SLEEP = 0.016f; + private static final class ActivityKind { public final byte type; public final String label; @@ -266,16 +269,18 @@ public class SleepChartActivity extends Activity { short movement = sample.getIntensity(); - - BarEntry emptyEntry = createEntry(0, i); float value; if (type == GBActivitySample.TYPE_DEEP_SLEEP) { - value = 0.01f; +// value = Y_VALUE_DEEP_SLEEP; + value = ((float) movement) / movement_divisor; +// value += Y_VALUE_DEEP_SLEEP; activityEntries.add(createEntry(value, i)); colors.add(akDeepSleep.color); } else { if (type == GBActivitySample.TYPE_LIGHT_SLEEP) { - value = ((float) movement / movement_divisor); + value = ((float) movement) / movement_divisor; + value += Y_VALUE_LIGHT_SLEEP; +// value = Math.min(1.0f, Y_VALUE_LIGHT_SLEEP); activityEntries.add(createEntry(value, i)); colors.add(akLightSleep.color); } else { @@ -284,7 +289,7 @@ public class SleepChartActivity extends Activity { // I'm not sure using steps for this is actually a good idea movement = steps; } - value = ((float) movement / movement_divisor); + value = ((float) movement) / movement_divisor; activityEntries.add(createEntry(value, i)); colors.add(akActivity.color); }