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

📄 lcm.c

📁 一个LCM一般需要用的显示函数128*64等
💻 C
📖 第 1 页 / 共 3 页
字号:
#include <absacc.h>
#include "define.h"
#include "all.h"

sbit	P_LCM_D7=P1^4;

#define	LCM_ReverseOffset	36
#define	LCM_RESET_0	XBYTE[0xB030]=XBYTE[0xB040]&0xFE
#define	LCM_RESET_1	XBYTE[0xB030]=XBYTE[0xB040]|0x01
#define	LCM_A0_0	XBYTE[0xB030]=XBYTE[0xB040]&0xFD
#define	LCM_A0_1	XBYTE[0xB030]=XBYTE[0xB040]|0x02
#define	LCM_DATA_0	XBYTE[0xB030]=XBYTE[0xB040]&0xFB
#define	LCM_DATA_1	XBYTE[0xB030]=XBYTE[0xB040]|0x04
#define	LCM_CLK_0	XBYTE[0xB030]=XBYTE[0xB040]&0xF7
#define	LCM_CLK_1	XBYTE[0xB030]=XBYTE[0xB040]|0x08

data	bit	gb_Play_Pause=0;	// 0=Pause	1=Play
data	U8	gc_LCM_Media=0xFF;	// 0=Show LineIn BMP  1=Show playing info
data	U8	gw_DisplayVol;
data	U8	gc_DisplayEQ;
data	U8	gc_DisplayEQIcon=0xFF;
data	U8	gc_DisplaySongnameCount=0;
data	U8	gc_LCM_line;
data	U16	gw_DisplayBitRate=0xFFFF;
data	U16	gw_DisplayTime=0xFFFF;
data	U16	gw_DisplayBitrateTime=0;
data	U16	gw_DisplayFreq=0xFFFF;
data	U16	gw_DispSongNum=0xFFFF;
data	U16	gw_DispSongNum1=0xFFFF;

extern	U8		data	gc_xxx;
extern	U8		code	CompanyLogo128x32[];
extern	U8		code	CompanyLogo96x32[];
extern	U8		code	LineInIcon128x32[];
extern	U8		code	LineInIcon96x32[];
extern	U8		code	FM_Icon128x32[];
extern	U8		code	FM_Icon96x32[];
extern	U8		code	SD_Icon128x32[];
extern	U8		code	SD_Icon96x32[];
extern	U8		code	USB_Icon128x32[];
extern	U8		code	USB_Icon96x32[];
extern	U8		code	CharIcon8x16[];
extern	U8		code	CharIcon12x32[];
extern	U8		code	PAUSEIcon128x32[];
extern	U8		code	PAUSEIcon96x32[];
extern	U8 		code	PlayModeIcon128x64[];
extern	U8 		code	PlayModeIcon128x32[];
extern	U8 		code	PlayModeIcon96x32[];
extern	U8		code	MediaTypeIcon25x16[];
extern	U8		code	EQIcon128x64[];
extern	U8		code	PlayPauseIcon128x64[];
extern	U8		code	BitRateIcon128x64[];
extern	data	bit		gb_SelectVol;
extern	data	bit		gb_Frequency_Song;
extern	data	bit		gb_SelectEQ;
extern	data	bit		gb_LED_LCM;
extern	data	bit		gb_Err;
extern	data	bit		gb_ChannelSet;
extern	data	bit		gb_PickSong;
extern	data	bit		gb_LCMInitFrom2402;
extern	data	bit		gb_LCM_reverse;
extern	data	bit		gb_Media_type;
extern	data	U8		gc_LCM_Size;
extern	data	U8		gc_CurrentCard;
extern	data	U8		gc_SystemStateMode;
extern	data	U8		gc_DSP_Volume;
extern	data	U8		gc_DisplayPlayMode;
extern	data	U8		gc_PlaySequenceMode;
extern	data	U8		gc_PlayEQMode;
extern	data	U8		gc_NUMBER[];
extern	data	U8		gc_LCM_InitData1;
extern	data	U8		gc_LCM_InitData2;
extern	data	U16		gw_FM_frequency;
extern	data	U16		gw_ShowTimer;
extern	data	U16		gw_LCMScrollTimer;

void	LCM_Initial(void);
void	LCM_Display(void);
void	LCM_Send_Command(U8 tc_command);
void	LCM_Send_Data(U8 tc_data);
void	LCM_Send_Value(U8 tc_value);
void	LCM_Set_PageColumn(U8 tc_page,U8 tc_column);
void	LCM_ShowCompanyLogo(void);
void	LCM_ClearScreen(void);
void	LCM_ClearPage(U8 tc_page);
void	LCM_ShowLineIn(void);
void	LCM_ShowFMIcon(void);
void	LCM_ShowSDIcon(void);
void	LCM_ShowUSBIcon(void);
void	LCM_ShowMediaType(void);
void	LCM_ShowFrequency(void);
void	LCM_ShowFrequency_L(void);
void	LCM_ShowChar8x16(U8 Num,U8 tc_column);
void	LCM_ShowChar8x16_L2(U8 Num,U8 tc_column);
void	LCM_ShowChar12x32(U8 Num,U8 tc_volumn);
void	LCM_ShowPAUSE(void);
void	LCM_ShowVOL(void);
void	LCM_ShowBitRate(void);
void	LCM_ShowPlayTime(U16 tc_time);
void	LCM_ShowSongNumber(void);
void	LCM_ShowPlayMode(void);
void	LCM_ShowPlayModeIcon(void);
void	LCM_ShowEQ(void);
void	LCM_ShowEQIcon(void);
void	LCM_Show_Filename(void);
void	LCM_Show_NOMP3FILE(void);
void	LCM_ShowERROR(void);
void	LCM_ShowName(void);
void	LCM_ShowIRNum(void);
void	LCM_ShowPlayPauseIcon(void);
void	LCM_ShowBitRateIcon(void);
void	P_LCM_Write_CMD(U8 CMD);
void	P_LCM_Write_DAT(U8 DAT);
extern	void	USER_DelayDTms(U8);
extern	U8		Dos_GetFileLongName(U8 tc_FileHandle,U8 *tpc_LongName);

void LCM_Display(void)
{
	U16	tw_DisplayTime;

	if(gb_LED_LCM==0)	// 0=LED  1=LCM
	{
		return;
	}

	// Show "ERROR"
	if(gb_Err==1)
	{
		if(gc_LCM_Media!=9)
		{
			gc_LCM_Media=9;
			LCM_ShowERROR();
		}

		if(gc_LCM_Size==2) 
		{
			goto Show_SongTime;
		}
		return;
	}

	if(gc_LCM_Size==2)
	{
		// Show MP3/WMA icon
		if((U8)gb_Media_type!=gc_DSP_Codec_Mode)
		{
			gb_Media_type=(bit)gc_DSP_Codec_Mode;
			LCM_ShowMediaType();
		}
		
		// Show EQ icon
		if(gc_DisplayEQIcon!=gc_PlayEQMode)
		{
			gc_DisplayEQIcon=gc_PlayEQMode;
			LCM_ShowEQIcon();
		}

		// Show bit rate 
		if(gw_DisplayBitrateTime==0)
		{
			gw_DisplayBitrateTime=500;
			if(gw_DisplayBitRate!=gs_System_State.w_BitRate)
			{		
				gw_DisplayBitRate=gs_System_State.w_BitRate;
				LCM_ShowBitRate();
			}
		}
	}

	if((gb_ChannelSet==1)||(gb_PickSong==1))
	{
		if((gc_LCM_Media!=10)&&(gb_ChannelSet==1))
		{
			gc_LCM_Media=10;
			LCM_ClearScreen();
		}
		if((gc_LCM_Media!=11)&&(gb_PickSong==1))
		{
			gc_LCM_Media=11;
			LCM_ClearScreen();
		}
		LCM_ShowIRNum();
		if(gc_LCM_Size==2) 
		{
			goto Show_SongTime;
		}

		return;
	}

	if((gc_CurrentCard==2)||(gc_CurrentCard==3)||(gc_CurrentCard==5))	// Media insert
	{
		// Show "PAUSE"
		if(gc_SystemStateMode==5)	
		{
			if(gc_LCM_Media!=3)	// 3=Pause
			{
				gc_LCM_Media=3;
				LCM_ShowPAUSE();
				gw_DisplayTime=0xFFFF;
				gw_DisplayFreq=0xFFFF;
			}
			return;
		}

		// Show play mode icon
		if((gw_ShowTimer!=0)&&(gc_DisplayPlayMode!=gc_PlaySequenceMode))
		{
			if(gc_LCM_Media!=7)	// 7=Play mode
			{
				gc_LCM_Media=7;
				LCM_ClearScreen();
			}

			gc_DisplayPlayMode=gc_PlaySequenceMode;
			LCM_ShowPlayMode();
			if(gc_LCM_Size==2) 
			{
				// Show play mode small icon
				LCM_ShowPlayModeIcon();
				goto Show_SongTime;
			}
			return;
		}

		// Show EQ
		if((gw_ShowTimer!=0)&&(gb_SelectEQ==1))
		{
			gc_LCM_Media=8;		// 8=EQ

			if(gc_DisplayEQ!=gc_PlayEQMode)
			{
				gc_DisplayEQ=gc_PlayEQMode;
				LCM_ClearScreen();
				LCM_ShowEQ();
			}

			if(gc_LCM_Size==2) 
			{
				goto Show_SongTime;
			}

			return;
		}

		// Change Frequency
		if((gb_Frequency_Song==0)&&(gw_ShowTimer!=0))
		{
			if(gw_DisplayFreq!=gw_FM_frequency)
			{
				if(gc_LCM_Media!=6)
				{
					gc_LCM_Media=6;	// 6=Change Frequency
					LCM_ClearScreen();
				}
				gw_DisplayFreq=gw_FM_frequency;
				LCM_ShowFrequency_L();
				gw_DisplayTime=0xFFFF;
			}

			if(gc_LCM_Size==2) 
			{
				goto Show_SongTime;
			}

			return;
		}
		
		// Change Volumn
		if((gb_SelectVol==1)&&(gw_ShowTimer!=0))
		{
			if(gw_DisplayVol!=gc_DSP_Volume)
			{
				if(gc_LCM_Media!=4)
				{
					gc_LCM_Media=4;	// 4=Change VOL
					LCM_ClearScreen();
				}
				gw_DisplayVol=gc_DSP_Volume;
				LCM_ShowVOL();
				gw_DisplayTime=0xFFFF;
				gw_DisplayFreq=0xFFFF;
			}

			if(gc_LCM_Size==2) 
			{
				goto Show_SongTime;
			}

			return;
		}
		else
		{
			gw_DisplayVol=0xFF;
		}

		// Show Song Number
		if((gb_Frequency_Song==1)&&(gw_ShowTimer!=0))
		{
			if(gw_DisplayVol!=gc_DSP_Volume)
			{
				if(gw_DispSongNum!=gw_FileIndex[0])
				{
					gw_DispSongNum=gw_FileIndex[0];
					if(gc_LCM_Media!=5)
					{
						gc_LCM_Media=5;	// 5=Song Number
						LCM_ClearScreen();
					}
					LCM_ShowSongNumber();
					gw_DisplayTime=0xFFFF;
					gw_DisplayFreq=0xFFFF;
				}
			}

			if(gc_LCM_Size==2) 
			{
				goto Show_SongTime;
			}
			return;
		}
		else
		{
			gw_DisplayVol=0xFF;
		}

		if(gc_CurrentCard==5)
		{
			if(gc_LCM_Media!=1)
			{
				gc_LCM_Media=1;	// 1=USB
				LCM_ClearScreen();
				LCM_ShowFMIcon();
				LCM_ShowUSBIcon();
				gw_DisplayTime=0xFFFF;
				gw_DisplayFreq=0xFFFF;
			}
		}
		else
		{
			if(gc_LCM_Media!=2)
			{
				gc_LCM_Media=2;	// 2=SD/MMC
				LCM_ClearScreen();
				LCM_ShowFMIcon();
				LCM_ShowSDIcon();
				gw_DisplayTime=0xFFFF;
				gw_DisplayFreq=0xFFFF;
			}
		}

		// Show Play mode(128x32 only)
		if(gc_LCM_Size!=0)
		{
			gc_DisplayPlayMode=gc_PlaySequenceMode;
			LCM_ShowPlayModeIcon();
		}

		// Display Song name
		if(gw_FileTotalNumber[0]==0)
		{
			LCM_Show_NOMP3FILE();
			LCM_ShowPlayTime(0);
			gw_DisplayTime=tw_DisplayTime;			
		}
		else
		{
			if(gw_LCMScrollTimer==0)
			{
				if(gw_DispSongNum1!=gw_FileIndex[0])
				{
					U8	i;
					for(i=0;i<48;i++)
					{
						gc_FileLongName[i]=0;
					}
					gw_DispSongNum1=gw_FileIndex[0];
					Dos_GetFileLongName(0,gc_FileLongName);
				}

				LCM_Show_Filename();
				gw_LCMScrollTimer=1000;
			}					
		}
	}
	else
	{
		if(gc_LCM_Media!=0)
		{
			gc_LCM_Media=0;	// 0=No media
			LCM_ShowLineIn();
			gw_DisplayTime=0xFFFF;
			gw_DisplayFreq=0xFFFF;
			gw_LCMScrollTimer=0;
			gc_DisplaySongnameCount=0;

			if(gc_LCM_Size==2)
			{
				LCM_ShowPlayModeIcon();
			}
		}
	}

	// Display Frequency
	if(gw_DisplayFreq!=gw_FM_frequency)
	{
		gw_DisplayFreq=gw_FM_frequency;
		LCM_ShowFrequency();
	}
Show_SongTime:
	if((gc_CurrentCard==0)&&(gc_LCM_Size==2))
	{
		tw_DisplayTime=0;
		if(tw_DisplayTime!=gw_DisplayTime)
		{	
			LCM_ShowPlayTime(tw_DisplayTime);
			gw_DisplayTime=tw_DisplayTime;
		}
		return;
	}
	if(gc_CurrentCard!=0)
	{
		tw_DisplayTime=DSP_Read_Information(DSP_READ_TIME_CMD);	// DSP_READ_TIME_CMD=0x1C
		if(tw_DisplayTime!=gw_DisplayTime)
		{	
			LCM_ShowPlayTime(tw_DisplayTime);
			gw_DisplayTime=tw_DisplayTime;
		}
	}
}


void LCM_ShowCompanyLogo(void)
{
    U8 i,j,k=0;
	U8 tc_offset=0;

	if(gb_LED_LCM==0)
	{
		return;
	}
	
	if(gc_LCM_Size==2)
	{
		for(i=0;i<8;i++)
		{
			LCM_ClearPage(i);
		}
		gb_LCM_reverse=0;
		tc_offset=16;
		k=2;
	}

	for(j=0;j<4;j++)
	{
		LCM_Set_PageColumn(j+k,(U8)gb_LCM_reverse*LCM_ReverseOffset+tc_offset);
		if(gc_LCM_Size==1)
		{
			for(i=0;i<128;i++)
			{
				LCM_Send_Data(CompanyLogo128x32[((U16)j*128)+i]);
			}
		}
		else if(gc_LCM_Size==0)
		{
			for(i=0;i<96;i++)
			{
				LCM_Send_Data(CompanyLogo96x32[((U16)j*96)+i]);
			}
		}
		else
		{
			for(i=0;i<96;i++)
			{
				LCM_Send_Data(CompanyLogo96x32[((U16)j*96)+i]);
			}
		}
	}
}


void LCM_Initial(void)
{
	U8	i;
	U8  code LCM_InitData[20]	=	{0xe2,0xa2,0xa0,0xc8,0xac,0xa6,0xa4,0x22,0x81,0x04,0xd5,0x00,0xd2,0x00,0x2f,0x40,0xb0,0x11,0x04,0xaf};
	U8  code LCM128x32[2]	=	{0x23,0x08};
	U8  code LCM96x32[2]	=	{0x22,0x24};
	U8	code LCM128x64[12]	=	
	{		0xe2,	//Reset
			0xa2,	//  1/65duty   1/9 bias:0xa2          1/7 bias:0xa3
			0xa0,	//Segment Driver Direction Select  Normal:0xa0  Reverse:0xa1
			0xc8,	//Common Output Mode Select        Normal:0xc0  Reverse :0xc8
			0xa6,	//Display Normal/Reverse           Normal:0xa6  Reverse:0xa7
			0xa4,	//Normal display mode
	    	       0x26,   //V5 Voltage Regulator Internal Resistor Ratio Set
			0x81,11,	//The Electronic Volume Mode Set
			0x2f,  //Power Controller Set
			0x40,  //Display Start Line Set
			0xaf,   //display ON
	};

	if(gb_LED_LCM==0)
	{
		return;
	}

	if(gc_LCM_Size==2)
	{
		XBYTE[0xB038]=0x7F;		// XGPIO[6..0]=Output
		XBYTE[0Xb402]|=0xF0;	// FM[15..12]=Output
		XBYTE[0xB403]|=0x04;	// FM[18]=Output
		XBYTE[0xB406]&=0x7F;	// LCM RES enable : FM[15]=0
		XBYTE[0xB406]|=0x40;	// LCM CS disable : FM[14]=1
		XBYTE[0xB406]|=0x20;	// LCM WR disalle : FM[13]=1
		XBYTE[0xB406]|=0x10;	// LCM A0->dat    : FM[12]=1
		XBYTE[0xB407]|=0x04;	// LCM RD disable : FM[18]=1
		XBYTE[0xB406]|=0x80;	// LCM RES disable: FM[15]=1

		for(i=0;i<12;i++)
		{
			P_LCM_Write_CMD(LCM128x64[i]);
		}

		return;
	}

	// LCM RESET=0
	LCM_RESET_0;
	USER_DelayDTms(10);
	// LCM RESET=1
	LCM_RESET_1;
	USER_DelayDTms(10);
	// Initial LCM - Send parameters to LCM
	for(i=0;i<20;i++)
	{
		if((i!=7)&&(i!=9))
		{
			if((i==2)&&(gb_LCM_reverse==1))
			{
				LCM_Send_Command(0xA1);
			}
			else if((i==3)&&(gb_LCM_reverse==1))
			{
				LCM_Send_Command(0xC0);
			}
			else
			{
				LCM_Send_Command(LCM_InitData[i]);
			}
		}
		else
		{
			if(gb_LCMInitFrom2402==0)
			{
				if(gc_LCM_Size==0)
				{
					LCM_Send_Command(LCM96x32[(i-7)/2]);
				}
				else if(gc_LCM_Size==1)
				{
					LCM_Send_Command(LCM128x32[(i-7)/2]);
				}
				else
				{
					LCM_Send_Command(LCM128x64[(i-7)/2]);
				}
			}

⌨️ 快捷键说明

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