Search in sources :

Example 6 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip by NightscoutFoundation.

the class BgSendQueue method getSensorSteps.

public static DataMap getSensorSteps(SharedPreferences prefs) {
    Log.d("BgSendQueue", "getSensorSteps");
    DataMap dataMap = new DataMap();
    final long t = System.currentTimeMillis();
    final PebbleMovement pm = PebbleMovement.last();
    final boolean show_steps = prefs.getBoolean("showSteps", true);
    final boolean show_heart_rate = prefs.getBoolean("showHeartRate", true);
    final boolean use_wear_health = prefs.getBoolean("use_wear_health", true);
    if (use_wear_health || show_steps) {
        boolean sameDay = pm != null ? ListenerService.isSameDay(t, pm.timestamp) : false;
        if (!sameDay) {
            dataMap.putInt("steps", 0);
            dataMap.putLong("steps_timestamp", t);
            Log.d("BgSendQueue", "getSensorSteps isSameDay false t=" + JoH.dateTimeText(t));
        } else {
            dataMap.putInt("steps", pm.metric);
            dataMap.putLong("steps_timestamp", pm.timestamp);
            Log.d("BgSendQueue", "getSensorSteps isSameDay true pm.timestamp=" + JoH.dateTimeText(pm.timestamp) + " metric=" + pm.metric);
        }
    }
    if (use_wear_health && show_heart_rate) {
        final HeartRate lastHeartRateReading = HeartRate.last();
        if (lastHeartRateReading != null) {
            dataMap.putInt("heart_rate", lastHeartRateReading.bpm);
            dataMap.putLong("heart_rate_timestamp", lastHeartRateReading.timestamp);
        }
    }
    return dataMap;
}
Also used : HeartRate(com.eveningoutpost.dexdrip.Models.HeartRate) PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement) DataMap(com.google.android.gms.wearable.DataMap)

Example 7 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip-plus by jamorham.

the class ListenerService method resetCounters.

private void resetCounters() {
    // initCounters();
    mSteps = (int) PersistentStore.getLong(pref_msteps);
    last_movement_timestamp = (int) PersistentStore.getLong(pref_last_movement_timestamp);
    Log.d(TAG, "resetCounters Sensor Enter PersistentStore mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
    PebbleMovement last = PebbleMovement.last();
    boolean sameDay = last != null ? ListenerService.isSameDay(System.currentTimeMillis(), last.timestamp) : false;
    if (!sameDay) {
        initCounters();
        Log.d(TAG, "resetCounters Sensor isSameDay=false initCounters mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
    } else {
        mCounterSteps = 0;
        mPreviousCounterSteps = mSteps;
        Log.d(TAG, "resetCounters Sensor isSameDay=true PersistentStore mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
    }
}
Also used : PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement)

Example 8 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip-plus by jamorham.

the class ListenerService method initCounters.

private synchronized void initCounters() {
    long t = System.currentTimeMillis();
    final PebbleMovement pm = PebbleMovement.createEfficientRecord(t, 0);
    Log.d(TAG, "initCounters Saving First Movement: " + pm.toS() + " at midnight t=" + JoH.dateTimeText(t));
    mSteps = 0;
    mCounterSteps = 0;
    mPreviousCounterSteps = 0;
}
Also used : PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement)

Example 9 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip-plus by jamorham.

the class ListenerService method restartMeasurement.

private void restartMeasurement() {
    PebbleMovement last = PebbleMovement.last();
    boolean sameDay = last != null ? ListenerService.isSameDay(System.currentTimeMillis(), last.timestamp) : false;
    if (!sameDay) {
        initCounters();
        Log.d(TAG, "restartMeasurement Sensor isSameDay=false initCounters mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
        stopMeasurement();
        startMeasurement();
    } else {
        Log.d(TAG, "restartMeasurement Sensor isSameDay=true PersistentStore mSteps = " + mSteps + " mCounterSteps = " + mCounterSteps + " mPreviousCounterSteps = " + mPreviousCounterSteps + " last_movement_timestamp = " + JoH.dateTimeText(last_movement_timestamp));
    }
}
Also used : PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement)

Example 10 with PebbleMovement

use of com.eveningoutpost.dexdrip.Models.PebbleMovement in project xDrip-plus by jamorham.

the class BgSendQueue method getSensorSteps.

public static DataMap getSensorSteps(SharedPreferences prefs) {
    Log.d("BgSendQueue", "getSensorSteps");
    DataMap dataMap = new DataMap();
    final long t = System.currentTimeMillis();
    final PebbleMovement pm = PebbleMovement.last();
    final boolean show_steps = prefs.getBoolean("showSteps", true);
    final boolean show_heart_rate = prefs.getBoolean("showHeartRate", true);
    final boolean use_wear_health = prefs.getBoolean("use_wear_health", true);
    if (use_wear_health || show_steps) {
        boolean sameDay = pm != null ? ListenerService.isSameDay(t, pm.timestamp) : false;
        if (!sameDay) {
            dataMap.putInt("steps", 0);
            dataMap.putLong("steps_timestamp", t);
            Log.d("BgSendQueue", "getSensorSteps isSameDay false t=" + JoH.dateTimeText(t));
        } else {
            dataMap.putInt("steps", pm.metric);
            dataMap.putLong("steps_timestamp", pm.timestamp);
            Log.d("BgSendQueue", "getSensorSteps isSameDay true pm.timestamp=" + JoH.dateTimeText(pm.timestamp) + " metric=" + pm.metric);
        }
    }
    if (use_wear_health && show_heart_rate) {
        final HeartRate lastHeartRateReading = HeartRate.last();
        if (lastHeartRateReading != null) {
            dataMap.putInt("heart_rate", lastHeartRateReading.bpm);
            dataMap.putLong("heart_rate_timestamp", lastHeartRateReading.timestamp);
        }
    }
    return dataMap;
}
Also used : HeartRate(com.eveningoutpost.dexdrip.Models.HeartRate) PebbleMovement(com.eveningoutpost.dexdrip.Models.PebbleMovement) DataMap(com.google.android.gms.wearable.DataMap)

Aggregations

PebbleMovement (com.eveningoutpost.dexdrip.Models.PebbleMovement)10 DataMap (com.google.android.gms.wearable.DataMap)4 HeartRate (com.eveningoutpost.dexdrip.Models.HeartRate)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2