点阵字模显示

LED点阵显示并放大的要点
* 先根据字模提取的方式将其储存在 16*16 two-dimension array 中,方便读取
* 在读取字模时,利用二维数组,同时读取前16个byte和后16个byte
* 4中取膜方式的读取方法都大同小异

1. 点阵格式:阴码
取膜方式:逐行
取膜走向:顺向
输出数制:16进制

/****************************************
FileName: YinCode_Row_FirstHigh
Description: output "暨", extract font mask of "暨" by yin code, row by row, first bit is high
Reversion History: 2
Author: greyson
Date: 2014/04/26
****************************************/
#include<stdio.h>

#define uchar unsigned char

void ExtractJi();
void display( uchar );

uchar Ji[16][16];
uchar size;

uchar JiMask[32]={0x7D,0xFC,0x44,0x20,0x7D,0x20,0x45,0xFE,0x7C,0x50,0x48,0x52,0x54,0x92,0x65,0x0E,
0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x00,0x00,0xFF,0xFE,0x00,0x00};

int main()
{
ExtractJi();

while(1){
printf("请输入字体扩大的倍数(1至5之间的整数,按其他数字则退出)\n");
scanf("%d",&size);
if (size >= 6)
return 0;
display(size);
}

return 0;
}

/* transform JiMask into 2-dimension array(16*16) */
void ExtractJi()
{
uchar bit;
uchar i, j;
for(i=0; i<16; i++){
bit=0x80;
for(j=0; j<8; j++){
if( (JiMask[2*i] & bit) != 0 )
Ji[i][j]=1;
else
Ji[i][j]=0;

if( (JiMask[2 * i + 1] & bit) != 0 )
Ji[i][j+8]=1;
else
Ji[i][j+8]=0;

bit=bit>>1;
}
}
}

/* display "暨" according to array Ji */
void display(uchar n)
{
uchar i, j, m, k;

for (i = 0; i < 16; i++)
for (m = 1; m <= n; m++){
for (j = 0; j < 16; j++){
for(k = 1; k <= n; k++){
if ( Ji[i][j] == 1)
printf("*");
else
printf(" ");
}
}
printf("\n");
}
}


1.  点阵格式:阴码
取膜方式:列行式
取膜走向:逆向(低位在前)

/****************************************
FileName: YinCode_RowByCol_FirstLow
Description: output "暨", extract font mask of "暨" by yin code, row by column, first bit is low
Reversion History: 1
Author: greyson
Date: 2014/04/27
****************************************/
#include<stdio.h>

#define uchar unsigned char

void ExtractJi();
void display( uchar );

uchar Ji[16][16];
uchar size;

uchar JiMask[32]={0x00,0xFF,0x95,0x55,0x35,0xDF,0x00,0x8D,0x49,0x39,0x0F,0x79,0x89,0x89,0xE8,0x00,
0x40,0x40,0x40,0x5F,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x5F,0x40,0x40,0x40,0x00};

int main()
{
ExtractJi();

while(1){
printf("请输入字体扩大的倍数(1至5之间的整数,按其他数字则退出)\n");
scanf("%d",&size);
if (size >= 6)
return 0;
display(size);
}

return 0;
}

/* transform JiMask into 2-dimension array(16*16) */
void ExtractJi()
{
uchar bit;
uchar i, j;
bit=0x01;
for(i=0; i<8; i++){
for(j=0; j<16; j++){
if( (JiMask[j] & bit) != 0 )
Ji[i][j]=1;
else
Ji[i][j]=0;

if( (JiMask[j + 16] & bit) != 0 )
Ji[i+8][j]=1;
else
Ji[i+8][j]=0;
}
bit=bit<<1;
}
}

/* display "暨" according to array Ji,which store data by display format*/
void display(uchar n)
{
uchar i, j, m, k;

for (i = 0; i < 16; i++)
for (m = 1; m <= n; m++){
for (j = 0; j < 16; j++){
for(k = 1; k <= n; k++){
if ( Ji[i][j] == 1)
printf("*");
else
printf(" ");
}
}
printf("\n");
}
}


你可能感兴趣的:(点阵字模显示)