📄 testgpc.c
字号:
/*************************************************************************
*
* Copyright (C) Asic Center. 2001
* All Rights Reserved
*
* Filename : testcode.c
* Function : Some tasks for testing system prototype, such as SHELL, TIMER
* TASK, IDLE TASK, TASK A,B,C, and so on.
* Revision :
* 2001/10/9 Pessia Create this file
* 2001/10/25 longn_qi revise shell_task.
*
************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <asixsys.h>
void shell_task(void);
void a_task(void);
void b_task(void);
void c_task(void);
void gpctest( void );
extern void AppendDebugLogString( char *lpText );
/********************************************************************
* Function shell_task()
* param in: void
* param out: void
* description: Shell Task
* In test, we just add 1 or 2 icon on the screen,
* when you push it, shell task will send a message to
* system task to start a special task.
********************************************************************/
void shell_task(void)
{
MSG msg;
int i=0;
char tmp[7];
char coord[40];
int x,y,len;
gpctest();
//gpcSetColor(0xff8800);
//gpcDrawText(10,2,"Shell is running",13);
while(1)
{
SysRecvMessage(&msg, -1);
//debug
switch(msg.message)
{
case SM_KEYDOWN :
case SM_KEYREPEAT :
case SM_KEYUP :
switch( msg.wparam )
{
case PDAVK_OK:
strcpy( tmp, "OK" );
break;
case PDAVK_CANCEL:
strcpy( tmp, "CANCEL" );
break;
case PDAVK_LEFT:
strcpy( tmp, "LEFT" );
break;
case PDAVK_RIGHT:
strcpy( tmp, "RIGHT" );
break;
case PDAVK_UP:
strcpy( tmp, "UP" );
break;
case PDAVK_DOWN:
strcpy( tmp, "DOWN" );
break;
case PDAVK_CENTER:
strcpy( tmp, "CENTER");
break;
case PDAVK_FUNCLEFT:
strcpy( tmp, "FUNC A");
break;
case PDAVK_FUNCRIGHT:
strcpy( tmp, "FUNC B");
break;
case PDAVK_SIDEUP:
strcpy( tmp, "SIDE U");
break;
case PDAVK_SIDEMIDDLE:
strcpy( tmp, "SIDE M");
break;
case PDAVK_SIDEDOWN:
strcpy( tmp, "SIDE D");
break;
default:
tmp[0] = (char) msg.wparam;
tmp[1] = '\0';
}
//gpcDrawText(5,30,tmp,1);
AppendDebugLogString(tmp);
break;
case SM_PENDOWN :
x = ((POINTS *)&msg.lparam)->x;
y = ((POINTS *)&msg.lparam)->y;
sprintf(coord, "d:%d,%d",x,y);
len = strlen(coord);
//gpcSetColor(0x228000);
//gpcDrawText(5,50,coord,len);
AppendDebugLogString(coord);
break;
case SM_PENMOVE :
x = ((POINTS *)&msg.lparam)->x;
y = ((POINTS *)&msg.lparam)->y;
sprintf(coord, "m:%d,%d",x,y);
len = strlen(coord);
//gpcDrawText(5,70,coord,len);
AppendDebugLogString(coord);
break;
case SM_PENUP :
x = ((POINTS *)&msg.lparam)->x;
y = ((POINTS *)&msg.lparam)->y;
sprintf(coord, "u:%d,%d",x,y);
len = strlen(coord);
//gpcDrawText(5,90,coord,len);
AppendDebugLogString(coord);
break;
default:
break;
}
}
}
/********************************************************************
* Function timer_task()
* param in: void
* param out: void
* description: Timer Task
* In test, while timer task receives a timer click,
* it just adds a counter and does nothing else.
********************************************************************/
/*
void timer_task(void)
{
static UW timecount=0;
UINT flgptn;
char tmp[2]="+";
while(1)
{
// if receive a message
wai_flg(&flgptn, TIMER_EVENT, 0x01, TWF_ORW);
// just increase timecount
timecount++;
tmp[0] = (char)(timecount - 0 + '0');
tmp[1] = 0;
//gpcDrawText(30,110,tmp,1);
// avoid overflow
if( timecount = 9 )
timecount = 0;
}
}
*/
/********************************************************************
* Function a_task()
* param in: void
* param out: void
* description: Task A
********************************************************************/
void a_task(void)
{
}
/********************************************************************
* Function b_task()
* param in:
* param out:
* description: Task B
********************************************************************/
void b_task(void)
{
}
/********************************************************************
* Function IdleHandler()
* param in:
* param out:
* description: Task C
********************************************************************/
void c_task(void)
{
}
// gpc debug
void gpctest( )
{
SHORT i, x, y, xh, yh, xv, yv, xl11, yl11, xl12, yl12, xl21, xl22, yl21, yl22, xr1, yr1, xr2, yr2, xc, yc, xs, ys;
WORD width, height, radius, xLength, yLength, dotlineh, dotlinev, dotline, dotliner, oldWidth;
DWORD rgb, rgbh, rgbv, rgbl, rgbr, rgbc, rgbs;
//S16 x = 50;
//S16 y = 50;
//S16 x1 = 10;
//S16 y1 = 10;
//S16 x2 = 60;
//S16 y2 = 30;
//DWORD rgb = GPC_BLACK;
WORD *pbuffer;
PWORD bitmap;
WORD reserved = 1;
//WORD dotLine = GPC_SOLID_LINE;
//WORD width = 10;
//WORD height = 10;
//WORD radius = 81;
//WORD xLength = 10;
//WORD yLength = 20;
WORD newWidth = 10;
//P_WORD *oldWidth;
WORD numberOfPoints;
WORD mode = 1;
PPOINTS pointPtr;
GC *pGC;
numberOfPoints = 3;
pGC = ( GC * ) malloc( sizeof( GC ) );
pointPtr = ( PPOINTS ) malloc( sizeof( POINTS )*numberOfPoints );
pbuffer = ( WORD * )malloc( 160*240*2 );
memset( pbuffer, 0xf0, 160*240*2);
bitmap = ( PWORD )malloc( 160*240*2 );
//oldWidth = ( WORD * )malloc( sizeof( PWORD ) );
//*oldWidth = 10;
x = 60;
y = 100;
xh = 10;
yh = 50;
xv = 30;
yv = 10;
xl11 = 10;
yl11 = 10;
xl12 = 150;
yl12 = 190;
xl21 = 50;
xl22 = 10;
yl21 = 10;
yl22 = 90;
xr1 = 50;
yr1 = 50;
xr2 = 100;
yr2 = 150;
xc = xs = 30;
yc = ys = 50;
width = 40;
height = 80;
radius = 20;
xLength = 20;
yLength = 40;
dotlineh = GPC_SOLID_LINE;
dotlinev = GPC_SOLID_LINE;
dotline = GPC_SOLID_LINE;
dotliner = GPC_SOLID_LINE;
rgb = GPC_WHITE;//GPC_LIGHTRED;
rgbv = rgbh = GPC_RED;
rgbl = GPC_MAGENTA;
rgbr = GPC_BLACK;
rgbc = GPC_GREEN;
rgbs = GPC_BLUE;
mode = 1;
//init GC
pGC->frt_color = GPC_LIGHTGREEN; //前景色
pGC->bk_color = GPC_BLACK; //背景色
pGC->dotwidth = 1; //当前线宽
pGC->status = 1; //状态(是否拥有LCD?)
pGC->width = 160; //屏幕宽(逻辑)
pGC->height = 240; //屏幕高(逻辑)
pGC->vram = pbuffer; //vram指针
pGC->lcd_x = 0; //物理屏幕在逻辑屏幕上的坐标
pGC->lcd_y = 0; //物理屏幕在逻辑屏幕上的坐标
/*
typedef struct{
WORD x; // x point
WORD y; // y point
}POINT, *P_POINT;
*/
//init POINT
pointPtr[1].x = 60;
pointPtr[1].y = 60;
pointPtr[2].x = 60;
pointPtr[2].y = 90;
pointPtr[3].x = 100;
pointPtr[3].y = 80;
SysSetFont( ( DWORD )pGC, ( PBYTE )GPCFONT11A, ( PBYTE )GPCFONT11K );
//SysGetDisplayX();
//SysGetDisplayY(void);
//SysGetLogicalX(( DWORD )pGC);
//SysGetLogicalY(( DWORD )pGC);
//SysGetGC(void);
//SysSetDotWidth( (DWORD)pGC, newWidth, &oldWidth );
for( i = 0; i <= 10; i++ )
{
y = y + i;
SysDrawDot( ( DWORD )pGC, rgb, x, y, GPC_REPLACE_STYLE );
}
SysDrawHorz( ( DWORD )pGC, rgbh, xh, yh, width, dotlineh, GPC_REPLACE_STYLE );
SysDrawVert( ( DWORD )pGC, rgbv, xv, yv, height, dotlinev, GPC_REPLACE_STYLE );
SysDrawLine( ( DWORD )pGC, rgbl, xl11, yl11, xl12, yl12, dotline, GPC_REPLACE_STYLE );//wrong
SysDrawLine( ( DWORD )pGC, rgbl, xl21, yl21, xl22, yl22, dotline, GPC_REPLACE_STYLE );//wrong
SysSaveRec( ( DWORD )pGC, bitmap, xh, yh, width, height, reserved );
SysDrawRec( ( DWORD )pGC, rgbr, xr1, yr1, xr2, yr2, dotliner, GPC_REPLACE_STYLE );
SysDrawCircle( ( DWORD )pGC, rgbc, xc, yc, radius, GPC_REPLACE_STYLE );
SysDrawEllipse( ( DWORD )pGC, rgbs, xs, ys, xLength, yLength, GPC_REPLACE_STYLE );
SysDrawVector( ( DWORD )pGC, rgbc, numberOfPoints, pointPtr, GPC_REPLACE_STYLE, mode);
//SysClearScreen( ( DWORD )pGC, rgb );
//SysPutRec( ( DWORD )pGC, bitmap, xh, yh, width, height, GPC_REPLACE_STYLE, reserved );
//SysClearRec( ( DWORD )pGC, rgb, x, y, width, height, GPC_REPLACE_STYLE );
//SysInvRec( ( DWORD )pGC, xh, yh, width, height );
SysDrawText( ( DWORD )pGC, xh, yh, "ASIC中心", 8 );
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -