change step calculation and fix time setting (got the actual vs requested time wrong)
This commit is contained in:
parent
29b5ad9696
commit
e20084c97f
1 changed files with 10 additions and 6 deletions
|
@ -168,8 +168,10 @@ public class SetTbrCommand implements Command {
|
||||||
{
|
{
|
||||||
if(retries>0) {
|
if(retries>0) {
|
||||||
retries--;
|
retries--;
|
||||||
int steps = (int) ((percentage - currentPercentage) / 10.0);
|
int requestedPercentage = (int) percentage;
|
||||||
Log.v("SetTbrCommand:tick",state+": adjusting basal with "+steps+" steps and "+retries+" retries left");
|
int actualPercentage = (int) currentPercentage;
|
||||||
|
int steps = (requestedPercentage - actualPercentage) / 10;
|
||||||
|
Log.v("SetTbrCommand:tick",state+": adjusting basal("+requestedPercentage+"/"+actualPercentage+") with "+steps+" steps and "+retries+" retries left");
|
||||||
scripter.step(steps,(steps<0? RuffyScripter.Key.DOWN: RuffyScripter.Key.UP), 500);
|
scripter.step(steps,(steps<0? RuffyScripter.Key.DOWN: RuffyScripter.Key.UP), 500);
|
||||||
scripter.waitScreen(1000);
|
scripter.waitScreen(1000);
|
||||||
}
|
}
|
||||||
|
@ -232,12 +234,14 @@ public class SetTbrCommand implements Command {
|
||||||
{
|
{
|
||||||
if(retries>0) {
|
if(retries>0) {
|
||||||
retries--;
|
retries--;
|
||||||
int steps = (int)((currentDuration - duration)/15.0);
|
int requestedDuration = (int) duration;
|
||||||
if(currentDuration+(steps*15)<duration)
|
int actualDuration = (int) currentDuration;
|
||||||
|
int steps = (requestedDuration - actualDuration)/15;
|
||||||
|
if(currentDuration+(steps*15)<requestedDuration)
|
||||||
steps++;
|
steps++;
|
||||||
else if(currentDuration+(steps*15)>duration)
|
else if(currentDuration+(steps*15)>requestedDuration)
|
||||||
steps--;
|
steps--;
|
||||||
Log.v("SetTbrCommand:tick",state+": adjusting duration with "+steps+" steps and "+retries+" retries left");
|
Log.v("SetTbrCommand:tick",state+": adjusting duration("+requestedDuration+"/"+actualDuration+") with "+steps+" steps and "+retries+" retries left");
|
||||||
scripter.step(steps,(steps>0? RuffyScripter.Key.UP: RuffyScripter.Key.DOWN), 500);
|
scripter.step(steps,(steps>0? RuffyScripter.Key.UP: RuffyScripter.Key.DOWN), 500);
|
||||||
scripter.waitScreen(1000);
|
scripter.waitScreen(1000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue