p10单 {MOD}16*32led点阵 汉字滚动 c程序如何写。
求各位大神帮忙 。。
- #define uint unsigned int
- #define uchar unsigned char
-
- sbit sh_cp=P1^6;
- sbit st_cp=P1^5;
- sbit DIN=P1^7;
- //sbit OE=P1^2;
- sbit OA1=P1^4;
- sbit OB1=P1^3;
- /*--------------
- 字模程序
- ---------------*/
- uchar code tab_zimo[][32]={ //字模去正序
- /*-- 文字: 科 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- {0x08,0x10,0x1D,0x10,0xF0,0x90,0x10,0x90, 0x10,0x10,0xFD,0x10,0x10,0x90,0x38,0x90,
- 0x34,0x10,0x50,0x1E,0x53,0xF0,0x90,0x10, 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10},
- /*-- 文字: 学 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- {0x22,0x08,0x11,0x08,0x11,0x10,0x00,0x20,0x7F,0xFE,0x40,0x02,0x80,0x04,0x1F,0xE0,
- 0x00,0x40,0x01,0x80,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00},
- };
- /*-------------
- 数据传输子程序
- ---------------*/
- void send_dat(uchar dat)
- {
- uchar i;
- for(i=0;i<8;i++)
- {
- DIN=dat&(0x80>>i);
- sh_cp=0;_nop_();
- sh_cp=1;
- }
- }
- /*----------------
- 四个595级联传输
- ------------*/ /*
- void send_595(uchar dat1,uchar dat2,uchar dat3,uchar dat4) //四个595级联
- {
- send_dat(dat1);
- send_dat(dat2);
- send_dat(dat3);
- send_dat(dat4);
- } */
- /*----------------
- 138行扫描子程序
- ----------------*/
- /*void dis_row(uchar k)
- {
- uchar i;
- //OE=1;
- for(i=0;i<k;i++)
- {
- OA1=i&0x01;
- OB1=i&0x02;
- }
- } */
- /*-------------
- 数据锁存输出
- ---------------*/
- void send_out()
- {
- st_cp=0;
- st_cp=1;
- }
- /*-----------
- 显示子程序
- ------------*/
- void display()
- {
- uchar i,j,k;
- for(i=0;i<4;i++)
- {
- for(j=0;j<2;j++)
- {
- for(k=0;k<2;k++)
- {
- send_dat(~tab_zimo[j][3*8+k+i*2]);
- send_dat(~tab_zimo[j][2*8+k+i*2]);
- send_dat(~tab_zimo[j][1*8+k+i*2]);
- send_dat(~tab_zimo[j][0*8+k+i*2]);
- }
-
- }
- send_out();
- OA1=0x01&i;
- OB1=0x02&i;
- }
-
- }
- /*------------
- 主函数
- ------------------*/
- main()
- {
- while(1)
- {
- display();
- }
- }
复制代码
一周热门 更多>