I have code as below. I want to blink particular cursor position while editing mode. The problem i m facing here the cursor get blink when value being changed.Instead of keep flickering. Here I am checking which key being pressed and taking action depend on it .I tried another way where i am not specifying condition if none key pressed keep flicker postion while edit mode. But problem i found it not exit lcd_display loop
In my code. all things are working fine . like i can change menu. i can edit parameter . But only problem i am facing here while editing value flickering of value not happening.in above code the date value get flicker only when it being changed . suppose i change value from 01 to 02 while changing 02 it flicker then it stops.but i wanted to flicker postion all time in edit mode.
Code i pasted is part of code.
int Blink_pos[6][2]={
{
5,0 }
,
{
8,0 }
,
{
11,0 }
,
{
5,1 }
,
{
8,1 }
,
{
11,1 }
};
void loop()
{
LCD_Display();
CHK_Key();
Serial.println("loop EXT:");
}
void CHK_Key()
{
int button;
button = read_LCD_buttons();
switch(button)
{
case btnRIGHT:
Action_RIGHT();
break;
case btnUP:
Action_UP();
break;
case btnDOWN:
Action_DOWN();
break;
case btnLEFT:
Action_LEFT();
break;
case btnSELECT:
Action_SELECT();
break;
case btnNONE:
break;
}
timedBeep(shortBeep,1);
}
void LCD_Display()
{
Display_counter1=Display_counter1+1;
if(Display_counter1>=5)
{
Display_counter1=0;
Update_Screen=1;
}
if(Update_Screen==1)
{
lcdClear();
switch(cur_disp_screen_type1)
{
case SET_PARAMETER:
Set_Parameter();
break;
case GET_PASSWORD:
GetEditPassword(Edit_password,4);
break;
case EDIT_MODE:
Edit_parameter();
break;
case EDIT_DATE_TIME:
ClockEditDisplay(edit_date_time,6);
break;
}
Update_Screen=0;
if( cur_disp_screen_type1>DISPLAY_COUNT_MAX)
{
cur_disp_screen_type1= DATE_TIME;
}
}
}
void Action_RIGHT()
{
switch(cur_disp_screen_type1)
{
case SET_PARAMETER:
cur_disp_screen_type1=GET_PASSWORD;
initialize_Password();
ase GET_PASSWORD:
pasword_status=setCustomPassword(Edit_password);
if(pasword_status==1)
{
lcd.setCursor(0,0);
lcd.print("PASWORD VALID ");
lcd.setCursor(0,1);
lcd.print(" ");
cur_disp_screen_type1=EDIT_MODE;
timedBeep(shortBeep,1);
initialize_Password();
}
else
{
lcd.setCursor(0,0);
lcd.print("PASWORD INVALID");
lcd.setCursor(0,1);
lcd.print(" ");
cur_disp_screen_type1=DATE_TIME;
timedBeep(shortBeep,1);
}
Update_Screen=1;
break;
case EDIT_MODE:
cur_disp_screen_type1=EDIT_DATE_TIME ;
Update_Screen=1;
break;
case EDIT_DATE_TIME:
setCustomDateTime(edit_date_time);
cur_disp_screen_type1 = EDIT_TRACK_TIME;
Update_Screen=1;
break;
}
}
void Action_LEFT()
{
switch(cur_disp_screen_type1)
{
case SET_PARAMETER:
cur_disp_screen_type1=DATE_TIME;
Update_Screen=1;
break;
case GET_PASSWORD:
cur_disp_screen_type1=DATE_TIME;
Password_Screen();
break;
case EDIT_MODE:
cur_disp_screen_type1=DATE_TIME;
Update_Screen=1;
break;
case EDIT_DATE_TIME:
cur_disp_screen_type1=DATE_TIME;
Update_Screen=1;
break;
}
}
void Action_UP()
{
switch(cur_disp_screen_type1)
{
case SET_PARAMETER:
Set_Parameter();
timedBeep(shortBeep,1);
Update_Screen=1;
break;
case GET_PASSWORD:
Edit_password[current_Password]++;
if(Edit_password[current_Password] > edit_password_table[current_Password][TABLE_MAX])
Edit_password[current_Password] = edit_password_table[current_Password][TABLE_MIN];
Update_Screen=1;
break;
case EDIT_MODE:
Edit_parameter();
timedBeep(shortBeep,1);
Update_Screen=1;
break;
case EDIT_DATE_TIME:
edit_date_time[cur_edit_item]++;
Blink_LCD(cur_edit_item);
if(edit_date_time[cur_edit_item] > edit_date_time_table[cur_edit_item][TABLE_MAX])
edit_date_time[cur_edit_item] = edit_date_time_table[cur_edit_item][TABLE_MIN];
Update_Screen=1;
break;
}
}
void Action_DOWN()
{
switch(cur_disp_screen_type1)
{
case SET_PARAMETER:
Set_Parameter();
timedBeep(shortBeep,1);
Update_Screen=1;
break;
case GET_PASSWORD:
Edit_password[current_Password]++;
if(Edit_password[current_Password] > edit_password_table[current_Password][TABLE_MAX])
Edit_password[current_Password] = edit_password_table[current_Password][TABLE_MIN];
Update_Screen=1;
break;
case EDIT_MODE:
Edit_parameter();
timedBeep(shortBeep,1);
Update_Screen=1;
break;
case EDIT_DATE_TIME:
edit_date_time[cur_edit_item]--;
Blink_LCD(cur_edit_item);
if(edit_date_time[cur_edit_item] < edit_date_time_table[cur_edit_item][TABLE_MAX])
edit_date_time[cur_edit_item] = edit_date_time_table[cur_edit_item][TABLE_MIN];
Update_Screen=1;
break;
}
}
void Action_SELECT()
{
switch(cur_disp_screen_type1)
{
case EDIT_DATE_TIME:
Update_Screen=1;
cur_edit_item = cur_edit_item+1;
if(cur_edit_item > EDIT_SEC)
cur_edit_item=EDIT_DAY;
break;
}
}
void Blink_LCD(int blink_item )
{
int term1;
int term2;
lcd.cursor();
delay(40);
switch(blink_item)
{
case EDIT_DAY:// lcd.print(local_day);
term1=(int)(local_day/10);
term2=(local_day%10);
lcd.print(term1);
lcd.print(term2);
goto LABEL;
break;
case EDIT_MONTH:
term1=(int)(local_month/10);
term2=(local_month%10);
lcd.print(term1);
lcd.print(term2);
goto LABEL;
break;
case EDIT_YEAR:
lcd.print(local_year);
goto LABEL;
break;
case EDIT_HOUR: //lcd.print(local_h);
term1=(int)(local_h/10);
term2=(local_h%10);
lcd.print(term1);
lcd.print(term2);
goto LABEL;
break;
case EDIT_MINUTE://lcd.print(local_m);
term1=(int)(local_m/10);
term2=(local_m%10);
lcd.print(term1);
lcd.print(term2);
goto LABEL;
break;
case EDIT_SEC://lcd.print(local_s);
term1=(int)(local_s/10);
term2=(local_s%10);
lcd.print(term1);
lcd.print(term2);
goto LABEL;
break;
}
LABEL:
lcd.setCursor(Blink_pos[blink_item][0],Blink_pos[blink_item][1]);
lcd.noCursor();
delay(40);
}