milan.rajik
Banned
- Joined
- Apr 1, 2013
- Messages
- 2,524
- Helped
- 540
- Reputation
- 1,078
- Reaction score
- 524
- Trophy points
- 1,393
- Activity points
- 0
The download link at that page is not working.
https://www.4shared.com/get/a-sBoMVF/prayer.html
If you have downloaded that file then post it here. The complete project files.
In the mikroBasic code which variables hold the prayer times ? I need it to know to send them to LCD.
Why there are two variables for each value ?
Only aser, maghreb and isha ? Where are others ? What does x and x1 contain ?
marbtime = dhrtime + durinalarc / 15
marb1 = marbtime
marbtime = marbtime - marb1
marb = floor(marbtime * 60)
EshaArc = acos((sin(-18 * PI / 180) - sin(Dec1 * PI / 180) * sin(ard * PI / 180)) / (cos(Dec1 * PI / 180) * cos(ard * PI / 180))) * 180 / PI
eshatime = dhrtime + EshaArc / 15
esha1 = eshatime
eshatime = eshatime - esha1
esha = floor(eshatime * 60)
fajrtime = dhrtime - EshaArc / 15
fjr1 = fajrtime
fajrtime = fajrtime - fjr1
fjr = floor(fajrtime * 60)
dhr = Dec2Bcd(dhr)
dhr1 = Dec2Bcd(dhr1)
fjr = Dec2Bcd(fjr)
fjr1 = Dec2Bcd(fjr1)
Just show me where is
fager
shrouq
zoher
in mikroBasic code and I will modify it to display data on LCD.
dhr = Dec2Bcd(dhr)
dhr1 = Dec2Bcd(dhr1)
fjr = Dec2Bcd(fjr)
fjr1 = Dec2Bcd(fjr1)
IntToStr()
Ltrim()
Remove Dec2Bcd conversion code. Usefunction to convert the Integer value to string. UseCode:IntToStr()
to trim the leading spaces. Send the string to LCD at required line and column.Code:Ltrim()
Try attached code and Proteus file. I have shown an example by displaying esha. Find out which other variables you want to display and convert them to string and display it.
Here is mikroC PRO PIC and mikroBasic PRO PIC code for DS1307. Use it if you want to display date and time.
http://www.libstock.com/projects/view/210/rtc2-click-example
unsigned short Jan [32][6]={{5,6,11,2,4,6},{7,41,45,31,52,14},{7,41,45,32,53,15},{7,41,46,32,54,15},{7,41,46,33,55,16},{8,41,47,34,55,17},{8,41,47,35,56,17},{8,41,48,35,57,18},{8,41,48,36,58,19},{8,42,49,37,59,19},{8,42,49,38,0,20},{8,42,50,38,1,21},{8,42,50,39,2,21},{8,42,51,40,2,22},{9,42,51,41,3,23},{9,42,52,41,4,23},{9,42,52,42,5,24},{9,42,52,43,6,25},{9,41,52,44,7,26},{8,41,53,44,8,26},{8,40,53,45,9,27},{8,40,53,46,9,28},{7,39,54,47,10,29},{7,39,54,48,11,30},{7,38,54,48,12,30},{7,38,54,49,13,31},{7,38,54,50,14,32},{6,37,55,51,15,33},{6,37,55,52,15,34},{6,36,55,53,16,35},{5,36,56,53,17,35},{5,35,56,54,18,36}};
unsigned short Feb [30][6]={{5,6,11,2,5,6},{5,35,56,55,19,37},{4,34,56,56,20,38},{4,34,56,56,21,38},{3,33,56,57,22,39},{2,32,56,58,22,40},{2,31,56,58,23,41},{1,31,56,59,24,41},{5,30,56,3,25,42},{4,29,56,3,26,43},{59,28,56,1,27,44},{58,28,56,2,28,44},{58,27,56,2,29,45},{57,26,56,3,29,46},{56,25,56,4,30,47},{56,25,56,4,31,47},{55,24,56,5,32,48},{54,23,56,5,33,49},{53,22,56,6,34,50},{52,21,56,7,34,50},{51,20,56,7,35,51},{50,19,56,7,36,52},{49,18,56,8,37,53},{48,17,56,9,37,53},{47,15,55,9,38,54},{46,14,55,9,39,55},{45,13,55,10,40,56},{44,12,55,11,41,57},{43,11,55,11,41,57}} ;
unsigned short March [32][6]={{4,6,11,3,5,6},{41,9,55,12,43,59},{40,8,55,12,44,7},{39,7,54,13,44,7},{37,5,54,13,45,1},{36,4,54,13,46,2},{35,3,54,13,47,2},{34,2,53,14,47,3},{33,1,53,14,48,4},{31,5,53,14,49,4},{30,59,53,14,50,5},{29,58,52,15,50,6},{28,57,52,15,50,6},{27,55,52,15,52,7},{25,53,52,15,53,8},{24,52,51,16,53,8},{23,51,51,16,54,9},{22,50,51,16,55,10},{20,48,50,16,55,11},{19,47,50,16,56,11},{17,46,50,16,57,12},{16,44,49,17,57,13},{15,43,49,17,58,13},{13,42,49,17,59,14},{12,41,49,17,6,15},{11,39,48,17,6,16},{9,38,48,17,1,17},{8,37,48,17,2,17},{7,35,47,18,2,18},{5,34,47,18,3,19},{4,33,47,18,4,19},{2,31,46,18,4,20}};
unsigned short April [31][6]={{5,6,12,4,7,8},{1,30,46,3,6,21},{3,29,46,18,6,22},{58,28,45,18,6 ,23},{57,26,45,18,7,24},{55,25,45,18,7,24},{54,24,45,18,8,25},{52,23,44,18,9,26},{51,22,44,18,9,27},{49,20,44,19,10,28},{48,19,44,19,10,29},{46,18,43,19,11,30},{45,17,43,19,12,31},{43,16,43,19,12,31},{42,14,43,19,13,32},{40,13,42,19,13,33},{39,12,42,19,1434},{38,11,42,19,15,35},{36,10,42,19,15,36},{35,9,41,19,16,37},{34,8,41,19,17,38},{33,7,41,19,18,39},{31,6,41,19,18,40},{30,5,41,19,19,41},{29,4,40,18,20,41},{28,3,40,18,21,42},{26,2,40,18,21,43},{25,1,40,18,22,45},{24,4,40,18,23,45},{23,59,39,18,24,46},{21,58,39,18,24,47} };
unsigned short May [32][6]={{4,5,12,4,7,8},{20,57,39,18,25,48},{19,56,39,18,26,49},{18,55,39,18,26,50},{17,55,39,18,27,51},{15,54,39,18,28,52},{14,53,39,18,28,53},{13,52,39,18,29,54},{12,51,39,18,30,55},{11,51,39,18,30,55},{10,50,39,18,31,56},{9,49,39,18,32,57},{8,48,39,18,32,59},{6,47,39,18,33,8},{4,46,39,18,34,1},{3,45,39,18,35,2},{2,45,39,18,36,3},{1,44,39,18,36,4},{1,44,39,18,37,5},{2,43,39,18,37,6},{59,43,39,18,38,6},{59,42,39,18,39,7},{58,42,39,18,39,8},{57,41,39,18,40,9},{56,41,40,19,41,10},{55,41,40,19,41,11},{55,40,40,19,42,12},{54,40,40,19,43,12},{53,39,40,19,43,13},{53,39,40,19,44,14},{52,38,40,19,44,15}};
const short June [31][6]={{3,5,12,4,7,9},{51,38,40,19,45,16},{51,38,40,19,45,17},{51,38,41,19,46,17},{50,38,41,20,46,18},{50,38,41,20,47,18},{50,38,41,20,47,19},{50,38,42,20,48,20},{50,38,42,20,48,20},{49,37,42,21,49,21},{49,37,42,21,49,21},{49,37,43,21,50,22},{49,37,43,21,50,23},{49,37,43,21,51,23},{48,37,43,22,51,24},{48,37,44,22,52,24},{48,37,44,22,52,25},{48,37,44,22,52,25},{49,38,44,22,52,25},{49,38,44,23,52,25},{49,38,45,23,53,25},{50,38,45,23,53,25},{50,39,45,23,53,25},{50,39,45,23,53,25},{51,39,45,24,53,25},{51,39,45,24,53,26},{51,40,45,24,53,26},{52,40,45,24,53,26},{52,40,46,24,54,26},{52,40,46,25,54,26},{53,41,46,25,54,26} };
const short July [32][6]={{3,5,12,4,7,9},{53,41,46,25,54,26},{54,42,46,25,54,26},{54,42,46,25,54,25},{55,43,46,26,53,25},{56,43,47,26,53,25},{56,44,47,26,53,24},{57,44,47,26,53,24},{58,45,47,26,53,24},{58,45,47,27,52,23},{59,46,47,27,52,23},{3,46,47,27,52,23},{3,47,47,27,52,22},{1,47,48,27,52,22},{2,48,48,28,51,22},{2,48,48,28,51,21},{3,49,48,28,51,21},{4,50,48,28,50,20},{5,50,48,28,50,19},{6,51,48,28,49,18},{7,51,48,28,49,17},{8,52,48,28,48,17},{9,53,48,28,47,16},{10,53,48,28,47,15},{11,54,48,28,46,14},{11,55,48,28,45,13},{12,55,48,28,45,12},{13,56,48,28,44,11},{14,57,48,28,43,11},{15,57,48,28,43,10},{16,58,48,28,42,9},{17,58,48,28,42,8}};
const short August [32][6]={{4,5,12,4,7,9},{18,59,48,28,41,7},{19,5,48,28,40,6},{20,5,48,28,39,5},{21,1,48,27,38,3},{22,1,47,27,37,2},{23,2,47,27,36,1},{24,3,47,27,35,7},{25,3,47,27,34,59},{26,4,47,26,34,57},{27,4,47,26,33,56},{28,5,47,26,32,55},{29,6,47,26,30,54},{30,6,46,26,30,53},{31,7,46,25,29,51},{32,7,46,25,28,50},{33,8,46,25,27,49},{34,9,46,25,26,48},{35,9,46,24,25,46},{36,10,45,23,24,45},{37,10,45,23,23,43},{37,11,45,23,21,42},{38,12,44,22,20,41},{39,12,44,21,19,39},{40,13,44,21,18,38},{41,14,44,21,17,37},{42,14,44,20,16,35},{43,15,43,19,15,34},{43,16,43,19,13,33},{44,16,43,19,12,31},{45,17,42,18,11,30},{46,17,42,17,10,28}};
const short September [31][6]={{4,6,12,4,7,8},{47,18,42,17,9,27},{48,19,42,16,8,26},{48,19,41,16,6,24},{49,20,41,15,5,23},{50,20,41,14,4,21},{51,21,40,14,3,20},{51,22,40,13,1,19},{52,22,40,12,5,17},{53,23,39,12,59,16},{54,23,39,11,58,14},{54,24,39,10,56,13},{55,25,38,10,55,12},{56,25,38,9,54,10},{57,26,38,8,53,9},{57,26,37,8,51,7},{58,27,37,7,50,6},{59,28,37,6,49,5},{59,28,36,5,47,3},{4,29,36,5,46,2},{1,29,36,4,45,6},{1,30,35,3,43,59},{2,31,35,2,42,58},{3,31,35,1,41,57},{3,32,34,1,39,55},{4,32,34,2,38,54},{5,33,34,59,37,53},{5,34,33,58,35,51},{6,34,33,57,34,50},{7,35,33,57,33,49},{7,35,32,56,31,48} };
const short October [32][6]={{4,5,11,2,5,6},{8,36,32,55,30,46},{9,37,32,54,29,45},{9,37,31,53,28,44},{10,38,31,52,26,42},{11,39,31,52,25,41},{11,39,31,51,24,40},{12,40,30,50,23,39},{13,41,30,49,22,38},{13,41,30,48,20,36},{14,42,30,47,19,35},{15,43,29,46,18,34},{15,43,29,45,17,33},{16,44,29,45,16,32},{17,45,29,44,14,30},{17,45,28,43,13,29},{18,46,28,42,12,28},{19,47,28,41,11,27},{19,48,28,40,9,26},{20,48,28,40,8,25},{21,49,28,39,7,24},{21,50,27,38,6,23},{22,50,27,38,5,22},{23,51,27,37,4,21},{24,52,27,36,3,20},{24,53,27,35,2,20},{25,54,27,34,1,19},{26,54,27,34,5,18},{6,55,26,33,59,17},{27,56,26,32,58,16},{28,56,26,32,57,15},{28,57,26,31,56,14}};
const short November [31][6]={{4,5,11,2,4,6},{29,58,26,30,56,13},{30,59,26,30,55,12},{30,6,26,29,55,12},{31,1,26,29,54,11},{32,1,26,28,53,11},{33,2,26,28,53,10},{33,3,26,27,52,10},{34,4,26,27,51,9},{35,5,27,26,51,9},{36,6,27,26,50,8},{36,7,27,25,49,8},{37,8,27,25,49,7},{38,8,27,24,48,7},{39,9,27,24,47,6},{39,10,27,23,47,6},{40,11,27,23,46,5},{41,12,27,23,46,5},{41,13,28,23,45,5},{42,14,28,22,45,4},{43,14,28,22,45,4},{43,15,28,22,45,4},{44,16,29,22,44,4},{45,17,29,22,44,4},{45,18,29,21,44,3},{46,19,29,21,44,3},{47,20,30,21,43,3},{47,21,30,21,43,3},{48,21,30,21,43,3},{49,22,30,20,43,2},{49,23,31,20,42,2} };
const short December [32][6]={{4,6,11,2,4,6},{50,24,31,20,42,2},{51,25,31,20,42,2},{51,25,32,20,42,3},{52,26,32,21,42,3},{53,27,33,21,43,3},{54,28,33,21,43,3},{54,28,34,21,43,4},{55,29,34,21,43,4},{56,30,35,22,43,4},{57,31,35,22,43,4},{57,31,36,22,43,5},{58,32,36,22,43,5},{59,33,37,22,44,5},{5,34,37,23,44,5},{5,34,38,23,44,6},{1,35,38,23,44,6},{1,36,38,23,44,6},{2,36,39,24,45,7},{2,36,39,25,46,8},{3,37,40,25,46,8},{3,37,40,25,46,8},{3,37,41,26,47,9},{4,38,41,27,48,10},{4,38,42,27,48,10},{4,38,42,27,48,10},{5,39,42,28,49,11},{5,39,43,29,50,12},{5,39,43,29,50,12},{6,40,44,29,50,12},{6,40,44,30,51,13},{7,41,45,31,52,14}};
unsigned short fager[3];
unsigned short shrouq[3];
unsigned short zoher[4];
unsigned short aser[3];
unsigned short maghreb[3];
unsigned short isha[3];
//shrouq,zoher,aser,maghreb,isha;
unsigned short read_ds1307(unsigned short address );
void write_ds1307(unsigned short address,unsigned short w_data);
unsigned short set_count1 = 0;
short set1;
unsigned short sec;
unsigned short minute;
unsigned short hour;
unsigned short day;
unsigned short date;
unsigned short month;
unsigned short year;
unsigned short data;
char x=0;
unsigned short i=0 ,date1,date2,date3;
unsigned short hourrr ;
//// unsigned short counter1=0 ;
//unsigned short counter2=0 ;
//unsigned short j=14;
char bcdtodec(char num) ;
char time11[] = "00:00:00 PM";
char date11[] = "00-00-00";
char BCD[60]={0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21,22,23,24,25,32,33,34,36,37,38,39,40,41,48,49,50,51,52,53,54,55,56,57,64,65,67,68,69,70,71,72,73,80,81,82,83,84,85,86,87,88,89} ;
char AMPM[24]={0x52,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x50,0x51,0x72,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x70,0x71};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
void interrupt(){
if(x==0) {portb=0;portd=sec;porta=fager[0]; }
if(x==1) {portb=1;portd=minute;porta=fager[1]; }
if(x==2) {portb=2;portd=hour;porta=fager[2]; }
////
if(x==3) {portb=3;portd=date3;porta=shrouq[0]; }
if(x==4) {portb=4;portd=month;porta=shrouq[1]; }
if(x==5) {portb=5;portd=year;porta=shrouq[2]; }
if(x==6) {portb=6;porta=zoher[0];portd=aser[0]; }
if(x==7) {portb=7;porta=zoher[1]; portd=aser[1];}
if(x==8) {portb=8;porta=zoher[2]; portd=aser[2];}
if(x==9) {portb=9;porta=zoher[3];portd=isha[0]; }
if(x==10) {portb=10;porta= maghreb[0];portd=isha[1]; }
if(x==11) {portb=11;porta= maghreb[1];portd=isha[2]; }
if(x==12) {portb=12;porta= maghreb[2] ;}
//if(x==13) {portb=j;portd=counter1 ; porta=counter2 ;}
x++;
INTCON=0b00100000;
TMR0L=222;
if(x==13) x=0;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
void main(){
trisd=0; trisb=0b11110000; trisc=0b00111000; trisa=0; trise=0;
INTCON=0b10100000;
T0CON=0b11000101;
I2C_Init(100000);
TRISD = 0; // PORTB is output
Lcd_Custom_Config(&PORTD,7,6,5,4,&PORTD,2,0,3); // Initialize LCD on PORTB
Lcd_Custom_Cmd(Lcd_CURSOR_OFF); // Turn off cursor
Lcd_Custom_Out(1, 1, "AAA"); // Print text at LCD
//
TMR0L=0;
////Set Time
write_ds1307(0,0x58); //Reset second to 0 sec. and stop Oscillator
write_ds1307(1,0x6); //write min 27
write_ds1307(2,0x45); //write hour 14
write_ds1307(3,1); //write day of week 2:Monday
write_ds1307(4,0x1); // write date 17
write_ds1307(5,0x12); // write month 6 June
write_ds1307(6,0x12); // write year 8 --> 2008
write_ds1307(7,80); //SQWE output at 1 Hz
while(1)
{
Lcd_Custom_Cmd(Lcd_CURSOR_OFF); // Turn off cursor
Lcd_Custom_Out(2, 1, "AAA"); // Print text at LCD
sec=read_ds1307(0); // read second
minute=read_ds1307(1); // read minute
hourrr=read_ds1307(2); // read hour
hour=hourrr&0b00011111;
day=read_ds1307(3); // read day
date3=read_ds1307(4); // read date
month=read_ds1307(5); // read month
year=read_ds1307(6); // read year
date= bcdtodec(date3);
/// áÖÈØ ÇáæÞÊ
if(portb.f7==1) {
if (portb.f4==1) { write_ds1307(1,BCD[i]) ; write_ds1307(0,0); delay_ms(300); i++; if (i==59) i=0;} // min
if (portb.f5==1) { write_ds1307(2,AMPM[i]) ; write_ds1307(0,0); delay_ms(300); i++; if (i==24) i=0;} // hour
if (portb.f6==1) { write_ds1307(0,0) ;write_ds1307(1,0);write_ds1307(2,0);write_ds1307(4,0);write_ds1307(5,0);write_ds1307(6,0); delay_ms(300); } // clear
}
///áÖÈØ ÇáÊÇÑíÎ
if(portb.f7==0) {
if (portb.f4==1) { write_ds1307(4,BCD[i]); delay_ms(300); i++; if (i==32) i=0;} // date
if (portb.f5==1) { write_ds1307(5,BCD[i]); delay_ms(300); i++; if (i==12) i=0;} // month
if (portb.f6==1) { write_ds1307(5,BCD[i]); delay_ms(300); i++; if (i==22) i=0;} // year
}
if(hourrr.f5==0){porte.f0=1;} //AM
if(hourrr.f5==1){porte.f0=0;} //PM
// Print text at LCD
////////////////////////////////////// Jan
///////////////// Adition ///////////////////////
Lcd_out(1,1,"Time:");
Lcd_out(2,1,"Date:");
if (month==1) {
fager[2]=Jan[0][0];
fager[1]=0;
fager[0]=Jan[date][0];
// fager[2]=5;
// fager[1]=4;
// fager[0]=7;
shrouq[2]=Jan[0][1] ;
shrouq[1]=((Jan[date][1])/10)%10 ;
shrouq[0]=(Jan[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=1 ;
zoher[1]=((Jan[date][2])/10)%10 ;
zoher[0]=(Jan[date][2])%10 ;
//zoher[3]=1 ;
//zoher[2]=1 ;
//zoher[1]=3 ;
//zoher[0]=5 ;
aser[2]=2 ;
aser[1]=((Jan[date][3])/10)%10 ;
aser[0]=(Jan[date][3])%10 ;
if (date<10) { maghreb[2]=4 ;} else { maghreb[2]=5; }
maghreb[1]=((Jan[date][4])/10)%10 ;
maghreb[0]=(Jan[date][4])%10 ;
isha[2]=6 ;
isha[1]=((Jan[date][5])/10)%10 ;
isha[0]=(Jan[date][5])%10 ;
}
////////////////////////////////////// Feb
if (month==2) {
if (date<10) { fager[2]=5 ;} else { fager[2]=4; }
fager[1]=((Feb[date][0])/10)%10 ;
fager[0]=(Feb[date][0])%10 ;
shrouq[2]=Feb[0][1] ;
shrouq[1]=((Feb[date][1])/10)%10 ;
shrouq[0]=(Feb[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=1 ;
zoher[1]=((Feb[date][2])/10)%10 ;
zoher[0]=(Feb[date][2])%10 ;
if (date<8) { aser[2]=2 ;} else { aser[2]=3; }
aser[1]=((Feb[date][3])/10)%10 ;
aser[0]=(Feb[date][3])%10 ;
maghreb[2]=Feb[0][4] ;
maghreb[1]=((Feb[date][4])/10)%10 ;
maghreb[0]=(Feb[date][4])%10 ;
isha[2]=Feb[0][5] ;
isha[1]=((Feb[date][5])/10)%10 ;
isha[0]=(Feb[date][5])%10 ;
}
////////////////////////////////////// March
if (month==3) {
fager[2]=March[0][0] ;
fager[1]=((March[date][0])/10)%10 ;
fager[0]=(March[date][0])%10 ;
if (date<9) { shrouq[2]=6 ;} else { shrouq[2]=5; }
shrouq[1]=((March[date][1])/10)%10 ;
shrouq[0]=(March[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=1 ;
zoher[1]=((March[date][2])/10)%10 ;
zoher[0]=(March[date][2])%10 ;
aser[2]=3;
aser[1]=((March[date][3])/10)%10 ;
aser[0]=(March[date][3])%10 ;
if (date<24) { maghreb[2]=5 ;} else { maghreb[2]=6; }
maghreb[1]=((March[date][4])/10)%10 ;
maghreb[0]=(March[date][4])%10 ;
if (date<2) { isha[2]=6 ;} else { isha[2]=7; }
isha[1]=((March[date][5])/10)%10 ;
isha[0]=(March[date][5])%10 ;
}
////////////////////////////////////// April
if (month==4) {
if (date<3) { fager[2]=3 ;} else { fager[2]=4; }
fager[1]=((April[date][0])/10)%10 ;
fager[0]=(April[date][0])%10 ;
if (date<29) { shrouq[2]=5 ;} else { shrouq[2]=4; }
shrouq[1]=((April[date][1])/10)%10 ;
shrouq[0]=(April[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=1 ;
zoher[1]=((April[date][2])/10)%10 ;
zoher[0]=(April[date][2])%10 ;
aser[2]=3;
aser[1]=((April[date][3])/10)%10 ;
aser[0]=(April[date][3])%10 ;
maghreb[2]=6;
maghreb[1]=((April[date][4])/10)%10 ;
maghreb[0]=(April[date][4])%10 ;
isha[2]=7;
isha[1]=((April[date][5])/10)%10 ;
isha[0]=(April[date][5])%10 ;
}
////////////////////////////////////// May
if (month==5) {
if (date<21) { fager[2]=4 ;} else { fager[2]=3; }
fager[1]=((May[date][0])/10)%10 ;
fager[0]=(May[date][0])%10 ;
shrouq[2]=5;
shrouq[1]=((May[date][1])/10)%10 ;
shrouq[0]=(May[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=2 ;
zoher[1]=((May[date][2])/10)%10 ;
zoher[0]=(May[date][2])%10 ;
aser[2]=4;
aser[1]=((May[date][3])/10)%10 ;
aser[0]=(May[date][3])%10 ;
maghreb[2]=7;
maghreb[1]=((May[date][4])/10)%10 ;
maghreb[0]=(May[date][4])%10 ;
if (date<14) { isha[2]=8 ;} else { isha[2]=9; }
isha[1]=((May[date][5])/10)%10 ;
isha[0]=(May[date][5])%10 ;
}
////////////////////////////////////// June
if (month==6) {
fager[2]=3;
fager[1]=((June[date][0])/10)%10 ;
fager[0]=(June[date][0])%10 ;
shrouq[2]=5;
shrouq[1]=((June[date][1])/10)%10 ;
shrouq[0]=(June[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=2 ;
zoher[1]=((June[date][2])/10)%10 ;
zoher[0]=(June[date][2])%10 ;
aser[2]=4;
aser[1]=((June[date][3])/10)%10 ;
aser[0]=(June[date][3])%10 ;
maghreb[2]=7;
maghreb[1]=((June[date][4])/10)%10 ;
maghreb[0]=(June[date][4])%10 ;
isha[2]=9;
isha[1]=((June[date][5])/10)%10 ;
isha[0]=(June[date][5])%10 ;
}
////////////////////////////////////// July
if (month==7) {
if (date<11) { fager[2]=3 ;} else { fager[2]=4; }
fager[1]=((July[date][0])/10)%10 ;
fager[0]=(July[date][0])%10 ;
shrouq[2]=5;
shrouq[1]=((July[date][1])/10)%10 ;
shrouq[0]=(July[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=2 ;
zoher[1]=((July[date][2])/10)%10 ;
zoher[0]=(July[date][2])%10 ;
aser[2]=4;
aser[1]=((July[date][3])/10)%10 ;
aser[0]=(July[date][3])%10 ;
maghreb[2]=7;
maghreb[1]=((June[date][4])/10)%10 ;
maghreb[0]=(June[date][4])%10 ;
isha[2]=9;
isha[1]=((July[date][5])/10)%10 ;
isha[0]=(July[date][5])%10 ;
}
////////////////////////////////////// August
if (month==8) {
fager[2]=4;
fager[1]=((August[date][0])/10)%10 ;
fager[0]=(August[date][0])%10 ;
if (date<2) { shrouq[2]=5 ;} else { shrouq[2]=6; }
shrouq[1]=((August[date][1])/10)%10 ;
shrouq[0]=(August[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=2 ;
zoher[1]=((August[date][2])/10)%10 ;
zoher[0]=(August[date][2])%10 ;
aser[2]=4;
aser[1]=((August[date][3])/10)%10 ;
aser[0]=(August[date][3])%10 ;
maghreb[2]=7;
maghreb[1]=((August[date][4])/10)%10 ;
maghreb[0]=(August[date][4])%10 ;
if (date<8) { isha[2]=9 ;} else { isha[2]=8; }
isha[1]=((August[date][5])/10)%10 ;
isha[0]=(August[date][5])%10 ;
}
////////////////////////////////////// September
if (month==9) {
if (date<19) { fager[2]=4 ;} else { fager[2]=5; }
fager[1]=((September[date][0])/10)%10 ;
fager[0]=(September[date][0])%10 ;
shrouq[2]=6;
shrouq[1]=((September[date][1])/10)%10 ;
shrouq[0]=(September[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=2 ;
zoher[1]=((September[date][2])/10)%10 ;
zoher[0]=(September[date][2])%10 ;
if (date<26) { aser[2]=4 ;} else { aser[2]=3; }
aser[1]=((September[date][3])/10)%10 ;
aser[0]=(September[date][3])%10 ;
if (date<9) { maghreb[2]=7 ;} else { maghreb[2]=6; }
maghreb[1]=((September[date][4])/10)%10 ;
maghreb[0]=(September[date][4])%10 ;
if (date<21) { isha[2]=8 ;} else { isha[2]=7; }
isha[1]=((September[date][5])/10)%10 ;
isha[0]=(September[date][5])%10 ;
}
////////////////////////////////////// October
if (month==0x10) {
fager[2]=4;
fager[1]=((October[date][0])/10)%10 ;
fager[0]=(October[date][0])%10 ;
shrouq[2]=5;
shrouq[1]=((October[date][1])/10)%10 ;
shrouq[0]=(October[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=1 ;
zoher[1]=((October[date][2])/10)%10 ;
zoher[0]=(October[date][2])%10 ;
aser[2]=2;
aser[1]=((October[date][3])/10)%10 ;
aser[0]=(October[date][3])%10 ;
if (date<28) { maghreb[2]=5 ;} else { maghreb[2]=4; }
maghreb[1]=((October[date][4])/10)%10 ;
maghreb[0]=(October[date][4])%10 ;
isha[2]=6;
isha[1]=((October[date][5])/10)%10 ;
isha[0]=(October[date][5])%10 ;
}
////////////////////////////////////// November
if (month==0x11) {
fager[2]=4;
fager[1]=((November[date][0])/10)%10 ;
fager[0]=(November[date][0])%10 ;
if (date<3) { shrouq[2]=5 ;} else { shrouq[2]=6; }
shrouq[1]=((November[date][1])/10)%10 ;
shrouq[0]=(November[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=1 ;
zoher[1]=((November[date][2])/10)%10 ;
zoher[0]=(November[date][2])%10 ;
aser[2]=2;
aser[1]=((November[date][3])/10)%10 ;
aser[0]=(November[date][3])%10 ;
maghreb[2]=4;
maghreb[1]=((November[date][4])/10)%10 ;
maghreb[0]=(November[date][4])%10 ;
isha[2]=6;
isha[1]=((November[date][5])/10)%10 ;
isha[0]=(November[date][5])%10 ;
}
////////////////////////////////////// December
if (month==0x12) {
if (date<14) { fager[2]=4 ;} else { fager[2]=5; }
fager[1]=((December[date][0])/10)%10 ;
fager[0]=(December[date][0])%10 ;
shrouq[2]=6;
shrouq[1]=((December[date][1])/10)%10 ;
shrouq[0]=(December[date][1])%10 ;
zoher[3]=1 ;
zoher[2]=1 ;
zoher[1]=((December[date][2])/10)%10 ;
zoher[0]=(December[date][2])%10 ;
aser[2]=2;
aser[1]=((December[date][3])/10)%10 ;
aser[0]=(December[date][3])%10 ;
maghreb[2]=4;
maghreb[1]=((December[date][4])/10)%10 ;
maghreb[0]=(December[date][4])%10 ;
isha[2]=6;
isha[1]=((December[date][5])/10)%10 ;
isha[0]=(December[date][5])%10 ;
}
Lcd_Custom_Out(1, 1, fager);
//Lcd_Custom_Out(1, 1, shrouq);
//Lcd_Custom_Out(2, 1,zoher);
//Lcd_Custom_Out(2, 1,aser);
//Lcd_Custom_Out(2, 1,maghreb);
//Lcd_Custom_Out(2, 1,isha);
// ÃØÝÇÁ ÚÏÇÏ ÇáÇÞÇãÉ ÚäÏ æÞÊ ÇáÇÞÇãÉ
//
// if(i==99 &&(counter1==(minute&0x0f) )&&(counter2==((minute&0xf0)>>4))) { j=14;i=0;}
//
//
//
//// AM RC1 ON ,,,, PM RC2 ON
//if(hourrr.f5==0){portc.f1=1; portc.f2=0;} //AM
//if(hourrr.f5==1) {portc.f1=0; portc.f2=1; } //PM
//
// ãÞÇÑäÉ ÇáÓÇÚÉ ãÚ ÇæÞÇÊ ÇáÕáÇÉ
if(hourrr.f5==0 && (minute&0x0f)==fager[0] && ((minute&0xf0)>>4)==fager[1] && hour==fager[2] )
{
// i=99;
// j=13;
// ÇÞÇãÉ ÕáÇÉ ÇáÝÌÑ ÈÚÏ 20 ÏÞíÞÉ
//counter1= minute&0x0f;
//counter2 =(minute&0xf0)>>4;
//if (counter2==4) counter2=0;
//else if (counter2==5) counter2=1;
//else if (counter2<4) counter2=counter2+2;
// RC0 one min ON led at athan time
if(sec<89) portc.f0=1; // 96 dec = 60 hex
else portc.f0=0;
}
//
if( hourrr.f5==0 &&(minute&0x0f)==shrouq[0] && ((minute&0xf0)>>4)==shrouq[1] && hour==shrouq[2] )
{
if(sec<89) portc.f1=1;
else portc.f1=0;
}
//
//
//
if( zoher[3]==1 && hourrr.f5==0 && (minute&0x0f)==zoher[0] && ((minute&0xf0)>>4)==zoher[1] &&( hour&0x0f)==zoher[2] )
{
//
//i=99;
// j=13;
// // 15 ÏÞíÞÉ ÇáÙåÑ
//counter1= minute&0x0f;
//counter2 =(minute&0xf0)>>4;
//
//if (counter2<=4&&counter1<5){counter1=counter1+5;counter2=counter2+1;}
//else if (counter2<=5&&counter1>=5){counter1=counter1-5;counter2=counter2+2;}
//else if(counter2==4&&counter1>=5){counter1=counter1-5;counter2=0;}
//else if(counter2==5&&counter1<5){counter1=counter1+5;counter2=0;}
//else if(counter2==5&&counter1>=5){counter1=counter1-5;counter2=1;}
if(sec<89) portc.f2=1;
else portc.f2=0;
}
//
//
if( zoher[3]==2 &&hourrr.f5==1 && (minute&0x0f)==zoher[0] && ((minute&0xf0)>>4)==zoher[1] && (hour&0x0f)==zoher[2] )
{
// i=99;
// j=13;
// // 15 ÏÞíÞÉ ÇáÙåÑ
//counter1= minute&0x0f;
//counter2 =(minute&0xf0)>>4;
//
//if (counter2<=4&&counter1<5){counter1=counter1+5;counter2=counter2+1;}
//else if (counter2<=5&&counter1>=5){counter1=counter1-5;counter2=counter2+2;}
//else if(counter2==4&&counter1>=5){counter1=counter1-5;counter2=0;}
//else if(counter2==5&&counter1<5){counter1=counter1+5;counter2=0;}
//else if(counter2==5&&counter1>=5){counter1=counter1-5;counter2=1;}
if(sec<89) portc.f3=1;
else portc.f3=0;
}
//
if( hourrr.f5==1 &&(minute&0x0f)==aser[0] && ((minute&0xf0)>>4)==aser[1] && hour==aser[2] )
{
if(sec<89) portc.f4=1;
else portc.f4=0;
}
//
if( hourrr.f5==1 &&(minute&0x0f)==maghreb[0] && ((minute&0xf0)>>4)==maghreb[1] && hour==maghreb[2] )
{
if(sec<89) portc.f5=1;
else portc.f5=0;
}
//
//
if( hourrr.f5==1 &&(minute&0x0f)==isha[0] && ((minute&0xf0)>>4)==isha[1] && hour==isha[2] )
{
if(sec<89) portc.f6=1;
else portc.f6=0;
}
}
}
unsigned char BCD2UpperCh(unsigned char bcd)
{
return ((bcd >> 4) + '0');
}
unsigned char BCD2LowerCh(unsigned char bcd)
{
return ((bcd & 0x0F) + '0');
}
int Binary2BCD(int a)
{
int t1, t2;
t1 = a%10;
t1 = t1 & 0x0F;
a = a/10;
t2 = a%10;
t2 = 0x0F & t2;
t2 = t2 << 4;
t2 = 0xF0 & t2;
t1 = t1 | t2;
return t1;
}
int BCD2Binary(int a)
{
int r,t;
t = a & 0x0F;
r = t;
a = 0xF0 & a;
t = a >> 4;
t = 0x0F & t;
r = t*10 + r;
return r;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
unsigned short read_ds1307(unsigned short address)
{
I2C_Start();
I2C_Wr(0xd0); //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
I2C_Wr(address);
I2C_Repeated_Start();
I2C_Wr(0xd1); //0x68 followed by 1 --> 0xD1
data=I2C_Rd(0);
I2C_Stop();
return(data);
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
void write_ds1307(unsigned short address,unsigned short w_data)
{
I2C_Start(); // issue I2C start signal
//address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
I2C_Wr(0xD0); // send byte via I2C (device address + W)
I2C_Wr(address); // send byte (address of DS1307 location)
I2C_Wr(w_data); // send data (data to be written)
I2C_Stop(); // issue I2C stop signal
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// // Convert Decimal to Binary Coded Decimal (BCD)
//char dec2bcd(char num)
//{
// return ((num/10 * 16) + (num % 10));
//}
//// Convert Binary Coded Decimal (BCD) to Decimal
char bcdtodec(char num)
{
return ((num/16 * 10) + (num % 16));
}
RTC is not working properly that is time is not set properly. Search in this forum and also you can use the libstock RTC2 Click example for RTC DS1307. Search in this forum for RTC DS1307. I have done mikroC and Hi-Tech C DS1307 projects and also you will get projects done by others here.
program prayer_time
' Lcd module connections
dim LCD_RS as sbit at LATD0_bit
LCD_EN as sbit at LATD1_bit
LCD_D4 as sbit at LATD4_bit
LCD_D5 as sbit at LATD5_bit
LCD_D6 as sbit at LATD6_bit
LCD_D7 as sbit at LATD7_bit
LCD_RS_Direction as sbit at TRISD0_bit
LCD_EN_Direction as sbit at TRISD1_bit
LCD_D4_Direction as sbit at TRISD4_bit
LCD_D5_Direction as sbit at TRISD5_bit
LCD_D6_Direction as sbit at TRISD6_bit
LCD_D7_Direction as sbit at TRISD7_bit
' End Lcd module connections
'////////////////////////////////////////////////////////////////////////////////////////
' RTC Definitions
hours, minutes, seconds, day, week, month, year as byte ' Global date/time variables
oldstate as byte
' RTC Definitions
const RTC_ADDR = 0xD0
' Configure user buttons
'TRISA0_bit = 1 ' Set RA0 pin as input.
'{**************************************************************************************************
'* DS1307 Functions
'**************************************************************************************************}
'{**************************************************************************************************
'* Read data from RTC DS1307
'* input : addres of RTC register
'* output: value of of RTC register
'**************************************************************************************************}
sub function RTC_Read(dim addr as byte) as byte
dim value as byte
I2C1_Start() ' Issue start signal
I2C1_Wr(RTC_ADDR) ' Address DS1307, see DS1307 datasheet
I2C1_Wr(addr) ' Start from address 2
I2C1_Start() ' Issue repeated start signal
I2C1_Wr(RTC_ADDR) ' Address DS1307 for reading R/W=1
value = I2C1_Rd(0) ' Read seconds byte
I2C1_Stop() ' Issue stop signal
result = value
end sub
'{**************************************************************************************************
'* Write data from DS1307
'* input : addres of RTC register, value of of RTC register
'**************************************************************************************************}
sub procedure RTC_Write(dim addr as byte, dim value as byte)
I2C1_Start() ' Issue start signal
I2C1_Wr(RTC_ADDR) ' Address DS1307
I2C1_Wr(addr) ' Start from address
I2C1_Wr(value) ' Write value to RTC register
I2C1_Stop() ' Issue stop signal
end sub
'{**************************************************************************************************
'* Read time from RTC DS1307
'* input : pointer to variables where RTC data will be stored
'* output: variables with RTC data
'**************************************************************************************************}
sub procedure Read_Time(dim p_hours as ^byte, dim p_minutes as ^byte, dim p_seconds as ^byte,
dim p_day as ^byte, dim p_week as ^byte, dim p_month as ^byte, dim p_year as ^byte)
I2C1_Start() ' Issue start signal
I2C1_Wr(RTC_ADDR) ' Address DS1307, see DS1307 datasheet
I2C1_Wr(0) ' Start from address 0
I2C1_Repeated_Start() ' Issue repeated start signal
I2C1_Wr(RTC_ADDR + 1) ' Address DS1307 for reading R/W=1
p_seconds^ = I2C1_Rd(1) ' Read seconds byte
p_minutes^ = I2C1_Rd(1) ' Read minutes byte
p_hours^ = I2C1_Rd(1) ' Read hours byte
p_week^ = I2C1_Rd(1)
p_day^ = I2C1_Rd(1)
p_month^ = I2C1_Rd(1)
p_year^ = I2C1_Rd(0)
I2C1_Stop() ' Issue stop signal
end sub
'{**************************************************************************************************
'* Write time to RTC DS1307
'* input : variables with RTC data
'**************************************************************************************************}
sub procedure Write_Time(dim c_hours as byte, dim c_minutes as byte, dim c_seconds as byte,
dim c_day as byte, dim c_week as byte, dim c_month as byte, dim c_year as byte)
I2C1_Start() ' issue start signal
I2C1_Wr(RTC_ADDR) ' address DS1307
I2C1_Wr(0) ' start from word at address (REG0)
I2C1_Wr(0x80) ' write $80 to REG0. (pause counter + 0 sec)
I2C1_Wr(c_minutes) ' write 0 to minutes word to (REG1)
I2C1_Wr(c_hours) ' write 17 to hours word (24-hours mode)(REG2)
I2C1_Wr(c_week) ' write 2 - Monday (REG3)
I2C1_Wr(c_day) ' write 4 to date word (REG4)
I2C1_Wr(c_month) ' write 5 (May) to month word (REG5)
I2C1_Wr(c_year) ' write 01 to year word (REG6)
I2C1_Stop() ' issue stop signal
I2C1_Start() ' issue start signal
I2C1_Wr(RTC_ADDR) ' address DS1307
I2C1_Wr(0) ' start from word at address 0
I2C1_Wr(0 or c_seconds) ' write 0 to REG0 (enable counting + 0 sec)
I2C1_Stop() ' issue stop signal
end sub
'{**************************************************************************************************
'* Show on the LCD display
'* input : variables with RTC data
'**************************************************************************************************}
sub procedure Show_Time()
dim txt as string[4]
seconds = ((seconds and 0x70) >> 4)*10 + (seconds and 0x0F)
minutes = ((minutes and 0xF0) >> 4)*10 + (minutes and 0x0F)
hours = ((hours and 0x30) >> 4)*10 + (hours and 0x0F)
week = (week and 0x07)
day = ((day and 0xF0) >> 4)*10 + (day and 0x0F)
month = ((month and 0x10) >> 4)*10 + (month and 0x0F)
year = ((year and 0xF0) >> 4)*10+(year and 0x0F)
select case week
case 1
txt = "Sun"
case 2
txt = "Mon"
case 3
txt = "Tue"
case 4
txt = "Wed"
case 5
txt = "Thu"
case 6
txt = "Fri"
case 7
txt = "Sat"
end select
LCD_Out(1,1, txt)
Lcd_Chr(1, 6, (day div 10) + 48) ' Print tens digit of day variable
Lcd_Chr(1, 7, (day mod 10) + 48) ' Print oness digit of day variable
Lcd_Chr(1, 9, (month div 10) + 48)
Lcd_Chr(1,10, (month mod 10) + 48)
Lcd_Chr(1,14, (year div 10) + 48)
Lcd_Chr(1,15, (year mod 10) + 48)
Lcd_Chr(2, 6, (hours div 10) + 48)
Lcd_Chr(2, 7, (hours mod 10) + 48)
Lcd_Chr(2, 9, (minutes div 10) + 48)
Lcd_Chr(2,10, (minutes mod 10) + 48)
Lcd_Chr(2,12, (seconds div 10) + 48)
Lcd_Chr(2,13, (seconds mod 10) + 48)
end sub
'/////////////////////////////////////////////////////////////////////
Dim y, L1 as longint
Dim D_, L, ty, Lambda, Obliquity, Alpha, ST, Dec1, noon, utnoon, dhrtime, asrtime, asralt, durinalarc, marbtime, EshaArc, M, eshatime, fajrtime, shroq, ard, tol as float
i, farq as byte
day_, month_, dhr, dhr1, asr, asr1, fjr, fjr1, marb, marb1, esha, esha1 as byte
Dim x, x1 as byte[48]
Dim sec, minutes_, hr, week_day, dday, mn, year_ as short 'edited
Dim str,str1,strzoherh,strzoherm,strasrh,strasrm,strmagrebh,strmagrebm,strfajrh,strfajrm as String[20]
Dim ssec, sminutes, shr, sweek_day, sdday, smn, syear as String[20]
sub procedure awqat()
ard = 34.54
tol = 31.522
farq = 2
D_ = ((367 * y) - (floor((1.75) * (y + floor((month_ + 9) / 12)))) + floor(275 * (month_ / 9)) + day - 730531.5)
L = 280.461+0.9856474 * D_
L1 = L
L = L - L1
L1 = L1 mod 360
L = L1 + L
M = 357.528 + 0.9856003 * D_
L1 = M
M = M - L1
L1 = L1 mod 360
M = L1 + M
Obliquity = 23.439 - 0.0000004 * D_
Lambda = L + 1.915 * sin(M * PI / 180) + 0.02 * sin(2 * M * PI / 180)
L1 = Lambda
Lambda = Lambda - L1
L1 = L1 mod 360
Lambda = L1 + Lambda
Alpha = atan(cos(Obliquity * PI / 180) * tan(Lambda * PI / 180)) * 180/PI
Alpha = Alpha - (360 * floor(Alpha / 360))
Alpha = Alpha + 90 * (floor(Lambda / 90) - floor(Alpha / 90))
ST = 100.46 + 0.985647352 * D_
L1 = ST
ST = ST - L1
L1 = L1 mod 360
ST = L1 + ST
Dec1 = asin(sin(Obliquity * PI / 180) * sin(Lambda * PI / 180)) * 180 / PI
noon = Alpha - ST
if noon >= 0 then
noon = fabs(noon)
L1 = fabs(noon)
noon = noon - L1
L1 = L1 mod 360
noon = noon + L1
else
noon = fabs(noon)
L1 = fabs(noon)
noon = noon - L1
L1 = L1 mod 360
noon = noon + L1
noon = 360 - noon
end if
utnoon = noon - tol
dhrtime = (utnoon/15)+farq
dhr1 = dhrtime
dhrtime = dhrtime - dhr1
dhr = floor(dhrtime * 60)
dhrtime = (utnoon / 15) + 3
asralt = atan(1 + tan((ard - Dec1) * PI / 180)) * 180 / PI
asrtime = acos((sin((90 - asralt) * PI / 180) - sin(Dec1 * PI / 180) * sin(ard * PI / 180)) / (cos(Dec1 * PI / 180) * COS(ard * PI / 180))) * 180 / PI
asrtime = (asrtime / 15) + dhrtime
asr1 = asrtime
asrtime = asrtime - asr1
asr=floor(asrtime * 60)
durinalarc = acos((sin( - 0.8333 * PI / 180) - sin(Dec1 * PI / 180) * sin(ard * PI / 180)) / (cos(Dec1 * PI / 180) * cos(ard * PI / 180))) * 180 / PI
shroq = dhrtime - durinalarc / 15
marbtime = dhrtime + durinalarc / 15
marb1 = marbtime
marbtime = marbtime - marb1
marb = floor(marbtime * 60)
EshaArc = acos((sin(-18 * PI / 180) - sin(Dec1 * PI / 180) * sin(ard * PI / 180)) / (cos(Dec1 * PI / 180) * cos(ard * PI / 180))) * 180 / PI
eshatime = dhrtime + EshaArc / 15
esha1 = eshatime
eshatime = eshatime - esha1
esha = floor(eshatime * 60)
fajrtime = dhrtime - EshaArc / 15
fjr1 = fajrtime
fajrtime = fajrtime - fjr1
fjr = floor(fajrtime * 60)
'dhr = Dec2Bcd(dhr)
'dhr1 = Dec2Bcd(dhr1)
'fjr = Dec2Bcd(fjr)
'fjr1 = Dec2Bcd(fjr1)
if asr1 > 12 then
asr1 = asr1 - 12
end if
if marb1 > 12 then
marb1 = marb1 - 12
end if
if esha1 > 12 then
esha1 = esha1 - 12
end if
'
'asr = Dec2Bcd(asr)
'asr1 = Dec2Bcd(asr1)
'marb = Dec2Bcd(marb)
'marb1= Dec2Bcd(marb1)
'esha = Dec2Bcd(esha)
'esha1 = Dec2Bcd(esha1)
end sub
sub procedure Read_Time_(Dim byref sec, minutes, hr, week_day, dday, mn, year as short)
I2C1_Start()
I2C1_Wr(0xD0)
I2C1_Wr(0)
I2C1_Repeated_Start()
I2C1_Wr(0xD1)
sec = I2C1_Rd(1)
minutes = I2C1_Rd(1)
hr = I2C1_Rd(1)
week_day = I2C1_Rd(1)
dday = I2C1_Rd(1)
mn = I2C1_Rd(1)
year = I2C1_Rd(0)
I2C1_Stop()
end sub
sub procedure Write_Time_(Dim address as short, Dim data_wr as short)
I2C1_Start()
I2C1_Wr(0xD0)
I2C1_Wr(address)
I2C1_Wr(data_wr)
I2C1_Stop()
end sub
sub procedure showpray()
LCD_Out(1,1,"F")
LCD_Out_cp(strfajrh)
LCD_Out_cp(":")
LCD_Out_cp(strfajrm)
LCD_Out_cp(" Z")
LCD_Out_cp(strzoherh)
LCD_Out_cp(":")
LCD_Out_cp(strzoherm)
LCD_Out_cp(" A")
LCD_Out_cp(strasrh)
LCD_Out_cp(":")
LCD_Out_cp(strasrm)
LCD_Out(2,1," M ")
LCD_Out_cp(strmagrebh)
LCD_Out_cp(":")
LCD_Out_cp(strmagrebm)
LCD_Out_cp(" E ")
LCD_Out_cp(str1)
LCD_Out_cp(":")
LCD_Out_cp(str)
end sub
main:
TRISB = 0
PORTB = 0
TRISC.0 = 0
TRISC.1 = 0
TRISC.2 = 0
TRISA.0 = 0
TRISC.3 = 1
TRISC.4 = 1
TRISD = 0
PORTA = 0x00
PORTB = 0x00
PORTC = 0x00
PORTD = 0x00
PORTE = 0x00
LATA = 0x00
LATB = 0x00
LATC = 0x00
LATD = 0x00
LATE = 0x00
LCD_Init()
LCD_Cmd(_LCD_CURSOR_OFF)
LCD_Cmd(_LCD_CLEAR)
LCD_Out(1,1,"Prayer Time")
Delay_ms(2000)
LCD_Cmd(_LCD_CLEAR)
I2C1_Init(100000)
while true
Read_Time(hr,minutes,sec,dday, week_day, mn, year)
day = Bcd2Dec(dday)
month_= Bcd2Dec(mn)
y = 2015
awqat()
for i = 0 to 47
x[i] = 0
x1[i] = 0
next i
memset(@x, 0, sizeof(x))
memset(@x1, 0, sizeof(x1))
for i = 0 to 7
x[i] = dhr.i
x1[i] = esha.i
next i
for i = 0 to 7
x[i+8] = dhr1.i
x1[i+8] = esha1.i
next i
for i = 0 to 7
x[i+16] = fjr.i
x1[i+16] = marb.i
next i
for i = 0 to 7
x[i+24] = fjr1.i
x1[i+24] = marb1.i
next i
for i = 0 to 7
x[i+32] = minutes.i
x1[i+32] = asr.i
next i
for i = 0 to 7
x[i+40] = hr.i
x1[i+40] = asr1.i
next i
for i = 0 to 47
PORTB.0 = x[i]
PORTC.0 = x1[i]
PORTB.1 = 0
PORTC.1 = 0
Delay_us(20)
PORTB.1 = 1
PORTC.1 = 1
next i
PORTA.0 = 1
Delay_ms(300)
PORTB.2 = 0
PORTC.2 = 0
Delay_us(20)
PORTB.2 = 1
PORTC.2 = 1
PORTA.0 = 0
Delay_ms(300)
'LCD_Out(1,1,"Esha")
IntToStr(esha, str)
IntToStr(esha1, str1)
IntToStr(dhr1, strzoherh)
IntToStr(dhrtime, strzoherm)
IntToStr(asr1, strasrh)
IntToStr(asrtime, strasrm)
IntToStr(marb1, strmagrebh)
IntToStr(marb, strmagrebm)
IntToStr(fjr1, strfajrh)
IntToStr(fajrtime, strfajrm)
Ltrim(str)
Ltrim(str1)
Ltrim(strmagrebh)
Ltrim(strmagrebm)
Ltrim(strasrh)
Ltrim(strasrm)
Ltrim(strzoherh)
Ltrim(strzoherm)
Ltrim(strfajrh)
Ltrim(strfajrm)
'///////////////////////////////////////////////////////////
Lcd_Cmd(_LCD_CLEAR) ' Prepare and output static text on LCD
LCD_Chr(1,8,".")
LCD_Chr(1,11,".")
LCD_Out(2,1,"Time:")
LCD_Chr(2,8,":")
LCD_Chr(2,11,":")
LCD_Out(1,12,"201")
' Start the test examples
while(TRUE) ' Endless loop
' if (Button(PORTA, 0, 1, 0)) then ' Detect logical one
' oldstate = 1 ' Update flag
' end if
' if (oldstate and Button(PORTA, 0, 1, 1)) then ' Detect one-to-zero transition
' Write TIME 11 : 15 : 00 : 24. tuesday april 2012
Write_Time(0x11, 0x15, 0x00, 0x24, 0x03, 0x04, 0x12)
oldstate = 0 ' Update flag
' end if
Read_Time(@hours, @minutes, @seconds, @day, @week, @month, @year)
Show_Time()
Delay_mS(1000)
'////////////////////////////////////////////////////////////
showpray()
Delay_mS(1000)
wend
wend
end.
Please zip and post complete mikroBasic project files.
No, because there is no code which calculates Prayer times from RTC data.
ard = 31.51667
tol = 34.48333
farq = 3
D_ = ((367 * y) - (floor((1.75) * (y + floor((month_ + 9) / 12)))) + floor(275 * (month_ / 9)) + day - 730531.5)
L = 280.461+0.9856474 * D_
L1 = L
L = L - L1
L1 = L1 mod 360
L = L1 + L
M = 357.528 + 0.9856003 * D_
L1 = M
M = M - L1
L1 = L1 mod 360
M = L1 + M
Obliquity = 23.439 - 0.0000004 * D_
Lambda = L + 1.915 * sin(M * PI / 180) + 0.02 * sin(2 * M * PI / 180)
L1 = Lambda
Lambda = Lambda - L1
L1 = L1 mod 360
Lambda = L1 + Lambda
Alpha = atan(cos(Obliquity * PI / 180) * tan(Lambda * PI / 180)) * 180/PI
Alpha = Alpha - (360 * floor(Alpha / 360))
Alpha = Alpha + 90 * (floor(Lambda / 90) - floor(Alpha / 90))
ST = 100.46 + 0.985647352 * D_
L1 = ST
ST = ST - L1
L1 = L1 mod 360
ST = L1 + ST
Dec1 = asin(sin(Obliquity * PI / 180) * sin(Lambda * PI / 180)) * 180 / PI
noon = Alpha - ST
if noon >= 0 then
noon = fabs(noon)
L1 = fabs(noon)
noon = noon - L1
L1 = L1 mod 360
noon = noon + L1
else
noon = fabs(noon)
L1 = fabs(noon)
noon = noon - L1
L1 = L1 mod 360
noon = noon + L1
noon = 360 - noon
end if
utnoon = noon - tol
dhrtime = (utnoon/15)+farq
dhr1 = dhrtime
dhrtime = dhrtime - dhr1
dhr = floor(dhrtime * 60)
dhrtime = (utnoon / 15) + 3
asralt = atan(1 + tan((ard - Dec1) * PI / 180)) * 180 / PI
asrtime = acos((sin((90 - asralt) * PI / 180) - sin(Dec1 * PI / 180) * sin(ard * PI / 180)) / (cos(Dec1 * PI / 180) * COS(ard * PI / 180))) * 180 / PI
asrtime = (asrtime / 15) + dhrtime
asr1 = asrtime
asrtime = asrtime - asr1
asr=floor(asrtime * 60)
durinalarc = acos((sin( - 0.8333 * PI / 180) - sin(Dec1 * PI / 180) * sin(ard * PI / 180)) / (cos(Dec1 * PI / 180) * cos(ard * PI / 180))) * 180 / PI
shroq = dhrtime - durinalarc / 15
marbtime = dhrtime + durinalarc / 15
marb1 = marbtime
marbtime = marbtime - marb1
marb = floor(marbtime * 60)
EshaArc = acos((sin(-18 * PI / 180) - sin(Dec1 * PI / 180) * sin(ard * PI / 180)) / (cos(Dec1 * PI / 180) * cos(ard * PI / 180))) * 180 / PI
eshatime = dhrtime + EshaArc / 15
esha1 = eshatime
eshatime = eshatime - esha1
esha = floor(eshatime * 60)
fajrtime = dhrtime - EshaArc / 15
fjr1 = fajrtime
fajrtime = fajrtime - fjr1
fjr = floor(fajrtime * 60)
'dhr = Dec2Bcd(dhr)
'dhr1 = Dec2Bcd(dhr1)
'fjr = Dec2Bcd(fjr)
'fjr1 = Dec2Bcd(fjr1)
if asr1 > 12 then
asr1 = asr1 - 12
end if
if marb1 > 12 then
marb1 = marb1 - 12
end if
if esha1 > 12 then
esha1 = esha1 - 12
end if
Only month_ data is passed. Is it correct ?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?