You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you first activate the auto-insertion, you must save your insulin:carbs ratio. Example: What is your carb intake for 1u? 9g
When you add an insulin amount, you can select (checkbox) if you want to disable or enable the auto-insertion. If you have it enabled, it will save the carb amount (insulin x ratio), so the amounts for 2u will be 2u and 18g of carbs.
With the new smart pens, it makes it much easier to control in libreview, for example.
edit with my beta code:
SharedPreferences sharedPref = context.getSharedPreferences("MyPreferences", MODE_PRIVATE); //if there was a saved insulin:carb ratio, load it
float savedRatio = sharedPref.getFloat("insulin_carb_ratio", 0.0f);
ratioInput = new EditText(context);
ratioInput.setText(String.valueOf(savedRatio)); //if there was a saved ratio, it will be shown in the EditText widget
autobutton = new CheckBox(context);
autobutton.setChecked(true);
(...)
new View[]{datebutton, mealbutton,source,timebutton,ratioInput,autobutton}
(...)
savebutton.setOnClickListener(v -> {
MainActivity act=(MainActivity)v.getContext();
GlucoseCurve.reopener();
if(saveamount(act,timeview, valueedit,newmealptr[0],lasttime)) {
if(autobutton.isChecked() && labelsel==0 && !valueedit.getText().toString().equals("")) {
//if the auto-calculator is checked, the inserted value is insulin (labelsel {0-insulin, 1-carbs}) and the insulin value is not null, then proceed with the calculation
EditText nvalueedit = geteditview(context,new editfocus());
String ratioString = ratioInput.getText().toString();
float ratio = ratioString.isEmpty() ? 0.0f : Float.parseFloat(ratioString);
String text_calc = new String();
switch(labelsel) { //check if the inserted amount is insulin or carbs
case 0:
labelsel++; //if insulin switch to carbs and multiply by the ratio
text_calc = String.valueOf(Integer.parseInt(valueedit.getText().toString())*ratio);
case 1:
labelsel--; //if carbs switch to insulin and divide by the ratio
float pre_calc = Math.round(Integer.parseInt(valueedit.getText().toString())/ratio* 2) / 2.0f; //round to the nearest half unit
text_calc = String.format("%.1f", pre_calc); //set only one decimal place
}
nvalueedit.setText(text_calc);
saveamount(act, timeview, nvalueedit, newmealptr[0], lasttime);
SharedPreferences.Editor editor = sharedPref.edit(); //save the ratio (it can also be done autonomously only when there is a detected change)
editor.putFloat("insulin_carb_ratio", ratio);
editor.apply();
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Concept:
When you first activate the auto-insertion, you must save your insulin:carbs ratio. Example: What is your carb intake for 1u? 9g
When you add an insulin amount, you can select (checkbox) if you want to disable or enable the auto-insertion. If you have it enabled, it will save the carb amount (insulin x ratio), so the amounts for 2u will be 2u and 18g of carbs.
With the new smart pens, it makes it much easier to control in libreview, for example.
edit with my beta code:
Beta Was this translation helpful? Give feedback.
All reactions