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

📄 loadfile.c

📁 这是嵌入式软件电话本的小软件
💻 C
字号:
#include  "..\inc\drv.h"

extern U8 tx_buf[16*1024];
extern U8 Page_Buf[528];
volatile unsigned char *downPt;
extern unsigned int fileSize;

U8 U12font[]={'U','1','2','X','1','2',' ',' ','F','N','T'};
U8 U16font[]={'U','1','6','X','1','6',' ',' ','F','N','T'};
U8 U24font[]={'U','2','4','X','2','4',' ',' ','F','N','T'};

char SYSFile[]={'S','Y','S',' ',' ',' ',' ',' ','D','A','T'};

U8 UFont12[256][12];	//半字宽12x12字符
U8 UCFont12[21312][24];	//全字宽12x12字符
U8 UFont16[256][16];	//半字宽16x16字符
U8 UCFont16[21312][32];	//全字宽16x16字符
U8 UFont24[256][48];	//半字宽24x24字符
U8 UCFont24[21312][72];	//全字宽24x24字符

U32 sucloadedfile;


U8 Load16Font()
{
	U32 i,point1,point2,root_location;
	root_location=find_file(U16font);
	
	//get the file first cluster//
	current_block=root_buf[root_location][27]*256+root_buf[root_location][26];
	point1=point2=0;
	
	if(root_location==FILE_NO_FOUND){
		Uart_Printf("16x16 font file is not found!\n");
		LCD_printf("16x16 font file is not found!\n");
		return 0;
	}

	Uart_Printf("Font's first Block/Cluster is at %d\n",current_block);
	Uart_Printf("   Loading 16x16 font,please wait...\n");
	LCD_printf("   Loading 16x16 font,\n   please wait...\n");
	while(1){
		read_file(tx_buf);
		for(i=0;i<BLOCK_SIZE;i++)
		{
			if(point1/16<256){//前256个半宽字符
				UFont16[point1/16][point1%16]=tx_buf[i];
				point1++;
			}
			else if(point2/32<21312){
				UCFont16[point2/32][point2%32]=tx_buf[i];
				point2++;
			}
		}
		current_block=Page_Buf[512+14]*256+Page_Buf[512+15];
		if(current_block==0xffff)
			break;
	}
	Uart_Printf("16x16 font loading finished\n");
	LCD_printf("16x16 font loading finished\n");
	sucloadedfile|=LOADU16FONT;
	return 1;
}

U8 Load12Font()
{
	U32 i,point1,point2,root_location;
	root_location=find_file(U12font);
	
	//get the file first cluster//
	current_block=root_buf[root_location][27]*256+root_buf[root_location][26];
	point1=point2=0;
	
	if(root_location==FILE_NO_FOUND){
		Uart_Printf("12x12 font file is not found!\n");
		LCD_printf("12x12 font file is not found!\n");
		return 0;
	}

	Uart_Printf("Font's first Block/Cluster is at %d\n",current_block);
	Uart_Printf("   Loading 12x12 font,please wait...\n");
	LCD_printf("   Loading 12x12 font,\n   please wait...\n");
	while(1){
		read_file(tx_buf);
		for(i=0;i<BLOCK_SIZE;i++)
		{
			if(point1/12<256){//前256个半宽字符
				UFont12[point1/12][point1%12]=tx_buf[i];
				point1++;
			}
			else if(point2/24<21312){
				UCFont12[point2/24][point2%24]=tx_buf[i];
				point2++;
			}
		}
		current_block=Page_Buf[512+14]*256+Page_Buf[512+15];
		if(current_block==0xffff)
			break;
	}
	Uart_Printf("12x12 font loading finished\n");
	LCD_printf("12x12 font loading finished\n");
	sucloadedfile|=LOADU12FONT;
	return 1;
}

U8 Load24Font()
{
	U32 i,point1,point2,root_location;
	root_location=find_file(U24font);
	
	//get the file first cluster//
	current_block=root_buf[root_location][27]*256+root_buf[root_location][26];
	point1=point2=0;
	
	if(root_location==FILE_NO_FOUND){
		Uart_Printf("24x24 font file is not found!\n");
		LCD_printf("24x24 font file is not found!\n");
		return 0;
	}

	Uart_Printf("Font's first Block/Cluster is at %d\n",current_block);
	Uart_Printf("   Loading 24x24 font,please wait...\n");
	LCD_printf("   Loading 24x24 font,\n   please wait...\n");
	while(1){
		read_file(tx_buf);
		for(i=0;i<BLOCK_SIZE;i++)
		{
			if(point1/48<256){//前256个半宽字符
				UFont24[point1/48][point1%48]=tx_buf[i];
				point1++;
			}
			else if(point2/72<21312){
				UCFont24[point2/72][point2%72]=tx_buf[i];
				point2++;
			}
		}
		current_block=Page_Buf[512+14]*256+Page_Buf[512+15];
		if(current_block==0xffff)
			break;
	}
	Uart_Printf("24x24 font loading finished\n");
	LCD_printf("24x24 font loading finished\n");
	sucloadedfile|=LOADU24FONT;
	return 1;
}

U8 LoadFont()
{
	U8 tmp=1;
	tmp&=Load12Font();
	tmp&=Load16Font();

#if LOAD_24FONT_EN==1
	tmp&=Load24Font();
#endif

	return tmp;
}

U8 LoadSYS()
{
	U8 *point;
	U32 i,root_location;
	root_location=find_file((U8*)SYSFile);
	
	//get the file first cluster//
	current_block=root_buf[root_location][27]*256+root_buf[root_location][26];
	
	if(root_location==FILE_NO_FOUND){
		Uart_Printf("Sys.dat file is not found!\n");
		LCD_printf("Sys.dat font file is not found!\n");
		return 0;
	}

	Uart_Printf("Sys.dat file first Block/Cluster is at %d\n",current_block);

	read_file(tx_buf);
	Uart_Printf("sys.dat file loading finished\n");
	LCD_printf("sys.dat file loading finished\n");
	return 1;
}

U8 isConfigsysLoad=FALSE;
U8 sysCONFIG[]={'C','O','N','F','I','G',' ', ' ','S','Y','S'};
U32 ConfigSysdata[16*1024/4];

U8 LoadConfigSys()
{
	U32 root_location;
	root_location=find_file(sysCONFIG);
	
	//get the file first cluster//
	current_block=root_buf[root_location][27]*256+root_buf[root_location][26];
	
	if(root_location==FILE_NO_FOUND){
		Uart_Printf("\nConFig.sys no found!");
		LCD_printf("ConFig.sys no found!\n");
		isConfigsysLoad=FALSE;
		return FALSE;
	}

	Uart_Printf("\nLoading ConFig.sys...");
	LCD_printf("Loading ConFig.sys...\n");
	read_file((U8*)ConfigSysdata);

	Uart_Printf("\nLoad ConFig.sys OK!\n");
	LCD_printf("Load ConFig.sys OK!\n");
	isConfigsysLoad=TRUE;
	return TRUE;
}

⌨️ 快捷键说明

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