Java Code Examples for com.eveningoutpost.dexdrip.Models.BgReading#currentSlope()
The following examples show how to use
com.eveningoutpost.dexdrip.Models.BgReading#currentSlope() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Unitized.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static String unitizedDeltaString(boolean showUnit, boolean highGranularity, boolean is_follower, boolean doMgdl) { List<BgReading> last2 = BgReading.latest(2,is_follower); if (last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > 20 * 60 * 1000) { // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope(is_follower) * 5 * 60 * 1000; return unitizedDeltaStringRaw(showUnit, highGranularity, value, doMgdl); }
Example 2
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static String unitizedDeltaString(boolean showUnit, boolean highGranularity, boolean is_follower, boolean doMgdl) { List<BgReading> last2 = BgReading.latest(2,is_follower); if (last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > 20 * 60 * 1000) { // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope(is_follower) * 5 * 60 * 1000; return unitizedDeltaStringRaw(showUnit, highGranularity, value, doMgdl); }
Example 3
Source File: Unitized.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static String unitizedDeltaString(boolean showUnit, boolean highGranularity, boolean is_follower, boolean doMgdl) { List<BgReading> last2 = BgReading.latest(2,is_follower); if (last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > 20 * 60 * 1000) { // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope(is_follower) * 5 * 60 * 1000; return unitizedDeltaStringRaw(showUnit, highGranularity, value, doMgdl); }
Example 4
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static String unitizedDeltaString(boolean showUnit, boolean highGranularity, boolean is_follower, boolean doMgdl) { List<BgReading> last2 = BgReading.latest(2,is_follower); if (last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > 20 * 60 * 1000) { // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope(is_follower) * 5 * 60 * 1000; return unitizedDeltaStringRaw(showUnit, highGranularity, value, doMgdl); }
Example 5
Source File: Unitized.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static String unitizedDeltaString(boolean showUnit, boolean highGranularity, boolean is_follower, boolean doMgdl) { List<BgReading> last2 = BgReading.latest(2,is_follower); if (last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > 20 * 60 * 1000) { // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope(is_follower) * 5 * 60 * 1000; return unitizedDeltaStringRaw(showUnit, highGranularity, value, doMgdl); }
Example 6
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static String unitizedDeltaString(boolean showUnit, boolean highGranularity, boolean is_follower, boolean doMgdl) { List<BgReading> last2 = BgReading.latest(2,is_follower); if (last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > 20 * 60 * 1000) { // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope(is_follower) * 5 * 60 * 1000; return unitizedDeltaStringRaw(showUnit, highGranularity, value, doMgdl); }
Example 7
Source File: Unitized.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static String unitizedDeltaString(boolean showUnit, boolean highGranularity, boolean is_follower, boolean doMgdl) { List<BgReading> last2 = BgReading.latest(2,is_follower); if (last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > 20 * 60 * 1000) { // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope(is_follower) * 5 * 60 * 1000; return unitizedDeltaStringRaw(showUnit, highGranularity, value, doMgdl); }
Example 8
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static String unitizedDeltaString(boolean showUnit, boolean highGranularity, boolean is_follower, boolean doMgdl) { List<BgReading> last2 = BgReading.latest(2,is_follower); if (last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > 20 * 60 * 1000) { // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope(is_follower) * 5 * 60 * 1000; return unitizedDeltaStringRaw(showUnit, highGranularity, value, doMgdl); }
Example 9
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 4 votes |
public String oldunitizedDeltaString(boolean showUnit, boolean highGranularity) { List<BgReading> last2 = BgReading.latest(2); if(last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > MAX_SLOPE_MINUTES * 60 * 1000){ // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope() * 5*60*1000; if(Math.abs(value) > 100){ // a delta > 100 will not happen with real BG values -> problematic sensor data return "ERR"; } // TODO: allow localization from os settings once pebble doesn't require english locale DecimalFormat df = new DecimalFormat("#", new DecimalFormatSymbols(Locale.ENGLISH)); String delta_sign = ""; if (value > 0) { delta_sign = "+"; } if(doMgdl) { if(highGranularity){ df.setMaximumFractionDigits(1); } else { df.setMaximumFractionDigits(0); } return delta_sign + df.format(unitized(value)) + (showUnit?" mg/dl":""); } else { if(highGranularity){ df.setMaximumFractionDigits(2); } else { df.setMaximumFractionDigits(1); } df.setMinimumFractionDigits(1); df.setMinimumIntegerDigits(1); return delta_sign + df.format(unitized(value)) + (showUnit?" mmol/l":""); } }
Example 10
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public String oldunitizedDeltaString(boolean showUnit, boolean highGranularity) { List<BgReading> last2 = BgReading.latest(2); if(last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > MAX_SLOPE_MINUTES * 60 * 1000){ // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope() * 5*60*1000; if(Math.abs(value) > 100){ // a delta > 100 will not happen with real BG values -> problematic sensor data return "ERR"; } // TODO: allow localization from os settings once pebble doesn't require english locale DecimalFormat df = new DecimalFormat("#", new DecimalFormatSymbols(Locale.ENGLISH)); String delta_sign = ""; if (value > 0) { delta_sign = "+"; } if(doMgdl) { if(highGranularity){ df.setMaximumFractionDigits(1); } else { df.setMaximumFractionDigits(0); } return delta_sign + df.format(unitized(value)) + (showUnit?" mg/dl":""); } else { if(highGranularity){ df.setMaximumFractionDigits(2); } else { df.setMaximumFractionDigits(1); } df.setMinimumFractionDigits(1); df.setMinimumIntegerDigits(1); return delta_sign + df.format(unitized(value)) + (showUnit?" mmol/l":""); } }
Example 11
Source File: BgGraphBuilder.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
public String unitizedDeltaString(boolean showUnit, boolean highGranularity) { List<BgReading> last2 = BgReading.latest(2); if(last2.size() < 2 || last2.get(0).timestamp - last2.get(1).timestamp > MAX_SLOPE_MINUTES * 60 * 1000){ // don't show delta if there are not enough values or the values are more than 20 mintes apart return "???"; } double value = BgReading.currentSlope() * 5*60*1000; if(Math.abs(value) > 100){ // a delta > 100 will not happen with real BG values -> problematic sensor data return "ERR"; } // TODO: allow localization from os settings once pebble doesn't require english locale DecimalFormat df = new DecimalFormat("#", new DecimalFormatSymbols(Locale.ENGLISH)); String delta_sign = ""; if (value > 0) { delta_sign = "+"; } if(doMgdl) { if(highGranularity){ df.setMaximumFractionDigits(1); } else { df.setMaximumFractionDigits(0); } return delta_sign + df.format(unitized(value)) + (showUnit?" mg/dl":""); } else { if(highGranularity){ df.setMaximumFractionDigits(2); } else { df.setMaximumFractionDigits(1); } df.setMinimumFractionDigits(1); df.setMinimumIntegerDigits(1); return delta_sign + df.format(unitized(value)) + (showUnit?" mmol/l":""); } }
Example 12
Source File: BgSendQueue.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
public static void handleNewBgReading(BgReading bgReading, String operation_type, Context context) { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "sendQueue"); wakeLock.acquire(); try { addToQueue(bgReading, operation_type); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Intent updateIntent = new Intent(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA); context.sendBroadcast(updateIntent); if(AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, xDripWidget.class)).length > 0){ context.startService(new Intent(context, WidgetUpdateService.class)); } if (prefs.getBoolean("broadcast_data_through_intents", false)) { //prepare data double calculated_value = bgReading.calculated_value; boolean hide_slope = bgReading.hide_slope; String slopeName = hide_slope?null:bgReading.slopeName(); int batteryLevel = getBatteryLevel(context); final long timestamp = bgReading.timestamp; Calibration cal = Calibration.last(); double raw = NightscoutUploader.getNightscoutRaw(bgReading, cal); double slope = BgReading.currentSlope(); //send broadcast BgEstimateBroadcaster.broadcastBgEstimate(calculated_value, raw, timestamp, slope, slopeName, batteryLevel, context); //just keep it alive for 3 more seconds to allow the watch to be updated // TODO: change NightWatch to not allow the system to sleep. powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "broadcastNightWatch").acquire(3000); } // send to wear if (prefs.getBoolean("wear_sync", false)) { /*By integrating the watch part of Nightwatch we inherited the same wakelock problems NW had - so adding the same quick fix for now. TODO: properly "wakelock" the wear (and probably pebble) services */ context.startService(new Intent(context, WatchUpdaterService.class)); powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "quickFix3").acquire(15000); } // send to pebble if(prefs.getBoolean("broadcast_to_pebble", false)) { context.startService(new Intent(context, PebbleSync.class)); } if (prefs.getBoolean("share_upload", false)) { Log.d("ShareRest", "About to call ShareRest!!"); String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase(); BgUploader bgUploader = new BgUploader(context); bgUploader.upload(new ShareUploadPayload(receiverSn, bgReading)); } context.startService(new Intent(context, SyncService.class)); //Text to speech Log.d("BgToSpeech", "gonna call speak"); BgToSpeech.speak(bgReading.calculated_value, bgReading.timestamp); } finally { wakeLock.release(); } }