/*************************************************************
                      旋转LED立体显示字测试程序
单片机 STC12C5A32S2 或者其他51
字模软件用  PC2002
逐列取模方式

电机旋转方向 逆时针
/*****************************************************
说明：
	  硬件介绍:用单片机的36个IO口独立驱动LED灯,这么做一是充分利用了资源 ,
还有就是可以避免用选通显示上下不对称的问题,所以为制作好的效果提供了硬件基础.采用
无线供电方式以及性能较好的RF370电机,在5V供电下 显示的效果非常好.电机速度也够快 
够安静.

	看程序前请看下原理图，根据原理图来理解比较容易!
    程序用判断红外起点的方法开始显示 每转一圈，列数往后移动一列
显示完指定的字数后循环	此种弊端是没用中断，一圈的开始后必须要显示完
指定的列数才能退出，如果电机速度太快会造成头吃尾的后果，后面会介绍避免
头吃尾的方法，让整一圈都能显示字 盲点很小。

学习知识：
    只为简单的理解显示的原理，利用人眼视觉暂存，用电机旋转做列扫描，
每送一列数据延时 再送下一列数据，原理比较简单，跟点阵显示差不多。
平面显示字效果比较差，由于一圈中半径的问题，这里没有去想过多算法
解决此问题。
/***************************************************/
#include "NEW_8051.H"
#define uchar unsigned char
#define uint unsigned int    //宏定义

sbit KEY=P3^2;  //红外检测起点
//pc2002 设置 阳码 逐列 顺向取模   见设置图片
//立体显示字符	DIY视界欢迎你！祝大家制作成功~ 平面测试字体效果。少壮不努力老大徒伤悲~
uchar code zimo[]={
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*" ",0*/

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*" ",1*/

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*" ",2*/

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*"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0x5F,0xFE,0xDF,0xF9,0xDF,0xF7,0xDF,0xCF,0xDF,0x9F,0xDF,0x3F,0xDF,0xBF,0xFF,0xFF,/*"大",33*/

0xEF,0xFE,0x77,0xFF,0x3B,0x00,0xC4,0x7F,0xED,0xBF,0xBF,0xDF,0xB7,0xE3,0xB7,0xDF,0xB7,0xBF,0x80,0x80,0xB7,0xBB,0xB7,0xBB,0xB7,0xBB,0xBF,0xBF,0xFF,0xBF,0xFF,0xFF,/*"徒",34*/

0x7F,0xFF,0xBF,0xFF,0xDF,0xFF,0x07,0x00,0xB8,0xFF,0xDD,0x7F,0xAF,0xBF,0xB0,0xCF,0xB5,0xF3,0x07,0xFC,0xB7,0xFF,0xB7,0xBF,0xB7,0x7F,0x33,0x80,0xF7,0xFF,0xFF,0xFF,/*"伤",35*/

0xFF,0xFF,0xBB,0xDF,0xAB,0xC7,0xAB,0xFF,0xAB,0xC3,0x00,0xBE,0xFF,0xBF,0xFF,0xBD,0xFF,0xB3,0x00,0xBE,0xAB,0xBF,0xAB,0x8F,0xAB,0xFF,0xBB,0xF7,0xBF,0xCF,0xFF,0xFF,/*"悲",36*/

0xFF,0xFF,0xF9,0xFF,0xFE,0xFF,0xFE,0xFF,0xFD,0xFF,0xFD,0xFF,0xFB,0xFF,0xFB,0xFF,/*"~",37*/


0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0xA0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*"！",9*/
};
/*****n（us）延时子程序*****/
void DelayUs(uint N)
{
    uint x ;
    for(x=0;x<=N;x++);
}

/*****主函数*****/
void main(void)
{
    uint i=0,j=0 ; 
//    led1=0 ;
    //主程序中只检测按键
    while(1)
    {
        if(KEY==0) //红外接收管 判断起始位
        {
            j++;            
            if(j>672) //根据显示的字数定义改数值672/16=42个字 显示完42个字后 重新开始
            {
                j=0 ;
            }            
            for(i=j;i<128+j;i++) //每转一圈  前进一列  这里定义一圈中同时显示128/16=8个字，
            {                    //在这个程序中如果此参数设置过大会造成头吃尾的后果，如果过少盲点又会太大           
              					 //所以比较麻烦 要根据电机速度来调整此参数
				P2=zimo[i*2]; //送数据低位显示
				P4=(zimo[i*2+1]);//送数据高位显示	这里用了单片机P4 和P5口 是LQFP48脚才有的  
				P5=(zimo[i*2+1])>>4;//这里行和列 都是IO口独立驱动的LED
                DelayUs(200);	//延时让LED亮起来 每列延时的时间
				P2=0XFF;
				P4=P5=0XFF;
                
            }
        }
    }
}
/*****END*****/