void Task2(void *pdata) { unsigned int i, x, m, n, k, y; int tmp,key; int width = 10; int height = 100; if(user_task2_firstboot == 1) { //LCD 初始化 Lcd_Display(); user_task2_firstboot = 0; } while(1) { i++; if(i>99)i=0; if(rBCDYEAR == 0x99) rYear = 1999; else rYear = (2000 + rBCDYEAR); rMonth = FROM_BCD(rBCDMON & 0x1f); rDay = FROM_BCD(rBCDDAY & 0x03f); rDayOfWeek = rBCDDATE - 1; rHour = FROM_BCD(rBCDHOUR & 0x3f); rMinute = FROM_BCD(rBCDMIN & 0x7f); rSecond = FROM_BCD(rBCDSEC & 0x7f); OSTimeDly( 5 ); OSPrintf("\nEnter Task2\n"); OSPrintf("LCD display Test!\n\n"); //在LCD上打印日期,星期,时间 Lcd_printf(0,65,RGB( 0xFF,0xFF,0xFF),RGB( 0x00,0x00,0x00),0,"时间:%4d-%02d-%02d 星期%d %02d:%02d:%02d\n", rYear, rMonth, rDay,rDayOfWeek, rHour, rMinute, rSecond); Lcd_printf(84,92,RGB( 0xFF,0xFF,0xFF),RGB( 0x00,0x00,0x00),1," uC/OS2任务演示"); Lcd_printf(89,122,RGB( 0xFF,0xFF,0xFF),RGB( 0x00,0x00,0x00),0,"任务 计数中:%02d" , i); OSTimeDly(OS_TICKS_PER_SEC/5); } }
/* * * Name : Lcd_Init * * Initialize the *LCD* in 16 characters and 2 lines mode with cursor type as selected in the /MegaIDE/ .This function does not return a value . * * E.g. Usage : * * /Lcd_Init ();/ - Initializes the *LCD* */ void Lcd_Init() { volatile int i; DDRC=0xFF; DDRG=0x1F; PORTC=0; Lcd_WriteCommand(0x38); for(i=8000;i>0;i--); Lcd_WriteCommand(0x01); for(i=8000;i>0;i--); Lcd_WriteCommand(LCDCURSOR); #ifdef LCD_WELCOME_MESSAGE Lcd_printf(LCD_WELCOME_MESSAGE); #endif }
/***************************************************************** * 函数名称:showTime * 描述说明:显示倒计时剩余的时间 * 输入参数:restTime:剩下的时间值 * 输出参数:无 *****************************************************************/ void showTime(int restTime) { Lcd_printf(20, 30, 0, 0xffff, 1, "剩余时间%2d秒", restTime); }