📄 lcd_api.cpp
字号:
#include <stdio.h>
#include <string.h>
#include "HD61202.h"
#include "lcd_api.h"
#include "dotlib.h"
DOTLIB LCD_Dot;
int XOREnable;
// return = 0: ok!
// = -1: fail
int LCD_Init( char* CHN_FntFile, char* ASCII_FntFile )
{
InitLCD( );
LCD_Dot.initiChinese( CHN_FntFile, ASCII_FntFile );
XOREnable = 0;
return 0;
}
int LCD_Clearup( )
{
return ClearScreen( );
}
// Mode = 0: copy write for dot, line
// = 1: xor write for dot, line
int LCD_SetMode( int Mode )
{
if( Mode == 0 ) XOREnable = 0;
else XOREnable = 0x80;
return 0;
}
// x0, x1 = 0 -- 127; y0, y1 = 0 -- 63;
// color = 0, 1
int LCD_PutPixel( int x0, int y0, int color )
{
return WritePixel( x0, y0, color|XOREnable );
}
int LCD_DrawLine( int x0, int y0, int x1, int y1, int color )
{
int i, x1x, y1y, y;
if( x1>x0) { x1x=x1-x0; }
else { x1x=x0-x1; }
if( y1>y0) { y1y=y1-y0; y=y0; }
else { y1y=y0-y1; y=y1; }
if( x1x!=0 )
{
for( i=0; i<x1x; i++ )
{
if( x0>x1 )
{
if( y0<y1 )
LCD_PutPixel( x1+i, y1-(y1y*i)/x1x, color );
else
LCD_PutPixel( x1+i, y1+(y1y*i)/x1x, color );
}
else
{
if( y0<y1 )
LCD_PutPixel( x0+i, y0+(y1y*i)/x1x, color );
else
LCD_PutPixel( x0+i, y0-(y1y*i)/x1x, color );
}
}
}
else
{
for( i=0; i<y1y; i++ )
LCD_PutPixel( x0, y+i, color );
}
return 0;
}
int LCD_FillBar( int x0, int y0, int x1, int y1, int color )
{
int yy, tmpXOR;
int x, y;
tmpXOR = XOREnable;
XOREnable = 0;
//for( yy=y0; yy<=y1; yy++ )
//LCD_DrawLine( x0, yy, x1, yy, color );
for( x=x0; x<x1; )
{
for( y=y0; y<y1; )
{
LCD_WriteString( x, y, " ", color, 1 );
y += 16;
}
x += 8;
}
XOREnable = tmpXOR;
return 0;
}
// x0 = 0 -- 127; y0 = 0 -- 63;
// txtcolor, bkcolor = 0, 1
int LCD_WriteString( int x0, int y0, char* pStr, int color, int len )
{
int i, i1;
char cc[2];
if( pStr==NULL ) return -1;
i1 = strlen(pStr);
if( (i1==0) && (len==0) ) return -1;
if( len==0 ) len = i1;
for( i=i1; i<len; i++ ) pStr[i] = ' ';
pStr[i] = '\0';
while( *pStr!='\0' )
{
cc[0]=*pStr++;
if((cc[0]&0x80)/128==1)
{
cc[1] = *pStr++;
LCD_Dot.WriteHz( x0, y0, cc, color );
x0 += 16;
}
else
{
if(cc[0]=='\\') cc[0]=*pStr++;
LCD_Dot.Writechar(x0, y0, cc[0], color );
x0 += 8;
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -