?? lcdlib.c
字號:
/*
* FILE: lcdlib.c
* 實現(xiàn)TFT LCD的測試函數(shù)
*/
#include <stdio.h>
#include "lcddrv.h"
#include "framebuffer.h"
/*
* 以240x320,8bpp的顯示模式測試TFT LCD
*/
void Test_Lcd_Tft_8Bit_240320(void)
{
Lcd_Port_Init(); // 設(shè)置LCD引腳
Tft_Lcd_Init(MODE_TFT_8BIT_240320); // 初始化LCD控制器
Lcd_PowerEnable(0, 1); // 設(shè)置LCD_PWREN有效,它用于打開LCD的電源
Lcd_EnvidOnOff(1); // 使能LCD控制器輸出信號
Lcd_Palette8Bit_Init(); // 初始化調(diào)色板
ClearScr(0x0); // 清屏
printf("[TFT 64K COLOR(16bpp) LCD TEST]\n");
printf("1. Press any key to draw line\n");
getc();
DrawLine(0 , 0 , 239, 0 , 0); // 顏色為DEMO256pal[0]
DrawLine(0 , 0 , 0 , 319, 1); // 顏色為DEMO256pal[1]
DrawLine(239, 0 , 239, 319, 2); // ……
DrawLine(0 , 319, 239, 319, 4);
DrawLine(0 , 0 , 239, 319, 8);
DrawLine(239, 0 , 0 , 319, 16);
DrawLine(120, 0 , 120, 319, 32);
DrawLine(0 , 160, 239, 160, 64);
printf("2. Press any key to draw circles\n");
getc();
Mire();
printf("3. Press any key to fill the screem with one color\n");
getc();
ClearScr(128); // 輸出單色圖像,顏色為DEMO256pal[128]
printf("4. Press any key to fill the screem by temporary palette\n");
getc();
ClearScrWithTmpPlt(0x0000ff); // 輸出單色圖像,顏色為藍色
printf("5. Press any key to fill the screem by palette\n");
getc();
DisableTmpPlt(); // 關(guān)閉臨時調(diào)色板寄存器
ChangePalette(0xffff00); // 改變整個調(diào)色板為黃色,輸出單色圖像
printf("6. Press any key stop the testing\n");
getc();
Lcd_EnvidOnOff(0);
}
/*
* 以240x320,16bpp的顯示模式測試TFT LCD
*/
void Test_Lcd_Tft_16Bit_240320(void)
{
Lcd_Port_Init(); // 設(shè)置LCD引腳
Tft_Lcd_Init(MODE_TFT_16BIT_240320); // 初始化LCD控制器
Lcd_PowerEnable(0, 1); // 設(shè)置LCD_PWREN有效,它用于打開LCD的電源
Lcd_EnvidOnOff(1); // 使能LCD控制器輸出信號
ClearScr(0x0); // 清屏,黑色
printf("[TFT 64K COLOR(16bpp) LCD TEST]\n");
printf("1. Press any key to draw line\n");
getc();
DrawLine(0 , 0 , 239, 0 , 0xff0000); // 紅色
DrawLine(0 , 0 , 0 , 319, 0x00ff00); // 綠色
DrawLine(239, 0 , 239, 319, 0x0000ff); // 藍色
DrawLine(0 , 319, 239, 319, 0xffffff); // 白色
DrawLine(0 , 0 , 239, 319, 0xffff00); // 黃色
DrawLine(239, 0 , 0 , 319, 0x8000ff); // 紫色
DrawLine(120, 0 , 120, 319, 0xe6e8fa); // 銀色
DrawLine(0 , 160, 239, 160, 0xcd7f32); // 金色
printf("2. Press any key to draw circles\n");
getc();
Mire();
printf("3. Press any key to fill the screem with one color\n");
getc();
ClearScr(0xff0000); // 紅色
printf("4. Press any key to fill the screem by temporary palette\n");
getc();
ClearScrWithTmpPlt(0x0000ff); // 藍色
printf("5. Press any key stop the testing\n");
getc();
Lcd_EnvidOnOff(0);
}
/*
* 以640x480,8bpp的顯示模式測試TFT LCD
*/
void Test_Lcd_Tft_8Bit_640480(void)
{
Lcd_Port_Init(); // 設(shè)置LCD引腳
Tft_Lcd_Init(MODE_TFT_8BIT_640480); // 初始化LCD控制器
Lcd_PowerEnable(0, 1); // 設(shè)置LCD_PWREN有效,它用于打開LCD的電源
Lcd_EnvidOnOff(1); // 使能LCD控制器輸出信號
Lcd_Palette8Bit_Init(); // 初始化調(diào)色板
ClearScr(0x0); // 清屏,黑色
printf("[TFT 64K COLOR(16bpp) LCD TEST]\n");
printf("1. Press any key to draw line\n");
getc();
DrawLine(0 , 0 , 639, 0 , 0); // 顏色為DEMO256pal[0]
DrawLine(0 , 0 , 0 , 479, 1); // 顏色為DEMO256pal[1]
DrawLine(639, 0 , 639, 479, 2); // ……
DrawLine(0 , 479, 639, 479, 4);
DrawLine(0 , 0 , 639, 479, 8);
DrawLine(639, 0 , 0 , 479, 16);
DrawLine(320, 0 , 320, 479, 32);
DrawLine(0 , 240, 639, 240, 64);
printf("2. Press any key to draw circles\n");
getc();
Mire();
printf("3. Press any key to fill the screem with one color\n");
getc();
ClearScr(128); // 輸出單色圖像,顏色為DEMO256pal[128]
printf("4. Press any key to fill the screem by temporary palette\n");
getc();
ClearScrWithTmpPlt(0x0000ff); // 輸出單色圖像,顏色為藍色
printf("5. Press any key to fill the screem by palette\n");
getc();
DisableTmpPlt(); // 關(guān)閉臨時調(diào)色板寄存器
ChangePalette(0xffff00); // 改變整個調(diào)色板為黃色,輸出單色圖像
printf("6. Press any key stop the testing\n");
getc();
Lcd_EnvidOnOff(0);
}
/*
* 以640x480,16bpp的顯示模式測試TFT LCD
*/
void Test_Lcd_Tft_16Bit_640480(void)
{
Lcd_Port_Init(); // 設(shè)置LCD引腳
Tft_Lcd_Init(MODE_TFT_16BIT_640480); // 初始化LCD控制器
Lcd_PowerEnable(0, 1); // 設(shè)置LCD_PWREN有效,它用于打開LCD的電源
Lcd_EnvidOnOff(1); // 使能LCD控制器輸出信號
ClearScr(0x0); // 清屏,黑色
printf("[TFT 64K COLOR(16bpp) LCD TEST]\n");
printf("1. Press any key to draw line\n");
getc();
DrawLine(0 , 0 , 639, 0 , 0xff0000); // 紅色
DrawLine(0 , 0 , 0 , 479, 0x00ff00); // 綠色
DrawLine(639, 0 , 639, 479, 0x0000ff); // 藍色
DrawLine(0 , 479, 639, 479, 0xffffff); // 白色
DrawLine(0 , 0 , 639, 479, 0xffff00); // 黃色
DrawLine(639, 0 , 0 , 479, 0x8000ff); // 紫色
DrawLine(320, 0 , 320, 479, 0xe6e8fa); // 銀色
DrawLine(0 , 240, 639, 240, 0xcd7f32); // 金色
printf("2. Press any key to draw circles\n");
getc();
Mire();
printf("3. Press any key to fill the screem with one color\n");
getc();
ClearScr(0xff0000); // 紅色
printf("4. Press any key to fill the screem by temporary palette\n");
getc();
ClearScrWithTmpPlt(0x0000ff); // 藍色
printf("5. Press any key stop the testing\n");
getc();
Lcd_EnvidOnOff(0);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -