📄 graphicdemo.c
字号:
/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: GraphicDemo.c
** Last modified Date: 2008-04-15
** Last Version: 1.0
** Descriptions: demonstrate the 2D Graphic
**
**------------------------------------------------------------------------------------------------------
** Created by: Houxiaolong
** Created date: 2008-04-14
** Version: 1.0
** Descriptions: demonstrate the 2D Graphic
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include "LCD2478.h"
#define LONGTH 60
extern unsigned char number[];
/*********************************************************************************************************
** Function name: __drawPolygon
** Descriptions: draw polygon
** Input parameters: none
** Output parameters: none
*********************************************************************************************************/
static void __drawPolygon(void)
{
uint32 const poly5[] = {135, 240, 120, 255, 120, 285, 150, 285, 150, 255, 135, 240};
GUI_RectangleFill(40, 180, 90, 220, YELLOW); /* fill the rectangle */
delay_Ns(1000);
GUI_RectangleFill(0, 40, GUI_LCM_XMAX, GUI_LCM_YMAX, BLACK); /* clear the panel */
GUI_CircleFill(90, 250, 30, GREEN); /* fill a circle */
delay_Ns(1000);
GUI_RectangleFill(0, 40, GUI_LCM_XMAX, GUI_LCM_YMAX, BLACK); /* clear the panel */
GUI_LineS(poly5, 6, RED); /* draw polygon */
delay_Ns(1000);
GUI_RectangleFill(0, 40, GUI_LCM_XMAX, GUI_LCM_YMAX, BLACK); /* clear the panel */
GUI_EllipseFill(180, 220, 200, 270, MAGENTA); /* fill a ellipse */
delay_Ns(1000);
GUI_RectangleFill(0, 40, GUI_LCM_XMAX, GUI_LCM_YMAX, BLACK); /* clear the panel */
}
/*********************************************************************************************************
** Function name: __drawMeter
** Descriptions: display the meter
** Input parameters: none
** Output parameters: none
*********************************************************************************************************/
static void __drawMeter(void)
{
unsigned char i;
char cbuff[3];
int ix0 = GUI_LCM_XMAX / 2;
int iy0 = GUI_LCM_YMAX / 2;
int ix = 0;
int iy = 0;
int dx = ix0;
int dy = iy0;
float uiangle;
GUI_Arc(ix0, iy0, LONGTH + 50, 30, 150, WHITE); /* draw arcs */
for (i = 0; i < 23; i++) {
uiangle = (-30 + i * 10) * 3.1415926 / 180;
ix = -(LONGTH + 40) * cos(uiangle) + ix0;
iy = -(LONGTH + 40) * sin(uiangle) + iy0;
if (i % 2 == 0) {
GUI_CircleFill(ix, iy, 2, GREEN); /* fill a circle */
} else {
GUI_CircleFill(ix, iy, 1, YELLOW); /* fill a circle */
}
GUI_SetColor(RED, BLACK);
if (i % 2 == 0) {
ix = -(LONGTH + 23) * cos(uiangle) + ix0;
iy = -(LONGTH + 30) * sin(uiangle) + iy0;
sprintf(cbuff, "%d", i * 10);
GUI_PutString(ix - 8, iy - 4, cbuff); /* display the meter's value */
}
}
/*
* display the meter
*/
GUI_SetColor(MAGENTA, BLACK);
for (i = 0; i < 221; i++) {
uiangle = (-30 + i ) * 3.1415926 / 180;
ix = -LONGTH * cos(uiangle) + ix0;
iy = -LONGTH * sin(uiangle) + iy0;
GUI_PutChar(ix0 + 30, iy0 + 40, number[i / 100]); /* 显示百位 */
GUI_PutChar(ix0 + 37, iy0 + 40, number[i % 100 / 10]); /* 显示十位 */
GUI_PutChar(ix0 + 44, iy0 + 40, number[i % 100 % 10]); /* 显示个位 */
GUI_LineWith(ix0, iy0, dx, dy, 2, BLACK); /* clear the track */
GUI_LineWith(ix0, iy0, ix, iy, 2, BLUE); /* display the pointer */
delay_Ns(40);
dx = ix;
dy = iy;
}
for (i = 220; i > 0; i--) {
uiangle = (-30 + i ) * 3.1415926 / 180;
ix = -LONGTH * cos(uiangle) + ix0;
iy = -LONGTH * sin(uiangle) + iy0;
GUI_PutChar(ix0 + 30, iy0 + 40, number[i / 100]); /* 显示百位 */
GUI_PutChar(ix0 + 37, iy0 + 40, number[i % 100 / 10]); /* 显示十位 */
GUI_PutChar(ix0 + 44, iy0 + 40, number[i % 100 % 10]); /* 显示个位 */
GUI_LineWith(ix0, iy0, dx, dy, 2, BLACK); /* clear the track */
GUI_LineWith(ix0, iy0, ix, iy, 2, BLUE); /* display the pointer */
delay_Ns(25);
dx = ix;
dy = iy;
}
GUI_LineWith(ix0, iy0, ix, iy, 2, BLUE);
GUI_PutChar(ix0 + 30, iy0 + 40, number[i / 100]); /* 显示百位 */
GUI_PutChar(ix0 + 37, iy0 + 40, number[i % 100 / 10]); /* 显示十位 */
GUI_PutChar(ix0 + 44, iy0 + 40, number[i % 100 % 10]); /* 显示个位 */
}
/*********************************************************************************************************
** Function name: __showName
** Descriptions: show the demo name
** Input parameters: none
** Output parameters: none
*********************************************************************************************************/
static void __showName(void)
{
delay_Ns(200);
GUI_FillSCR(YELLOW);
GUI_SetColor(RED, YELLOW);
GUI_PutString8_8(70, 150, "Graphic-Sample");
delay_Ns(1500);
}
/*********************************************************************************************************
** Function name: graphicDemo
** Descriptions: demonstrate the 2D Graphic's function
** Input parameters: none
** Output parameters: none
*********************************************************************************************************/
void graphicDemo(void)
{
__showName();
GUI_FillSCR(BLACK); /* clear the LCD panel */
GUI_SetColor(WHITE, BLACK);
GUI_PutString8_8(70, 20, "Graphic-Demo"); /* display "Graphic-Demo" */
__drawPolygon(); /* display the polygon */
__drawMeter(); /* display the meter */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -