switch(cnt)
{
case 7:A_138_L;B_138_L;C_138_L;break; //依次选中点阵的每一行
case 6:A_138_H;B_138_L;C_138_L;break;
case 5:A_138_L;B_138_H;C_138_L;break;
case 4:A_138_H;B_138_H;C_138_L;break;
case 3:A_138_L;B_138_L;C_138_H;break;
case 2:A_138_H;B_138_L;C_138_H;break;
case 1:A_138_L;B_138_H;C_138_H;break;
case 0:A_138_H;B_138_H;C_138_H;break;
default: break;
}
cnt++;
if(cnt>7)cnt=0;
}
#include "ku.h"
typedef unsigned char uchar;
typedef unsigned int uint;
uchar const quwei[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
unsigned char tt;
unsigned char a=0,cnt;
unsigned char date1;
unsigned char i,j,k=8,h=1,chi;
unsigned char t0,switch_time,mode_cnt;
unsigned int temper,time=1;
uchar read_temp_flag;
uchar dis_date_flag;
uchar cnt_ta=0;
#define DS_H P4OUT |= BIT0;//74HC595数据
#define DS_L P4OUT &= ~BIT0;
#define CLK_H P4OUT |= BIT1;//74HC595时钟
#define CLK_L P4OUT &= ~BIT1;
#define DATA_OUT_H P4OUT |= BIT2;//74HC595数据输出锁存
#define DATA_OUT_L P4OUT &= ~BIT2;
#define OE_H P4OUT |= BIT3;
#define OE_L P4OUT &= ~BIT3;
#define A_138_H P5OUT |= BIT0;//
#define A_138_L P5OUT &= ~BIT0;
#define B_138_H P5OUT |= BIT1;//
#define B_138_L P5OUT &= ~BIT1;
#define C_138_H P5OUT |= BIT2;//
#define C_138_L P5OUT &= ~BIT2;
#define EN_138_H P5OUT |= BIT3;//
#define EN_138_L P5OUT &= ~BIT3;
uchar cnt;
void delay(uint ms)
{
uint j,k;
for(j=0;j<ms;j++)
for(k=0;k<100;k++);
}
void read_byte_L(uchar date)
{
uchar i;
for(i=0;i<8;i++)
{
date<<=1;
CLK_L;
if(date&0x80)
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
}
}
void HangXuan(unsigned char x)
{
if(x<8)
{
EN_138_H;
}
else
{
EN_138_L
}
switch(cnt)
{
case 7:A_138_L;B_138_L;C_138_L;break; //依次选中点阵的每一行
case 6:A_138_H;B_138_L;C_138_L;break;
case 5:A_138_L;B_138_H;C_138_L;break;
case 4:A_138_H;B_138_H;C_138_L;break;
case 3:A_138_L;B_138_L;C_138_H;break;
case 2:A_138_H;B_138_L;C_138_H;break;
case 1:A_138_L;B_138_H;C_138_H;break;
case 0:A_138_H;B_138_H;C_138_H;break;
default: break;
}
cnt++;
if(cnt>7)cnt=0;
}
/******************************************************
函数功能:显示汉字,不流动
*******************************************************/
void display_hanzi(unsigned char *p)//*p:指针p是用来指向你想要显示的数组首地址
{
unsigned char j;
for(j=0;j<16;j++)
{
read_byte_L(p[2*j+1+96]);
read_byte_L(p[2*j+96]);
read_byte_L(p[2*j+1+64]);
read_byte_L(p[2*j+64]);
read_byte_L(p[2*j+1+32]);
read_byte_L(p[2*j+32]);
read_byte_L(p[2*j+1]);
read_byte_L(p[2*j]);
DATA_OUT_L;
DATA_OUT_H;
OE_L;
HangXuan(j);
// delay_ms(5);
OE_H;
}
}
/******************************************************
函数功能:流动显示固定中文、英文、阿拉伯数字等
*******************************************************/
void Dis_LiuDongHanzi()
{
OE_L;
for(j=0;j<16;j++)
{
for(i=k;i<8;i++)
{
if(ku[h+7][j]&quwei[i])
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
}
for(i=0;i<7;i++)
{
date1=ku[6-i+h][j];
if(date1&0x01)
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
if(date1&0x02)
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
if(date1&0x04)
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
if(date1&0x08)
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
if(date1&0x10)
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
if(date1&0x20)
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
if(date1&0x40)
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
if(date1&0x80)
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
}
for(i=0;i<k;i++)
{
if(ku[h-1][j]&quwei[i])
{
DS_H;
}
else
{
DS_L;
}
CLK_H;
CLK_L;
}
P5OUT=15-j;
DATA_OUT_H;
DATA_OUT_L;
}
chi++;
if(chi==1) //改变它的值,可改变流动速度
{
chi=0;
if(k==0)
{
k=7;
if(h>20) //改变此值,可改变显示图像的长短
{
h=1;
dis_date_flag=1;
}
else h++;
}
else k--;
}
}
/********************主函数********************/
void main(void)
{
/*下面六行程序关闭所有的IO口*/
P1DIR = 0XFF;P1OUT = 0XFF;
P2DIR = 0XFF;P2OUT = 0XFF;
P3DIR = 0XFF;P3OUT = 0XFF;
P4DIR = 0XFF;P4OUT = 0XFF;
P5DIR = 0XFF;P5OUT = 0XFF;
P6DIR = 0XFF;P6OUT = 0XFF;
WDTCTL = WDTPW + WDTHOLD;
P6DIR |= BIT2;P6OUT |= BIT2; //关闭电平转换
P1DIR = BIT7; //设置P1.0~P.3为输入状态,P.7为输出
P1OUT = 0;
P3DIR |= BIT4; // P3.4 output
while(1)
{
Dis_LiuDongHanzi();
}
}
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
{
}
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
}
一周热门 更多>