?? main1.c
字號:
/***************************************************************************\
Copyright (c) 2004-2007 threewater@up-tech.com, All rights reserved.
by threewter 2004.5.12
\***************************************************************************/
/***************************************************************************\
#說明: C main 函數(shù),ucos-ii初始化等定義
---------------------------------- Bug --------------------------------------
---------------------------------- TODO list --------------------------------------
----------------------------------修正--------------------------------------
2004-5-12 創(chuàng)建
\***************************************************************************/
#include"../ucos-ii/includes.h" /* uC/OS interface */
#include "../ucos-ii/add/osaddition.h"
#include "../inc/drivers.h"
#include "../inc/sys/lib.h"
#include "../src/gui/gui.h"
#include <string.h>
#include <stdio.h>
#include "uhal/uhal.h"
#include "inc/lcd320.h"
#include "inc/macro.h"
#include "inc/drv/reg2410.h"
#pragma import(__use_no_semihosting_swi) // ensure no functions that use semihosting
///******************任務(wù)定義***************///
OS_STK task1_Stack[STACKSIZE]={0, }; //Main_Test_Task堆棧
void Task1(void *Id); //Main_Test_Task
#define Task1_Prio 2
extern OS_EVENT *pevent;
extern void TchScr_init(void);
extern void irq_TCHSCR(void);
extern void LCD_Init(void);
extern void draw_keyboard(void);
extern void clearscreen(void);
U32 TchScr_GetOSXY(int *x, int *y,int lable);
void getkey(int x,int y);
#pragma import(__use_no_semihosting_swi) // ensure no functions that use semihosting
void ARMTargetInit(void);
extern U32 LCDBufferII2[480][640];
void drawline(int x,int y,int length,int flag,unsigned short color_mask);
static void drawpixel(int x, int y, unsigned short color_mask);
void draw_char(int x,int y,unsigned char c,unsigned short color_mask);
#define WIDTH_GAP 150
#define HEIGHT_GAP 100
#define WIDTH_INIT 20
#define HEIGHT_INIT 40
#define CHAR_WIDTH_INIT 80
#define CHAR_HEIGHT_INIT 60
static unsigned char letter[][3] = { {'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'0', '*', '#'},
};
static unsigned char fx[4] = { '1', '2','3', '4' };
///*****************事件定義*****************///
/////////////////////////////////////////////////////
// Main function. //
////////////////////////////////////////////////////
int main(void)
{
int i = 0;
int j = 0;
int width = 20;
int height = 40;
int x = 0, y = 0;
ARMTargetInit(); // do target (uHAL based ARM system) initialisation //
OSInit(); // needed by uC/OS-II //
LCD_Init();
LCD_Refresh();
clearscreen();
TchScr_init1(); //初始化觸摸屏,此時為非中斷方式。
TchScr_Clibrate(); //校準(zhǔn)觸摸屏,在每次啟動觸摸屏?xí)r都運行該程序;
//第一次運行后要被注釋掉!
//( 校準(zhǔn)觸摸屏); //校準(zhǔn)觸摸屏,取得LCD四個角上的電壓值,然后求得電壓值最大最小值。
//draw_keyboard();
OSTaskCreate(Task1, (void *)0, (OS_STK *)&task1_Stack[STACKSIZE-1], Task1_Prio);
pevent=OSMboxCreate((void*)NULL);
OSAddTask_Init(1);
OSStart(); // start the OS //
return 0;
}//main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Task1(void *Id)
{
U16 timeout=0;
U8 err;
int x,y;
U32 mode;
TchScr_init(); //初始化觸摸屏,以中斷方式開始工作。
for(;;){
OSMboxPend(pevent,timeout,&err); //等到觸摸屏中斷
mode=TchScr_GetOSXY(&x, &y,1); //進(jìn)行坐標(biāo)轉(zhuǎn)換,取得在LCD坐標(biāo)值。
printf("\nx=%d,\ty=%d\n",x,y);
//getkey(x,y); //取得鍵盤值。
OSTimeDly(1000);
}
}
/*void drawline(int x,int y,int length,int flag,unsigned short color_mask)
{
int i;
if (flag==0)
for (i = 0; i < length; i++)
drawpixel(x+i, y, color_mask);
//畫橫線;
if (flag==1)
for (i = 0; i < length; i++)
drawpixel(x, y+i, color_mask);
//畫豎線;
}
void drawpixel(int x, int y, unsigned short color_mask)
{
unsigned int bits = (SCREEN_WIDTH*y+x)*BITS_PER_PIXEL;
unsigned short *tmp;
//計算像素在內(nèi)存中的地址;
tmp = (unsigned short *)LCD_MEM_BASE + bits / 16;
//給象素填充顏色;
*tmp = color_mask;
return ;
}
void draw_char(int x,int y,unsigned char c,unsigned short color_mask)
{
int i,j,t;
int m, n;
unsigned short *p = helvB12_bits+(c-0x20)*14;//計算字符在字庫中的位置;
for (i=0;i<CHAR_HEIGHT;i++)
{
unsigned short tmp = p[i];
for (j=0;j<CHAR_WIDTH;j++)
{
if (tmp & 0x8000)
{
for (m = 0; m < 5; m++)
for(n = 0; n < 5; n++)
//如果為1,則在字符的相應(yīng)位置畫一個像素;
drawpixel(x+5*j+m, y+5*i+n, color_mask);
}
tmp = tmp << 1;
}
}
}*/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -