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

📄 lcd.c

📁 智原mp3 SDK 开发包 与巨力 有mp3 wma ogg decoder
💻 C
字号:
#include <string.h>
#include "api.h"
//#include "mp3app.h"
#include "get_latin2.h"
#include "lcd.h"
#include "get_latin2.h"
#include"common.h"


#define MIN(a,b)	((a) < (b) ? (a) : (b))
#define MAX(a,b)	((a) > (b) ? (a) : (b))

UINT8 lcd_max_str;

#ifdef loop_show_file_name
INT8 sonename_loop_step;//john 070606
INT8 songname_Chinese_max;//john 070606
INT8 songname_English_max;//john 070606
#endif

UINT16 fg_color, bg_color;
UINT16 bg_pixel[SCREEN_WIDTH];
UINT16 pixel_buf[256];


void delay_1ms(void)
{
	UINT16 n;
	
	for(n = 420; n > 0; n--) {}
}

void delay(UINT16 n)
{
	while(n--)
		delay_1ms();
}

void writec(UINT8 cmd)
{
	lcd_setcmd(cmd);
}
void writed(UINT8 lcddata)
{
	lcd_setdata(lcddata);
}

void write2c(UINT8 i, UINT8 j)
{
	writec(i);
	writec(j);
}

BOOLEAN lcd_put_data(UINT16 buf, UINT16 size)
{
	return api_bLcdDataMove(buf,size);
}


void lcd_set_rw_area(UINT8 x, UINT8 y, UINT8 w, UINT8 h)
{
    	api_vLcdPinSelect();
		
	writec(0x43);
	writec(x);			// start x
	writec(x + w - 1);		// end x
	
	writec(0x42);
	writec(y+2);			// start y
	writec(y + h + 1 );		// end y
    	api_vLcdPinRecover();
} 

void lcd_set_disply_mode(UINT8 disply_mode,UINT8 scan_direction )
{
	api_vLcdPinSelect();
	writec(0x40);
	writec(disply_mode); //显示模式
	writec(0x10);
	writec(scan_direction); // 扫描方向 22 和 26相反
	api_vLcdPinRecover();	
}



void lcd_clear(void)
{
	UINT8 i;
	
	lcd_set_rw_area(0, 0, XRES, YRES);
	
	memset(pixel_buf, 0x0, sizeof(pixel_buf));
	
	for(i = 0; i < YRES; i++)
		lcd_put_data((UINT16)pixel_buf, XRES << 1);
}
void lcd_clear_word(void)
{
	UINT8 i;
	
	lcd_set_rw_area(50, 74, 54, 80);
	
	memset(pixel_buf, 0xF77F, sizeof(pixel_buf));
	
	for(i = 96; i < 102; i++)
		lcd_put_data((UINT16)pixel_buf, XRES << 1);
}

void lcd_set_brightness(UINT8 v)
{
#if 1
	api_vLcdPinSelect();
	writec(0x2a);
	writec(0xce+v);  //90 0xde   c8
	delay(20);
	writec(0x2b);
	writec(0x44+v); //90 0x54    c8
	api_vLcdPinRecover();
#else
	api_vLcdPinSelect();
	writec(0x2a);
	writec(v*8);  //90 0xde   c8
	delay(20);
	writec(0x2b);
	writec(v*8); //90 0x54    c8
	api_vLcdPinRecover();
#endif
}

void lcd_init(void)
{	       
     // 	CDIR = 1;
//	 Print("LCD Init\n");
	api_vLcdInit(LCM_INTERFACE_8080);
	api_vLcdPinSelect();
	bLCD_PIN_RESET = 0;
       delay(100);
      bLCD_PIN_RESET = 1;
    
	delay(100);
//-------------------------------------------------
	writec(0x2C);
	delay(20);
//-------------------------------------------------
	writec(0x02);
	writec(0x01);
	delay(20);
//-------------------------------------------------
	writec(0x26);
	writec(0x01);
	delay(20);
	writec(0x26);
	writec(0x09);
	delay(20);
	writec(0x26);
	writec(0x0b);
	delay(20);
	writec(0x26);
	writec(0x0f);
	delay(20);
//------------------------------------------------
	writec(0x10);
	writec(0x23);  // 21,25
	delay(5);
//-------------------------------------------------
	writec(0x20);
	writec(0x03); //20
	delay(20);
//-------------------------------------------------
	writec(0x22);
	writec(0x11);
	delay(5);
//------------------------------------------------
	writec(0x24);
	writec(0x11); //00
	delay(20);
//-------------------------------------------------
	writec(0x28);
	writec(0x01);
	delay(20);
/*******************对比度调节****************/
	writec(0x2a);
	writec(0xde);  //90 0xde   c8
	delay(20);
	writec(0x2b);
	writec(0x54); //90 0x54    c8
	delay(10);
/***************************************************/
	writec(0x30);
	writec(0x09); //0b
	delay(20);
//------------------------------------------------
	writec(0x32);
	writec(0x0E);
	delay(20);
//-----------------------------------------------
	writec(0x34);
	writec(0x08);//0d
	delay(20);
//-------------------------------------------------
	writec(0x36);
	writec(0x00);
	delay(20);
/*********************显示模式******************/
	writec(0x40);
	writec(0x00);//显示模式08和 00相反 竖屏
	writec(0x10);
	writec(0x22);//扫描方式22和26相反 横屏
	delay(20);
/****************************************************/
	writec(0x43);
	writec(0x00);
	writec(0x7F);
	delay(20);
//------------------------------------------------
	writec(0x42);
	writec(0x00);
	writec(0x9F);
	delay(20);
//------------------------------------------------
	writec(0x53);
	writec(0x00);
	delay(20);
	




//-------------------------------------------------
	writec(0xEB);
	delay(20);
//-------------------------------------------------
	writec(0x45);
	writec(0x00);
//-------------------------------------------------
	writec(0x55);
	writec(0x00);
	delay(20);
//------------------------------------------------
	writec(0x5A);
	writec(0x00);
	delay(20);



//------------------------------------------------
	writec(0x51);
	delay(40);
	
	api_vLcdPinRecover();
	lcd_set_brightness(10);
}

⌨️ 快捷键说明

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