All,
Looking for some help on some code which seems to be behaving weirdly… @ScruffR, @peekay123.
I have a couple of loops running through the ButtonClick library (to drive some LCD and button controlled motors).
Would there be any reason, in the code below, that after the while loop (while timeElapsed < interval) would kick out and run again (LCD display seems to run a couple of times, despite the while loop completing).
Any ideas on how to test, or perhaps to make the code more efficient would be most appreciated… I realise I’m using the d-word / delays but this was put together quickly.
Thanks all. Comments / suggestions welcome.
if(function == 2) { //double click
}
if(function == 3) { //triple click
}
if(function == -1) { //single long click on button 2
while(timeElapsed < interval){ //timeout function (interval is above) after no button pressed it exits
if (digitalRead(D3) == LOW){
ml_dose = dose_amt[dose_amt_select];
dose_amt_select++;
display.clearDisplay();
display.setTextSize(3); // from 1-9 sensible actually can be bigger but useless
display.setTextColor(WHITE, BLACK); // 'inverted' text
if (ml_dose>99) {
display.setCursor(17,10);
display.println(ml_dose);
}
else if (ml_dose<100) {
display.setCursor(35,10);
display.println(ml_dose);
}
display.setCursor(71,10); // 128,64 pixels
display.println("ml");
display.setTextSize(2);
display.setCursor(30,35); // 128,64 pixels
display.println("Choose");
display.setCursor(11,50); // 128,64 pixels
display.println("Dose Size");
display.setTextSize(3);
display.display();
timeElapsed = 0;
if (dose_amt_select == 11){ dose_amt_select = 0; }
}
}