/******************************************************************* * * _Label Labels the x & y-axis */ static void _Label(void) { int x, y; GUI_SetBkColor(GUI_RED); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("MEMDEV_DrawGraph - Sample", 160, 5); GUI_SetPenSize(1); GUI_ClearRect(0, (LCD_YSIZE - 21) - YSIZE, (LCD_XSIZE - 1), (LCD_YSIZE - 1)); GUI_DrawRect(18, (LCD_YSIZE - 21) - YSIZE, (LCD_XSIZE - 1), (LCD_YSIZE - 20)); GUI_SetFont(&GUI_Font6x8); for (x = 0; x < (LCD_XSIZE - 20); x += 40) { int xPos = x + 18; GUI_DrawVLine(xPos, (LCD_YSIZE - 20), (LCD_YSIZE - 14)); GUI_DispDecAt(x / 40, xPos - 2, (LCD_YSIZE - 9), 1); } for (y = 0; y < YSIZE / 2; y += 20) { int yPos = (LCD_YSIZE - 20) - YSIZE / 2 + y; GUI_DrawHLine(yPos, 13, 18); if (y) { GUI_GotoXY(1, yPos - 4); GUI_DispSDec(-y / 20, 2); yPos = (LCD_YSIZE - 20) - YSIZE / 2 - y; GUI_DrawHLine(yPos, 13, 18); GUI_GotoXY(1, yPos - 4); GUI_DispSDec(y / 20, 2); } else { GUI_DispCharAt('0', 7, yPos - 4); } } }
static void _Label(void) { int x, y; GUI_SetPenSize(1); GUI_ClearRect(0, (LCD_GetYSize() - 21) - _YSize, (LCD_GetXSize() - 1), (LCD_GetYSize() - 1)); GUI_DrawRect(18, (LCD_GetYSize() - 21) - _YSize, (LCD_GetXSize() - 1), (LCD_GetYSize() - 20)); GUI_SetFont(&GUI_Font6x8); for (x = 0; x < (LCD_GetXSize() - 20); x += 40) { int xPos = x + 18; GUI_DrawVLine(xPos, (LCD_GetYSize() - 20), (LCD_GetYSize() - 14)); GUI_DispDecAt(x / 40, xPos - 2, (LCD_GetYSize() - 9), 1); } for (y = 0; y < _YSize / 2; y += 20) { int yPos = (LCD_GetYSize() - 20) - _YSize / 2 + y; GUI_DrawHLine(yPos, 13, 18); if (y) { GUI_GotoXY(1, yPos - 4); GUI_DispSDec(-y / 20, 2); yPos = (LCD_GetYSize() - 20) - _YSize / 2 - y; GUI_DrawHLine(yPos, 13, 18); GUI_GotoXY(1, yPos - 4); GUI_DispSDec(y / 20, 2); } else { GUI_DispCharAt('0', 7, yPos - 4); } } }
static void utf16big_dispstr(char *s, int len , int x, int y) { __u16 xdist; __u16 b, tmp; int i=0; xdist = x; while( i < len ) { b = s[i] & 0xff; tmp = s[i+1] & 0xff; tmp += b<<8; if( (tmp == 13) || (tmp == 10)) // 换行\r\n { i+=2; continue; } if( tmp == 9) tmp = 0x20; GUI_DispCharAt(tmp, xdist, y); xdist += GUI_GetCharDistX(tmp); i += 2; } }
/******************************************************************************* * Function Name : testgui * Description : GUI测试函数,初化后,显示数据 * Input : None * Output : None * Return : None *******************************************************************************/ void test_gui(void) { int i; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE); GUI_Init(); GUI_Initialized = 1; GUI_DispChars('/', 53); for( i= 0; i < 240; i += 8) { GUI_DispCharAt('/', 312, i); GUI_DispCharAt('/', 1, i); } GUI_DispChars('/', 52); GUI_SetFont(&GUI_Font24B_ASCII); GUI_SetColor(GUI_RED); GUI_DispStringAt("This is a test program!",10,110); }
/********************************************************************* * * _ShowCursorType */ static void _ShowCursorType(const CURSORTYPE_INFO* pCursorType, int x0, int y0) { const GUI_CURSOR * pCursor; char Char; int yMax; int yHot; int i; int x; int y; yMax = 0; yHot = 0; // // Calculate height and width of biggest cursor // for (i = 0; i < NUM_CURSORS; i++) { pCursor = pCursorType->aCursor[i].pCursor; if (pCursor->pBitmap->YSize > yMax) { yMax = pCursor->pBitmap->YSize; yHot = pCursor->yHot; } } GUI_SetFont(&GUI_FontRounded16); #if (NUM_CURSORS != 3) GUI_SetLBorder(x0); #endif GUI_DispStringAt(pCursorType->pType, x0, y0); y0 += GUI_GetFontDistY() + 1; GUI_SetFont(&GUI_Font13B_ASCII); for (i = 0; i < NUM_CURSORS; i++) { pCursor = pCursorType->aCursor[i].pCursor; Char = pCursorType->aCursor[i].Size; y = y0 + yHot - pCursor->yHot; x = ((pCursor->pBitmap->XSize - GUI_GetCharDistX(Char)) / 2); GUI_DrawBitmap(pCursor->pBitmap, x0 + XMAX * i + 5, y); GUI_DispCharAt(Char, x0 + XMAX * i + 5 + x, y0 + yMax + 2); } }
/******************************************************************* * * _DrawScale Drawing a scale using GUI-functions */ static void _DrawScale(void) { int XSize = LCD_GetXSize(); int YSize = LCD_GetYSize(); int XMid = XSize / 2; int i; int r1 = 110; int r2 = 140; int rt = 100; int y = 240; int step = 15; int r = (r1 + r2) / 2; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_DispStringAt("DrawScale - Sample", 160, 5); while (1) { int c = 0; GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font8x16); GUI_SetTextAlign(GUI_TA_LEFT); GUI_Delay(SPEED / 2); GUI_DispStringAtCEOL("using", 5, 40); GUI_DispStringAtCEOL("GUI_AA_DrawArc", 5, 55); GUI_Delay(SPEED * 2); GUI_SetPenSize(r2 - r1); GUI_SetColor(0x0000AA); GUI_AA_DrawArc(XMid, y, r, r, 45, 60); GUI_Delay(SPEED); GUI_SetColor(0x00AA00); GUI_AA_DrawArc(XMid, y, r, r, 60, 90); GUI_Delay(SPEED); GUI_SetPenSize(2); GUI_SetColor(GUI_WHITE); GUI_AA_DrawArc(XMid, y, r1, r1, 45, 135); GUI_Delay(SPEED); GUI_AA_DrawArc(XMid, y, r2, r2, 45, 135); GUI_Delay(SPEED); GUI_DispStringAtCEOL("", 5, 55); GUI_Delay(200); GUI_DispStringAtCEOL("using", 5, 40); GUI_DispStringAtCEOL("GUI_AA_DrawLine & GUI_DispCharAt", 5, 55); GUI_Delay(SPEED * 3); for (i = 45; i <= 135; i += step) { float co = cos(i * 3.1415926 / 180); float si = sin(i * 3.1415926 / 180); int x1 = XMid - r1 * co; int y1 = y - r1 * si; int x2 = XMid - (r2 - 1) * co; int y2 = y - (r2 - 1) * si; int xt = XMid - rt * co; int yt = y - rt * si; GUI_SetColor(GUI_WHITE); GUI_SetPenSize(2); GUI_AA_DrawLine(x1, y1, x2, y2); GUI_SetColor(GUI_GREEN); GUI_SetFont(&GUI_Font8x8); GUI_DispCharAt('0' + c++, xt - 4, yt - 4); GUI_Delay(SPEED / 2); } GUI_Delay(SPEED * 3); GUI_ClearRect(0, 30, 320, 240); } }
/***************************************************************************** ** Main Function rtc_main() ******************************************************************************/ void rtc_main (void) { /* SystemClockUpdate() updates the SystemFrequency variable */ SystemCoreClockUpdate(); /* Initialize RTC module */ RTCInit(); GUIDEMO_ShowIntro("Real Time Clock", "Showing" "\nReal Time Clock" "\nBy Siddharth Kaul"); GUI_Clear(); GUI_SetBkColor(GUI_BLUE); GUI_SetColor(GUI_LIGHTRED); GUI_Clear(); GUI_SetFont(&GUI_Font24B_1); local_time.RTC_Sec = 0; local_time.RTC_Min = 0; local_time.RTC_Hour = 0; local_time.RTC_Mday = 8; local_time.RTC_Wday = 3; local_time.RTC_Yday = 12; /* current date 07/12/2006 */ local_time.RTC_Mon = 7; local_time.RTC_Year = 2006; RTCSetTime( local_time ); /* Set local time */ alarm_time.RTC_Sec = 0; alarm_time.RTC_Min = 0; alarm_time.RTC_Hour = 0; alarm_time.RTC_Mday = 1; alarm_time.RTC_Wday = 0; alarm_time.RTC_Yday = 1; /* alarm date 01/01/2007 */ alarm_time.RTC_Mon = 1; alarm_time.RTC_Year = 2007; RTCSetAlarm( alarm_time ); /* set alarm time */ NVIC_EnableIRQ(RTC_IRQn); /* mask off alarm mask, turn on IMYEAR in the counter increment interrupt register */ RTCSetAlarmMask(AMRSEC|AMRMIN|AMRHOUR|AMRDOM|AMRDOW|AMRDOY|AMRMON|AMRYEAR); LPC_RTC->CIIR = IMMIN | IMYEAR; /* 2007/01/01/00:00:00 is the alarm on */ RTCStart(); while (1) { /* Loop forever */ current_time = RTCGetTime(); { char rtc_sec,rtc_min,rtc_hour; rtc_sec = current_time.RTC_Sec; rtc_min = current_time.RTC_Min; rtc_hour = current_time.RTC_Hour; GUI_DispCharAt(rtc_sec, 10, 10); GUI_DispCharAt(rtc_min, 14, 20); GUI_DispCharAt(rtc_hour, 18, 30); } } }