点阵如何显示

2019-07-16 02:08发布

如图注释大部分地方理解了,只是对于数字字母是如何显示的比较困惑,或者说红 {MOD}的二维数组是根据什么编出来的?求解,非常感谢。
#include<reg51.h>
unsigned char code tab[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,};  //列选通控制   

unsigned char code digittab[18][8]={
{0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00}, //0
{0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00}, //1
{0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00}, //2
{0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00}, //3
{0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00}, //4
{0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00}, //5
{0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00}, //6
{0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00}, //7
{0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00}, //8
{0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00}, //9
{0x00,0x00,0x7F,0x48,0x48,0x30,0x00,0x00}, //P
{0x00,0x00,0x7F,0x48,0x4C,0x73,0x00,0x00}, //R
{0x00,0x00,0x7F,0x49,0x49,0x49,0x00,0x00}, //E
{0x00,0x00,0x3E,0x41,0x41,0x62,0x00,0x00}, //C
{0x00,0x00,0x7F,0x08,0x08,0x7F,0x00,0x00}, //H
{0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00}, //I
{0x00,0x7F,0x10,0x08,0x04,0x7F,0x00,0x00}, //N
{0x7C,0x48,0x48,0xFF,0x48,0x48,0x7C,0x00}  //中
};
unsigned int timecount1 , timecount2;  //定义的变量
unsigned char cntx , cnty ;  //cntx列控制数的变量   cnty用来控制 字符与字符之间的切换
void main(void)
{
  cnty=0;
  cntx=0;
while(1)
{
   if(cnty<18) //红 {MOD}
  {
    P1=0xFF; //绿 {MOD}选通都关闭掉
    P2=tab[cntx];  // 列线
    P0=digittab[cnty][cntx];   // 行线
  }
  else //绿 {MOD}
  {
    P2=0xFF;  //红 {MOD}的列选通都关闭掉
    P1=tab[cntx];   // 列线
    P0=digittab[cnty-18][cntx];  // 行线
  }

//用于控制动态扫描的速度
  if(++timecount1>=50)  //每50个扫描周期cntx才加一。
  {
    timecount1=0;
    if(++cntx>=8) cntx=0; //要知道为什么是8,显示的每个数字用了八个十六进制数。
  }

//用于控制动字符间的切换速度
  if(++timecount2>=20000) //每20000个扫描周期cnty才加一
  {
    timecount2=0;
    if(++cnty>=36)cnty=0; //红 {MOD}显示16行绿 {MOD}显示16行。所以是36
  }
}
}


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。