带农历及农历纪念日的万年历c程序
JAVA《万年历系统》课程设计报告附源码
2013-2014学年第二学期《面向对象程序设计》课程设计报告题目:万年历系统专业:计算机科学与技术班级:姓名:学号:指导教师:成绩:计算机与信息工程系2014年6月6日目录1 设计内容及要求 (1)1.1设计内容 (1)1.2设计任务及具体要求 (1)2 概要设计 (2)2.1程序设计思路 (2)2.2 总体程序框图 (3)3 设计过程或程序代码 (4)3.1各个模块的程序流程图及运行界面 (4)3.2对关键代码加以分析说明 (7)4 设计结果与分析 (13)4.1程序调试的结果 (13)4.2程序设计分析 (13)5 小结 (14)致谢 (15)参考文献 (16)源程序 (17)1 设计内容及要求1.1设计内容万年历,实际上就是记录一定时间范围内(比如100年或更多)的具体阳历或阴历的日期的年历,方便有需要的人查询使用。
在我设计的万年历中主要有:(1)使用图形用户界面来查询用用户所需的日期信息,符合日常软件使用规范。
(2)按月份查询,实现了显示查询1901~2100年某月所有日期的阴阳历对照。
(3)并且添加了重大节日与星座等信息,界面采用日常的星期与月份结合的格式,方便查看与使用。
(4)编写万年历的课程设计,是为了使同学们更加了解高级程序设计语言的结构,掌握基本的程序设计过程和技巧,掌握基本的分析问题和利用计算机求解问题的能力,具备初步的高级语言程序设计能力。
为后续各门计算机课程的学习和毕业设计打下坚实基础。
1.2设计任务及具体要求利用JAVA语言编写的万年历系统采用了多种JAVA语句来实现多种功能。
用户可以通过本程序的applet运行界面来查找一整年某月的农历和阳历,可以查找用户所想了解的某一天具体为星期几,并且可以看到一些重大节日的具体时间。
要求:满足设计万年历系统的目的,即当用户查询年份与月份时,系统就要将这一年的某一月份的阴历与阳历全部显示出来,并且附带这一月份的重大节日。
当用户随意改动年份或月份时系统自动显示与星期对应的日期。
C#实现农历日历的方法
C#实现农历⽇历的⽅法本⽂实例讲述了C#实现农历⽇历的⽅法。
分享给⼤家供⼤家参考。
具体实现⽅法如下:复制代码代码如下://天⼲private static string []TianGan = {"甲","⼄","丙","丁","戊","⼰","庚","⾟","壬","癸"};//地⽀private static string []DiZhi = {"⼦","丑","寅","卯","⾠","巳","午","未","申","⾣","戌","亥"};//⼗⼆⽣肖private static string []ShengXiao = {"⿏","⽜","虎","兔","龙","蛇","马","⽺","猴","鸡","狗","猪"};//农历⽇期private static string []DayName = {"*","初⼀","初⼆","初三","初四","初五","初六","初七","初⼋","初九","初⼗", "⼗⼀","⼗⼆","⼗三","⼗四","⼗五", "⼗六","⼗七","⼗⼋","⼗九","⼆⼗", "廿⼀","廿⼆","廿三","廿四","廿五", "廿六","廿七","廿⼋","廿九","三⼗"};//农历⽉份private static string []MonthName = {"*","正","⼆","三","四","五","六","七","⼋","九","⼗","⼗⼀","腊"};//公历⽉计数天private static int []MonthAdd = {0,31,59,90,120,151,181,212,243,273,304,334};//农历数据private static int []LunarData = {2635,333387,1701,1748,267701,694,2391,133423,1175,396438,3402,3749,331177,1453,694,201326,2350,465197,3221,3402,400202,2901,1386,267611,605,2349,137515,2709,464533,1738,2901,330421,1242,2651,199255,1323,529706,3733,1706,398762,2741,1206,267438,2647,1318,204070,3477,461653,1386,2413,330077,1197,2637,268877,3365,531109,2900,2922,398042,2395,1179,267415,2635,661067,1701,1748,398772,2742,2391,330031,1175,1611,200010,3749,527717,1452,2742,332397,2350,3222,268949,3402,3493,133973,1386,464219,605,2349,334123,2709,2890,267946,2773,592565,1210,2651,395863,1323,2707,265877};/// <summary>/// 获取对应⽇期的农历////// </summary>/// <param name="dtDay">公历⽇期</param>//////<returns></returns>public string GetLunarCalendar(DateTime dtDay){string sYear = dtDay.Year.ToString(); string sMonth = dtDay.Month.ToString();string sDay = dtDay.Day.ToString();int year;int month;int day;try {year = int.Parse(sYear);month = int.Parse(sMonth);day = int.Parse(sDay);}catch {year = DateTime.Now.Year;month = DateTime.Now.Month;day = DateTime.Now.Day;}int nTheDate;int nIsEnd;int k, m, n, nBit, i;string calendar = string.Empty;//计算到初始时间1921年2⽉8⽇的天数:1921-2-8(正⽉初⼀)nTheDate = (year - 1921) * 365 + (year - 1921) / 4 + day + MonthAdd[month - 1] - 38; if ((year % 4 == 0) && (month > 2)) nTheDate += 1;//计算天⼲,地⽀,⽉,⽇nIsEnd = 0; m = 0; k = 0; n = 0;while (nIsEnd != 1){if (LunarData[m] < 4095) k = 11; else k = 12; n = k; while (n >= 0){ //获取LunarData[m]的第n个⼆进制位的值nBit = LunarData[m];for (i = 1; i < n + 1; i++) nBit = nBit / 2;nBit = nBit % 2;if (nTheDate <= (29 + nBit)) { nIsEnd = 1; break; }nTheDate = nTheDate - 29 - nBit; n = n - 1;}if (nIsEnd == 1) break; m = m + 1;}year = 1921 + m; month = k - n + 1; day = nTheDate;#region 格式化⽇期显⽰为三⽉廿四if (k == 12){if (month == LunarData[m] / 65536 + 1)month = 1 - month;else if (month > LunarData[m] / 65536 + 1)month = month - 1;}//⽣肖//calendar = ShengXiao[(year - 4) % 60 % 12].ToString() + "年 ";// // //天⼲// //calendar += TianGan[(year - 4) % 60 % 10].ToString();// // //地⽀// //calendar += DiZhi[(year - 4) % 60 % 12].ToString() + " ";//// //农历⽉//if (month < 1)//calendar += "闰" + MonthName[-1 * month].ToString() + "⽉";elsecalendar += MonthName[month].ToString() + "⽉";//// //农历⽇//calendar += DayName[day].ToString() + "⽇";////return calendar;////#endregion}希望本⽂所述对⼤家的C#程序设计有所帮助。
CC++程序设计——万年历(完整代码+实验报告)
2、主要函数流程图: (1)类的构造函数:用于给类的对象赋值。提示用户输入数据,并具有较强的错误输 入数据检查功能。(参见图 3-1) (2)闰年判断函数:判断哪些年份为闰年。 (图 3-2)
正文 第 2 页(共 18 页)
开 始
开 始
year%4==0
否
输入待查询的 年份
是
否
year%100==0
* ","***** ","***** ","***** ","***** ","***** "," * ","***** ","***** "," * ","***** ","***** ","
"***** ","
=====================公元"<<year<<"年日历====================="<<endl; =====================公元"<<year<<"年日历====================="<<endl;
/*实现 3 维数组图案的输出*/ for(int g=0;g<5;g++) { cout<<" fout<<" for(int i=0;i<4;i++) for(int h=0;h<7;h++) { cout<<ss[g][num[i]][h]; fout<<ss[g][num[i]][h]; } cout<<endl; fout<<endl; } }
C语言课程设计万年历 完整版
目录一引言 (2)二系统功能和数据说明 (3)一)功能简介 (3)二)程序中的数据说明 (3)三程序总体设计及流程图 (4)一)应用到的c语言 (4)二)程序的总框架 (5)四功能模块设计及调试 (5)一)算法说明 (5)1.总天数的算法 (5)2.计算输入日期是星期几 (6)3.对输入信息的汇总 (8)4..界面的控制 (10)二)调试结果 (11)五程序清单 (12)六结束语 (17)一引言通过大一上学期对C语言的学习,了解到了很多C语言的相关知识。
学习的过程有很多困惑但是当自己能够独立的看懂,能过独立的完成一个简单的程序时,心中就会收获无限的喜悦和成就感。
我可以里哟哦那个它看懂一些简单的程序,编写一些简单的计算程序,更多的是学会了一种思想——编程,它让我在去思考很多日常生活中的事物是怎么样通过一个个小小的函数实现功能的,激发我对探究的兴趣。
C语言是近年在国内外得到迅速推广应用的一种语言。
C语言功能丰富,表达能力强,使用灵活方便,应用面广,目标程序效率高,可移植性好,既具有高级语言的优点,又具有低级语言的许多特点。
因此,C语言特别适合于编写各种软件。
在这次的课程设计中我将把日常生活中最经常接触的——日期的查询利用C语言的程序编成一个简单的日历。
通过这个小小的日历可以实现很多功能。
在程序中你能看到很多熟悉的C语言关键字,同时也加入了很多自己课外了解到的一些关键字。
在不断的调试中最终才获得最为完整的程序。
接下来就是我的C 语言课程设计的具体内容来了二系统功能和数据说明(一)功能简介在我们的日常生活中能接触到很多不同类型的日历,在日历上我们通常希望它能简介明了的给我们最想要的日期信息。
在我的万年历当中,就是将日历,月历做的简单明了,很方便我们的使用。
下面是它要实现的一些基本功能:用C语言编写万年历1、输入年份,判断是否为闰年2、输入年月日,判断改日为星期几3、输入年份,打出12个月历,输入月份,打出该月的日历4、要求用多个函数实现[名称]万年历[修改]1、对输入的日期进行容错处理2、增加和修改为英文的月份和星期显示3、采用指针形式的weeks和month数组(二)程序中的数据说明①int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};这是定义的关于每个月天数的数组,根据大小月以及二月分的特殊情况将每个月的天数最为数组中的元素存入数组当中。
单片机万年历带阴历
程序说明:1: 公农历自动转换,星期根据公历日期自动换算。
2: 没有采用时间IC(如DS1302 等),而是直接用单片机内的定时器。
3: 可显示简单的国家法定节假日,如到了农历8 月15,“单片机学徒”五个字会变成“中秋节”。
4: 在农历日期中采用初,廿等符合农历的用字。
5: 公历日期和时间可调,农历与星期是根据公历日期自动换算所得,所以不必调整。
6: 程序最终显示如下图所示。
实际在本人办公桌上使用中。
7: 在实际制作中如有疑问,欢迎大家交流.单片机学徒于2011 年3 月。
#include <reg52.h>#include <intrins.h>#define uchar unsigned char#define uint unsigned int#define port P0#define TT 49962uchar month,day,week,one,two,thr,fou,fiv,key_v,key_t,flagt;uchar year,yyear,ymonth,yday,key;char hour,min,sec;bit flagjr = 0;bit flagturn;bit flagnl = 0;sbit e = P2^3;sbit rw = P2^4;sbit rs = P2^5;sbit cs1 = P2^6;sbit cs2 = P2^7;sbit add = P3^3;sbit ok = P3^4;sbit set = P3^5;sbit dec = P3^6;sbit armn = P3^1;sbit armh = P3^7;void refweek();void key_t0(key_v);void displayday();void lcd_datey(uint x,uchar y,uchar z);uchar monthcode[]={0,31,0,31,30,31,30,31,31,30,31,30,31};uchar code day_code1[9]={0x0,0x1f,0x3b,0x5a,0x78,0x97,0xb5,0xd4,0xf3}; uint code day_code2[3]={0x111,0x130,0x14e};uchar code year_code[]={0x4d,0x4A,0xB8, //20010x0d,0x4A,0x4C, //20020x0d,0xA5,0x41, //20030x25,0xAA,0xB6, //20040x05,0x6A,0x49, //20050x7A,0xAd,0xBd, //20060x02,0x5d,0x52, //20070x09,0x2d,0x47, //20080x5C,0x95,0xBA, //20090x0A,0x95,0x4e, //20100x0B,0x4A,0x43, //20110x4B,0x55,0x37, //20120x0A,0xd5,0x4A, //20130x95,0x5A,0xBf, //20140x04,0xBA,0x53, //20150x0A,0x5B,0x48, //20160x65,0x2B,0xBC, //20170x05,0x2B,0x50, //20180x0A,0x93,0x45, //20190x47,0x4A,0xB9, //20200x06,0xAA,0x4C, //20210x24,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, //20650x05,0x6A,0x4e, //20670x0A,0x6d,0x43, //20680x45,0x2e,0xB7, //20690x05,0x2d,0x4B, //20700x8A,0x95,0xBf, //20710x0A,0x95,0x53, //20720x0B,0x4A,0x47, //20730x6B,0x55,0x3B, //20740x0A,0xd5,0x4f, //20750x05,0x5A,0x45, //20760x4A,0x5d,0x38, //20770x0A,0x5B,0x4C, //20780x05,0x2B,0x42, //20790x3A,0x93,0xB6, //20800x06,0x93,0x49, //20810x77,0x29,0xBd, //20820x06,0xAA,0x51, //20830x0A,0xd5,0x46, //20840x54,0xdA,0xBA, //20850x04,0xB6,0x4e, //20860x0A,0x57,0x43, //20870x45,0x27,0x38, //20880x0d,0x26,0x4A, //20890x8e,0x93,0x3e, //20900x0d,0x52,0x52, //20910x0d,0xAA,0x47, //20920x66,0xB5,0x3B, //20930x05,0x6d,0x4f, //20940x04,0xAe,0x45, //20950x4A,0x4e,0xB9, //20960x0A,0x4d,0x4C, //20970x0d,0x15,0x41, //20980x2d,0x92,0xB5, //2099};uchar code shuzi[][16]={{0xFF,0x0F,0x07,0xF3,0xFB,0xFB,0xF3,0x07,0xFF,0xF0,0xE0,0xCF,0xDF,0xD F,0xCF,0xE0},{0xFF,0xFF,0xF7,0xF7,0x03,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0xC 0,0xFF,0xFF},{0xFF,0xCF,0xC7,0xF3,0xFB,0xFB,0x73,0x07,0xFF,0xCF,0xC7,0xD3,0xD9,0xD C,0xDE,0xDF},{0xFF,0xEF,0xE7,0x73,0x7B,0x7B,0x33,0x87,0xFF,0xF7,0xE7,0xCF,0xDF,0xD F,0xCE,0xE0},B,0xC0,0xC0},{0xFF,0x03,0x03,0x3B,0xBB,0xBB,0x3B,0x7B,0xFF,0xF6,0xE6,0xCF,0xDF,0xD F,0xCF,0xE0},{0xFF,0x0F,0x07,0x33,0xBB,0xBB,0x33,0x67,0xFF,0xF0,0xE0,0xCF,0xDF,0xD F,0xCF,0xE0},{0xFF,0xFB,0xFB,0xFB,0x7B,0x1B,0x8B,0xE3,0xFF,0xFF,0xFF,0xC3,0xC0,0xF C,0xFF,0xFF},{0xFF,0xCF,0x87,0x33,0x7B,0x7B,0x33,0x87,0xFF,0xF1,0xE0,0xCE,0xDF,0xD F,0xCE,0xE0},{0xFF,0x0F,0x07,0xF3,0xFB,0xFB,0xF3,0x07,0xFF,0xF7,0xE6,0xCC,0xDD,0xD D,0x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1,0x67,0xB7,0xFF,0xF7,0xF7,0x07,0xF7,0xF7,0x0 3,0xF7,0xFF,0xFD,0xFE,0xFF,0x80,0xFE,0xFD,0xBB,0xDF,0xEF,0xF3,0xFC,0xDF,0xBF,0xC0 ,0xFF,0xFF},{0xDF,0xDF,0xDF,0xDF,0x00,0xDF,0xDF,0xDF,0xDF,0xDF,0x00,0xDF,0xDF,0xD F,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0xDF,0xDF,0xDF,0xDF,0xDF,0x80,0xFF,0xFF,0xFF ,0xFF,0xFF},};void Delay(uint a){uchar i;while(a--)for(i=0;i<125;i++);}void Lcd_Display_On(){port=0x3f;rs=0;rw=0;e=1;e=0;}void Lcd_Display_Off(){port=0x3e;rs=0;rw=0;e=1;e=0;}void Lcd_Set_X(uchar x){port=0xb8|x;rs=0;rw=0;e=1;e=0;}void Lcd_Set_Y(uchar y){port=0x40|y;rs=0;rw=0;e=1;e=0;}void Lcd_Set_X_Y(uchar x, uchar y){if( y<64 ){ cs1=1; cs2=0; Lcd_Set_Y( y ); }else{ cs1=0; cs2=1; Lcd_Set_Y( y-64 ); }Lcd_Set_X( x);}void Lcd_Write_Command(uchar temp){port=temp;rs=0;rw=0;e=1;e=0;}void Lcd_Write_Byte(uchar temp){port=temp;rs=1;rw=0;e=1;e=0;}void showword816( bit bit_flag, uchar x, uchar y, uchar code *point ) {uchar i , j,temp;temp=y;if( bit_flag ){for( i=0; i<2; i++ ){x+=i;y=temp;for( j=0;j<8;j++ ){Lcd_Set_X_Y( x, y ); y++;Lcd_Write_Byte( point[ i*8 + j] );}}}else{for( i = 0; i < 2; i++ ){x += i;y = temp;for( j = 0; j < 8; j++ ){Lcd_Set_X_Y( x, y ); y++;Lcd_Write_Byte( ~point[ i * 8 + j ] );}}}}void showword1616( bit bit_flag, uchar x, uchar y, uchar code *point ) {uchar i,j,temp ;temp=y;if( bit_flag ){for( i=0; i<2; i++ ){x+=i;y=temp;for( j=0;j<16;j++ ){Lcd_Set_X_Y( x, y ); y++;Lcd_Write_Byte( point[ i*16 + j] );}}else{for( i = 0; i<2; i++ ){x += i;y = temp;for( j = 0; j < 16; j++ ){Lcd_Set_X_Y( x, y ); y++;Lcd_Write_Byte( ~ point[ i * 16 + j ] );}}}}void Lcd_Clear(){uchar i,j;cs1=1;cs2=1;for(i=0;i<8;i++){Lcd_Set_X( i );Lcd_Set_Y( 0 );for(j=0;j<64;j++)Lcd_Write_Byte(0x00);}}void Lcd_init(){Lcd_Display_Off();Lcd_Write_Command(0xb8);Lcd_Write_Command(0x40);Lcd_Write_Command(0xc0);Lcd_Clear();Lcd_Display_On();}uchar leapyear(uint year){return(year%4==0&&year%100!=0)||(year%400==0); }void refweek(){uint i,d,w = 5;for (i=2000;i<2000+year;i++)d = leapyear(i)? 366:365;w = (w+d)%7;}d = 0;for (i=0;i<month;i++)d += monthcode[i];d += day;week = (w+d+6)%7;}bit get_moon_day(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(uchar year,uchar month,uchar day)uchar temp1,temp2,temp3,month_p;uint temp4,table_addr;bit flag_y;table_addr=(year-1)*3;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=day_code1[month-1]+day-1;}else{temp4=day_code2[month-10]+day-1;}if ((month>0x2)&&(year%0x4==0)){temp4+=1;}if (temp4>=temp3){temp4-=temp3;month=0x1;month_p=0x1;flag_y=0;if(get_moon_day(month_p,table_addr)==0)temp1=0x1d; else temp1=0x1e;temp2=year_code[table_addr]/16;while(temp4>=temp1){temp4-=temp1;month_p+=1;if(month==temp2){flag_y=~flag_y;if(flag_y==0)month+=1;}else month+=1;if(get_moon_day(month_p,table_addr)==0)temp1=0x1d; else temp1=0x1e;}day=temp4+1;}else{temp3-=temp4;year-=1;table_addr-=0x3;month=0xc;temp2=year_code[table_addr]/16;if (temp2==0)month_p=0xc;else month_p=0xd;flag_y=0;if(get_moon_day(month_p,table_addr)==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;if(get_moon_day(month_p,table_addr)==0)temp1=0x1d; else temp1=0x1e;}day=temp1-temp3+1;}yyear = year;ymonth = month;yday = day;flagnl = 1;}void mcuinit(){flagt = 0;flagjr = 1;flagnl = 0;year = 11;month = 3;day = 10;hour = 12;min = 0;sec = 0;TMOD = 0X01;TH0 = (65536-TT)/256;TL0 = (65536-TT)%256;EA = 1;ET0 = 1;EX0 = 1;IT0 = 1;TR0 = 1;}void displayday(){if ((ymonth==1 && yday==1)||(ymonth==5 && yday==5)||(ymonth==8 && yday==15)){if (ymonth==1 && yday==1){one = 29;two = 18;thr = 13;fou = 18;fiv = 19;}if (ymonth==5 && yday==5){one = 30;two = 18;thr = 17;fou = 18;fiv = 13;}if (ymonth==8 && yday==15){one = 6;two = 18;thr = 31;fou = 18;fiv = 13;}}else{((month==1&&day==1)||(month==5&&day==1)||(month==6&&day==1)||(month== 4&&day==1)||(month==3&&day==8)||(month==10&&day==1)){if (month==1&&day==1){one = 7;two = 18;thr = 8;fou = 18;fiv = 13;}if (month==3&&day==8){one = 22;two = 18;thr = 23;fou = 18;fiv = 13;}if (month==4&&day==1){one = 24;two = 18;thr = 21;fou = 18;fiv = 13;}if (month==5&&day==1){one = 9;two = 18;thr = 10;fou = 18;fiv = 13;}if (month==6&&day==1){one = 25;two = 18;thr = 26;fou = 18;fiv = 13;if (month==10&&day==1){one = 11;two = 18;thr = 12;fou = 18;fiv = 13;}}else{one = 32;two = 33;thr = 34;fou = 35;fiv = 36;}}flagjr = 0;}void display(){if (flagjr == 1){Conversion(year,month,day); displayday();}refweek();if (flagt == 1){showword816(0,0,32,shuzi[year/10]); showword816(0,0,40,shuzi[year%10]); }else{showword816(1,0,32,shuzi[year/10]); showword816(1,0,40,shuzi[year%10]); }if (flagt == 2){showword816(0,0,64,shuzi[month/10]); showword816(0,0,72,shuzi[month%10]); }else{showword816(1,0,64,shuzi[month/10]); showword816(1,0,72,shuzi[month%10]); }if (flagt == 3){showword816(0,0,96,shuzi[day/10]); showword816(0,0,104,shuzi[day%10]); }else{showword816(1,0,96,shuzi[day/10]); showword816(1,0,104,shuzi[day%10]); }showword816(1,4,32,gonli[yyear/10]); showword816(1,4,40,gonli[yyear%10]); if (ymonth == 1)showword1616(1,4,64,hanzi[27]);elseif (ymonth == 12)showword1616(1,4,64,hanzi[28]);else{showword816(1,4,64,gonli[ymonth/10]); showword816(1,4,72,gonli[ymonth%10]); }if (yday/10==0){showword1616(1,4,96,yinli[10]);}elseif (yday/10==1){if (yday%10==0)showword1616(1,4,96,yinli[10]);elseshowword1616(1,4,96,yinli[0]);}elseif (yday/10==2)showword1616(1,4,96,yinli[11]);elseif (yday/10 == 3)showword1616(1,4,112,yinli[yday%10]); if (flagt == 4){showword816(0,2,32,shisu[hour/10]); showword816(0,2,40,shisu[hour%10]); }else{showword816(1,2,32,shisu[hour/10]); showword816(1,2,40,shisu[hour%10]); }if (flagt == 5){showword816(0,2,64,shisu[min/10]); showword816(0,2,72,shisu[min%10]);}else{showword816(1,2,64,shisu[min/10]); showword816(1,2,72,shisu[min%10]);}if (flagt == 6){showword816(0,2,96,shisu[sec/10]); showword816(0,2,104,shisu[sec%10]); }else{showword816(1,2,96,shisu[sec/10]); showword816(1,2,104,shisu[sec%10]); }showword1616(1,6,16,xinqi[week]); showword1616(1,0,112,hanzi[2]); showword1616(1,4,0,hanzi[16]); showword816(1,4,16,gonli[2]); showword816(1,4,24,gonli[0]); showword1616(1,0,0,hanzi[15]); showword816(1,0,16,shuzi[2]); showword816(1,0,24,shuzi[0]); showword1616(1,0,48,hanzi[0]); showword1616(1,0,80,hanzi[1]); showword1616(1,4,48,hanzi[0]); showword1616(1,4,80,hanzi[1]);showword1616(1,2,16,hanzi[20]); showword1616(1,2,48,hanzi[3]); showword1616(1,2,80,hanzi[4]); showword1616(1,2,112,hanzi[5]); showword1616(1,6,0,hanzi[14]); showword1616(1,6,32,hanzi[18]); showword1616(1,6,48,hanzi[one]); showword1616(1,6,64,hanzi[two]); showword1616(1,6,80,hanzi[thr]); showword1616(1,6,96,hanzi[fou]); showword1616(1,6,112,hanzi[fiv]); }void int0_0() interrupt 0{if (set == 0){EX0 = 0;Delay(10);if (set == 0){while (!set);TR0 = 0;flagt++;if (flagt > 6)flagt = 1;}EX0 = 1;}if (flagt != 0){if (add == 0){EX0 = 0;Delay(10);if (add == 0){while (!add);if (flagt == 1){year++;if (year > 99)year = 1;flagjr = 1;Conversion(year,month,day);}if (flagt == 2){month++;if (month > 12)month = 1;flagjr = 1;Conversion(year,month,day);}if (flagt == 3){day++;if(month==1||month==3||month==5||month==7||month==8||month==10||month== 12){if (day > 31)day = 1;}if (month==4||month==6||month==9||month==11){if (day > 30)day = 1;}if (month==2){if (leapyear(year)){if (day > 29)day = 1;}else{if (day > 28)day = 1;}}flagjr = 1;Conversion(year,month,day);}if (flagt == 4){hour++;if (hour > 23)hour = 0;}if (flagt == 5){min++;if (min > 59)min = 0;}if(flagt == 6){sec++;if (sec > 59)sec = 0;}}EX0 = 1;}if (dec == 0){EX0 = 0;Delay(10);if (dec == 0){while (!dec);if (flagt == 1){year--;if (year < 1)year = 99;flagjr = 1;Conversion(year,month,day); }if (flagt == 2){month--;if (month < 1)month = 12;flagjr = 1;Conversion(year,month,day); }if (flagt == 3){day--;if(month==1||month==3||month==5||month==7||month==8||month==10||month== 12){if (day < 1)day = 31;}if (month==4||month==6||month==9||month==11){if (day < 1)day = 30;}if (month==2){if (leapyear(year)){if (day < 1)day = 29;}else{if (day < 1)day = 28;}}flagjr = 1;Conversion(year,month,day);}if (flagt == 4){hour--;if (hour < 0)hour = 23;}if (flagt == 5){min--;if (min < 0)min = 59;}if (flagt == 6){sec--;if (sec < 0)sec = 59;}}}EX0 = 1;}if (ok == 0){Delay(10);EX0 = 0;if (ok == 0){while (!ok);TR0 = 1;flagt = 0;flagjr = 1;Conversion(year,month,day); }EX0 = 1;}}void main(){Lcd_init();mcuinit();while (1){display();}}void timer0() interrupt 1 {static uchar i;TH0 = (65536-TT)/256;TL0 = (65536-TT)%256;i++;if(i>19){i = 0;sec++;if (sec>59){sec = 0;min++;。
月记事表-有农历得Excel打开-20240206
3 初三
11
4 初四
5 初五
6 初六
7 初七
8 初八
9 初九
10 初十
12
11 十一
12 十二
13 十三
14 十四
15 十五
16 十六
17
18
19
20
十七
十八
十九
廿
13
21 廿一
22 廿二
23 廿三
24
25
26
27
28
29
30
廿四
廿五
廿六
廿七
廿八
廿九
卅
14
月记事表
周次
1 初一
星期日
15
2 初二
星期一
29 廿
23 十四
24 十五
月记事表
周次
31 廿二
星期日
1
星期一
星期二
星期三
星期四
1 廿一
星期五
2 廿二
2024年3月 星期六
3 廿三
2
4 廿四
5 廿五
6 廿六
7 廿七
8 廿八
9 廿九
10 二月
3
11 初二
12 初三
13 初四
14 初五
15 初六
16 初七
17 初八
4
18 初九
19 初十
20 十一
10 初八
11 初九
12 初十
13 十一
8
14 十二
15 十三
16 十四
17 十五
18 十六
19 十七
20
21
22
十八
十九
廿
9
C++程序设计(万年历——说明书)
C++程序设计说明书题目:万年历班级学号:学生姓名:目录一.应用程序的名称二.应用程序的主题、设计目的三.应用程序简介1.程序的基本结构及内容2。
程序的运行环境四.主要运行界面的介绍五.程序亮点六.课程设计中存在的问题及解决方法一.课程设计名称万年历二.应用程序要求、目的主题:万年历目的:实现对年月的查询三.应用程序简介(1)基本结构:整个程序有cls_screen(清屏)、judgement(判断是否为闰年)、show_week(记录周几)、print_year(查询某年)、print_year_month(查询某年某月)等自定义函数,程序中涉及到switch语句、for语句、if语句等和多次函数调用语句,开头定义了day_of_month[]数组,主要目的是将12个月每个月有多少天依次排出,在后面又用if语句判断二月的天数是28还是29。
在主函数中运用while 语言与switch语句的嵌套,是程序拥有了循环的功能.用fflush(stdin);语句清除输入缓存,使程序在使用过程中不会太过眼花缭乱。
万年历的编程,需要两个方面的讨论和研究,一是要在用户输入年份的时候,判断该年是否为闰年,而对于闰年的判断,能被4整除但不能被100整除,或者能被400整除的年份为闰年,否则为平年。
所以会改变day_of_month[]数组中的二月份的数值。
二是在用户输入年月份的时候,判断该年该月的第一天是周几,从来好排列。
而对于判断周几,需要运用公式:w=(y+[y/4]+[c/4]—2c+[26(m+1)/10]+d-1)%7并用if语句使用判断。
通过这两个方面的讨论和实现,才能合理的编程出万年历的基本程序代码.(2)源程序代码:#include〈stdio.h>#include 〈string。
h〉#include 〈time.h>#include <math。
h〉#include 〈windows。
c万年历课程设计
c万年历课程设计一、课程目标知识目标:1. 学生能理解万年历的基本概念,掌握年、月、日的关系及其换算方法。
2. 学生能运用所学的数学知识,编写简单的万年历程序,计算任意日期是星期几。
3. 学生了解历法的起源和发展,理解我国农历与公历的区别和联系。
技能目标:1. 学生通过编写万年历程序,提高编程能力和逻辑思维能力。
2. 学生能够运用万年历知识解决实际问题,如计算节日日期、安排活动等。
3. 学生学会查阅相关资料,培养自主学习能力和合作精神。
情感态度价值观目标:1. 学生对万年历产生兴趣,激发学习数学和编程的热情。
2. 学生通过了解历法的发展,增强对传统文化的认识,培养民族自豪感。
3. 学生在合作学习中,学会尊重他人,培养团队协作意识。
本课程旨在结合学生年级特点,以提高学生的数学应用能力和编程技能为核心,通过万年历的学习,使学生在掌握知识的同时,培养良好的学习态度和价值观。
课程目标具体、可衡量,为教学设计和评估提供明确方向。
二、教学内容1. 万年历的基本概念:年、月、日的关系,闰年的判断方法,星期计算。
2. 编写万年历程序:流程图设计,算法实现,调试与优化。
3. 历法的起源与发展:古代历法,农历与公历的转换,二十四节气。
4. 实践应用:计算特定日期的星期,安排节日活动,了解历史上的今天。
教学大纲:第一课时:万年历的基本概念,闰年的判断方法,星期计算。
第二课时:编写万年历程序,学习流程图设计,实现基本算法。
第三课时:历法的起源与发展,了解农历与公历的转换,学习二十四节气。
第四课时:实践应用,解决实际问题,如计算节日日期,了解历史上的今天。
教学内容依据课程目标,结合课本章节,保证科学性和系统性。
通过以上安排,使学生掌握万年历相关知识,提高编程技能,并培养对传统文化的认识。
三、教学方法本课程采用以下多样化的教学方法,旨在激发学生的学习兴趣,提高主动性和参与度:1. 讲授法:教师通过生动的语言和形象的比喻,讲解万年历的基本概念、历法的发展和算法原理,为学生奠定坚实的理论基础。
C语言万年历代码
else if(ch=='n'||ch=='N')
{ month+=1;
if(month>12) {month=1;year+=1;}
}
printf("\t\t********e退出 p上一月 n下一月********");
}
void first_set(int *year,int *month)
{ do{
printf ("please input the year(1~9999):");
if (choose=='y'||choose=='Y') main();
}
days_of_month(int x,int y)
{
int z;
switch (y)
{case 1:
case 3:
case 5:
case 7:
case 8:
printf ("please input the month(1~12):");
scanf ("%d",month);
if(*month<1||*month>12) printf ("WANNING:ERROR,please input again!\n");
printf ("\n\n********************************************************************************\n\n");
自己做的日历(C语言)
本帖最后由 kekeyu 于 2010-8-15 16:59 编辑
C++实现万年历(原创)
C++实现万年历(原创)任务要求功能要求:(1)提供菜单⽅式选择,假定输⼊的年份在1940-2040年之间。
(2)输⼊⼀个年份,输出是在屏幕上显⽰该年的⽇历。
(3)输⼊年⽉,输出该⽉的⽇历,如图2-1所⽰: 图2- 1 ⽉⽇历(4)输⼊年份、⽉份、⽇期,计算得到的是这⼀天据今天有多少天,星期⼏。
(5)输⼊公历的年⽉⽇,输出农历年⽉⽇。
(6)输⼊农历节⽓,输出当年农历的年⽉⽇及公历年⽉⽇。
可以假定只涉及年份是1940年到2040年。
总体设计将⽂件三部分 Date.h、main.cpp、Date.cpp1) Date.h:包括函数的声明。
2) main.cpp:包含调⽤与模拟交互界⾯的函数代码3) Date.cpp://输⼊输⼊⼀个年份,输出是在屏幕上显⽰该年的⽇历。
void print_annual_calendar(int year)//输⼊年⽉,输出该⽉的⽇历。
void print_monthly_calendar(int year,int month)//输⼊年份、⽉份、⽇期,计算得到的是这⼀天据今天有多少天,星期⼏。
void print_number_week(int year,int month ,int day)//输⼊公历,显⽰农历。
void gregorian_to_lunar (int year,int month,int day)//输⼊农历节⽓,输出当年农历的年⽉⽇和公历年⽉⽇。
void solar_term(char *str)详细设计说明(1) 查询距今多少天,星期⼏?①计算某⼀⽇期到1939年1⽉1⽇的天数:getDaysTo1939(int year, int month, int day)1. 判断是否是闰年(平年365天,闰年366天),函数如表4-1所⽰:表4- 1 isLeapYear函数定义函数bool isLeapYear(int year)返回值若year年是闰年返回true,否则返回false参数说明year参数是要判断的年份1. 判断某年某⽉有多少天?函数如表4-2所⽰:表4- 2 getDaysOfMonth函数定义函数int getDaysOfMonth(int year,int month)返回值返回year年month⽉的天数参数说明year、month参数分别是要查询的年、⽉例如:计算2020年8⽉14⽇到1939年1⽉1⽇的天数。
万年历程序(不要嫌程序长,功能很齐全,而且对初学者很有帮助)
#include <REG51.H>#include <intrins.h>#define uint unsigned int#define uchar unsigned charvoid Stopwatch(); //声明秒表函数void Clock(); //声明闹钟函数void Output(); //声明输出函数void important(); //声明重要函数(相当于mian()函数)void TLimit(); //声明调节温度上下限函数sbit DS1302_CLK = P1^7; //实时时钟时钟线引脚sbit DS1302_IO = P1^6; //实时时钟数据线引脚sbit DS1302_RST = P1^5; //实时时钟复位线引脚sbit wireless_1 = P3^0; //温度过上限标志sbit wireless_2 = P3^1; //温度适中标志sbit wireless_3 = P3^2; //温度过下限标志sbit fan = P3^4; //开风扇标志sbit clock=P3^5; //开关闹钟sbit setclock = P3^6; //闹钟开启控制sbit stopwatch = P3^7; //秒表开启控制sbit ACC0 = ACC^0;sbit ACC7 = ACC^7;char hide_sec,hide_min,hide_hour,hide_day,hide_week,hide_month,hide_year; //秒,分,时到日,月,年位闪的计数sbit Set = P2^0; //模式切换键sbit Up = P2^1; //加法按钮sbit Down = P2^2; //减法按钮sbit out = P2^3; //立刻跳出调整模式按钮sbit DQ = P1^0; //温度传送数据IO口char c3,c2=0;char c=0,LowerBonud=20,UpperLimit=30;char a1=0,a2=0,a3=0,a4=0;char k[8]={'0','0',':','0','0',':','0','0'};void InitTimer0(void)//产生10ms时间间隔{TMOD = (TMOD & 0XF0) | 0X01; //定时器0工作在模式1,16Bit定时器模式TH0 = (65536 - 8000)/256;TL0 = (65536 - 8000)%256;TR0 =1; ET0 =1;//开启定时器和中断EA = 1;}char done,count,temp,flag,up_flag,down_flag; //uchar temp_value; //温度值uchar TempBuffer[5],week_value[2],h[8]; //unsigned char NL[5];void show_time(); //液晶显示程序/***********1602液晶显示部分子程序****************///Port Definitions**********************************************************sbit LcdRs = P2^5;sbit LcdRw = P2^6;sbit LcdEn = P2^7;sfr DBPort = 0x80; //P0=0x80,P1=0x90,P2=0xA0,P3=0xB0.数据端口//内部等待函数************************************************************************** unsigned char LCD_Wait(void){LcdRs=0;LcdRw=1; _nop_();LcdEn=1; _nop_();LcdEn=0;return DBPort;}//向LCD写入命令或数据************************************************************#define LCD_COMMAND 0 // Command#define LCD_DATA 1 // Data#define LCD_CLEAR_SCREEN 0x01 // 清屏#define LCD_HOMING 0x02 // 光标返回原点void LCD_Write(bit style, unsigned char input){LcdEn=0;LcdRs=style;LcdRw=0; _nop_();DBPort=input; _nop_();//注意顺序LcdEn=1; _nop_();//注意顺序LcdEn=0; _nop_();LCD_Wait();}//设置显示模式************************************************************#define LCD_SHOW 0x04 //显示开#define LCD_HIDE 0x00 //显示关#define LCD_CURSOR 0x02 //显示光标#define LCD_NO_CURSOR 0x00 //无光标#define LCD_FLASH 0x01 //光标闪动#define LCD_NO_FLASH 0x00 //光标不闪动void LCD_SetDisplay(unsigned char DisplayMode){LCD_Write(LCD_COMMAND, 0x08|DisplayMode);}//设置输入模式************************************************************ #define LCD_AC_UP 0x02#define LCD_AC_DOWN 0x00 // default#define LCD_MOVE 0x01 // 画面可平移#define LCD_NO_MOVE 0x00 //defaultvoid LCD_SetInput(unsigned char InputMode){LCD_Write(LCD_COMMAND, 0x04|InputMode);}//初始化LCD************************************************************ void LCD_Initial(){LcdEn=0;LCD_Write(LCD_COMMAND,0x38); //8位数据端口,2行显示,5*7点阵LCD_Write(LCD_COMMAND,0x38);LCD_SetDisplay(LCD_SHOW|LCD_NO_CURSOR); //开启显示, 无光标LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN); //清屏LCD_SetInput(LCD_AC_UP|LCD_NO_MOVE); //AC递增, 画面不动}//液晶字符输入的位置************************void GotoXY(unsigned char x, unsigned char y){if(y==0)LCD_Write(LCD_COMMAND,0x80|x);if(y==1)LCD_Write(LCD_COMMAND,0x80|(x-0x40));}//将字符输出到液晶显示void Print(unsigned char *str){while(*str!='\0')//while(*str!='\0'){LCD_Write(LCD_DATA,*str);str++;}}/***********DS1302时钟部分子程序******************/typedef struct SYSTEMTIME{unsigned char Second;unsigned char Minute;unsigned char Hour;unsigned char Week;unsigned char Day;unsigned char Month;unsigned char Year;unsigned char YearH;unsigned char YearL;unsigned char day;unsigned char month;unsigned char year;unsigned char DateString[11];unsigned char NLDateString[12];unsigned char TimeString[9];}SYSTEMTIME; //定义的时间类型SYSTEMTIME CurrentTime; //#define AM(X) X#define PM(X) (X+12) // 转成24小时制#define DS1302_SECOND 0x80 //时钟芯片的寄存器位置,存放时间#define DS1302_MINUTE 0x82#define DS1302_HOUR 0x84#define DS1302_WEEK 0x8A#define DS1302_DAY 0x86#define DS1302_MONTH 0x88#define DS1302_YEAR 0x8C#define DS1302_YEARH 0xC0void DS1302InputByte(unsigned char d) //实时时钟写入一字节(内部函数) {unsigned char i;ACC = d;for(i=8; i>0; i--){DS1302_IO = ACC0; //相当于汇编中的RRCDS1302_CLK = 1;DS1302_CLK = 0;ACC = ACC >> 1;}}unsigned char DS1302OutputByte(void) //实时时钟读取一字节(内部函数){unsigned char i;for(i=8; i>0; i--){ACC = ACC >>1; //相当于汇编中的RRCACC7 = DS1302_IO;DS1302_CLK = 1;DS1302_CLK = 0;}return(ACC);}void Write1302(unsigned char ucAddr, unsigned char ucDa) //ucAddr: DS1302地址, ucData: 要写的数据{DS1302_RST = 0;DS1302_CLK = 0;DS1302_RST = 1;DS1302InputByte(ucAddr); // 地址,命令DS1302InputByte(ucDa); // 写1Byte数据DS1302_CLK = 1;DS1302_RST = 0;}unsigned char Read1302(unsigned char ucAddr) //读取DS1302某地址的数据{unsigned char ucData;DS1302_RST = 0;DS1302_CLK = 0;DS1302_RST = 1;DS1302InputByte(ucAddr|0x01); // 地址,命令ucData = DS1302OutputByte(); // 读1Byte数据DS1302_CLK = 1;DS1302_RST = 0;return(ucData);}void DS1302_GetTime(SYSTEMTIME *Time) //获取时钟芯片的时钟数据到自定义的结构型数组{unsigned char ReadV alue;ReadValue = Read1302(DS1302_SECOND);Time->Second = ((ReadValue&0x70)>>4)*10 + (ReadValue&0x0F);ReadValue = Read1302(DS1302_MINUTE);Time->Minute = ((ReadV alue&0x70)>>4)*10 + (ReadValue&0x0F);ReadValue = Read1302(DS1302_HOUR);Time->Hour = ((ReadV alue&0x70)>>4)*10 + (ReadV alue&0x0F);ReadValue = Read1302(DS1302_DAY);Time->Day = ((ReadV alue&0x70)>>4)*10 + (ReadV alue&0x0F);ReadValue = Read1302(DS1302_WEEK);Time->Week = ((ReadValue&0x70)>>4)*10 + (ReadV alue&0x0F);ReadValue = Read1302(DS1302_MONTH);Time->Month = ((ReadValue&0x70)>>4)*10 + (ReadValue&0x0F);ReadValue = Read1302(DS1302_YEAR);Time->Year = ((ReadValue&0x70)>>4)*10 + (ReadV alue&0x0F);Time->YearH = 20;}void DateToStr(SYSTEMTIME *Time) //将时间年,月,日,星期数据转换成液晶显示字符串,放到数组里DateString[]{ if(hide_year<2) //这里的if,else语句都是判断位闪烁,<2显示数据,>2就不显示,输出字符串为2007/07/22{Time->DateString[0] = Time->YearH/10 + '0';Time->DateString[1] = Time->YearH%10 + '0';Time->DateString[2] = Time->Year/10 + '0';Time->DateString[3] = Time->Year%10 + '0';}else{Time->DateString[0] = ' ';Time->DateString[1] = ' ';Time->DateString[2] = ' ';Time->DateString[3] = ' ';}Time->DateString[4] = '/';if(hide_month<2){Time->DateString[5] = Time->Month/10 + '0';Time->DateString[6] = Time->Month%10 + '0';}else{Time->DateString[5] = ' ';Time->DateString[6] = ' ';}Time->DateString[7] = '/';if(hide_day<2){Time->DateString[8] = Time->Day/10 + '0';Time->DateString[9] = Time->Day%10 + '0';}else{Time->DateString[8] = ' ';Time->DateString[9] = ' ';}if(hide_week<2){week_value[0] = Time->Week%10 + '0'; //星期的数据另外放到week_value[]数组里,跟年,月,日的分开存放,因为等一下要在最后显示}else{week_value[0] = ' ';}week_value[1] = '\0';Time->DateString[10] = '\0'; //字符串末尾加'\0' ,判断结束字符}void TimeToStr(SYSTEMTIME *Time) //将时,分,秒数据转换成液晶显示字符放到数组TimeString[];{ if(hide_hour<2){Time->TimeString[0] = Time->Hour/10 + '0';Time->TimeString[1] = Time->Hour%10 + '0';h[0]=Time->TimeString[0];h[1]=Time->TimeString[1];}else{Time->TimeString[0] = ' ';Time->TimeString[1] = ' ';}Time->TimeString[2] = ':';h[2]=Time->TimeString[2];if(hide_min<2){Time->TimeString[3] = Time->Minute/10 + '0';Time->TimeString[4] = Time->Minute%10 + '0';h[3]=Time->TimeString[3];h[4]=Time->TimeString[4];}else{Time->TimeString[3] = ' ';Time->TimeString[4] = ' ';}Time->TimeString[5] = ':';h[5]=Time->TimeString[5];if(hide_sec<2){Time->TimeString[6] = Time->Second/10 + '0';Time->TimeString[7] = Time->Second%10 + '0';h[6]=Time->TimeString[6];h[7]=Time->TimeString[7];}else{Time->TimeString[6] = ' ';Time->TimeString[7] = ' ';}Time->DateString[8] = '\0';if ((a1==h[4])&&(a2==h[3])&&(a3<=h[7])&&((a4==h[6])||(a4==h[6]-1))) {clock=0;c=10;}}void Initial_DS1302(void) //时钟芯片初始化{unsigned char Second=Read1302(DS1302_SECOND);if(Second&0x80) //判断时钟芯片是否关闭{Write1302(0x8e,0x00); //写入允许Write1302(0xC0,0x20);Write1302(0x8c,0x09); //以下写入初始化时间日期:2007/07/25.星期: 3. 时间: 23:59:55 Write1302(0x88,0x06);Write1302(0x86,0x05);Write1302(0x8a,0x07); //xingqiWrite1302(0x84,0x23);Write1302(0x82,0x59);Write1302(0x80,0x55);Write1302(0x8e,0x80); //禁止写入}}/***********ds18b20子程序*************************//***********ds18b20延迟子函数(晶振12MHz )*******/void delay_18B20(unsigned int i){while(i--);}/**********ds18b20初始化函数**********************/void Init_DS18B20(void){unsigned char x=0;DQ = 1; //DQ复位delay_18B20(8); //稍做延时DQ = 0; //单片机将DQ拉低delay_18B20(80); //精确延时大于480usDQ = 1; //拉高总线delay_18B20(14);x=DQ; //稍做延时后如果x=0则初始化成功x=1则初始化失败delay_18B20(20);}/***********ds18b20读一个字节**************/unsigned char ReadOneChar(void){uchar i=0;uchar dat = 0;for (i=8;i>0;i--){DQ = 0; // 给脉冲信号dat>>=1; //数据右移一位DQ = 1; // 给脉冲信号if(DQ)dat|=0x80; //按位或,取最高位delay_18B20(4);}return(dat);}/*************ds18b20写一个字节****************/void WriteOneChar(uchar dat){unsigned char i=0;for (i=8; i>0; i--){DQ = 0;DQ = dat&0x01; //取最低位delay_18B20(5);DQ = 1; //上升沿将数据送入dat>>=1;}}/**************读取ds18b20当前温度************/void ReadTemp(void){unsigned char a=0;unsigned char b=0;unsigned char t=0;Init_DS18B20();WriteOneChar(0xCC); // 跳过读序号列号的操作WriteOneChar(0x44); // 启动温度转换delay_18B20(100); // this message is wery importantInit_DS18B20();WriteOneChar(0xCC); //跳过读序号列号的操作WriteOneChar(0xBE); //读取温度寄存器等(共可读9个寄存器)前两个就是温度delay_18B20(100);a=ReadOneChar(); //读取温度值低位b=ReadOneChar(); //读取温度值高位temp_value=b<<4; //左移四位,扩大16倍,变为一个字节的高四位temp_value+=(a&0xf0)>>4;//取温度值的地位的高四位,右移四位后与温度的高四位相加得到温度值if (temp_value>=UpperLimit) {wireless_1 =0;fan=1;}else {wireless_1 =1;fan=0;}if ((temp_value>LowerBonud)&&(temp_value<UpperLimit)) wireless_2 =0;else wireless_2 =1;if (temp_value<=LowerBonud) wireless_3 =0;else wireless_3 =1;}void temp_to_str() //温度数据转换成液晶字符显示{TempBuffer[0]=temp_value/10+'0'; //十位TempBuffer[1]=temp_value%10+'0'; //个位TempBuffer[2]=0xdf; //温度符号TempBuffer[3]='C';TempBuffer[4]='\0';}void Delay1ms(unsigned int count){unsigned int i,j;for(i=0;i<count;i++)for(j=0;j<120;j++){if (!stopwatch) {c++;Stopwatch();}if (!setclock) {c2++;Clock();}if ((!out)&&(!Set)) {TLimit();}if (!out) clock=1; //关闭闹钟}}/*延时子程序*/void mdelay(uint delay){ uint i;for(;delay>0;delay--)for(i=0;i<32;i++); //1ms延时.}/*****************************阳历转换阴历***********************************/ code unsigned char year_code[597]={0x04,0xAe,0x53, //1901 00x0A,0x57,0x48, //1902 30x55,0x26,0xBd, //1903 60x0d,0x26,0x50, //1904 90x0d,0x95,0x44, //1905 120x46,0xAA,0xB9, //1906 150x05,0x6A,0x4d, //1907 180x09,0xAd,0x42, //1908 210x24,0xAe,0xB6, //19090x04,0xAe,0x4A, //19100x6A,0x4d,0xBe, //19110x0A,0x4d,0x52, //19120x0d,0x25,0x46, //19130x5d,0x52,0xBA, //19140x0B,0x54,0x4e, //19150x0d,0x6A,0x43, //19160x29,0x6d,0x37, //19170x09,0x5B,0x4B, //19180x74,0x9B,0xC1, //19190x04,0x97,0x54, //19200x0A,0x4B,0x48, //19210x5B,0x25,0xBC, //19220x06,0xA5,0x50, //19230x06,0xd4,0x45, //19240x4A,0xdA,0xB8, //19250x02,0xB6,0x4d, //19260x09,0x57,0x42, //19270x24,0x97,0xB7, //19280x04,0x97,0x4A, //19290x66,0x4B,0x3e, //19300x0d,0x4A,0x51, //19310x0e,0xA5,0x46, //19320x56,0xd4,0xBA, //19330x05,0xAd,0x4e, //19340x02,0xB6,0x44, //19350x39,0x37,0x38, //19360x09,0x2e,0x4B, //19370x0C,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, //19810x0A,0x4B,0x4d, //19830xAB,0x25,0xC2, //19840x06,0xA5,0x54, //19850x06,0xd4,0x49, //19860x6A,0xdA,0x3d, //19870x0A,0xB6,0x51, //19880x09,0x37,0x46, //19890x54,0x97,0xBB, //19900x04,0x97,0x4f, //19910x06,0x4B,0x44, //19920x36,0xA5,0x37, //19930x0e,0xA5,0x4A, //19940x86,0xB2,0xBf, //19950x05,0xAC,0x53, //19960x0A,0xB6,0x47, //19970x59,0x36,0xBC, //19980x09,0x2e,0x50, //1999 294 0x0C,0x96,0x45, //2000 297 0x4d,0x4A,0xB8, //20010x0d,0x4A,0x4C, //20020x0d,0xA5,0x41, //20030x25,0xAA,0xB6, //20040x05,0x6A,0x49, //20050x7A,0xAd,0xBd, //20060x02,0x5d,0x52, //20070x09,0x2d,0x47, //20080x5C,0x95,0xBA, //20090x0A,0x95,0x4e, //20100x0B,0x4A,0x43, //20110x4B,0x55,0x37, //20120x0A,0xd5,0x4A, //20130x95,0x5A,0xBf, //20140x04,0xBA,0x53, //20150x0A,0x5B,0x48, //20160x65,0x2B,0xBC, //20170x05,0x2B,0x50, //20180x0A,0x93,0x45, //20190x47,0x4A,0xB9, //20200x06,0xAA,0x4C, //20210x0A,0xd5,0x41, //20220x24,0xdA,0xB6, //20230x04,0xB6,0x4A, //20240x69,0x57,0x3d, //20250x0d,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, //20690x8A,0x95,0xBf, //20710x0A,0x95,0x53, //20720x0B,0x4A,0x47, //20730x6B,0x55,0x3B, //20740x0A,0xd5,0x4f, //20750x05,0x5A,0x45, //20760x4A,0x5d,0x38, //20770x0A,0x5B,0x4C, //20780x05,0x2B,0x42, //20790x3A,0x93,0xB6, //20800x06,0x93,0x49, //20810x77,0x29,0xBd, //20820x06,0xAA,0x51, //20830x0A,0xd5,0x46, //20840x54,0xdA,0xBA, //20850x04,0xB6,0x4e, //20860x0A,0x57,0x43, //20870x45,0x27,0x38, //20880x0d,0x26,0x4A, //20890x8e,0x93,0x3e, //20900x0d,0x52,0x52, //20910x0d,0xAA,0x47, //20920x66,0xB5,0x3B, //20930x05,0x6d,0x4f, //20940x04,0xAe,0x45, //20950x4A,0x4e,0xB9, //20960x0A,0x4d,0x4C, //20970x0d,0x15,0x41, //20980x2d,0x92,0xB5, //2099};//月份数据表code unsigned char day_code1[9]={0x0,0x1f,0x3b,0x5a,0x78,0x97,0xb5,0xd4,0xf3};code unsigned int day_code2[3]={0x111,0x130,0x14e};/**************************************************************************** * 子函数,用于读取数据表中农历月的大月或小月,如果该月为大返回1,为小返回0****************************************************************************/ bit GetMoonDay(unsigned char month_p,unsigned short table_addr){switch (month_p){case 1:if((year_code[table_addr]&0x08)==0) return(0);else return(1);case 2:if((year_code[table_addr]&0x04)==0) return(0);else return(1);case 3:if((year_code[table_addr]&0x02)==0) return(0);else return(1);case 4:if((year_code[table_addr]&0x01)==0) return(0);else return(1);case 5:if((year_code[table_addr+1]&0x80)==0) return(0);else return(1);case 6:if((year_code[table_addr+1]&0x40)==0) return(0);else return(1);case 7:if((year_code[table_addr+1]&0x20)==0) return(0);else return(1);case 8:if((year_code[table_addr+1]&0x10)==0) return(0);else return(1);case 9:if((year_code[table_addr+1]&0x08)==0) return(0);else return(1);case 10:if((year_code[table_addr+1]&0x04)==0) return(0);else return(1);case 11:if((year_code[table_addr+1]&0x02)==0) return(0);else return(1);case 12:if((year_code[table_addr+1]&0x01)==0) return(0);else return(1);case 13:if((year_code[table_addr+2]&0x80)==0) return(0);else return(1);}return(0);}/****************************************************************************** ***************************** 函数名称:GetChinaCalendar** 功能描述:公农历转换(只允许1901-2099年)** 输入: year 公历年** month 公历月** day 公历日** p 储存农历日期地址** 输出: 1 成功** 0 失败** 作者: Campo** 修改: 赖皮** 日期: 2007年02月06日**-------------------------------------------------------------------------------------------------------** 修改人:** 日期:**------------------------------------------------------------------------------------------------------******************************************************************************* *************************/unsigned char GetChinaCalendar(unsigned int year,unsigned char month,unsigned char day){unsigned char temp1,temp2,temp3,month_p,yearH,yearL;unsigned char flag_y;unsigned short temp4,table_addr;yearH=year/100; yearL=year%100;if((yearH!=19)&&(yearH!=20)) return(0);// 定位数据表地址if(yearH==20) table_addr=(yearL+100-1)*3;else table_addr=(yearL-1)*3;// 取当年春节所在的公历月份temp1=year_code[table_addr+2]&0x60;temp1>>=5;// 取当年春节所在的公历日temp2=year_code[table_addr+2]&31;// 计算当年春年离当年元旦的天数,春节只会在公历1月或2月if(temp1==1) t emp3=temp2-1;else temp3=temp2+31-1;// 计算公历日离当年元旦的天数if (month<10) temp4=day_code1[month-1]+day-1;else temp4=day_code2[month-10]+day-1;// 如果公历月大于2月并且该年的2月为闰月,天数加1if ((month>2)&&(yearL%4==0)) temp4++;// 判断公历日在春节前还是春节后if (temp4>=temp3){temp4-=temp3;month=1;month_p=1;flag_y=0;if(GetMoonDay(month_p,table_addr)==0) temp1=29; //小月29天else temp1=30; //大小30天// 从数据表中取该年的闰月月份,如为0则该年无闰月temp2=year_code[table_addr]/16;while(temp4>=temp1){temp4-=temp1;month_p++;if(month==temp2){NL[4]='R';flag_y=~flag_y;if(flag_y==0) {month++;NL[4]=' ';}}else {month++;NL[4]=' ';}if(GetMoonDay(month_p,table_addr)==0) temp1=29;else temp1=30;}day=temp4+1;}// 公历日在春节前使用下面代码进行运算else{temp3-=temp4;if (yearL==0){yearL=100-1;yearH=19;}else yearL--;table_addr-=3;month=12;temp2=year_code[table_addr]/16;if (temp2==0) {month_p=12;NL[4]=' ';}else {month_p=13;NL[4]='R';}flag_y=0;if(GetMoonDay(month_p,table_addr)==0) temp1=29;else temp1=30;while(temp3>temp1){temp3-=temp1;month_p--;if(flag_y==0) month--;if(month==temp2) flag_y=~flag_y;if(GetMoonDay(month_p,table_addr)==0) temp1=29;else temp1=30;}day=temp1-temp3+1;}/////////////////////////NL[0]=yearH;NL[1]=yearL;NL[2]=month;NL[3]=day;return(1);}void zhuan(SYSTEMTIME *Time){GetChinaCalendar(Time->YearH*100+Time->Year,Time->Month,Time->Day);Time->day = NL[3];Time->month =NL[2];//将时间年,月,日,星期数据转换成液晶显示字符串,放到数组里DateString[]if(hide_year<2) //这里的if,else语句都是判断位闪烁,<2显示数据,>2就不显示,输出字符串为2007/07/22{Time->NLDateString[0] = NL[0]/10 + '0';Time->NLDateString[1] = NL[0]%10 + '0';Time->NLDateString[2] = NL[1]/10 + '0';Time->NLDateString[3] = NL[1]%10 + '0';}else{Time->NLDateString[0] = ' ';Time->NLDateString[1] = ' ';Time->NLDateString[2] = ' ';Time->NLDateString[3] = ' ';}Time->NLDateString[4] = '/';if(hide_month<2){Time->NLDateString[5] =NL[4] ;Time->NLDateString[6] = Time->month/10 + '0';Time->NLDateString[7] = Time->month%10 + '0';}else{Time->NLDateString[6] = ' ';Time->NLDateString[7] = ' ';}Time->NLDateString[8] = '/';if(hide_day<2){Time->NLDateString[9] = Time->day/10 + '0';Time->NLDateString[10] = Time->day%10 + '0';}else{Time->NLDateString[9] = ' ';Time->NLDateString[10] = ' ';}Time->NLDateString[11] = '\0'; //字符串末尾加'\0' ,判断结束字符//////////////////////}//显示天干生肖void lcd_digan(){temp = NL[1]%12;switch(temp){case 0: GotoXY(3,0); Print("Chen LongYear");//龙break;case 1: GotoXY(3,0); Print("Si She ear");//蛇break;case 2: GotoXY(3,0); Print("Wu Ma Year");//马break;case 3: GotoXY(3,0); Print("Wei YangYear"); //羊break;case 4: GotoXY(3,0); Print("Chen Hou Year"); //猴break;case 5: GotoXY(3,0); Print("You Ji Year"); //鸡break;case 6: GotoXY(3,0); Print("Xu Gou Year"); //狗break;case 7: GotoXY(3,0); Print("Hai Zhu Year"); //猪break;case 8: GotoXY(3,0); Print("Zi Shu Year"); //鼠break;case 9: GotoXY(3,0); Print("Chou Niu Year"); //牛break;case 10:GotoXY(3,0); Print("Yin Hu Year"); //虎break;case 11:GotoXY(3,0); Print("Mao Tu Year"); //兔break;}}//显示天支void lcd_tianzhi(){temp = NL[1]%10;switch(temp){case 0: GotoXY(0,0); Print("Gen");//庚break;case 1: GotoXY(0,0); Print("Xin");//辛break;case 2: GotoXY(0,0); Print("Ren");//壬break;case 3: GotoXY(0,0); Print("Gui"); //癸?break;case 4: GotoXY(0,0); Print("Jia"); //甲break;case 5: GotoXY(0,0); Print("Yi"); //乙break;case 6: GotoXY(0,0); Print("Bin"); //丙break;case 7: GotoXY(0,0); Print("Din"); //丁break;case 8: GotoXY(0,0); Print("Wu"); //戊break;case 9: GotoXY(0,0); Print("Ji");//己break;}}void outkey() //跳出调整模式,返回默认显示{ uchar Second;if(out==0)//if(out==0||wireless_1==1) //{ mdelay(4);count=0;hide_sec=0,hide_min=0,hide_hour=0,hide_day=0,hide_week=0,hide_month=0,hide_year=0;Second=Read1302(DS1302_SECOND);Write1302(0x8e,0x00); //写入允许Write1302(0x80,Second&0x7f);Write1302(0x8E,0x80); //禁止写入done=0;while(out==0);//while(wireless_1==1);}}////////////////////////////////////////////////////////////////////////////////////////////////////////////void Upkey()//升序按键{Up=1;if(Up==0)//if(Up==0||wireless_2==1){mdelay(4);switch(count){case 1:temp=Read1302(DS1302_SECOND); //读取秒数temp=temp+1; //秒数加1up_flag=1; //数据调整后更新标志if((temp&0x7f)>0x59) //超过59秒,清零temp=0;break;case 2:temp=Read1302(DS1302_MINUTE); //读取分数temp=temp+1; //分数加1up_flag=1;if(temp>0x59) //超过59分,清零temp=0;break;case 3:temp=Read1302(DS1302_HOUR); //读取小时数temp=temp+1; //小时数加1up_flag=1;if(temp>0x23) //超过23小时,清零temp=0;break;case 4:temp=Read1302(DS1302_WEEK); //读取星期数temp=temp+1; //星期数加1up_flag=1;if(temp>0x7)temp=1;break;case 5:temp=Read1302(DS1302_DAY); //读取日数temp=temp+1; //日数加1up_flag=1;if(temp>0x31)temp=1;break;case 6:temp=Read1302(DS1302_MONTH); //读取月数temp=temp+1; //月数加1up_flag=1;if(temp>0x12)temp=1;break;case 7:temp=Read1302(DS1302_YEAR); //读取年数temp=temp+1; //年数加1up_flag=1;if(temp>0x85)temp=0;break;default:break;}while(Up==0);//while(wireless_2==1);}}////////////////////////////////////////////////////////////////////////////////////////////////////////////void Downkey()//降序按键{Down=1;if(Down==0)//if(Down==0||wireless_3==1){mdelay(4);switch(count){case 1:temp=Read1302(DS1302_SECOND); //读取秒数temp=temp-1; //秒数减1down_flag=1; //数据调整后更新标志if(temp==0x7f) //小于0秒,返回59秒temp=0x59;break;case 2:temp=Read1302(DS1302_MINUTE); //读取分数temp=temp-1; //分数减1down_flag=1;if(temp==-1)temp=0x59; //小于0秒,返回59秒break;case 3:temp=Read1302(DS1302_HOUR); //读取小时数temp=temp-1; //小时数减1down_flag=1;if(temp==-1)temp=0x23;break;case 4:temp=Read1302(DS1302_WEEK); //读取星期数temp=temp-1; //星期数减1down_flag=1;if(temp==0)temp=0x7;;break;case 5:temp=Read1302(DS1302_DAY); //读取日数temp=temp-1; //日数减1down_flag=1;if(temp==0)temp=31;break;case 6:temp=Read1302(DS1302_MONTH); //读取月数temp=temp-1; //月数减1down_flag=1;if(temp==0)temp=12;break;case 7:temp=Read1302(DS1302_YEAR); //读取年数temp=temp-1; //年数减1down_flag=1;if(temp==-1)temp=0x85;break;default:break;}while(Down==0);//while(wireless_3==1);}}void Setkey()//模式选择按键{Set=1;if(Set==0)//if(Set==0||wireless_4==1){mdelay(4);count=count+1; //Setkey按一次,count就加1done=1; //进入调整模式while(Set==0);//while(wireless_4==1);}}void keydone()//按键功能执行{ uchar Second;if(flag==0) //关闭时钟,停止计时{ Write1302(0x8e,0x00); //写入允许temp=Read1302(0x80);Write1302(0x80,temp|0x80);Write1302(0x8e,0x80); //禁止写入flag=1;。
基于单片机的万年历设计
题目:基于单片机的电子万年历设计基于单片机的万年历设计摘要随着科技的快速发展,时间的流逝,从观太阳、摆钟到现在电子钟,人类不断研究,不断创新纪录。
目前,单片机技术的应用产品已经走进了千家万户。
电子万年历的出现给人们的生活带来了诸多方便。
本设计是一个基于AT89S52单片机的日历显示系统,本设计能显示公历年、月、日,以及时、分、秒、温度、星期等信息,而且还提供了农历信息,具有调整时间,温度采集,闹钟及个性化的闹铃等功能。
系统所用的时钟日历芯片DS1302具有高性能、低功耗、接口简单的特点,使本系统电路简化,编程方便,同时功能也很强。
采用AT89S52单片机的万年历系统可以很好的改善传统采用模拟电路引起的计时不准确,不可靠,一致性差等问题。
此系统计时精确,价格低廉,可以广泛应用在生活,学习和工作等任何领域,并且起到重要作用。
关键词:万年历;单片机;时钟芯片;温度芯片;公历转农历The Design of Electronic Calendar clock Based on Single-chipMicrocomputerAbstractAlong with the technical fast development, time passing, to from the view sun, the pendulum clock to the present electron clock, the humanity studies unceasingly, innovates unceasingly the record. At present, the monolithic integrated circuit technology's application product already entered everyone. The electronic ten thousand calendar's appearances have brought conveniently many for people's life.This design is one based on AT89S52 single-chip microcomputer calendar display system, it can demonstrate years, the month, the date of the Gregorian calendar, and hour, minute, second, temperature, week and so on. Moreover it has also provided the lunar calendar information, adjustable time pattern, temperature sample, alarm system, individual quarter-bell and so on. The system clock calendar DS1302 with high performance, low power consumption and simple interface features Circuit enable the system to streamline programming convenience, but also highly functional. The problems of inaccurate, unreliable, and the uniform inferior can be come up when you use the analogous circuit. However, it can be improved when you use the clock system based on AT89S52 single-chip microcomputer. The system time accurate, low cost and can be widely applied to the life, study and work in any field, and has played an important role.Key words:The Electronic Calendar Clock;Single-chip Microcomputer;The Time Calendar Clock;Temperature Chip;The Lunar Calendar Convert To The Gregorian Calendar目录摘要 (I)Abstract (II)第一章引言 (1)1.1 概述 (1)1.2 单片机的简介 (1)第二章方案设计与论证 (4)2.1 单片机芯片设计与论证 (4)2.2 电源模块设计与论证 (5)2.3 按键控制模块设计与论证 (5)2.4 时钟模块设计与论证 (5)2.5 温度采集模块设计与论证 (5)2.6 显示模块模块设计与论证 (6)第三章系统的硬件设计 (7)3.1 主控芯片AT89S52与最小外围系统 (7)3.1.1 AT89S52的概述 (7)3.1.2 AT89S52最小系统的设计 (10)3.2 时钟芯片DS1302接口设计与性能分析 (11)3.2.1 DS1302性能简介 (11)3.2.2 DS1302接口电路设计 (12)3.3 温度芯片DS18B20接口设计与性能分析 (14)3.3.1 DS18B20性能简介 (14)3.3.2 DS18B20接口电路设计 (15)3.3.3 DS18B20的工作时序 (16)3.4 闹钟模块接口设计与性能分析 (17)3.4.1 AT24C02器件使用 (17)3.4.2 接口电路设计 (19)3.5 LCD显示模块 (19)3.5.1 LCM1602的特性及使用说明 (19)3.5.2 LCM1602与MCU的接口电路 (21)3.6 按键模块设计 (21)第四章软件设计 (23)4.1 软件总体部分的设计 (23)4.2 LCD驱动及液晶显示 (24)4.3 按键识别及处理 (25)4.4 温度数据采集 (26)4.5 时间数据采集 (27)4.6 闹钟程序 (28)4.7 公历转农历的实现 (28)第五章系统的调试 (30)总结 (31)参考文献 (32)附录A 设计原理图 (33)附录B 源程序 (34)附录C 公历对应的农历数据表 (55)致谢 (58)第一章引言1.1 概述随着电子技术的发展,人类不断研究,不断创新纪录。
万年历
编写一个万年历程序,能显示日历,查询任意日期。
日历初始化和显示。
能根据系统日期进行初始化,并显示当前月份的月历,并突出显示当前日期。
日期查询,可以输入一个日期,然后查询并正确显示日期所在月份的月历,并突出显示查询日期,如果输入日期不正确给出提示。
#include<stdio.h>#include<time.h>#include<iostream.h>#include"万年历.h"int main(){int y,m,d,h,min,sec;//系统时间参数int cho;//用户选项int yt,mt,dt;//拥护输入的时间参数while(1){cout<<"≡≡≡≡≡≡万年历菜单选项≡≡≡≡≡";cout<<"请按编号选择功能";cout<<" ⑴查询当前时间";cout<<" ⑵显示本月月历";cout<<" ⑶查找给定日期对应的月历";cout<<" ⑷退出万年历";cin>>cho;Initdate(y,m,d,h,min,sec);switch(cho){case 1: cout<<"当前时间为<<y<<"."<<m<<"."<<d<<"."<<" "<<h<<":"<<min<<":"<<sec<<" ";week(y,m,d);break;case 2: printmonth(y,m,d);break;case 3: cout<<"请输入所要查找的日期,格式如2000 7 5";cin>>yt<<mt<<dt;search(yt,mt,dt);break;case 4: exit(1);break;default :cout<<"输入错误,请重新输入";}}return;}void week(y,m,d)//日期对于的星期{int c,w;c=y/100+1;if(m<=2) {m=m+12;y=y-1;}w=(y+y/4+c/4-2*c+26*(m+1)/10+d-1)%7;if(w=0) cout("Sun");else if (w==1)cout<<"Mon";else if (w==2)cout<<"Tue";else if (w==3)cout<<"wed";else if (w==4)cout<<"Thu";else if (w=5)cout<<"Fri";else cout<<"Sta"; }void Initdate(&y,&m,&d,&h,&min,&sec)//根据系统时间初始化万年历{time_t t;time(&t);struct tm * local_time = localtime(&t);sec=local_time->tm_sec;min=local_time->tm_min ;h=local_time->tm_hour ;d=local_time->tm_mday ;m=local_time->tm_mon+1;y=local_time->tm_year+1900;}void printmonth(y,m,d)//打印出给定时间对于月历{int ym[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};int leap,i;leap=(y%4==0&&y%100!=0||y%400==0)for(i=1;i<d;i++)cout<<i<<" "<<week(y,m,i)<<endl;cout<<"★" ;for(i=d;i<=ym[leap][m];i++)cout<<i<<" "<<week(y,m,i)<<endl;}int judge(y,m,d)//判断给定时间是否存在{int ym[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};int leap,i;if(y<=0||m<1||m>12)return 0;leap=(y%4==0&&y%100!=0||y%400==0);if(d<1||d>ym[leap][m])return 0;else return 1;}int search(y,m,d)//查找打印给定时间对应阅历{if(judge(y,m,d)==0)cout<<"error date";else printmonth(y,m,d);}2011-8-9 16:29最佳答案// abc4.cpp : 定义控制台应用程序的入口点。
万年历代码c语言
万年历代码c语言万年历是一种实用的日历工具,它可以根据年、月、日来显示当天的日期信息,并可以切换到其他日期来查询对应的日期信息。
在编写万年历的代码时,我们需要考虑输入的年份是否为闰年、每个月的天数、以及每个月第一天是星期几等等。
以下是一份使用C语言编写万年历的参考代码:```c#include <stdio.h>// 判断是否为闰年int isLeapYear(int year) {return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); }// 获取某年某月的天数int getMonthDays(int year, int month) {int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};if (month == 2 && isLeapYear(year)) {return 29;}return days[month - 1];}// 获取某年某月第一天是星期几int getFirstDayOfWeek(int year, int month) {int day = 1;for (int i = 1800; i < year; i++) {if (isLeapYear(i)) {day = (day + 366) % 7;} else {day = (day + 365) % 7;}}for (int i = 1; i < month; i++) {day = (day + getMonthDays(year, i)) % 7;}return day;}int main() {int year, month;printf("请输入年份:");scanf("%d", &year);printf("请输入月份:");scanf("%d", &month);// 判断输入是否合法if (year < 1800 || month < 1 || month > 12) {printf("输入的年份或月份不合法!\n");return 0;}// 获取某年某月的天数和第一天是星期几int days = getMonthDays(year, month);int firstDayOfWeek = getFirstDayOfWeek(year, month); // 打印万年历printf("日一二三四五六\n");for (int i = 0; i < firstDayOfWeek; i++) {printf(" ");}for (int i = 1; i <= days; i++) {printf("%2d ", i);if ((firstDayOfWeek + i) % 7 == 0) {printf("\n");}}printf("\n");return 0;}```以上代码实现了一个简单的万年历功能,在控制台输出给定年份和月份的月历。
2023年日历带农历备忘录记事本精美打印名言警句版(书山有路勤为径学海无涯苦作舟)
名言警句:
知而好问,然后能才。 ——《荀子》 译:聪明的人还一定得勤学好问才能 成才。)
本月记录:
星期天 星期一 星期二 星期三 星期四 星期五 星期六
1 建军节
2 十六
3 十七
4 十八
5 十九
6 二十
7 廿一
8 立秋
9 廿三
10 末伏
11 廿五
12 廿六
13 廿七
14 廿八
15 廿九
16 初一
27 初六
28 初七
29 初八
30 初九
31 初十
名言警句:
三思而后行。 ——《论语》 译:每做一件事情必须要经过反复的 考虑后才去做。
本月记录:
星期天
2 十二
9 十九 16 廿六 23 初四 30 十一
星期一
3 十三 10 二十 17 廿七 24 初五
星期二
4 十四 11 廿一 18 廿八 25 初六
30
平安夜 圣诞节
十四
十五
十六
名言警句:
欲安其家,必先安于国。 ——武则天 译:如果想建立个人幸福的小家,必 须先让国定安定,繁荣起来。
本月记录:
本月记录:
星期天
星期一
星期二
星期三
星期四
星期五
星期六
1 劳动节
2 十三
3 十四
4 青年节
5 十六
6 立夏
7 十八
8 十九
9 二十
10 廿一
11 廿二
12 廿三
13 廿四
14 母亲节
15 廿六
16 廿七
17 廿八
18 廿九
19 谷雨
20 初二
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
/****************************************************************************** ***************程序名:带字库12864LCC电子钟程序器件:STC89C52,LCD12864(内置汉字字库),18B20温度芯片,1302时钟芯片MCU晶振:12MHZ设计:中国机器(仿造杜洋万年历程序并增加了农历功能)功能:显示公历年月日农历年月日星期(星期不调用DS1302内的数据,二十根据公历年月日推算的)温度时分秒公历重大节日农历纪念日与节日(用于提醒农历生日非常实用)注:1、当农历纪念日与公历纪念日碰到同一天,则按一秒的间隔轮流显示2、20100226加入阳历大小月和平闰年判断,调日历时自动控制每个月份的天数/****************************************************************************** ***************/****************************************************************************** ***************///程序部分开始///****************************************************************************/ //头文件#include <A T89X52.h>#include <string.h>/*****************************************************************************///定做PCB板的灯与扬声器定义sbit led_back = P2^7;//背光控制(V2.1程序中加入了背光控制的硬件电路)sbit beep = P3^1;//扬声器/*****************************************************************************///定做PCB板温度传感器引脚定义sbit DQ = P2 ^0 ;//ds18B20*//*****************************************************************************/ //键盘引脚定义sbit KEY_1 = P1^7; //退出设置键,显示版本信息键sbit KEY_2 = P1^6; //上调键sbit KEY_3 = P1^5; //设置键sbit KEY_4 = P1^4; //减,下调键sbit KEY_5 = P1^3; //LED控制每次按动改变背光开关/****************************************************************************///LCD接口定义sbit RS = P1^0;//模式位,为0输入指令,为1输入数据sbit RW = P1^1;//读写位,为0读,为1写sbit E = P1^2;//使能位#define Lcd_Bus P0 //数据总线/*****************************************************************************///定义DS1302时钟接口sbit clock_clk = P3 ^ 0;//ds1302_clk(时钟线)sbit clock_dat = P3 ^ 6;//ds1302_dat(数据线)sbit clock_Rst = P3 ^ 7;//ds1302_Rst(复位线)/*****************************************************************************/ //定义累加器A中的各位sbit a0 = ACC ^ 0;sbit a1 = ACC ^ 1;sbit a2 = ACC ^ 2;sbit a3 = ACC ^ 3;sbit a4 = ACC ^ 4;sbit a5 = ACC ^ 5;sbit a6 = ACC ^ 6;sbit a7 = ACC ^ 7;/****************************************************************************/ //定义全局变量unsigned char yy,mo,dd,xq,hh,mm,ss,month_moon,day_moon,week,tiangan,dizhi,moontemp1,moontemp2;//定义时间映射全局变量(专用寄存器)bit w = 0; //调时标志位,=0时为走时状态,=1时为调时状态static unsigned char menu = 0;//定义静态小时更新用数据变量static unsigned char keys = 0;//定义静态小时更新用数据变量static unsigned char timecount = 0;//定义静态软件计数器变量signed char address,item,max,mini;/****************************************************************************/ void DelayM(unsigned int a){//延时函数1MS/次unsigned char i;while( --a != 0){for(i = 0; i < 125; i++); //一个; 表示空语句,CPU空转。
} //i 从0加到125,CPU大概就耗时1毫秒}/****************************************************************************//****************************************************************************** ///LCD驱动(DY12864CBL液晶显示屏并口驱动程序)/****************************************************************************** /void chk_busy(){//检查忙位(底层)RS=0;RW=1;E=1;Lcd_Bus=0xff;while((Lcd_Bus&0x80)==0x80);E=0;}/****************************************************************************** /void write_com(unsigned char cmdcode){//写命令到LCD(底层)chk_busy();RS=0;RW=0;E=1;Lcd_Bus=cmdcode;E=0;}/****************************************************************************** /void write_data(unsigned char Dispdata){ //写数据到LCD(底层)chk_busy();RS=1;RW=0;E=1;Lcd_Bus=Dispdata;E=0;}/****************************************************************************** /void lcm_init(){//初始化LCD屏(被调用层)write_com(0x30); //选择8bit数据流write_com(0x0c); //开显示(无游标、不反白)write_com(0x01); //清除显示,并且设定地址指针为00H}/*****************************************************************************/ void lcm_w_word(unsigned char *s){//向LCM发送一个字符串,长度64字符(一行)之内。
(被调用层)while(*s>0){ //应用:lcm_w_word("您好!"),直接显示:您好!write_data(*s);s++;}}/****************************************************************************** /void lcm_w_test(bit i,unsigned char word){//写指令或数据(被调用层)if(i == 0){write_com(word);//写指令或数据(0,指令)}else{write_data(word);//写指令或数据(1,数据)}}/****************************************************************************** /void lcm_clr(void){//清屏函数lcm_w_test(0,0x01);}/****************************************************************************** /void lcm_clr2(void){//清屏上面3行(用空格填满要清显示的地方,因为液晶屏是静态显示的,所以这办法常用)lcm_w_test(0,0x80);//第一行lcm_w_word("");//标尺("1234567812345678"应该能够显示满一行)lcm_w_test(0,0x90);//第二行lcm_w_word("");//标尺("1234567812345678"应该能够显示满一行)lcm_w_test(0,0x88);//第一行lcm_w_word("");//标尺("1234567812345678"应该能够显示满一行)}/****************************************************************************** ///DS18B20温度传感器驱动(显示0至60度,小数点后显示一位)/******************************************************************************/void Delay(int num){//延时函数while(num--) ;}/****************************************************************************** /void Init_DS18B20(void){//初始化ds1820unsigned char x=0;DQ = 1; //DQ复位Delay(8); //稍做延时DQ = 0; //单片机将DQ拉低Delay(80); //精确延时大于480usDQ = 1; //拉高总线Delay(14);x=DQ; //稍做延时后如果x=0则初始化成功x=1则初始化失败Delay(20);}/****************************************************************************** /unsigned char ReadOneChar(void){//读一个字节unsigned char i=0;unsigned char dat = 0;for (i=8;i>0;i--){DQ = 0; // 给脉冲信号dat>>=1;DQ = 1; // 给脉冲信号if(DQ)dat|=0x80;Delay(4);}return(dat);}/****************************************************************************** /void WriteOneChar(unsigned char dat){//写一个字节unsigned char i=0;for (i=8; i>0; i--){DQ = 0;DQ = dat&0x01;Delay(5);DQ = 1;dat>>=1;}}/****************************************************************************** /unsigned int ReadTemperature(void){//读取温度,温度值返回到此函数中,供调用unsigned char a=0;unsigned char b=0;unsigned int t=0;float tt=0;Init_DS18B20();WriteOneChar(0xCC); // 跳过读序号列号的操作WriteOneChar(0x44); // 启动温度转换Init_DS18B20();WriteOneChar(0xCC); //跳过读序号列号的操作WriteOneChar(0xBE); //读取温度寄存器a=ReadOneChar(); //读低8位b=ReadOneChar(); //读高8位t=b;t<<=8;t=t|a;tt=t*0.0625;t= tt*10+0.5; //放大10倍输出并四舍五入return(t);//t内的温度值,返回到子函数中,要将温度传输到temp变量,应用temp=ReabTemperature()}/*****************************************************************************/ //后面会出现的函数声明(当各函数的排列适当时可不用声明,加入函数声明就不用管各个子函数出现的位置先后了?)void lcm_w_ss(void);//向液晶LCM中写秒数据void lcm_w_mm(void);//向液晶LCM中写分数据void lcm_w_hh(void);//向液晶LCM中写小时数据void lcm_w_dd(void);//写日数据void lcm_w_mo(void);//写月数据void lcm_w_yy(void);//写年数据void lcm_w_xq(void);//星期处理并送入LCM的指定区域unsigned char clock_in(void);//DS1302逐位写入字节(底层协议)void clock_out(unsigned char dd);//1302驱动程序逐位读出字节(底层协议?void Init_1302(void);//-设置1302的初始时间(2007年1月1日00时00分00秒星期一)unsigned char read_clock(unsigned char ord);//DS1302读数据(底层协议)void read_clockS(void);void Set_time(unsigned char sel);//根据选择调整的相应项目sel加1并写入DS1302void write_clock(unsigned char ord, unsigned char dd);//DS1302写数据(底层协议)void updata (void);void lcm_w_nl(void);//显示农历子函数void Conversion(bit c,unsigned char year,unsigned char month,unsigned char day); //农历年月日计算子函数void Conver_week(bit c,unsigned char year,unsigned char month,unsigned char day);//星期计算子函数void ds_w(void);/*****************************************************************************/ //设置1302的初始时间(自动初始化)void Init_1302(void){//-设置1302的初始时间(2007年1月1日00时00分00秒星期一)unsigned char f;if(read_clock(0xc1) != 0xaa){write_clock(0x8e,0x00);//允许写操作write_clock(0x8c,0x07);//年write_clock(0x8a,0x01);//星期write_clock(0x88,0x01);//月write_clock(0x86,0x01);//日write_clock(0x84,0x00);//小时write_clock(0x82,0x00);//分钟write_clock(0x80,0x00);//秒write_clock(0x90,0xa5);//充电write_clock(0xc0,0xaa);//写入初始化标志RAM(第00个RAM位置)for(f=0;f<60;f=f+2){//清除闹钟RAM位为0write_clock(0xc2+f,0x00);}write_clock(0x8e,0x80);//禁止写操作}}/*****************************************************************************/ //DS1302写数据(底层协议)void write_clock(unsigned char ord, unsigned char dd){clock_clk=0;clock_Rst=0;clock_Rst=1;clock_out(ord);clock_out(dd);clock_Rst=0;clock_clk=1;}/*****************************************************************************/ //1302驱动程序逐位读出字节(底层协议)void clock_out(unsigned char dd){ACC=dd;clock_dat=a0; clock_clk=1; clock_clk=0;clock_dat=a1; clock_clk=1; clock_clk=0;clock_dat=a2; clock_clk=1; clock_clk=0;clock_dat=a3; clock_clk=1; clock_clk=0;clock_dat=a4; clock_clk=1; clock_clk=0;clock_dat=a5; clock_clk=1; clock_clk=0;clock_dat=a6; clock_clk=1; clock_clk=0;clock_dat=a7; clock_clk=1; clock_clk=0;}/*****************************************************************************/ //DS1302逐位写入字节(底层协议)unsigned char clock_in(void){clock_dat=1;a0=clock_dat;clock_clk=1; clock_clk=0; a1=clock_dat;clock_clk=1; clock_clk=0; a2=clock_dat;clock_clk=1; clock_clk=0; a3=clock_dat;clock_clk=1; clock_clk=0; a4=clock_dat;clock_clk=1; clock_clk=0; a5=clock_dat;clock_clk=1; clock_clk=0; a6=clock_dat;clock_clk=1; clock_clk=0; a7=clock_dat;return(ACC);}/*****************************************************************************/ //DS1302读数据(底层协议)供调用时钟数据unsigned char read_clock(unsigned char ord){unsigned char dd=0;clock_clk=0;clock_Rst=0;clock_Rst=1;clock_out(ord);dd=clock_in();clock_Rst=0;clock_clk=1;return(dd);}/*****************************************************************************/ //扬声器驱动程序(闹钟音乐)/*****************************************************************************/void Beep(void){//BELL-扬声器--整点报时unsigned char a;//定义变量用于发声的长度设置for(a=60;a>0;a--){//第一个声音的长度beep = ~beep;//取反扬声器驱动口,以产生音频Delay(100);//音调设置延时}for(a=100;a>0;a--){//同上beep = ~beep;Delay(80);//}for(a=100;a>0;a--){//同上beep = ~beep;Delay(30);//}beep = 0;//音乐结束后扬声器输出0关闭,因为后端用9014驱动,所以控制输出1时蜂鸣响}/*****************************************************************************/ void Beep_set(void){//BELL -扬声器--确定设置unsigned char a;//定义变量用于发声的长度设置for(a=50;a>0;a--){//第一个声音的长度beep = ~beep;//取反扬声器驱动口,以产生音频Delay(100);//音调设置延时}for(a=100;a>0;a--){//同上beep = ~beep;Delay(50);//}for(a=50;a>0;a--){//同上beep = ~beep;Delay(100);//}beep = 0;//音乐结束后扬声器输出0关闭,因为后端用9014反相驱动,所以控制输出0时蜂鸣响}/*****************************************************************************/ void Beep_key(void){//-扬声器--按键音unsigned char a;//定义变量用于发声的长度设置for(a=100;a>0;a--){//声音的长度beep = ~beep;Delay(50);//音调设置延时}beep = 0;//音乐结束后扬声器拉高关闭}/****************************************************************************** ///农历节日数据库表,农历纪念日数据表,加上公历的重大节日/****************************************************************************** /void jie_nl(void){ //dd = read_clock(0x87);//日mo = read_clock(0x89);//月yy = read_clock(0x8d);//年Conversion(0,yy,mo,dd);//调用公历转农历子函数//调用函数后,原有数据不变,读c_moon农历世纪,year_moon农历年,month_moon,day_moon 得出阴历BCD数据lcm_w_test(0,0x98);//在屏幕第四行显示节日(下面的注释行用坐标尺,不要改动)//农历节日://----|----------------|标尺,汉字不要对在空隙上if ( month_moon == 0x12 && day_moon == 0x29 ){ lcm_w_word(" 明天是春节!!"); }if ( month_moon == 0x12 && day_moon == 0x30 ){ lcm_w_word(" 今天是春节!!"); } if ( month_moon == 0x01 && day_moon == 0x01 ){ lcm_w_word("大年初一拜年啦"); }if ( month_moon == 0x01 && day_moon == 0x14 ){ lcm_w_word(" 明天元宵节!"); }if ( month_moon == 0x01 && day_moon == 0x15 ){ lcm_w_word(" 元宵节到啦! "); }if ( month_moon == 0x05 && day_moon == 0x04 ){ lcm_w_word(" 明天端午"); }if ( month_moon == 0x05 && day_moon == 0x05 ){ lcm_w_word(" 今天端午"); }if ( month_moon == 0x07 && day_moon == 0x06 ){ lcm_w_word(" 明天七月七啦"); }if ( month_moon == 0x07 && day_moon == 0x07 ){ lcm_w_word("牛郎织女鹊桥相会"); }if ( month_moon == 0x08 && day_moon == 0x14 ){ lcm_w_word(" 明天仲秋节"); }if ( month_moon == 0x08 && day_moon == 0x15 ){ lcm_w_word(" 仲秋佳节"); }if ( month_moon == 0x09 && day_moon == 0x08 ){ lcm_w_word(" 明天重阳"); }if ( month_moon == 0x09 && day_moon == 0x09 ){ lcm_w_word(" 今天重阳节"); }if ( month_moon == 0x12 && day_moon == 0x07 ){ lcm_w_word(" 明天腊八"); }if ( month_moon == 0x12 && day_moon == 0x08 ){ lcm_w_word(" 今天腊八"); }if ( month_moon == 0x12 && day_moon == 0x22 ){ lcm_w_word(" 明日辞灶"); }if ( month_moon == 0x12 && day_moon == 0x23 ){ lcm_w_word(" 今日辞灶"); }/*农历生日:if ( month_moon == 0x01 && day_moon == 0x03 ){ lcm_w_word("明天月月妈妈生日"); }if ( month_moon == 0x10 && day_moon == 0x11 ){ lcm_w_word(" 明天三姨生日"); }if ( month_moon == 0x10 && day_moon == 0x11 ){ lcm_w_word("今天三姨生日!"); }*/}void jie_gl(void){ //dd = read_clock(0x87);//日mo = read_clock(0x89);//月yy = read_clock(0x8d);//年//Conversion(0,yy,mo,dd);//调用公历转农历子函数//调用函数后,原有数据不变,读c_moon农历世纪,year_moon农历年,month_moon,day_moon 得出阴历BCD数据lcm_w_test(0,0x98);//在屏幕第四行显示节日(下面的注释行用坐标尺,不要改动)//下面是公历的,有些没意思的,就不显示了if ( mo == 0x01 && dd == 0x01 ){ lcm_w_word(" Happy new year!"); }// ( mo == 0x01 && dd == 0x22 ){ lcm_w_word(" 节日实验"); }//2010-01-22是农历腊八节,用于实验轮流显示if ( mo == 0x02 && dd == 0x13 ){ lcm_w_word("明天情人节了"); }if ( mo == 0x02 && dd == 0x14 ){ lcm_w_word("今天是情人节"); }if ( mo == 0x03 && dd == 0x08 ){ lcm_w_word(" 3.8妇女节"); }if ( mo == 0x03 && dd == 0x11 ){ lcm_w_word(" 明天是植树节"); }if ( mo == 0x03 && dd == 0x12 ){ lcm_w_word("植树节"); }if ( mo == 0x03 && dd == 0x14 ){ lcm_w_word("明天消费者权益日"); }if ( mo == 0x03 && dd == 0x15 ){ lcm_w_word("消费者权益日"); }if ( mo == 0x04 && dd == 0x01 ){ lcm_w_word("愚人节小心上当"); }//if ( mo == 0x04 && dd == 0x07 ){ lcm_w_word(" 世界卫生日"); } if ( mo == 0x04 && dd == 0x08 ){ lcm_w_word("复活节"); }//if ( mo == 0x04 && dd == 0x13 ){ lcm_w_word(" 黑色星期五"); }if ( mo == 0x05 && dd == 0x01 ){ lcm_w_word("劳动节放假"); }//5 if ( mo == 0x05 && dd == 0x04 ){ lcm_w_word("青年节"); }if ( mo == 0x05 && dd == 0x08 ){ lcm_w_word("世界红十字日"); }if ( mo == 0x05 && dd == 0x12 ){ lcm_w_word("国际护士节"); }if ( mo == 0x05 && dd == 0x05 ){ lcm_w_word("近日注意母亲节"); }if ( mo == 0x05 && dd == 0x06 ){ lcm_w_word("近日注意母亲节"); }//if ( mo == 0x05 && dd == 0x15 ){ lcm_w_word(" 国际家庭日"); } if ( mo == 0x05 && dd == 0x31 ){ lcm_w_word("明天儿童节"); }if ( mo == 0x06 && dd == 0x01 ){ lcm_w_word("月月儿童节快乐! "); }//6 if ( mo == 0x06 && dd == 0x05 ){ lcm_w_word("世界环境日"); }//if ( mo == 0x06 && dd == 0x26 ){ lcm_w_word(" 国际禁毒日"); } //if ( mo == 0x06 && dd == 0x06 ){ lcm_w_word(" 全国爱眼日"); } if ( mo == 0x06 && dd == 0x13 ){ lcm_w_word("近日注意父亲节"); }if ( mo == 0x06 && dd == 0x15 ){ lcm_w_word("近日注意父亲节"); }if ( mo == 0x07 && dd == 0x01 ){ lcm_w_word("香港回归记念日"); }//7 //if ( mo == 0x07 && dd == 0x07 ){ lcm_w_word("抗日战争记念日"); } //if ( mo == 0x07 && dd == 0x11 ){ lcm_w_word(" 世界人口日"); }if ( mo == 0x08 && dd == 0x01 ){ lcm_w_word("八一建军节"); }//8 // if ( mo == 0x08 && dd == 0x08 ){ lcm_w_word("中国男子节"); } if ( mo == 0x08 && dd == 0x15 ){ lcm_w_word("抗战胜利记念日"); }if ( mo == 0x09 && dd == 0x09 ){ lcm_w_word("明天教师节"); }if ( mo == 0x09 && dd == 0x10 ){ lcm_w_word("中国教师节"); }//9 if ( mo == 0x09 && dd == 0x18 ){ lcm_w_word("九一八事变纪念"); }if ( mo == 0x09 && dd == 0x20 ){ lcm_w_word("国际爱牙日"); }if ( mo == 0x09 && dd == 0x27 ){ lcm_w_word("世界旅游日"); }if ( mo == 0x10 && dd == 0x01 ){ lcm_w_word("中国国庆节"); }//10 //if ( mo == 0x10 && dd == 0x04 ){ lcm_w_word(" 世界动物日"); } if ( mo == 0x10 && dd == 0x24 ){ lcm_w_word("联合国日"); }//if ( mo == 0x10 && dd == 0x12 ){ lcm_w_word("明天国际教师节"); } //if ( mo == 0x10 && dd == 0x13 ){ lcm_w_word(" 国际教师节"); }//if ( mo == 0x11 && dd == 0x10 ){ lcm_w_word(" 世界青年节"); }//11 // if ( mo == 0x11 && dd == 0x17 ){ lcm_w_word(" 世界学生节"); }// if ( mo == 0x12 && dd == 0x01 ){ lcm_w_word("世界艾滋病日"); }//12 if ( mo == 0x12 && dd == 0x23 ){ lcm_w_word("明晚平安夜"); }if ( mo == 0x12 && dd == 0x24 ){ lcm_w_word("今晚平安夜"); }if ( mo == 0x12 && dd == 0x25 ){ lcm_w_word("今天圣诞节"); }if ( mo == 0x12 && dd == 0x31 ){ lcm_w_word("明日元旦"); }else{//非节日时显示时晨信息,判断小时数据范围,调取显示if ( hh >= 0x04 && hh < 0x06 ){ lcm_w_word("★★__▲▲__凌晨"); }if ( hh >= 0x06 && hh < 0x08 ){ lcm_w_word("☆○__▲△__早晨"); }if ( hh >= 0x08 && hh < 0x12 ){ lcm_w_word("__●__▲▲__上午"); }if ( hh == 0x12) { lcm_w_word("____▲●▲__中午"); }if ( hh >= 0x13 && hh < 0x18 ){ lcm_w_word("__▲▲__●__下午"); }if ( hh >= 0x18 && hh < 0x22 ){ lcm_w_word("△▲__●☆__晚上"); }if ( hh >= 0x22 && hh <= 0x23 ){ lcm_w_word("△▲__★☆__夜里"); }if ( hh >= 0x00 && hh < 0x04 ){ lcm_w_word("__★▲▲★__深夜"); }}}/*****************************************************************************/ //电子钟应用层程序设计/*****************************************************************************/ //向LCM中填写年数据void lcm_w_yy(void){yy = read_clock(0x8d);//调用1302时钟数据中的年数据,从地址0x8d中lcm_w_test(0,0x80);lcm_w_word("20");//显示内容字符20lcm_w_test(1,(yy/16)+0x30);//函数参数1,代表本行写数据,YY/16+0X30得出年十位数字的显示码地址,送显示lcm_w_test(1,yy%16+0x30);//函数参数1,代表本行写数据,YY%得出年个位数字的显示码地址,送显示//因为年数据两位数字如果是09,C51默认是16进制数据,所以要用16来分离十位、个位。