void SunriseSunsetCalculations(u8 SolarNoonOffsetInDeciHours,u8 SolarNoonOffsetDirection){
if(SolarNoonOffsetInDeciHours>20){SolarNoonOffsetInDeciHours=0;}
u8 a[13][12]={
{120,120,120,120,120,120,120,120,120,120,120,120},
{126,125,124,123,122,121,119,118,116,115,115,114},
{129,128,127,125,123,121,119,117,115,113,112,111},
{132,131,129,127,124,121,118,115,113,110,109,108},
{135,134,131,128,125,122,118,114,111,108,106,105},
{139,137,134,130,127,122,117,113,108,105,102,101},
{143,141,137,133,128,123,117,111,106,102, 98, 97},
{148,145,141,135,130,123,116,109,103, 98, 94, 92},
{154,150,145,138,132,124,115,107,100, 93, 88, 86},
{161,157,150,142,134,124,114,105, 96, 88, 82, 79},
{170,165,156,146,137,125,113,102, 91, 81, 73, 69},
{183,176,165,152,140,126,112, 98, 84, 72, 61, 56},
{200,185,171,152,134,121,101, 84, 65, 53, 40, 33}
};
u8 b[]={6,12,17,22,27,32,37,42,47,52,57,62,90};
u8 lat=gps.Lat/10000000;
u8 i=0; while(b[i]<lat){i++;}
u8 k,ix;
k=gps.Day/15;if(k){k=1;}
if(!gps.LatDir){
if(gps.Mth<7){
ix=(gps.Mth-1)*2+k;
}else{
ix=11-(gps.Mth-7)*2-k;
}
}else{
if(gps.Mth<7){
ix=11-(gps.Mth-1)*2-k;
}else{
ix=(gps.Mth-7)*2+k;
}
}
u8 h=a[i][ix]/2;
u8 j[]={-1,1};
u8 sn=120+SolarNoonOffsetInDeciHours*j[SolarNoonOffsetDirection];
u8 srdh=sn-h;
u8 ssdh=sn+h;
gps.HmSunRise=deciHourTohhmm(srdh);
gps.HmSunSet =deciHourTohhmm(ssdh);
}
u16 deciHourTohhmm(u8 dh){
u16 h=(dh/10)*100;
u8 r= dh%10;
u8 m= 6*r;
return(h+m);
}