LCD_string("Status= ");LCD_string(rlyonoff[rly_data]); while(alarm_sw==1) //WHILE 2 //LOOP UNTILL ALARM_SW IS PRESSED BY USER { if(down_sw==0) {while(down_sw==0); if(rly_data==0){rly_data=1;}else{rly_data=0;} LCD_gotoxy(9,2); LCD_string(rlyonoff[rly_data]); } if(up_sw==0) {while(up_sw==0); if((++rly_no)>8){rly_no=1;} LCD_gotoxy(11,1); LCD_send_packedbcd(rly_no); } }//WHILE 2 //TO STORE DATA TO EEPROM while(alarm_sw==0); ee_location = alarm_check[alarmc]; // Get the location of eeprom to store Eeprom_write(ee_location,hex2bcd(aset[2]));//First store hour Eeprom_write(++ee_location,hex2bcd(aset[1])); Eeprom_write(++ee_location,hex2bcd(aset[0])); Eeprom_write(++ee_location,rly_no);//At last sore relay data //STORING FINISHED Eeprom_write(++ee_location,rly_data);//At last sore relay data //STORING FINISHE D LCD_command(LCD_clear);LCD_string("Saved to eeprom");//Indicate it to user Eeprom_write(0,alarmc); ii=0; //Must ee_location=0; aset[0]=0;aset[1]=0;aset[2]=0;rly_data=1;rly_no=1;//Reset all register if(alarmc>=30){LCD_command(LCD_clear);LCD_string("Alarms Excedded");DelayS(2);go to finish;}//TO CHECK MAXIMUM ALARMS SET goto beginn; }//SWITCH }//IF LOOP OF ALARM SW BUTTON if(time_sw==0) { while(time_sw==0);//wait to release the switch finish: LCD_command(LCD_clear);LCD_string("Number of alarms");LCD_gotoxy(1,2); LCD_string("is");LCD_gotoxy(5,2); LCD_send_packedbcd(hex2bcd(eeprom_read(0))); DelayS(1); LCD_command(LCD_clear); return; } if(up_sw==0) //MAIN UP_SW MONITORING { if((aset[ii]++)>=tcompare[ii]){aset[ii]=0;} LCD_timeset(hex2bcd(aset[ii]),LCD_position[ii]);//This is for up switch } if(down_sw==0) //MAIN DOWN_SW MONITORING { if((aset[ii]--)<=0){aset[ii]=tcompare[ii];}
LCD_timeset(hex2bcd(aset[ii]),LCD_position[ii]); //This is for down switch
} DelayMs(150); }// WHILE 1 LOOP while(1);//////////////////////// } //---------------------------------------------//PROCEDURE TO SET TIME //---------------------------------------------void set_time() { char week; while(time_sw==0); //FOR user errors LCD_command(LCD_clear); //Clear the lcd LCD_string(" : :SS"); LCD_gotoxy(14,1);LCD_string("Set");LCD_gotoxy(13,2);LCD_string("Time"); LCD_gotoxy(3,2);LCD_data(':'); LCD_gotoxy(6,2);LCD_data(':'); LCD_timeset(0x00,1); LCD_timeset(0x00,4); LCD_timeset(0x00,7); i=0; //Set i to seconds first tord=0;week=0; while(1) { //-------------if(alarm_sw==0) { while(alarm_sw==0); LCD_command(LCD_clear); LCD_string("Time Date Not"); LCD_gotoxy(1,2); LCD_string("Set Correctly"); DelayS(1); LCD_command(LCD_clear); return;} //Return with out setting alarm //-----------if(time_sw==0) { DelayMs(50); while(time_sw==0); // waits for button to be released ++i; //Because i will already pointing to seconds register so now p oints to minutes register switch(i) { case 1 : {LCD_gotoxy(1,1);LCD_string(setstring[0]);break;} ing i.e for above line case 2 : {LCD_gotoxy(1,1);LCD_string(setstring[1]);break;} g case 4 : {LCD_gotoxy(1,1);LCD_string(setstring[2]);break;} g case 5 : {LCD_gotoxy(1,1);LCD_string(setstring[3]);break;} ing
LCD_command(LCD_clear); //Clear the LCD rtc_settime(hex2bcd(tset[2]),hex2bcd(tset[1]),hex2bcd(tset[0])); LCD_string("Time is Set"); DelayBigMs(1000); LCD_command(LCD_clear); //Clear the LCD LCD_gotoxy(14,1);LCD_string("Set");LCD_gotoxy(13,2);LCD_string("Date"); LCD_gotoxy(1,1);LCD_string(" / /YY"); LCD_gotoxy(3,2);LCD_data('/'); LCD_gotoxy(6,2);LCD_string("/20"); LCD_timeset(0x01,1); LCD_timeset(0x01,4); LCD_timeset(0x01,9); tset[3]=1;tset[4]=1;tset[5]=1; //Because month date and year should first be 1; 0 means invalid tord=1;break; //This is for date case 6 : //Set Date and return LCD_command(LCD_clear); //Clear the LCD LCD_string("Set week="); LCD_gotoxy(14,1); LCD_string(week_strings[tset[i]]); tord=0; //Because week is 0 to 6 week=1;break; case 7 : //For week LCD_command(LCD_clear); //Clear the LCD rtc_setdate(hex2bcd(tset[3]),hex2bcd(tset[4]),hex2bcd(tset[5]),tset[6]); //10 :12:02(yy:mm:dd),week LCD_string("Date is Set"); DelayBigMs(1000); LCD_command(LCD_clear); return; default: break;//If nothing then break }//SWITCH LOOP } //-----------if(up_sw==0) { if((tset[i]++)>=tcompare[i]){tset[i]=tord;} //tord can be 0 or 1 0 for time 1 fo r date cause date cant start from 0 if(week==1){LCD_gotoxy(14,1);LCD_string(week_strings[tset[i]]);}//Point to parti cular week string else{LCD_timeset(hex2bcd(tset[i]),LCD_position[i]);} } //First increment seconds and so on //-----------if(down_sw==0) { if((tset[i]--)<=tord){tset[i]=tcompare[i];} if(week==1){LCD_gotoxy(14,1);LCD_string(week_strings[tset[i]]);} else{LCD_timeset(hex2bcd(tset[i]),LCD_position[i]);} } //-------------DelayMs(150); //For user delay //For while loop } }//while //------------------------------------------------