thannara123
Advanced Member level 5
Button Key Navigation Menu data value Accessing Logic ?
In a part of my project [avr gcc ,atmega16-controller]
I am struggling get the updated values from the navigation key while updated values on the LCD.
The UP and Down Key increments or decrements the values of corresponding variable . [ variables is Hour,Minute,second]
The right and Left key changes the position of the LCD as well as the variables ie hour to Minute or Second.
And the Okay button exit the while loop and save the variables to a structure
How to do this an efficient way ?
Made the following code but not works correctly any good logic or correction .
In a part of my project [avr gcc ,atmega16-controller]
I am struggling get the updated values from the navigation key while updated values on the LCD.
The UP and Down Key increments or decrements the values of corresponding variable . [ variables is Hour,Minute,second]
The right and Left key changes the position of the LCD as well as the variables ie hour to Minute or Second.
And the Okay button exit the while loop and save the variables to a structure
How to do this an efficient way ?
Made the following code but not works correctly any good logic or correction .
Code:
void UP_Down_Keyvalue(struct menu *s1ptr,int i,int b)
{ int temp=0,ch,position=0,lower=0,upper=12;
int array_temp[11];
LCD_GoToXY(1,i);
LCD_Printf("%d:%d:%d:%s",s1ptr->Hour,s1ptr->Minute,s1ptr->Second,"AM");
while(OK_S!=64)
{
LCD_GoToXY(1,i);
LCD_DisplayNumber(10,temp,2);
if(UP_S)
{ while(UP_S);
if(temp==upper)
temp=-1;
temp++;
}
if(DOWN_S) // down
{ while(DOWN_S);
if(temp==0)
temp=13;
--temp;
}
exit2:
if(RIGHT_S||LEFT_S)
{
array_temp[i];
if(RIGHT_S)
{ while(RIGHT_S);
if(i==11)goto exit1; // check is it last point 10 ie 11
i +=3;
temp=0;
}
exit1:
if (LEFT_S)
{ while(LEFT_S);
if(i==2) goto exit2;
i -=3;
temp=0;
}
// LCD_Printf("%d",i);
//DELAY_ms(10000);
}
s1ptr->Hour= array_temp[1];
s1ptr->Minute=array_temp[3];
s1ptr->Second=array_temp[5];
}
}
Last edited: