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

📄 hz.c

📁 我学习AVR的代码例子
💻 C
字号:
#ifndef HZ_C
#define HZ_C

#include <GUI.h>


#if defined(GB_16) || defined(ASC_16)
#include <HZ16.h>
uint8 printf_16(uint16 x,uint8 y,uint8 *ptr)
{
    uint8 c1,c2,i=0,j,uLen=0;
    while (ptr[uLen]!=0) //探测字串长度
    {
        uLen++;
    }
    while(i<uLen)
    {
        if(x>GUI_LCM_XMAX-16) {x=0;y+=16;}
        c1 = ptr[i];
        c2 = ptr[i+1];
        //ascii字符与汉字内码的区别在于128做分界,大于界线的为汉字码
        if(c1 <=128)	// ASCII
        {// 写数据(命令)
#ifdef ASC_16            
            if (c1 >= 0x20)
            {
                GUI_PutHZ(x,y,&ASC16[16*(c1-0x20)],8,16);
            }
            else
            {
                GUI_PutHZ(x,y,&ASC16[0],8,16);
            }
#endif            
        }
        else    	// 中文
        {
#ifdef GB_16
            for(j=0;j<sizeof(GB16_Index)/sizeof(GB16_Index[0]);j++)  	// 查找定位
            {
                if(c1 ==GB16_Index[j*2] && c2 == GB16_Index[j*2+1])
                {
                    break;
                }        				
            }
            if(j < sizeof(GB16_Index)/sizeof(GB16_Index[0]))
            {
                GUI_PutHZ(x,y,&GB16_Msk[32*j],16,16);
                x+=8;
                i++;
            }
            else
            {
                x+=8;
                i++;
            }
#endif
        };
        x+=8;
        i++;
    }
    return uLen;        //返回字串长度,汉字按2字节计算
}
#endif

#if defined(GB_24) || defined(ASC_24)
#include <HZ24.h>
uint8 printf_24(uint16 x,uint8 y,uint8 *ptr)
{
    uint8 c1,c2,i=0,j,uLen=0;
    while (ptr[uLen]!=0) //探测字串长度
    {
        uLen++;
    }
    while(i<uLen)
    {
        if(x>GUI_LCM_XMAX-24) {x=0;y+=24;}
        c1 = ptr[i];
        c2 = ptr[i+1];
        //ascii字符与汉字内码的区别在于128做分界,大于界线的为汉字码
        if(c1 <=128)	// ASCII
        {// 写数据(命令)
#ifdef ASC_24           
            for(j=0;j<sizeof(ASC24_Index)/sizeof(ASC24_Index[0]);j++)  	// 查找定位
            {
                if(c1 ==ASC24_Index[j])
                {
                    break;
                }        				
            }
            if(j < sizeof(ASC24_Index)/sizeof(ASC24_Index[0]))
            {
                if (c1 > 0x20)
                {
                    GUI_PutHZ(x,y,&ASC24[72*j],24,24);
                    x+=12;
                }
            }
            else
            {
                //x+=12;
            }
#endif
        }
        else    	// 中文
        {
#ifdef GB_24
            for(j=0;j<sizeof(GB24_Index)/sizeof(GB24_Index[0]);j++)  	// 查找定位
            {
                if(c1 ==GB24_Index[j*2] && c2 == GB24_Index[j*2+1])
                {
                    break;
                }        				
            }
            if(j < sizeof(GB24_Index)/sizeof(GB24_Index[0]))
            {
                GUI_PutHZ(x,y,&GB24_Msk[72*j],24,24);
                x+=12;
                i++;
            }
            else
            {
                x+=12;
                i++;
            }
#endif
        };
        x+=12;
        i++;
    }
    return uLen;        //返回字串长度,汉字按2字节计算
}
#endif

#if defined(GB_12) || defined(ASC_12)
#include <HZ12.h>
uint8 printf_12(uint16 x,uint8 y,uint8 *ptr)
{
    uint8 c1,c2,i=0,j,uLen=0;
    while (ptr[uLen]!=0) //探测字串长度
    {
        uLen++;
    }
    while(i<uLen)
    {
        if(x>GUI_LCM_XMAX-12) {x=0;y+=12;}
        c1 = ptr[i];
        c2 = ptr[i+1];
        //ascii字符与汉字内码的区别在于128做分界,大于界线的为汉字码
        if(c1 <=128)	// ASCII
        {// 写数据(命令)
#ifdef ASC_12           
            if (c1 >= 0x20)
            {
                GUI_PutHZ(x,y,&ASC12[12*(c1-0x20)],6,12);
            }
            else
            {
                GUI_PutHZ(x,y,&ASC12[0],6,12);
            }
#endif
        }
        else    	// 中文
        {
#ifdef GB_12
            for(j=0;j<sizeof(GB12_Index)/sizeof(GB12_Index[0]);j++)  	// 查找定位
            {
                if(c1 ==GB12_Index[j*2] && c2 == GB12_Index[j*2+1])
                {
                    break;
                }        				
            }
            if(j < sizeof(GB12_Index)/sizeof(GB12_Index[0]))
            {
                GUI_PutHZ(x,y,&GB12_Msk[24*j],12,12);
                x+=6;
                i++;
            }
            else
            {
                x+=6;
                i++;
            }
#endif
        };
        x+=6;
        i++;
    }
    return uLen;        //返回字串长度,汉字按2字节计算
}
#endif



#endif

⌨️ 快捷键说明

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