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

📄 mk0816a.cpp

📁 单片机开发必备
💻 CPP
字号:
/*ACM12232字符点阵提取程序(8*16字符)字符由键盘输入*/
#include <stdio.h>
#include <string.h>
#include <process.h>
unsigned char NumToChar(unsigned char nNum)
{
    if(nNum<=9)
       return nNum + 48 ;
    else
       return nNum + 55 ;
}

void main()
{
 FILE * fpHZK ;
 FILE * fpDot ;
 char strDotFile[12];
 unsigned char strHZ[100],nTemp,nTemp1,nTemp2;
 unsigned char aryHZKDot[16],aryLCDDot[16];
 unsigned long nOffset;
 unsigned int  nLenOfHZ,i,j;
 int ch;
 printf("AM12232 LCD 8*16 DOT PRODUCER\n");
 printf("Input Filename:");
 scanf("%s",strDotFile);
 printf("\n");
 printf("Input Character String:");
 scanf("%s",strHZ);
 nLenOfHZ = strlen(strHZ) ;
 printf("\n");
 fpHZK = fopen("asc16","rb") ;
 if(fpHZK == NULL)
 {
   printf("Can't open file asc16\n");
   exit(1);
 }
 fpDot = fopen(strDotFile,"wt") ;
  if(fpDot == NULL)
 {
   printf("Can't open file %s\n",strDotFile);
   exit(1);
 }
 for(i=0;i<nLenOfHZ;i++)
 {
   nOffset = strHZ[i]*16 ;
   fseek(fpHZK,nOffset,SEEK_SET);
   for(j=0;j<16;j++)
     aryHZKDot[j] =(unsigned char)getc(fpHZK) ;
   nTemp = 0x80 ;
   for(j=0;j<8;j++)
   {
      aryLCDDot[j] = ((aryHZKDot[7] & nTemp)==0?0x00:0x80) | ((aryHZKDot[6] & nTemp)==0?0x00:0x40) |
		  ((aryHZKDot[5] & nTemp)==0?0x00:0x20) | ((aryHZKDot[4] & nTemp)==0?0x00:0x10) |
		  ((aryHZKDot[3] & nTemp)==0?0x00:0x08) | ((aryHZKDot[2] & nTemp)==0?0x00:0x04) |
		  ((aryHZKDot[1] & nTemp)==0?0x00:0x02) | ((aryHZKDot[0] & nTemp)==0?0x00:0x01) ;
      nTemp >>= 1 ;
   }
   nTemp = 0x80 ;
   for(j=8;j<16;j++)
   {
     aryLCDDot[j] = ((aryHZKDot[15] & nTemp)==0?0x00:0x80) | ((aryHZKDot[14] & nTemp)==0?0x00:0x40) |
		  ((aryHZKDot[13] & nTemp)==0?0x00:0x20) | ((aryHZKDot[12] & nTemp)==0?0x00:0x10) |
		  ((aryHZKDot[11] & nTemp)==0?0x00:0x08) | ((aryHZKDot[10] & nTemp)==0?0x00:0x04) |
		  ((aryHZKDot[9] & nTemp)==0?0x00:0x02) | ((aryHZKDot[8] & nTemp)==0?0x00:0x01) ;

      nTemp >>= 1 ;
   }
   putc(strHZ[i],fpDot) ;
   putc(0x0a,fpDot);
//   putc(0x0d,fpDot);
   putc('{',fpDot);
   putc(0x0a,fpDot);
//   putc(0x0d,fpDot);
   for(j=0;j<16;j++)
    {
      nTemp1 = NumToChar((aryLCDDot[j] & 0xf0)>>4) ;
      nTemp2 = NumToChar(aryLCDDot[j] & 0x0f) ;
      putc('0',fpDot);
      putc('x',fpDot);
      putc(nTemp1,fpDot);
      putc(nTemp2,fpDot);
      if((j+1)%8==0)
       {
	 if(j!=15) putc(',',fpDot);
	 putc(0x0a,fpDot);
  //	 putc(0x0d,fpDot);
       }
      else
       putc(',',fpDot);
    }
   putc('}',fpDot);
   putc(0x0a,fpDot);
// putc(0x0d,fpDot);
  }
  fcloseall();
}

⌨️ 快捷键说明

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