?? s6d0139.c
字號:
uint8 TftSetWindow(uint16 x0, uint16 y0, uint16 x1, uint16 y1)
{ uint16 hea_hsa;
// 參數(shù)過濾
if(x1>239) x1 = 239;
if(y1>319) y1 = 319;
if((x1<=x0) || (y1<=y0)) return(FALSE);
// 設(shè)置數(shù)據(jù)填充窗口大小
hea_hsa = (x1<<8) | x0;
TftSendCom(SET_WINDOW_SX_EX);
TftSendDat(hea_hsa);
TftSendCom(SET_WINDOW_SY);
TftSendDat(y0);
TftSendCom(SET_WINDOW_EY);
TftSendDat(y1);
return(TRUE);
}
/*******************************************************
* 名稱: DelaymS
* 功能: 軟件延時(1mS,與系統(tǒng)時鐘有關(guān))。
* 入口參數(shù): no 延時控制(uint32),值越大延時越長
* 出口參數(shù): 無
*******************************************************/
void DelaymS(uint32 no)
{ uint32 i;
for(; no>0; no--)
{ for(i=0; i<500; i++);
}
}
/****************************************************************************
* 名稱:TFT_FillSCR()
* 功能:全屏填充。直接使用數(shù)據(jù)填充顯示緩沖區(qū)。
* 入口參數(shù):dat 填充的數(shù)據(jù)
* 出口參數(shù):無
****************************************************************************/
void TFT_FillSCR(uint16 dat)
{ uint16 i, j;
TftSetWindow(0,0, 239, 319);
TftSetWrite(0, 0);
for(i=0; i<GUI_LCM_YMAX; i++) // 歷遍所有行
{ for(j=0; j<GUI_LCM_XMAX; j++) // 歷遍所有行
{ TftSendDat(dat); // 填充數(shù)據(jù)
}
}
}
/*******************************************************
* 名稱: TftReset
* 功能: 控制TFT液晶模塊復(fù)位。
* 入口參數(shù): 無
* 出口參數(shù): 無
*******************************************************/
void TftReset(void)
{ PINSEL7 = PINSEL7 & (~(0x03<<16));
FIO3DIR = FIO3DIR | S6D0139_RST;
FIO3CLR = S6D0139_RST;
DelaymS(10);
FIO3SET = S6D0139_RST;
DelaymS(10);
}
// 定義TFT4137初始化數(shù)據(jù)信息
STCOM_INI TFT4137_INI[] =
{ // 電源設(shè)置
{0x0000, 0x0001, 10}, // Start Oscillation
{0x0007, 0x0000, 0}, // Display control1
{0x0013, 0x0000, 0}, // Power control4 setting
{0x0011, 0x2604, 0}, // Power control2 setting
{0x0014, 0x0015, 0}, // Power control5 setting
{0x0010, 0x3C00, 0}, // Power control1 setting
{0x0013, 0x0040, 10}, // Power control4 setting
{0x0013, 0x0060, 50}, // Power control4 setting
{0x0013, 0x0070, 40}, // Power control4 setting
{0x0001, 0x0127, 0}, // Driver output setting (240x320 mode, GS=0, SS=1)
{0x0002, 0x0700, 0}, // LCD driving waveform setting
{0x0003, 0x1030, 0}, // Entry mode setting (TRI=0, DFM=0, BGR=1, ID1:ID0 =11)
{0x0007, 0x0000, 0}, // Display control1
{0x0008, 0x0404, 0}, // Display control2
{0x000B, 0x0200, 0}, // Frame cycle setting
{0x000C, 0x0000, 0}, // External display interface setting
{0x00015,0x0000, 0},
//gamma setting
{0x0030, 0x0000, 0}, // Gamma control1
{0x0031, 0x0606, 0}, // Gamma control2
{0x0032, 0x0006, 0}, // Gamma control3
{0x0033, 0x0403, 0}, // Gamma control4
{0x0034, 0x0107, 0}, // Gamma control5
{0x0035, 0x0101, 0}, // Gamma control6
{0x0036, 0x0707, 0}, // Gamma control7
{0x0037, 0x0304, 0}, // Gamma control8
{0x0038, 0x0A00, 0}, // Gamma control9
{0x0039, 0x0706, 0}, // Gamma control10
{0x0040, 0x0000, 0}, // Gate scan position (start G1 scan)
{0x0041, 0x0000, 0}, // Vertical scroll setting
{0x0042, 0x013F, 0}, // Screen end position (320-1)
{0x0043, 0x0000, 0}, // Screen start position (0)
{0x0044, 0x0000, 0}, // 2th Screen end position
{0x0045, 0x0000, 0}, // 2th Screen start position
{0x0046, 0xEF00, 0}, // window addr set for x0,x1 (0, 239)
{0x0047, 0x013F, 0}, // window addr set for y0 (319)
{0x0048, 0x0000, 0}, // window addr set for y1 (0)
{0x0007, 0x0011, 40}, // Display control1
{0x0007, 0x0017, 0}, // Display control1
{DATA_END, 0, 0}
};
/*******************************************************
* 名稱: TftInit
* 功能: 初始化TFT液晶模塊。
* 入口參數(shù): 無
* 出口參數(shù): 無
*******************************************************/
void TftInit(void)
{ STCOM_INI init_dat;
int i;
TftReset();
for(i=0; i<100; i++) // 設(shè)定最多100條初始化命令
{ init_dat = TFT4137_INI[i];
if(init_dat.com==DATA_END) break;
TftSendCom(init_dat.com);
TftSendDat(init_dat.dat);
DelaymS(init_dat.dly);
}
}
/****************************************************************************
* 名稱:GUI_Initialize()
* 功能:初始化GUI,包括初始化顯示緩沖區(qū),初始化LCM并清屏。
* 入口參數(shù):無
* 出口參數(shù):無
* 說明:用戶根據(jù)LCM的實際情況編寫此函數(shù)。
****************************************************************************/
void GUI_Initialize(void)
{ TftInit();
TFT_FillSCR(GUI_CCOLOR);
}
/****************************************************************************
* 名稱:GUI_FillSCR()
* 功能:全屏填充。直接使用數(shù)據(jù)填充顯示緩沖區(qū)。
* 入口參數(shù):dat 填充的數(shù)據(jù)
* 出口參數(shù):無
* 說明:用戶根據(jù)LCM的實際情況編寫此函數(shù)。
****************************************************************************/
void GUI_FillSCR(TCOLOR dat)
{ TFT_FillSCR(dat);
}
/****************************************************************************
* 名稱:GUI_ClearSCR()
* 功能:清屏。
* 入口參數(shù):無
* 出口參數(shù):無
* 說明:用戶根據(jù)LCM的實際情況編寫此函數(shù)。
****************************************************************************/
void GUI_ClearSCR(void)
{ TFT_FillSCR(GUI_CCOLOR);
}
/****************************************************************************
* 名稱:GUI_Point()
* 功能:在指定位置上畫點。
* 入口參數(shù):x 指定點所在列的位置
* y 指定點所在行的位置
* color 顯示顏色
* 出口參數(shù):返回值為1時表示操作成功,為0時表示操作失敗。
****************************************************************************/
uint8 GUI_Point(uint16 x, uint16 y, TCOLOR color)
{ /* 參數(shù)過濾 */
if(x>=GUI_LCM_XMAX) return(0);
if(y>=GUI_LCM_YMAX) return(0);
/* 刷新顯示 */
TftSetWrite(x, y);
TftSendDat(color);
return(1);
}
/****************************************************************************
* 名稱:GUI_ReadPoint()
* 功能:讀取指定位置點的顏色數(shù)據(jù)。
* 入口參數(shù):x 指定點所在列的位置
* y 指定點所在行的位置
* 出口參數(shù):返回值即是讀出值(RRRRRGGGGGGBBBBB)。
****************************************************************************/
uint8 GUI_ReadPoint(uint16 x, uint16 y, TCOLOR *ret)
{ uint16 bak;
/* 參數(shù)過濾 */
if(x>=GUI_LCM_XMAX) return(0);
if(y>=GUI_LCM_YMAX) return(0);
/* 讀取數(shù)據(jù) */
TftSetAddr(x, y); // 設(shè)置地址
TftSendCom(WR_RD_DATA);
bak = TftRcvDat();
bak = TftRcvDat();
*ret = bak;
return(1);
}
/****************************************************************************
* 名稱:GUI_HLine()
* 功能:畫水平線。
* 入口參數(shù):x0 水平線起點所在列的位置
* y0 水平線起點所在行的位置
* x1 水平線終點所在列的位置
* color 顯示顏色
* 出口參數(shù):無
* 說明:操作失敗原因是指定地址超出緩沖區(qū)范圍。
****************************************************************************/
void GUI_HLine(uint16 x0, uint16 y0, uint16 x1, TCOLOR color)
{ uint16 bak;
if(x0>x1) // 對x0、x1大小進行排列,以便畫圖
{ bak = x1;
x1 = x0;
x0 = bak;
}
GUI_Point(x0, y0, color); // 顯示第一點
x0++;
while(x1>=x0)
{ TftSendDat(color); // 不斷填充并顯示
x0++;
}
}
/****************************************************************************
* 名稱:GUI_RLine()
* 功能:畫垂直線。
* 入口參數(shù): x0 垂直線起點所在列的位置
* y0 垂直線起點所在行的位置
* y1 垂直線終點所在行的位置
* color 顯示顏色
* 出口參數(shù):無
* 說明:操作失敗原因是指定地址超出緩沖區(qū)范圍。
****************************************************************************/
void GUI_RLine(uint16 x0, uint16 y0, uint16 y1, TCOLOR color)
{ uint16 bak;
if(y0>y1) // 對y0、y1大小進行排列,以便畫圖
{ bak = y1;
y1 = y0;
y0 = bak;
}
while(y1>=y0)
{ GUI_Point(x0, y0, color); // 逐點顯示,描出垂直線
y0++;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -