idata volatile char user_password[max_userkey_length]="1234";
void main(void)
{
char entered_key[4];
buzzer_pin=0;
#ifdef debug
Initialize_LCD();
// printf("Keypad debug\n");
debug_use(1,"Keypad debug");
#endif
indicate_power_up();
ini_all();
get_current_settings(); //via EEPROM
buzz_special(1);
TR0=0; // start counting
TR1=0;
pwm_value=25;
while(1)
{
indicate_power_up();
get_key(entered_key,max_userkey_length);
#ifdef debug
cls();
//printf("\n String entered %s",entered_key);
lcd_text(1,2,"String entered:");
lcd_text(2,6,entered_key);
delay_ms(500);
cls();
#endif
if(string_length(entered_key)==max_userkey_length)
{
delay_sec(1);
if(trial<legal_trial)
{
if(check_string(entered_key,user_password)) // here the checking takes place
{
#ifdef debug
debug_use(1,"Corct pass entry");
#endif
pwrLED(on);
modeLED(off);
okLED(on);
delay_ms(200);
okLED(off);
trial=0;
if(!freeze_mode)
password_correct_flag=1;
}
else
{
password_correct_flag=0;
pwrLED(off);
buzz_special(3);
pwrLED(on);
trial++;
#ifdef debug
debug_use(1,"Wrng pass entry");
debug_use(1,"User key:");
debug_use(2,user_password);
#endif
}
}
/* this function does the checking */
char check_string(unsigned char *to,unsigned char *with)
{
char i,j,temp=0;
temp=0;
#ifdef debug
cls();
debug_use(1,"to");
Position_LCD(1,6);
Write_LCD_Text(to);
delay_sec(1);
debug_use(2,"with");
Position_LCD(2,6);
Write_LCD_Text(with);
delay_sec(1);
cls();
#endif
i=string_length(to);
j=string_length(with);
if(i!=j)
temp=0;
else if(i==j)
{
for(i=0;i<j;i++)
{
if(to==with)
temp++;
else
temp=0;
}
if(temp!=j)
temp=0;
else if(temp==j)
temp=1;
else
temp=2;
}
return temp;
}