ajit_nayak87
Member level 5
I have the code here. I have 8 relay 8 combination where i could adjust 8 combination of Ontime and off time of device. I have key Select and advance function. Select key to decrement the Ontime of hour and advance key to increment the value.
How can i minimize the function . so i could able to write in 8 Relay 8 combination . these value are going to save in external eeprom 24LC08.
below code written for Relay1 with combination 1
How can i minimize the function . so i could able to write in 8 Relay 8 combination . these value are going to save in external eeprom 24LC08.
below code written for Relay1 with combination 1
Code:
const unsigned char DISPTABLE[30] = {0x03,0x9F,0x25,0x0D,0x99,0x49,0x41,0x1F,0x01,0x09,0x09,0x09,0x03,
//0 //1 //2 //3 //4 //5 //6 //7 //8 //9 //10 //11 //12
0x03,0x03,0X31,0xFF,0X31,0X85,0X11,0X55,0X89,0XF5,0XA9,0X91,0X61,0X41 };
//13 //14 //15 //16 //P //D //A //M //Y //r //W //H //C //G
unsigned char Hour_bit=0;
signed char Hour_ON1;
signed char Min_ON1;
signed char Hour_OFF1;
signed char MIN_OFF1;
signed char YEAR_SET=20;
unsigned char MONTH_SET=1;
unsigned char Day_SET=1;
unsigned char HOUR_SET=0;
unsigned char MIN_SET=0;
unsigned char SEC_SET=0;
unsigned char WK_DAY_SET=0;
unsigned char RLY_PATTERN=0;
unsigned char BLINKFLAG=0;
void Process_advance_SW() {
unsigned char Temp = 0;
if (pgm_run == 1) {
if (SELECTPRESS == 0) {
if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 1) && (Hour_bit == 1)) {
Hour_ON1++;
if (Hour_ON1 > 24) {
Hour_ON1 = 0;
}
LEDBuffer_1[1] = DISPTABLE[Hour_ON1 / 10];
LEDBuffer_1[0] = DISPTABLE[Hour_ON1 % 10];
} else if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 1) && (Hour_bit == 0)) {
Min_ON1++;
if (Min_ON1 > 59) {
Min_ON1 = 0;
}
LEDBuffer_1[1] = DISPTABLE[Min_ON1 / 10];
LEDBuffer_1[0] = DISPTABLE[Min_ON1 % 10];
} else if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 0) && (Hour_bit == 1)) {
Hour_OFF1++;
if (Hour_OFF1 > 24) {
Hour_OFF1 = 0;
}
LEDBuffer_1[1] = DISPTABLE[Hour_OFF1 / 10];
LEDBuffer_1[0] = DISPTABLE[Hour_OFF1 % 10];
}
if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 0) && (Hour_bit == 0)) {
MIN_OFF1++;
if (MIN_OFF1 > 59) {
MIN_OFF1 = 0;
}
LEDBuffer_1[1] = DISPTABLE[MIN_OFF1 / 10];
LEDBuffer_1[0] = DISPTABLE[MIN_OFF1 % 10];
}
DATE_TIME_SET_ADD();
}
}
}
void Process_select_SW() {
if (pgm_run == 1) {
if (SELECTPRESS == 0) {
if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 1) && (Hour_bit == 1)) {
Hour_ON1--;
if (Hour_ON1 < 1) {
Hour_ON1 = 24;
}
LEDBuffer_1[1] = DISPTABLE[Hour_ON1 / 10];
LEDBuffer_1[0] = DISPTABLE[Hour_ON1 % 10];
} else if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 1) && (Hour_bit == 0)) {
Min_ON1--;
if (Min_ON1 < 1) {
Min_ON1 = 59;
}
LEDBuffer_1[1] = DISPTABLE[Min_ON1 / 10];
LEDBuffer_1[0] = DISPTABLE[Min_ON1 % 10];
} else if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 0) && (Hour_bit == 1)) {
Hour_OFF1--;
if (Hour_OFF1 < 1) {
Hour_OFF1 = 24;
}
LEDBuffer_1[1] = DISPTABLE[Hour_OFF1 / 10];
LEDBuffer_1[0] = DISPTABLE[Hour_OFF1 % 10];
}
if ((Rly_No == 1) && (Comb_No == 1) && (on_offl == 0) && (Hour_bit == 0)) {
MIN_OFF1--;
if (MIN_OFF1 < 1) {
MIN_OFF1 = 59;
}
LEDBuffer_1[1] = DISPTABLE[MIN_OFF1 / 10];
LEDBuffer_1[0] = DISPTABLE[MIN_OFF1 % 10];
}
DATE_TIME_SET_SUB();
}
}
}