这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 数码管查表显示

共1条 1/1 1 跳转至

数码管查表显示

助工
2014-11-25 20:32:22     打赏

#include "HT48R0662.h"

const  INT8U TableDig[16] =
{
 0x3f,0x06,0x5b,0x4f,
 0x66,0x6d,0x7d,0x07,
 0x7f,0x6f,0x77,0x7c,
 0x39,0x5e,0x79,0x71
};

const  INT8U TableHex[100] = 
{
 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
};

void VFDLoadGMT(void)
{
 MinDig = TableHex[GMTMin];
 MinDigL = MinDig & 0x0f;
 MinDigH = MinDig >> 4;
 
 HourDig = TableHex[GMTHour];
 HourDigL = HourDig & 0x0f;
 HourDigH = HourDig >> 4;
 
 DigBit_5 = TableDig[MinDigL];
 DigBit_4 = TableDig[MinDigH];
 DigBit_2 = TableDig[HourDigL];
 DigBit_1 = TableDig[HourDigH];
 if(! HourDigH)
 {
  DigBit_1 = 0;
 }
}

 

void VFDScan()
{
 aBit = 1;
 bBit = 1;
 cBit = 1;
 dBit = 1;
 eBit = 1;
 fBit = 1;
 gBit = 1;

 HetBit = 1;
 PotBit = 1;
 RingBit = 1;
 PBit = 1;
 AutoBit = 1;

 Gate1 = 1;
 Gate2 = 1;
 Gate3 = 1;
 Gate4 = 1;
 Gate5 = 1;
 
// ++ ScanIndex;
 if(++ ScanIndex > 4) ScanIndex = 0;
 switch(ScanIndex)
 {
  case 0:   
   if( DigBit_10 ) aBit = 0;
   if( DigBit_11 ) bBit = 0;
   if( DigBit_12 ) cBit = 0;
   if( DigBit_13 ) dBit = 0;
   if( DigBit_14 ) eBit = 0;
   if( DigBit_15 ) fBit = 0;
   if( DigBit_16 ) gBit = 0;
   if( PLog  ) PBit = 0;
   if( AutoLog  ) AutoBit = 0;
      
   Gate1 = 0;
   break;
   
  case 1:     
   if( DigBit_20 ) aBit = 0;
   if( DigBit_21 ) bBit = 0;
   if( DigBit_22 ) cBit = 0;
   if( DigBit_23 ) dBit = 0;
   if( DigBit_24 ) eBit = 0;
   if( DigBit_25 ) fBit = 0;
   if( DigBit_26 ) gBit = 0;
    
   Gate2 = 0;     
   break;
   
  case 2:
   if( HetLog  ) HetBit = 0;
   if( PotLog  ) PotBit = 0;
   if( RingLog  ) RingBit = 0;
    
   Gate3 = 0;
   break;
   
  case 3:
   if( DigBit_40 ) aBit = 0;
   if( DigBit_41 ) bBit = 0;
   if( DigBit_42 ) cBit = 0;
   if( DigBit_43 ) dBit = 0;
   if( DigBit_44 ) eBit = 0;
   if( DigBit_45 ) fBit = 0;
   if( DigBit_46 ) gBit = 0;
    
   Gate4 = 0;
   break;
   
  case 4:
   if( DigBit_50 ) aBit = 0;
   if( DigBit_51 ) bBit = 0;
   if( DigBit_52 ) cBit = 0;
   if( DigBit_53 ) dBit = 0;
   if( DigBit_54 ) eBit = 0;
   if( DigBit_55 ) fBit = 0;
   if( DigBit_56 ) gBit = 0;
   
   
   Gate5 = 0;
   break;
 }

}

 

void main(void)

{

while(1)

{

 VFDLoadGMT();

 VFDScan();

}

}

 


共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]