📄 memdev_banding.c
字号:
/*********************************************************************************************************** uC/GUI* Universal graphic software for embedded applications** (c) Copyright 2002, Micrium Inc., Weston, FL* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH** 礐/GUI is protected by international copyright laws. Knowledge of the* source code may not be used to write a similar product. This file may* only be used in accordance with a license and should not be redistributed* in any way. We appreciate your understanding and fairness.*----------------------------------------------------------------------File : MEMDEV_Banding.cPurpose : Example demonstrating the use of banding memory devices----------------------------------------------------------------------*/#include "gui.h"#include "2410lib.h"static const GUI_POINT aPoints[] = { {-50, 0}, {-30, 30}, { 0, 50}, { 30, 30}, { 50, 0}, { 30,-30}, { 0,-50}, {-30,-30}};#define SIZE_OF_ARRAY(Array) (sizeof(Array) / sizeof(Array[0]))typedef struct { int XPos_Poly, YPos_Poly; int XPos_Text, YPos_Text; GUI_POINT aPointsDest[8];} tDrawItContext;/********************************************************************* Drawing routine**********************************************************************/static void DrawIt(void * pData) { tDrawItContext * pDrawItContext = (tDrawItContext *)pData; GUI_Clear(); GUI_SetFont(&GUI_Font8x8); GUI_SetTextMode(GUI_TM_TRANS); /* draw background */ GUI_SetColor(GUI_GREEN); GUI_FillRect(pDrawItContext->XPos_Text, pDrawItContext->YPos_Text - 20, pDrawItContext->XPos_Text + 100, pDrawItContext->YPos_Text - 0); /* draw polygon */ GUI_SetColor(GUI_BLUE); GUI_FillPolygon(pDrawItContext->aPointsDest, SIZE_OF_ARRAY(aPoints), 160,140); /* draw foreground */ GUI_SetColor(GUI_RED); GUI_FillRect(220 - pDrawItContext->XPos_Text, pDrawItContext->YPos_Text + 35, 220 - pDrawItContext->XPos_Text + 100, pDrawItContext->YPos_Text + 55);}/********************************************************************* Demonstrates the banding memory device**********************************************************************/#define USE_BANDING_MEMDEV (1) /* Set to 0 for drawing without banding memory device */void DemoBandingMemdev(void) { int i; int XSize = LCD_GET_XSIZE(); int YSize = LCD_GET_YSIZE(); tDrawItContext DrawItContext; //GUI_SetFont(&GUI_Font8x9); // GUI_SetColor(GUI_WHITE); //GUI_DispStringHCenterAt("Banding memory device\nwithout flickering", // XSize / 2, 40); DrawItContext.XPos_Poly = XSize / 2; DrawItContext.YPos_Poly = YSize / 2; DrawItContext.YPos_Text = YSize / 2 - 4; for (i = 0; i < (XSize - 100); i++) { float angle = i * 3.1415926 / 60; DrawItContext.XPos_Text = i; /* Rotate the polygon */ GUI_RotatePolygon(DrawItContext.aPointsDest, aPoints, SIZE_OF_ARRAY(aPoints), angle); #if USE_BANDING_MEMDEV { GUI_RECT Rect = {0, 70, 320,170}; /* Use banding memory device for drawing */ GUI_MEMDEV_Draw(&Rect, &DrawIt, &DrawItContext, 0, 0); } #else /* Simple drawing without using memory devices */ DrawIt((void *)&DrawItContext); #endif #ifdef WIN32 GUI_Delay(30); /* Use a short delay only in the simulation */ #endif if (Test_keyboard()==15) return; }}void DemoBegin(void) { int i; int XSize = LCD_GET_XSIZE(); int YSize = LCD_GET_YSIZE(); tDrawItContext DrawItContext; while(1) { GUI_FillRect(0,0,320,240); DrawItContext.XPos_Poly = XSize / 2; DrawItContext.YPos_Poly = YSize / 2; DrawItContext.YPos_Text = YSize / 2; for (i = 0; i < (XSize - 100); i++) { float angle = i * 3.1415926 / 60; DrawItContext.XPos_Text = i; GUI_RotatePolygon(DrawItContext.aPointsDest, aPoints, SIZE_OF_ARRAY(aPoints), angle); #if USE_BANDING_MEMDEV { GUI_RECT Rect = {0, 70, 320,190}; GUI_MEMDEV_Draw(&Rect, &DrawIt, &DrawItContext, 0, 0); } #else // DrawIt((void *)&DrawItContext); #endif #ifdef WIN32 GUI_Delay(30); /* Use a short delay only in the simulation */ #endif // if (Test_keyboard()!=16) // return; } }}void DemoPlay(void) { int i; int XSize = LCD_GET_XSIZE(); int YSize = LCD_GET_YSIZE(); U8 IISkey=16; tDrawItContext DrawItContext; GUI_SetFont(&GUI_Font8x9); GUI_SetColor(GUI_RED); while(1) { DrawItContext.XPos_Poly = XSize / 3; DrawItContext.YPos_Poly = YSize / 2; DrawItContext.YPos_Text = YSize / 2 - 24; for (i = 0; i < (XSize - 20); i++) { float angle = i * 3.1415926 / 120; DrawItContext.XPos_Text = i; /* Rotate the polygon */ GUI_RotatePolygon(DrawItContext.aPointsDest, aPoints, SIZE_OF_ARRAY(aPoints), angle); #if USE_BANDING_MEMDEV { GUI_RECT Rect = {0, 70, 320,190}; /* Use banding memory device for drawing */ GUI_MEMDEV_Draw(&Rect, &DrawIt, &DrawItContext, 0, 0); } #else /* Simple drawing without using memory devices */ DrawIt((void *)&DrawItContext); #endif #ifdef WIN32 GUI_Delay(30); /* Use a short delay only in the simulation */ #endif IISkey = Test_keyboard(); if (IISkey == 15 ||IISkey == 11 ||IISkey == 7 ||IISkey == 3 ) return; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -