📄 testasix.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
*
************************************************************************/
#include <stdio.h>
#include <string.h>
#include <asixwin.h>
#include <asixapp.h>
#include <asixwin\asix_mn.h>
#include <asixwin\select.h>
#include <asixwin\asix_sb.h>
#include <asixwin\asix_lb.h>
#include <asixwin\disp.h>
#include <asixwin\asix_ed.h>
#include <asixwin\asix_key.h>
#include <resource\bitmap.h>
#include <resource\picture.h>
void a_task(void);
void b_task(void);
void c_task(void);
extern unsigned char num0_bmp[];
extern unsigned char btbmp001[];
extern void temp_task(void);
extern void a_task(void);
extern void b_task(void);
extern void c_task(void);
extern void test_sed( void );
extern void test_kb( void );
extern void test_med( void );
TASKDESCRIPTION TempTskDesp =
{"temp_task", ASIX_APP, 0, news, 2048, 1, LCD_WIDTH, LCD_HEIGHT, temp_task, APP_PRI};
TASKDESCRIPTION TestkbTskDesp =
{"test_kb", ASIX_APP, 0, xitong, 2048, 1, LCD_WIDTH, LCD_HEIGHT, test_kb, APP_PRI};
TASKDESCRIPTION TestsedTskDesp =
{"test_sed", ASIX_APP, 0, yingyong, 2048, 1, LCD_WIDTH, LCD_HEIGHT, test_sed, APP_PRI};
TASKDESCRIPTION TestmedTskDesp =
{"test_med", ASIX_APP, 0, gupiao, 2048, 1, LCD_WIDTH, LCD_HEIGHT, test_med, APP_PRI};
TASKDESCRIPTION ATskDesp =
{"a_task", ASIX_APP, 0, dingwei, 2048, 1, LCD_WIDTH, LCD_HEIGHT, a_task, APP_PRI};
TASKDESCRIPTION BTskDesp =
{"b_task", ASIX_APP, 0, xh1, 2048, 1, LCD_WIDTH, LCD_HEIGHT, b_task, APP_PRI};
TASKDESCRIPTION CTskDesp =
{"c_task", ASIX_APP, 0, jishi1, 2048, 1, LCD_WIDTH, LCD_HEIGHT, c_task, APP_PRI};
/********************************************************************
* Function temp_task()
* param in: void
* param out: void
* description: 应用任务模板
********************************************************************/
void temp_task(void)
{
MSG msg;
U32 mainwin;
//U32 vscroll;
U32 tskbar;
U32 hGC;
U8 quit=0;
/* 创建主窗口 */
mainwin = CreateWindow( WNDCLASS_WIN, //窗口类型(主窗口)
"应用任务模板", //窗口标题
WS_OVERLAPPEDWINDOW, //窗口风格(主窗口风格的宏定义参见头文件asixwin.h)
0,0, //窗口左上角在逻辑屏幕中的坐标
PHY_LCD_W,PHY_LCD_H, //窗口的宽度和高度
0, //窗口的父窗口(主窗口没有父窗口)
0, //窗口的附加参数(主窗口没有附加参数)
NULL); //窗口的附加数据(主窗口没有附加数据)
/* 创建控件 */
/* 在此用户加入自己所需的控件 */
// 控件实例:
/*
vscroll = CreateWindow( WNDCLASS_SCROLL, //控件类型(滚动条)
"Scroll", //控件标题(对于滚动条,标题不会显示)
WS_CHILD|SBS_VERT, //控件风格(控件风格的宏定义参见头文件asixwin.h)
100,20, //控件左上角在逻辑屏幕中的坐标
12,120, //控件的宽度和高度
mainwin, //控件的父窗口(一般是主窗口)
MAKELONG(1,10), //控件的附加参数(对于滚动条,该参数表示滚动范围)
NULL); //控件的附加数据(滚动条不使用该参数)
*/
tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_REGULAR, 0, 0, 0, 0,mainwin, 0, NULL);
/* 用户可以在此绘图,但该图形不会被保存 */
hGC = GetGC();
PopUpWindow( mainwin, 0 );
// 消息处理
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
// 在此用户加入自己的消息处理
// 关闭窗口的消息,建议用户不要更改该消息的处理
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( mainwin );
EndofTask();
}
/********************************************************************
* Function a_task()
* param in: void
* param out: void
* description: Task A
********************************************************************/
void a_task(void)
{
MSG msg;
U32 frame;
U32 pGC;
U8 quit=0;
U32 vscroll;
// U32 hscroll;
U32 lbox;
U32 st;
U8 i=0;
U8 row = 0;
struct LBOX_ITEM lboxitem[] =
{
ICON_ENABLE, UNDERLINE, "abc",
ICON_ENABLE, UNUNDERLINE, "1234567",
ICON_DISABLE, UNDERLINE, "+-*/",
ICON_ENABLE, UNDERLINE, "Hello,Everybody!",
ICON_END, UNDERLINE, NULL
};
pGC = GetGC();
ClearScreen(pGC, GPC_GREENYELLOW);
frame = CreateWindow(WNDCLASS_WIN, "pessia!!", WS_OVERLAPPEDWINDOW, 0,0,PHY_LCD_W,PHY_LCD_H,0,0,NULL);
vscroll = CreateWindow(WNDCLASS_SCROLL, "Scroll", WS_CHILD|SBS_VERT, 100,20,20,120,frame,MAKELONG(1,10), NULL);
//hscroll = CreateWindow(WNDCLASS_SCROLL, "Check", WS_CHILD|SBS_HORZ, 0,140,120,20,frame,MAKELONG(1,10), NULL);
lbox = CreateWindow(WNDCLASS_LIST, "ListBox", WS_CHILD|LBS_POPUP, 10,40,70,16,frame,0, lboxitem);
//lbox = CreateWindow(WNDCLASS_LIST, "ListBox", WS_CHILD|LBS_ROLL, 10,40,85,16,frame,0, lboxitem);
st = CreateWindow(WNDCLASS_STATIC, "Static", WS_CHILD|SS_TEXT|SS_BOARD, 10,20,40,18,frame,0, NULL);
// TextOut( pGC, "ASIC工程中心", ColorTheme.form_text,10, 60, 0, GPC_REPLACE_STYLE);
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_COMMAND:
break;
case WM_LISTBOX:
MessageBox( 0,lboxitem[msg.wparam].item_text,"hello",MB_ICONHAND|MB_OK);
break;
case WM_QUIT:
if( MessageBox( 0,"You will close this programm,R u sure?",\
"R U Sure?",MB_ICONQUESTION|MB_YESNOCANCEL) == IDYES )
quit = 1;
break;
case WM_VSCROLL:
i=0;
switch(msg.wparam)
{
case SB_LINEDOWN :
if(++row >= 10) row = 10;
break;
case SB_LINEUP :
if(row!=0) row--;
break;
case SB_PAGEDOWN :
if((row+=3) >=10) row = 10;
break;
case SB_PAGEUP :
if(row >3) row-=3;
break;
case SB_THUMBTRACK :
i=1;//temp code
break;
case SB_ENDSCROLL :
i=1;//temp code
break;
default:
break;
}
if(!i) SetScrollPos( vscroll, row , 0 , 0 );
break;
default:
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( frame );
EndofTask();
}
/********************************************************************
* Function b_task()
* param in:
* param out:
* description: Task B
********************************************************************/
void b_task(void)
{
MSG msg;
U32 frame;
U32 pGC;
U32 bt1;
//U32 bt2;
U32 bt3;// fot test button
U32 menu; // for test menu
U32 checkb;
U32 quit=0, i=0;
char wtemp[2]={0,0};
struct MENU_ITEM menuitem[]=
{
1, 1, "hello",
1, 1, "why?",
1, 1, "1234567899999999",
1, 1, "sfdsdsdsdsdsdsd",
1, 1, "hello",
1, 1, "why?",
// 1, 1, "1234567899999999",
// 1, 1, "sfdsdsdsdsdsdsd",
// 1, 1, "hello",
// 1, 1, "why?",
// 1, 1, "1234567899999999",
// 1, 1, "sfdsdsdsdsdsdsd",
0, 0, NULL,
};
SL_ITEM item[]=
{
SL_CHECKED, "abc",
SL_CHECKED, "123",
0, NULL
};
pGC = GetGC();
ClearScreen(pGC, GPC_GREENYELLOW);
frame = CreateWindow(WNDCLASS_WIN, "pessia!!", WS_OVERLAPPEDWINDOW, 0,0,PHY_LCD_W,PHY_LCD_H,0,0,NULL);
bt1 = CreateWindow(WNDCLASS_BUTTON, "退出", WS_CHILD|BS_REGULAR, 40,43,68,20,frame,0,NULL);
//bt2 = CreateWindow(WNDCLASS_BUTTON, "Hello", WS_CHILD|BS_REGULAR, 40,80,68,20,frame,0,NULL);
bt3 = CreateWindow(WNDCLASS_BUTTON, "重画", WS_CHILD|BS_REGULAR, 40,110,68,20,frame,0,NULL);
menu = CreateWindow(WNDCLASS_MENU, "菜单", WS_CHILD, 10,30,16,20,frame,0, (void *)menuitem);
checkb = CreateWindow(WNDCLASS_SELECT, "Check", WS_CHILD|SLS_CHECKBOX|SLS_ENABLE, 10,63,60,40,frame,0, item);
//checkb = CreateWindow(WNDCLASS_SELECT, "Check", WS_CHILD|SLS_RADIOBOX|SLS_ENABLE, 10,63,60,40,frame,0, item);
SetFocus( bt1 );
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_COMMAND:
if ( msg.lparam == bt1 )
{
CreateDynamicTask( &TempTskDesp, RUN_AS_EXISTED_TASK );
//quit = 1;
}
else /*if (msg.lparam == checkb) {
TextOut(pGC, "Task B-RTC", 5, 5, 0, GPC_RED, GPC_REPLACE_STYLE);
i++;
if ( i > 1) {
SetWindowText(bt2, "World...", NULL);
i -= 2;
} else
SetWindowText(bt2, "Hello", NULL);
} else */if (msg.lparam == bt3) {
for( i = 0; i < 1000; i++ )
{
//DrawCircle(pGC, GPC_WHITE, 50, 50, i%25+1, GPC_XOR_STYLE);
//DrawHorz(pGC, GPC_WHITE, 20, (20+i)%100, (i+1)%100, GPC_SOLID_LINE, GPC_XOR_STYLE);
//DrawMonoImage(pGC, question_icon, 6+i%100, 30, 24, 24, GPC_LIGHTBLUE, GPC_WHITE);
{
U32 hbmp;
//U32 trColor;
U16 x = 6+i%100;
U16 y = 30;
U32 palette[] = { GPC_WHITE, GPC_LIGHTBLUE };
hbmp = LoadBitmap( question_icon, palette );
if( hbmp != 0 )
{
SetBMPPalette( hbmp, palette, NULL );
//SetBkFillMode( pGC, MAKELONG( GPC_REPLACE_STYLE, GPC_TRANSPARENT_STYLE ) );
//GetBMPPixel( pGC, 0, 0, hbmp, &trColor );
//DisplayBMPEx( pGC, x, y, hbmp, GPC_TRANSPARENT_STYLE, trColor );
DisplayBMP( pGC, x, y, hbmp );
FreeBitmap( hbmp );
}
}
}
} else if (msg.lparam == menu) {
;
}
break;
case WM_SELECTBOX:
quit = 0;
break;
case WM_QUIT:
quit = 1;
break;
default:
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( frame );
EndofTask();
}
/********************************************************************
* Function IdleHandler()
* param in:
* param out:
* description: Task C
********************************************************************/
void c_task(void)
{
MSG msg;
U32 frame;
U32 pGC;
U8 quit=0;
U32 tim_id;
U32 i;
// U16 *buffer;
const U16 wnd_x = 20, wnd_y = 20, wnd_w = PHY_LCD_W*2/3, wnd_h = PHY_LCD_H*2/3;
pGC = GetGC();
frame = CreateWindow(WNDCLASS_WIN, "pessia!!", WS_OVERLAPPEDWINDOW, wnd_x,wnd_y,wnd_w,wnd_h,0,0,NULL);
// buffer = (U16 *)Lmalloc( PHY_LCD_W * PHY_LCD_H *sizeof(U16) );
// SaveRec( pGC, buffer, 0, 0, PHY_LCD_W, PHY_LCD_H, 0 );
// PutRec( pGC, buffer, 0, 0, PHY_LCD_W, PHY_LCD_H, GPC_TRANSPARENT_STYLE, 0 );
CreateTimer( &tim_id, 1000, NULL, NULL, CYC_MODE|AUTO_START_MODE );
StartTimer( tim_id );
i = 1;
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_COMMAND:
break;
case WM_QUIT:
quit = 1;
break;
case WM_TIMER:
if( msg.lparam == tim_id )
{
DrawHorz(pGC, BLINK_MASK, wnd_x+20, wnd_y+20+i%100, i%100, GPC_SOLID_LINE, GPC_XOR_STYLE);
//DrawCircle(pGC, GPC_WHITE, 50, 50, i%25+1, GPC_XOR_STYLE);
i++;
PopUpWindow( frame, 0 );
//StartTimer( tim_id );
}
break;
default:
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
StopTimer( tim_id );
FreeTimer( tim_id );
DestroyWindow( frame );
EndofTask();
}
/********************************************************************
* Function test_sed()
* param in: void
* param out: void
* description: 测试单行编辑器
********************************************************************/
void test_sed(void) // test single editor
{
MSG msg, ed_msg;
U32 mainwin;
U32 hGC;
U32 bt1,bt2,bt3,bt4,bt5,bt6;
U32 edit1, edit2;
U8 quit=0;
U16 i=0;
S8 key[][4]={ "A",
"中",
"B",
"C",
"国",
"人",
"D"};
ASIX_WINDOW *focusWin;
struct ed_ctrl *edctrl;
mainwin = CreateWindow( WNDCLASS_WIN,
"单行编辑器测试",
WS_OVERLAPPEDWINDOW,
0,0,
PHY_LCD_W,PHY_LCD_H,
0,
0,
NULL);
bt1 = CreateWindow( WNDCLASS_BUTTON,
"按键",
WS_CHILD | BS_REGULAR,
20,30,
32,20,
mainwin,
0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -