/*公历节日数据库-------------------------------------------------------------*/
void days (void)
{ month=ds_read(ADDRESS_MONTH_887);
date=ds_read(ADDRESS_DAY_OF_MONTH_887);
month_moon=ds_read(ADDRESS_MONTH_887);
date_moon=ds_read(ADDRESS_DAY_OF_MONTH_887);
lcd_write_com(0x98);//在液晶屏的第四行第一列显示以下节日提示
if ( month == 1 && date == 1 ){ lcd_write_multibyte(" 元旦快乐 "); }//1月
if ( month == 1 && date == 28 ){ lcd_write_multibyte(" 世界麻风日 "); }
if (month_moon== 0x01 && date_moon == 0x01 ){ lcd_write_multibyte(" 春节快乐 "); }
if (month_moon== 0x01 && date_moon == 0x15 ){ lcd_write_multibyte(" 元宵节快乐 "); }
if (month_moon== 0x02 && date_moon == 0x02 ){ lcd_write_multibyte(" 青龙节 "); }
if ( month == 2 && date == 2 ){ lcd_write_multibyte(" 世界湿地日 "); }//2月
if ( month == 2 && date == 13 ){ lcd_write_multibyte(" 明天情人节了 "); }
if ( month == 2 && date == 14 ){ lcd_write_multibyte(" 今天是情人节 "); }
if ( month == 3 && date == 1 ){ lcd_write_multibyte(" 国际海豹日 "); }//3月
if ( month == 3 && date == 3 ){ lcd_write_multibyte(" 全国爱耳日 "); }
if ( month == 3 && date == 8 ){ lcd_write_multibyte("国际劳动妇女节 "); }
if ( month == 3 && date == 12 ){ lcd_write_multibyte(" 植树节 "); }
if ( month == 3 && date == 14 ){ lcd_write_multibyte(" 国际警_察日 "); }
if ( month == 3 && date == 15 ){ lcd_write_multibyte(" 消费者权益日 "); }
if ( month == 3 && date == 17 ){ lcd_write_multibyte(" 国际航海日 "); }
if ( month == 3 && date == 21 ){ lcd_write_multibyte(" 世界森林日 "); }
if ( month == 3 && date == 22 ){ lcd_write_multibyte(" 世界水日 "); }
if ( month == 3 && date == 23 ){ lcd_write_multibyte(" 世界气象日 "); }
if ( month == 3 && date == 24 ){ lcd_write_multibyte("世界防治结核病日"); }
if ( month == 4 && date == 1 ){ lcd_write_multibyte("愚人节 小心上当"); }//4
if ( month == 4 && date == 7 ){ lcd_write_multibyte(" 世界卫生日 "); }
if ( month == 4 && date == 8 ){ lcd_write_multibyte(" 复活节 "); }
if ( month == 4 && date == 13 ){ lcd_write_multibyte(" 黑 {MOD}星期五 "); }
if ( month == 5 && date == 1 ){ lcd_write_multibyte("五一国际劳动节 "); }//5
if ( month == 5 && date == 4 ){ lcd_write_multibyte(" 青年节 "); }
if ( month == 5 && date == 8 ){ lcd_write_multibyte(" 世界红十字日 "); }
if ( month == 5 && date == 12 ){ lcd_write_multibyte(" 国际护士节 "); }
if ( month == 5 && date == 5 ){ lcd_write_multibyte("近日请注意母亲节"); }
if ( month == 5 && date == 15 ){ lcd_write_multibyte(" 国际家庭日 "); }
if ( month == 5 && date == 31 ){ lcd_write_multibyte(" 世界无烟日 "); }
if ( month == 6 && date == 1 ){ lcd_write_multibyte(" 国际儿童节 "); }//6
if ( month == 6 && date == 5 ){ lcd_write_multibyte(" 世界环境日 "); }
if ( month == 6 && date == 26 ){ lcd_write_multibyte(" 国际禁毒日 "); }
if ( month == 6 && date == 6 ){ lcd_write_multibyte(" 全国爱眼日 "); }
if ( month == 6 && date == 13 ){ lcd_write_multibyte("近日请注意父亲节"); }
if ( month == 6 && date == 15 ){ lcd_write_multibyte("近日请注意父亲节"); }
if ( month == 7 && date == 1 ){ lcd_write_multibyte(" 七一_党生日 "); }//7
if ( month == 7 && date == 7 ){ lcd_write_multibyte("抗日战争纪念日 "); }
if ( month == 7 && date == 11 ){ lcd_write_multibyte(" 世界人口日 "); }
if ( month == 8 && date == 1 ){ lcd_write_multibyte(" 八一建军节 "); }//8
if ( month == 8 && date == 8 ){ lcd_write_multibyte(" 中国男子节 "); }
if ( month == 8 && date == 15 ){ lcd_write_multibyte("抗战胜利纪念日 "); }
if ( month == 9 && date == 10 ){ lcd_write_multibyte(" 中国教师节 "); }//9
if ( month == 9 && date == 18 ){ lcd_write_multibyte("九一八事变纪念日"); }
if ( month == 9 && date == 20 ){ lcd_write_multibyte(" 国际爱牙日 "); }
if ( month == 9 && date == 27 ){ lcd_write_multibyte(" 世界旅游日 "); }
if ( month == 10 && date == 1 ){ lcd_write_multibyte(" 中国国庆节 "); }//10
if ( month == 10 && date == 4 ){ lcd_write_multibyte(" 世界动物日 "); }
if ( month == 10 && date == 24 ){ lcd_write_multibyte(" 联合国日 "); }
if ( month == 10 && date == 12 ){ lcd_write_multibyte("明天是国际教师节"); }
if ( month == 10 && date == 13 ){ lcd_write_multibyte(" 国际教师节 "); }
if ( month == 11 && date == 10 ){ lcd_write_multibyte(" 世界青年节 "); }//11
if ( month == 11 && date == 17 ){ lcd_write_multibyte(" 世界学生节 "); }
if ( month == 12 && date == 1 ){ lcd_write_multibyte(" 世界艾滋病日 "); }//12
if ( month == 12 && date == 23 ){ lcd_write_multibyte(" 明晚平安夜 "); }
if ( month == 12 && date == 24 ){ lcd_write_multibyte(" 今晚平安夜 "); }
if ( month == 12 && date == 25 ){ lcd_write_multibyte(" 圣诞快乐 "); }
if ( month == 12 && date == 31 ){ lcd_write_multibyte(" 明日新年 "); }
else{
shi=ds_read(ADDRESS_HOUR_887);
if ( shi >= 4 && shi < 6 ){ lcd_write_multibyte("★★__▲▲__凌晨"); }
if ( shi >= 6 && shi < 8 ){ lcd_write_multibyte("☆○__▲△__早晨"); }
if ( shi >= 8 && shi < 12 ){ lcd_write_multibyte("__●__▲▲__上午"); }
if ( shi >= 13 && shi < 14 ){ lcd_write_multibyte("____▲●▲__中午"); }
if ( shi >= 15 && shi < 22 ){ lcd_write_multibyte("__▲▲__●__下午"); }
if ( shi >= 22 && shi <= 23 ){ lcd_write_multibyte("△▲__●☆__晚上"); }
if ( shi >= 0 && shi < 4 ){ lcd_write_multibyte("△▲__★☆__夜里"); }
}
}
/********阳历转换阴历********************************************************************/
code uchar year_code[597]={
0x04,0xAe,0x53, //1901 0
0x0A,0x57,0x48, //1902 3
0x55,0x26,0xBd, //1903 6
0x0d,0x26,0x50, //1904 9
0x0d,0x95,0x44, //1905 12
0x46,0xAA,0xB9, //1906 15
0x05,0x6A,0x4d, //1907 18
0x09,0xAd,0x42, //1908 21
0x24,0xAe,0xB6, //1909
0x04,0xAe,0x4A, //1910
0x6A,0x4d,0xBe, //1911
0x0A,0x4d,0x52, //1912
0x0d,0x25,0x46, //1913
0x5d,0x52,0xBA, //1914
0x0B,0x54,0x4e, //1915
0x0d,0x6A,0x43, //1916
0x29,0x6d,0x37, //1917
0x09,0x5B,0x4B, //1918
0x74,0x9B,0xC1, //1919
0x04,0x97,0x54, //1920
0x0A,0x4B,0x48, //1921
0x5B,0x25,0xBC, //1922
0x06,0xA5,0x50, //1923
0x06,0xd4,0x45, //1924
0x4A,0xdA,0xB8, //1925
0x02,0xB6,0x4d, //1926
0x09,0x57,0x42, //1927
0x24,0x97,0xB7, //1928
0x04,0x97,0x4A, //1929
0x66,0x4B,0x3e, //1930
0x0d,0x4A,0x51, //1931
0x0e,0xA5,0x46, //1932
0x56,0xd4,0xBA, //1933
0x05,0xAd,0x4e, //1934
0x02,0xB6,0x44, //1935
0x39,0x37,0x38, //1936
0x09,0x2e,0x4B, //1937
0x7C,0x96,0xBf, //1938
0x0C,0x95,0x53, //1939
0x0d,0x4A,0x48, //1940
0x6d,0xA5,0x3B, //1941
0x0B,0x55,0x4f, //1942
0x05,0x6A,0x45, //1943
0x4A,0xAd,0xB9, //1944
0x02,0x5d,0x4d, //1945
0x09,0x2d,0x42, //1946
0x2C,0x95,0xB6, //1947
0x0A,0x95,0x4A, //1948
0x7B,0x4A,0xBd, //1949
0x06,0xCA,0x51, //1950
0x0B,0x55,0x46, //1951
0x55,0x5A,0xBB, //1952
0x04,0xdA,0x4e, //1953
0x0A,0x5B,0x43, //1954
0x35,0x2B,0xB8, //1955
0x05,0x2B,0x4C, //1956
0x8A,0x95,0x3f, //1957
0x0e,0x95,0x52, //1958
0x06,0xAA,0x48, //1959
0x7A,0xd5,0x3C, //1960
0x0A,0xB5,0x4f, //1961
0x04,0xB6,0x45, //1962
0x4A,0x57,0x39, //1963
0x0A,0x57,0x4d, //1964
0x05,0x26,0x42, //1965
0x3e,0x93,0x35, //1966
0x0d,0x95,0x49, //1967
0x75,0xAA,0xBe, //1968
0x05,0x6A,0x51, //1969
0x09,0x6d,0x46, //1970
0x54,0xAe,0xBB, //1971
0x04,0xAd,0x4f, //1972
0x0A,0x4d,0x43, //1973
0x4d,0x26,0xB7, //1974
0x0d,0x25,0x4B, //1975
0x8d,0x52,0xBf, //1976
0x0B,0x54,0x52, //1977
0x0B,0x6A,0x47, //1978
0x69,0x6d,0x3C, //1979
0x09,0x5B,0x50, //1980
0x04,0x9B,0x45, //1981
0x4A,0x4B,0xB9, //1982
0x0A,0x4B,0x4d, //1983
0xAB,0x25,0xC2, //1984
0x06,0xA5,0x54, //1985
0x06,0xd4,0x49, //1986
0x6A,0xdA,0x3d, //1987
0x0A,0xB6,0x51, //1988
0x09,0x37,0x46, //1989
0x54,0x97,0xBB, //1990
0x04,0x97,0x4f, //1991
0x06,0x4B,0x44, //1992
0x36,0xA5,0x37, //1993
0x0e,0xA5,0x4A, //1994
0x86,0xB2,0xBf, //1995
0x05,0xAC,0x53, //1996
0x0A,0xB6,0x47, //1997
0x59,0x36,0xBC, //1998
0x09,0x2e,0x50, //1999 294
0x0C,0x96,0x45, //2000 297
0x4d,0x4A,0xB8, //2001
0x0d,0x4A,0x4C, //2002
0x0d,0xA5,0x41, //2003
0x25,0xAA,0xB6, //2004
0x05,0x6A,0x49, //2005
0x7A,0xAd,0xBd, //2006
0x02,0x5d,0x52, //2007
0x09,0x2d,0x47, //2008
0x5C,0x95,0xBA, //2009
0x0A,0x95,0x4e, //2010
0x0B,0x4A,0x43, //2011
0x4B,0x55,0x37, //2012
0x0A,0xd5,0x4A, //2013
0x95,0x5A,0xBf, //2014
0x04,0xBA,0x53, //2015
0x0A,0x5B,0x48, //2016
0x65,0x2B,0xBC, //2017
0x05,0x2B,0x50, //2018
0x0A,0x93,0x45, //2019
0x47,0x4A,0xB9, //2020
0x06,0xAA,0x4C, //2021
0x0A,0xd5,0x41, //2022
0x24,0xdA,0xB6, //2023
0x04,0xB6,0x4A, //2024
0x69,0x57,0x3d, //2025
0x0A,0x4e,0x51, //2026
0x0d,0x26,0x46, //2027
0x5e,0x93,0x3A, //2028
0x0d,0x53,0x4d, //2029
0x05,0xAA,0x43, //2030
0x36,0xB5,0x37, //2031
0x09,0x6d,0x4B, //2032
0xB4,0xAe,0xBf, //2033
0x04,0xAd,0x53, //2034
0x0A,0x4d,0x48, //2035
0x6d,0x25,0xBC, //2036
0x0d,0x25,0x4f, //2037
0x0d,0x52,0x44, //2038
0x5d,0xAA,0x38, //2039
0x0B,0x5A,0x4C, //2040
0x05,0x6d,0x41, //2041
0x24,0xAd,0xB6, //2042
0x04,0x9B,0x4A, //2043
0x7A,0x4B,0xBe, //2044
0x0A,0x4B,0x51, //2045
0x0A,0xA5,0x46, //2046
0x5B,0x52,0xBA, //2047
0x06,0xd2,0x4e, //2048
0x0A,0xdA,0x42, //2049
0x35,0x5B,0x37, //2050
0x09,0x37,0x4B, //2051
0x84,0x97,0xC1, //2052
0x04,0x97,0x53, //2053
0x06,0x4B,0x48, //2054
0x66,0xA5,0x3C, //2055
0x0e,0xA5,0x4f, //2056
0x06,0xB2,0x44, //2057
0x4A,0xB6,0x38, //2058
0x0A,0xAe,0x4C, //2059
0x09,0x2e,0x42, //2060
0x3C,0x97,0x35, //2061
0x0C,0x96,0x49, //2062
0x7d,0x4A,0xBd, //2063
0x0d,0x4A,0x51, //2064
0x0d,0xA5,0x45, //2065
0x55,0xAA,0xBA, //2066
0x05,0x6A,0x4e, //2067
0x0A,0x6d,0x43, //2068
0x45,0x2e,0xB7, //2069
0x05,0x2d,0x4B, //2070
0x8A,0x95,0xBf, //2071
0x0A,0x95,0x53, //2072
0x0B,0x4A,0x47, //2073
0x6B,0x55,0x3B, //2074
0x0A,0xd5,0x4f, //2075
0x05,0x5A,0x45, //2076
0x4A,0x5d,0x38, //2077
0x0A,0x5B,0x4C, //2078
0x05,0x2B,0x42, //2079
0x3A,0x93,0xB6, //2080
0x06,0x93,0x49, //2081
0x77,0x29,0xBd, //2082
0x06,0xAA,0x51, //2083
0x0A,0xd5,0x46, //2084
0x54,0xdA,0xBA, //2085
0x04,0xB6,0x4e, //2086
0x0A,0x57,0x43, //2087
0x45,0x27,0x38, //2088
0x0d,0x26,0x4A, //2089
0x8e,0x93,0x3e, //2090
0x0d,0x52,0x52, //2091
0x0d,0xAA,0x47, //2092
0x66,0xB5,0x3B, //2093
0x05,0x6d,0x4f, //2094
0x04,0xAe,0x45, //2095
0x4A,0x4e,0xB9, //2096
0x0A,0x4d,0x4C, //2097
0x0d,0x15,0x41, //2098
0x2d,0x92,0xB5, //2099
};
///月份数据表
code uchar date_code1[9]={0x0,0x1f,0x3b,0x5a,0x78,0x97,0xb5,0xd4,0xf3};
code uint date_code2[3]={0x111,0x130,0x14e};
bit c_moon;
data uchar year_moon,month_moon,date_moon,week;
bit get_moon_date(uchar month_p,uint table_addr)
{
uchar temp;
switch (month_p){
case 1:{temp=year_code[table_addr]&0x08;
if (temp==0)return(0);else return(1);}
case 2:{temp=year_code[table_addr]&0x04;
if (temp==0)return(0);else return(1);}
case 3:{temp=year_code[table_addr]&0x02;
if (temp==0)return(0);else return(1);}
case 4:{temp=year_code[table_addr]&0x01;
if (temp==0)return(0);else return(1);}
case 5:{temp=year_code[table_addr+1]&0x80;
if (temp==0) return(0);else return(1);}
case 6:{temp=year_code[table_addr+1]&0x40;
if (temp==0)return(0);else return(1);}
case 7:{temp=year_code[table_addr+1]&0x20;
if (temp==0)return(0);else return(1);}
case 8:{temp=year_code[table_addr+1]&0x10;
if (temp==0)return(0);else return(1);}
case 9:{temp=year_code[table_addr+1]&0x08;
if (temp==0)return(0);else return(1);}
case 10:{temp=year_code[table_addr+1]&0x04;
if (temp==0)return(0);else return(1);}
case 11:{temp=year_code[table_addr+1]&0x02;
if (temp==0)return(0);else return(1);}
case 12:{temp=year_code[table_addr+1]&0x01;
if (temp==0)return(0);else return(1);}
case 13:{temp=year_code[table_addr+2]&0x80;
if (temp==0)return(0);else return(1);}
}
}
//---------------------------------------------------------
void Conversion(bit c,uchar year,uchar month,uchar date) //转换
{
uchar temp1,temp2,temp3,month_p;
uint temp4,table_addr;
bit flag2,flag_y;
temp1=year/16; //BCD->hex 先把数据转换为十六进制
temp2=year%16;
year=temp1*10+temp2;
temp1=month/16;
temp2=month%16;
month=temp1*10+temp2;
temp1=date/16;
temp2=date%16;
date=temp1*10+temp2;
//定位数据表地址
if(c==0){
table_addr=(year+0x64-1)*0x3;
}
else {
table_addr=(year-1)*0x3;
}
temp1=year_code[table_addr+2]&0x60;
temp1=_cror_(temp1,5);
temp2=year_code[table_addr+2]&0x1f;
if(temp1==0x1){
temp3=temp2-1;
}
else{
temp3=temp2+0x1f-1;
}
if (month<10){
temp4=date_code1[month-1]+date-1;
}
else{
temp4=date_code2[month-10]+date-1;
}
if ((month>0x2)&&(year%0x4==0)){ //如果公历月大于2月并且该年的2月为闰月,天数加1
temp4+=1;
}
if (temp4>=temp3){ //公历日在春节后或就是春节当日使用下面代码进行运算
temp4-=temp3;
month=0x1;
month_p=0x1; //month_p为月份指向,公历日在春节前或就是春节当日month_p指向首月
flag2=get_moon_date(month_p,table_addr); //检查该农历月为大小还是小月,大月返回1,小月返回0
flag_y=0;
if(flag2==0)temp1=0x1d; //小月29天
else temp1=0x1e; //大小30天
temp2=year_code[table_addr]&0xf0;
temp2=_cror_(temp2,4); //从数据表中取该年的闰月月份,如为0则该年无闰月
while(temp4>=temp1){
temp4-=temp1;
month_p+=1;
if(month==temp2){
flag_y=~flag_y;
if(flag_y==0)month+=1;
}
else month+=1;
flag2=get_moon_date(month_p,table_addr);
if(flag2==0)temp1=0x1d;
else temp1=0x1e;
}
date=temp4+1;
}
else{ //公历日在春节前使用下面代码进行运算
temp3-=temp4;
if (year==0x0){year=0x63;c=1;}
else year-=1;
table_addr-=0x3;
month=0xc;
temp2=year_code[table_addr]&0xf0;
temp2=_cror_(temp2,4);
if (temp2==0)month_p=0xc;
else month_p=0xd; //
flag_y=0;
flag2=get_moon_date(month_p,table_addr);
if(flag2==0)temp1=0x1d;
else temp1=0x1e;
while(temp3>temp1){
temp3-=temp1;
month_p-=1;
if(flag_y==0)month-=1;
if(month==temp2)flag_y=~flag_y;
flag2=get_moon_date(month_p,table_addr);
if(flag2==0)temp1=0x1d;
else temp1=0x1e;
}
date=temp1-temp3+1;
}
c_moon=c; //HEX->BCD ,运算结束后,把数据转换为BCD数据
temp1=year/10;
temp1=_crol_(temp1,4);
temp2=year%10;
year_moon=temp1|temp2;
temp1=month/10;
temp1=_crol_(temp1,4);
temp2=month%10;
month_moon=temp1|temp2;
temp1=date/10;
temp1=_crol_(temp1,4);
temp2=date%10;
date_moon=temp1|temp2;
}
//-------------------------------------------------------
void nl() //
{
unsigned char yy1,yy2;
if(cen==0x19) {cen_m=1;}
if(cen==0x20) {cen_m=0;}
Conversion(cen_m,year,month,date);
lcd_write_com(0x85);
lcd_write_data(month_moon/16+'0');
lcd_write_data(month_moon%16+'0');
lcd_write_data('-');
lcd_write_data(date_moon/16+'0');
lcd_write_data(date_moon%16+'0');
yy1=ds_read(ADDRESS_YEAR_887);
// yy1=(year_moon/16)*10+year_moon%16;
yy2=yy1%12;
switch(yy2)
{
case 0: lcd_write_com(0x82);lcd_write_multibyte("龙");
break;
case 1: lcd_write_com(0x82);lcd_write_multibyte("蛇");
break;
case 2: lcd_write_com(0x82);lcd_write_multibyte("马");
break;
case 3: lcd_write_com(0x82);lcd_write_multibyte("羊");
break;
case 4: lcd_write_com(0x82);lcd_write_multibyte("猴");
break;
case 5: lcd_write_com(0x82);lcd_write_multibyte("鸡");
break;
case 6: lcd_write_com(0x82);lcd_write_multibyte("狗");
break;
case 7: lcd_write_com(0x82);lcd_write_multibyte("猪");
break;
case 8: lcd_write_com(0x82);lcd_write_multibyte("鼠");
break;
case 9: lcd_write_com(0x82);lcd_write_multibyte("牛");
break;
case 10: lcd_write_com(0x82);lcd_write_multibyte("虎");
break;
case 11: lcd_write_com(0x82);lcd_write_multibyte("兔");
break;
}
}
一周热门 更多>