⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.c.bak

📁 CH375移植到S3C44B0
💻 BAK
字号:
#include "44b.h"
#include "44blib.h"
#include "def.h"

#include "lcd.h"
#include "lcdlib.h"
#include "glib.h"
#include "Bmp_Color256_320_240.h"

#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
//*****************************************************************************
U8 LCD_BGColor;
U8 LCD_PenColor;
U8 FOver=0;
extern const unsigned char ASC12[];
//*****************************************************************************
U8 High_Low( U8 x )
{
	x = ( (x>>1)&0x1c ) | (x>>6) | (x<<5);
	return x ;
}
////////////////////用于颜色清屏和写图片/////////////////////////
void Lcd256_Clear( U8 Color)
{
    int i,j;

//    rPDATE=rPDATE&~(1<<5)|(1<<5);	//GPE5=H	 
//    rPCONE=rPCONE&~(3<<10)|(1<<10);	//GPE5=output
//    rPCONC=rPCONC&~(0xff<<8)|(0xff<<8);	//GPC[4:7] => VD[7:4]

//    Lcd_Init(MODE_COLOR);
//    Glib_Init(MODE_COLOR);

    for(i=0;i<240;i++)
    {
    	for(j=0;j<320;j++)
    	    PutPixel( j, i, High_Low(Color) );
    }
}

void LcdColor256_Bmp( unsigned char bmp[] )
{
    int i,j,k;
	k = 0 ;		
	//rPDATE=rPDATE&~(1<<5)|(1<<5);	//GPE5=H	 
    //    rPCONE=rPCONE&~(3<<10)|(1<<10);	//GPE5=output
    //    rPCONC=rPCONC&~(0xff<<8)|(0xff<<8);	//GPC[4:7] => VD[7:4]
        
    //    Lcd_Init(MODE_COLOR);
    //    Glib_Init(MODE_COLOR);
    for(i=0;i<240;i++)
    {
    	for(j=0;j<320;j++)
    	{
    	    PutPixel( j, i, High_Low(bmp[k]) );
    	    k++;
    	}
    }
}
////////////////////用于写局部内容////////////////////////////
void LCD_WritePixel(U32 x1, U32 y1, U32 x2, U32 y2, U8 *b)
{
	U32 x, y;     
	for(y = y1; y <= y2; y ++)
		for(x = x1; x <= x2; x ++)
			PutPixel(x, y, High_Low(*(b++) ) );
}
///////////////////////用于写单个汉字,暂时为十二点阵/////////////////////////
void LCD_TextOutGB2312(U8 ch, U8 cl, U32 x, U32 y)
{
	U8 b[144];
	U8 *buf = &b[0];
	U8 *font;
	U8 i;
	U32 offset;
	for(i = 0; i <144; i ++)
		if(FOver)
	    		b[i]=ReadPixel(x+i%12,y+i/12);
		else
			b[i] =LCD_BGColor;


	offset =(((U32)ch - 0xA1) * 94 + ((U32)cl - 0xA1))*24;
	font=(U32)HZK12+offset;
	for(i = 0; i < 24; i+=2)
	{
		if(font[i] & 0x80)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i] & 0x40)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i] & 0x20)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i] & 0x10)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i] & 0x08)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i] & 0x04)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i] & 0x02)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i] & 0x01)
			*buf = LCD_PenColor;
		buf ++;
		//----------------
		if(font[i+1] & 0x80)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i+1] & 0x40)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i+1] & 0x20)
			*buf = LCD_PenColor;
		buf ++;
		if(font[i+1] & 0x10)
			*buf = LCD_PenColor;
		buf ++;
		
	}
	LCD_WritePixel(x, y, x + 11, y + 11, b);
}
/////////////////////用于写12*8英文字///////////////////////////////
void LCD_TextOutASCII(U8 c, U32 x, U32 y)
{
	U8 b[96];
	U8 *buf = &b[0];
	U8 *font;
	U8 i;
	U32 offset;
	for(i = 0; i < 96; i ++)
		if(FOver)
			b[i]=ReadPixel(x+i%8,y+i/12);
		else
	        	b[i] =LCD_BGColor;
	offset =(c-32)*12;
	font=(U32)ASC12+offset;
	for(i = 0; i <12; i ++)
	{
		if(font[i] & 0x80)
			*buf = (U8)LCD_PenColor;
		buf ++;
		if(font[i] & 0x40)
			*buf = (U8)LCD_PenColor;
		buf ++;
		if(font[i] & 0x20)
			*buf = (U8)LCD_PenColor;
		buf ++;
		if(font[i] & 0x10)
			*buf = (U8)LCD_PenColor;
		buf ++;
		if(font[i] & 0x08)
			*buf = (U8)LCD_PenColor;
		buf ++;
		if(font[i] & 0x04)
			*buf = (U8)LCD_PenColor;
		buf ++;
		if(font[i] & 0x02)
			*buf = (U8)LCD_PenColor;
		buf ++;
		if(font[i] & 0x01)
			*buf = (U8)LCD_PenColor;
		buf ++;
	}
	LCD_WritePixel(x, y, x + 7, y + 11, b);
}
////////////////////////////字符串输出//////////////////////////
void LCD_TextOut(U8 *s, U32 x, U32 y)
{
	while(*s)
	{
		if(*s==13)//回车
		{
			x = 0;
			y += 15;
		}
		else if(*s==10)
		{}
		else if(*s < 0x80)
		{
			LCD_TextOutASCII(*s, x, y);
			x += 8;
			if(x > 312)
			{
				x = 0;
				y += 15;
			}
		}
		else if((*s > 0x7F) && (*(s + 1) >= 0x7f))
		{
			LCD_TextOutGB2312(*s, *(s + 1), x, y);
			x += 12;
			s ++;
			if(x >308)
			{
				x = 0;
				y += 15;
			}
		}
		s ++;
	}
}

//----------------------设置LCD_Printf();光标----------------------------------
U32 LCDX;
U32 LCDY;
void LCD_PrinSet(U32 x,U32 y)
{
	LCDX=x;
	LCDY=y;
}
//------------显示字符串----------------------------------
void LCD_Printf(char *fmt,...) 
{
  va_list ap;
  char string[256];

  va_start(ap,fmt);
  vsprintf(string,fmt,ap);
  LCD_TextOut(string,LCDX,LCDY);
  va_end(ap);
  //Reflash_LCD();
}
//-----------读一象素点------------------------------------
U8 ReadPixel(U32 x,U32 y)
{
	U8 t;
	if(x<SCR_XSIZE && y<SCR_YSIZE)
		t=frameBuffer256[(y)][(x)/4]>>(4-1-x%4)*8;	
	t = ( (t<<1)&0x38 ) | (t<<6) | (t>>5);
	
	return t;
}

void LCD_ReadPixel(U32 x1, U32 y1, U32 x2, U32 y2, U8 *b)
{
	U32 x, y;
	for(y = y1; y <= y2; y ++)
		for(x = x1; x <= x2; x ++)
			*(b++)=ReadPixel(x,y);
}
//-----------------是否字体叠加----------------------------------
void FontOver(U8 flag)
{
	FOver=flag;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -