Hi all,
I have an interrupt which is supposed to cycle through different modes on my LCD screen. The problem I have is that while my interrupt is activated, I would like the LCD screen to display which options you are running through. My LCD screen requires the program to have a delay after the data has been written to the LCD because I also have a clearLCD function, so the user wouldn't be able to see what is written as it is cycling through the program too fast. So what I am asking is how can I replace the delay function so that the LCD will display the options because I know that you cant have delay functions in an interrupt?
Here is my function which is called when the interrupt is activated:
void tripuino::funkvor(volatile int *function){
int pot;
while(digitalRead(4) == LOW){ //While "Enter not being pressed.."
pot = analogRead(0);
if(pot <= 1023 && pot >= 774){ //value between 1023 - 774 display 0 etc..
*function = 1;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(18);
Serial.print("Speed (KM/H)");
//delay(100) replacement here
}
else{
if(pot < 774 && pot >= 525){
*function = 2;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(19);
Serial.print("Speed (MPH)");
//delay(100) replacement here
}
else{
if(pot < 525 && pot >= 190){
*function = 3;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(16);
Serial.print("Avg.Speed (KM/H)");
//delay(100) replacement here
}
else{
if(pot < 190 && pot >= 55){
*function = 4;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(16);
Serial.print("Avg. Speed (MPH)");
//delay(100) replacement here
}
else{
if(pot < 55 && pot >= 28){
*function = 5;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(17);
Serial.print("Distance (KM)");
//delay(100) replacement here
}
else{
if(pot < 28 && pot >= 9){
*function = 6;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(17);
Serial.print("Distance (MI)");
//delay(100) replacement here
}
else{
if(pot < 9 && pot >= 4){
*function = 7;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(18);
Serial.print("Travel Time");
//delay(100) replacement here
}
else{
if(pot == 3){
*function = 8;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(20);
Serial.print("Security");
//delay(100) replacement here
}
else{
if(pot == 2){
*function = 9;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(17);
Serial.print("Security BETA");
//delay(100) replacement here
}
else{
if(pot == 1){
*function = 1;
lcd.clearLCD();
lcd.goTo(0);
Serial.print("Choose Function:");
lcd.goTo(17);
Serial.print("END - Go Back");
//delay(100) replacement here
}
}
}
}
}
}
}
}
}
}
}
}
Thanks in advance