⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memdev_banding.c

📁 An interrest demo of uCGUI base S3C44B0X
💻 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 <math.h>#include "44blib.h"U8 Time_Flag=0; extern int nsec,nmin,nhour,nyear,nmonth,nday,nweekday;#define Clock_CenterX 510#define Clock_CenterY 119extern const GUI_BITMAP bmtwins;extern const GUI_BITMAP bmbf;int left=0,kl=0,ml=0,mn=0,klh=0;unsigned char dir=1;#define SIZE_OF_ARRAY(Array) (sizeof(Array) / sizeof(Array[0]))static const GUI_POINT Hour_Polygon[] = {  {-3,  0},  {-3, 50},  { 0 , 70},  { 3, 50},  { 3,  0},  };static const GUI_POINT Min_Polygon[] = {  {-3,  0},  {-3, 60},  { 0 ,100},  { 3, 60},  { 3,  0},  };static const GUI_POINT Sec_Polygon[] = {  {0,  0},  {0, 115}, // { 0 , 119},  { 2, 115},  { 2,  0},  };typedef struct {  GUI_POINT Hour_PolygonDes[5];  GUI_POINT Min_PolygonDes[5];  GUI_POINT Sec_PolygonDes[5]; }Time_Struct;void Disp_TimeAd(void){      GUI_ClearRect(100,0,500,40);      GUI_SetFont(&GUI_Font16B_ASCII);     GUI_SetColor(GUI_RED);     GUI_DispStringAt(":       :", 118,0);     GUI_DispDecAt(nhour,100,0,2);     GUI_DispDecAt(nmin, 130,0,2);     GUI_DispDecAt(nsec, 160,0,2);     GUI_SetColor(GUI_BLUE);     GUI_DispStringAt("/       /",218,0);     GUI_DispDecAt(nyear,  200,0,2);     GUI_DispDecAt(nmonth, 230,0,2);     GUI_DispDecAt(nday,   260,0,2);      }void Disp_TimeDigital(void){      GUI_SetColor(GUI_RED);     GUI_SetFont(&GUI_FontD24x32);     GUI_DispStringAt(":  :", 110,50);     GUI_DispDecAt(nhour,60,50,2);     GUI_DispDecAt(nmin, 130,50,2);     GUI_DispDecAt(nsec, 200,50,2);     GUI_SetFont(&GUI_Font32B_ASCII);     GUI_SetColor(GUI_BLUE);     GUI_DispStringAt("/     /", 100,100);     GUI_DispDecAt(nyear,  65,100,2);     GUI_DispDecAt(nmonth, 110,100,2);     GUI_DispDecAt(nday,   160,100,2);     GUI_DispDecAt(nweekday,235,100,1);      }void Draw_TimeScale(void)   //绘制表盘,共12个,带显示修正{ U16 i=0,x=Clock_CenterX, y=Clock_CenterY;  int c=0;  GUI_SetColor(GUI_GREEN);  GUI_SetFont(&GUI_Font8x8);   for (i=0;i<12;i++)      {      float o=(180-i*30)*0.0174532;     // i%3==0?  GUI_SetFont(&GUI_Font16B_ASCII):GUI_SetFont(&GUI_Font8x8);      x= i>=6? (x-2) : x ;      if (c==0)           GUI_DispDecAt(12,x-6+100*sin(o),y+110*cos(o),2);      if (c>0&&c<=9)      GUI_DispDecAt(c,x+100*sin(o),y-2+110*cos(o),1);      if (c>9)            GUI_DispDecAt(c,x+100*sin(o),y+110*cos(o),2);      c++;      }             }   static void DrawIt(void * pData) {      Time_Struct * nTime_Struct = (Time_Struct *)pData;   GUI_Clear();  GUI_AA_SetFactor(6);  GUI_SetColor(GUI_GREEN);  GUI_AA_FillPolygon(nTime_Struct->Hour_PolygonDes,  SIZE_OF_ARRAY(Hour_Polygon),  Clock_CenterX, Clock_CenterY);  GUI_SetColor(GUI_GREEN);  GUI_AA_FillPolygon(nTime_Struct->Min_PolygonDes,   SIZE_OF_ARRAY(Min_Polygon),    Clock_CenterX, Clock_CenterY);   Disp_TimeDigital();    GUI_SetColor(GUI_RED);  GUI_AA_FillPolygon(nTime_Struct->Sec_PolygonDes,   SIZE_OF_ARRAY(Sec_Polygon),    Clock_CenterX, Clock_CenterY);  GUI_SetColor(GUI_BLUE);  GUI_DrawCircle(Clock_CenterX,Clock_CenterY,119);  GUI_SetTextMode(GUI_TM_TRANS);  Draw_TimeScale();  ml++; if (ml>=10){            ml=0;            if(mn>=280) {            			mn=280;            			dir=0;            			}            if(mn<=1)   {            			mn=1;            			dir=1;            			}                        if(dir==1) mn++;            if(dir==0) mn--;                        }  GUI_DrawBitmap(&bmtwins,mn,150); GUI_SetFont(&GUI_FontHZ12);  //GUI_SetFont(&GUI_Font_HZK16);    GUI_DispStringAt("使用uCOS II和uCGUI制作的时钟,操作系统创建3个任务",0,0);  GUI_DispStringAt("uCGUI旋转3个多边形、绘制表盘,6倍多边形抗锯齿特效",0,14);  GUI_DispStringAt("触摸屏调整时间,存储机制、全屏无闪烁显示移动图片",0,28);  if (kl>=30000){  				kl=0;  				klh++;  				if (klh>=3000)  					{  					klh=0;  					  					}  				}  GUI_DispDecAt(kl++,140,200,5);   GUI_DispDecAt(klh,80,200,5);   GUI_SetColor(GUI_BLUE);  GUI_DispStringAt("星期",200,111);  GUI_SetColor(GUI_GREEN);}void Sec(void) {      Time_Struct   DrawItContext;     float Angle_Hour =(180-30*nhour-nmin/2) * 0.017453292;     float Angle_Min = (180-6*(nmin)) * 0.017453292;     float Angle_Sec = (180-6*nsec) * 0.017453292;//3.1415926 / 60;          GUI_RotatePolygon(DrawItContext.Hour_PolygonDes, Hour_Polygon, SIZE_OF_ARRAY(Hour_Polygon), Angle_Hour);     GUI_RotatePolygon(DrawItContext.Min_PolygonDes,  Min_Polygon,  SIZE_OF_ARRAY(Min_Polygon),  Angle_Min);     GUI_RotatePolygon(DrawItContext.Sec_PolygonDes,  Sec_Polygon,  SIZE_OF_ARRAY(Sec_Polygon),  Angle_Sec);         {          GUI_RECT Rect = {0, 0, 640,240};      GUI_MEMDEV_Draw(&Rect, &DrawIt, &DrawItContext, 0, 0);     } }/*static const GUI_POINT aPoints[] = {  {-50,  0},  {-10, 10},  {  0, 50},  { 10, 10},  { 50,  0},  { 10,-10},  {  0,-50},  {-10,-10}};#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;static void DrawIt(void * pData) {  tDrawItContext * pDrawItContext = (tDrawItContext *)pData;  GUI_Clear();  GUI_SetFont(&GUI_Font8x8);  GUI_SetTextMode(GUI_TM_TRANS);  GUI_SetColor(GUI_GREEN);  GUI_FillRect(pDrawItContext->XPos_Text,                pDrawItContext->YPos_Text - 25,               pDrawItContext->XPos_Text + 100,               pDrawItContext->YPos_Text - 5);    GUI_SetColor(GUI_BLUE);  GUI_FillPolygon(pDrawItContext->aPointsDest, SIZE_OF_ARRAY(aPoints), 160, 120);  GUI_SetColor(GUI_RED);  GUI_FillRect(220 - pDrawItContext->XPos_Text,                pDrawItContext->YPos_Text + 5,               220 - pDrawItContext->XPos_Text + 100,               pDrawItContext->YPos_Text + 25);}#define USE_BANDING_MEMDEV 1void 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/3;    // 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           DrawIt((void *)&DrawItContext);    #endif    #ifdef WIN32      GUI_Delay(20);    #endif    if (GetKey()!=0xff)    	return;  }}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -