📄 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 <hardware\sif.h>
#include <hardware\bcu.h>
#include <hardware\int.h>
#include <hardware\io.h>
#include <hardware\presc.h>
#include <hardware\8timer.h>
#include <hardware\osc.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 <asixwin\bitmap.h>
void a_task(void);
void b_task(void);
void c_task(void);
void d_task(void);
void e_task(void);
/********************************************************************
* Function temp_task()
* param in: void
* param out: void
* description: 应用任务模板
********************************************************************/
void temp_task(void)
{
MSG msg;
U32 mainwin;
//U32 vscroll;
U32 hGC;
U8 quit=0;
/* 创建主窗口 */
mainwin = CreateWindow( WNDCLASS_WIN, //窗口类型(主窗口)
"pessia!!", //窗口标题
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, //控件左上角在逻辑屏幕中的坐标
20,120, //控件的宽度和高度
frame, //控件的父窗口(一般是主窗口)
MAKELONG(1,10), //控件的附加参数(对于滚动条,该参数表示滚动范围)
NULL); //控件的附加数据(滚动条不使用该参数)
*/
/* 用户可以在此绘图,但该图形不会被保存 */
hGC = GetGC();
// 消息处理
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;
// char *bb="中华"; 已经修改
//char b1='中'; 已经修改
//char b2='华'; 已经修改
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,16,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((U32)CurWindow,lboxitem[msg.wparam].item_text,"hello",MB_ICONHAND|MB_OK);
break;
case WM_QUIT:
if( MessageBox((U32)CurWindow,"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_UNCHECKED, "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,43,16,20,frame,0, (void *)menuitem);
checkb = CreateWindow(WNDCLASS_SELECT, "Check", WS_CHILD|SLS_CHECKBOX, 10,63,60,40,frame,0, item);
//checkb = CreateWindow(WNDCLASS_SELECT, "Check", WS_CHILD|SLS_RADIOBOX, 10,63,60,40,frame,0, item);
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_COMMAND:
if ( msg.lparam == bt1 )
{
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);
}
} 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,bt1,bt2;
U32 i;
//U16 buffer[PHY_LCD_W][PHY_LCD_H];
pGC = GetGC();
frame = CreateWindow(WNDCLASS_WIN, "gsm", WS_OVERLAPPEDWINDOW, 0,0,PHY_LCD_W,PHY_LCD_H,0,0,NULL);
bt1 = CreateWindow(WNDCLASS_BUTTON, "call", WS_CHILD|BS_REGULAR, 40,43,68,20,frame,0,NULL);
bt2 = CreateWindow(WNDCLASS_BUTTON, "halt", WS_CHILD|BS_REGULAR, 40,73,68,20,frame,0,NULL);
//Send_AT_CMD("ATATAT");
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_COMMAND:
if ( msg.lparam == bt1 )
{
//Send_AT_CMD("ATD13912979125;");
} else
if(msg.lparam == bt2)
{
//Send_AT_CMD("ATH");
/* enable GSM_RING interrupt */
*(volatile unsigned char *)0x40270 |= 0x04;
}
break;
case WM_QUIT:
quit = 1;
break;
case 0x400://phone ring
/* get this call */
i=1;
while(i++<200){}
//Send_AT_CMD("ATA");
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;
U16 key[]={ 'A',
0xD6D0,
'B',
'C',
0xB9FA,
0xC8CB,
'D'};
U16 *pkey = key;
struct ed_ctrl *edctrl;
mainwin = CreateWindow( WNDCLASS_WIN,
"pessia!!",
WS_OVERLAPPEDWINDOW,
0,0,
PHY_LCD_W,PHY_LCD_H,
0,
0,
NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -