📄 lcd.c
字号:
#include <string.h>
#include "..\inc\def.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\lcdlib.h"
#include "..\inc\glib.h"
#include "..\inc\lcd.h"
#include "..\inc\Slib.h"
void Test_LcdMono(void);
void Test_LcdG4(void);
void Test_LcdStr(void);
void Test_LcdMono(void)
{
int i,j;
Lcd_Init(MODE_MONO);
Lcd_DispON();
Glib_Init(MODE_MONO);
Uart_Printf("[Mono(1bit/1pixel) LCD Test]: Press Any Key!\n");
Glib_ClearScr(0);
//Slib_Printf("ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM ARM");
for(j=0;j<LCD_YSIZE;j+=16)
for(i=0;i<LCD_XSIZE;i+=16)
Glib_FilledRectangle(i,j,i+15,j+15,((j+i)/16)%2);
Uart_Printf("Mono test 1. Press any key!\n");
Uart_Getch();
Glib_ClearScr(0);
Glib_FilledRectangle(160,0,319,239,1);
Uart_Printf("Mono test 2. Press any key!\n");
Uart_Getch();
Glib_ClearScr(0);
Glib_Rectangle(0,0,319,239,1); // #0
Glib_Line(0,0,319,239,1); // 00
Glib_Line(0,239,319,0,1);
Glib_Rectangle(0+320,0,319+320,239,1); // 0#
Glib_Line(0+320,0,319+320,239,1); // 00
Glib_Line(0+320,239,319+320,0,1);
Glib_FilledRectangle(50+320,50,269+320,189,1);
Glib_Rectangle(0,0+240,319,239+240,1); // 00
Glib_Line(0,0+240,319,239+240,1); // #0
Glib_Line(0,239+240,319,0+240,1);
Glib_FilledRectangle(50,50+240,269,189+240,1);
Glib_Rectangle(0+320,0+240,319+320,239+240,1); // 00
Glib_Line(0+320,0+240,319+320,239+240,1); // 0#
Glib_Line(0+320,239+240,319+320,0+240,1);
Glib_Rectangle(50+320,50+240,269+320,189+240,1);
Uart_Printf("Virtual Screen Test(Mono). Press any key[ijkm\\r]!\n");
MoveViewPort(MODE_MONO);
Lcd_MoveViewPort(0,0,MODE_MONO);
}
void Test_LcdG4(void)
{
int i,j,k;
Lcd_Init(MODE_G4);
Lcd_DispON();
Glib_Init(MODE_G4);
Uart_Printf("[4gray(2bit/1pixel) LCD Test]: Press Any Key!\n");
Glib_ClearScr(0);
j=0;
for(i=0;i<320;i+=80)
Glib_FilledRectangle(0+i,0,79+i,239,j++);
Uart_Printf("4 gray mode test 1. Press any key!\n");
Uart_Getch();
Glib_ClearScr(0);
j=0;
for(i=0;i<320;i+=80)
{
Glib_FilledRectangle(0+i,0,79+i,119,j);
Glib_FilledRectangle(0+i,120,79+i,239,3-j);
j++;
}
Uart_Printf("4 gray mode test 2. Press any key!\n");
Uart_Getch();
Glib_ClearScr(0);
j=0;
for(i=0;i<240;i+=60)
{
Glib_FilledRectangle(i,i,i+59,i+59,j);
j++;
}
Uart_Printf("4 gray mode test 3. Press any key!\n");
Uart_Getch();
Glib_ClearScr(0);
/*
k=0;
for(i=160;i<480;i+=80)
{
for(j=120;j<360;j+=60)
{
Glib_FilledRectangle(i,j,i+79,j+59,k%4);
k++;
}
k+=2;;
}
*/
// #0
// 00
Glib_Rectangle(0,0,319,239,3);
Glib_Line(0,0,319,239,3);
Glib_Line(0,239,319,0,3);
// 0#
// 00
Glib_Rectangle(0+320,0,319+320,239,3);
Glib_Line(0+320,0,319+320,239,3);
Glib_Line(0+320,239,319+320,0,3);
// 00
// #0
Glib_Rectangle(0,0+240,319,239+240,3);
Glib_Line(0,0+240,319,239+240,3);
Glib_Line(0,239+240,319,0+240,3);
// 00
// 0#
Glib_Line(0+320,0+240,319+320,239+240,3);
Glib_Line(0+320,239+240,319+320,0+240,3);
Glib_Rectangle(50+320,50+240,269+320,189+240,3);
Uart_Printf("Virtual Screen Test(4 gray). Press any key[ijkm\\r]!\n");
MoveViewPort(MODE_G4);
Lcd_MoveViewPort(0,0,MODE_G4);
}
void MoveViewPort(int depth)
{
int vx=0,vy=0,vd;
vd=(depth==1)*16+(depth==4)*8+(depth==16)*4+(depth==256)*2;
while(1)
{
switch(Uart_Getch())
{
case 'i':
if(vy>=vd)vy-=vd;
break;
case 'j':
if(vx>=vd)vx-=vd;
break;
case 'k':
if(vx<=SCR_XSIZE-LCD_XSIZE-vd)vx+=vd;
break;
case 'm':
if(vy<=(SCR_YSIZE-LCD_YSIZE-vd))vy+=vd;
break;
case '\r':
return;
default:
break;
}
Uart_Printf("vx=%3d,vy=%3d\n",vx,vy);
Lcd_MoveViewPort(vx,vy,depth);
}
}
void Test_LcdStr(void)
{
char aa;
Lcd_Init(MODE_MONO);
Lcd_DispON();
Slib_ClearScr();
Slib_Init();
//Slib_Printf("\n # ");
//Slib_Printf("\n ### ");
//Slib_Printf(" ## ## ");
//Slib_Printf(" ## ## ");
//Slib_Printf(" ######### ");
//Slib_Printf(" ## ## ");
//Slib_Printf(" ## ## ");
//Slib_Printf(" #### #### ");
Slib_Printf("These texts are on the 1st line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 2nd line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 3rd line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 4th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 5th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 6th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 7th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 8th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 9th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 10th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 11th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 12th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 13th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 14th line ");
aa = Uart_Getch();
Slib_Printf("\nThese texts are on the 15th line ");
aa = Uart_Getch();
Slib_ClearScr();
Slib_SetCursor(0,0);
Slib_Printf("\n\n\n****************************************");
Slib_Printf("\n # ####### ### ###");
Slib_Printf("\n ### ## ## #### ####");
Slib_Printf("\n ## ## ## ## ## ## ## ##");
Slib_Printf("\n ## ## ####### ## ### ##");
Slib_Printf("\n ######### ## ## ## # ##");
Slib_Printf("\n ## ## ## ## ## ##");
Slib_Printf("\n### ### #### #### #### ####");
Slib_Printf("\n\n\n****************************************");
aa = Uart_Getch();
Slib_ClearScr();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -