打印
[STM32]

振南ZN-X开发板【STM32M3版】花样实验 之“16x16点阵滚动显示”

[复制链接]
3099|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
znmcu|  楼主 | 2014-10-10 10:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 znmcu 于 2014-10-10 14:17 编辑

振南网站还在继续美化改进,暂时提供一个平台来发布振南的实验和相关资料!
http://www.znmcu.cn/znx_m3_exp_huayang_leddz_rolling_test.html
振南QQ:987582714  群:198521880

振南ZN-X开发板(STM32F103) 基础花样实验 16x16点阵滚动显示
实验说明:
在完成了16x16点阵屏基本的汉字字形显示实验之后,振南就开始着手研究制作更为有趣的显示效果—“滚屏显示”!在点阵屏上实现滚动显示,是一种我们经常见到的显示效果。但是很多人对于它却无从下手。其实很简单,我们把LED点阵当作显示屏,在它上面显示的任何内容都是一帧帧的图像。要作出滚动效果,最根本的就是由字模点阵数据计算出“字模串位”的效果。理解这个原理,我们就可以实现左移、右移、上移、下移,甚至是斜移,以及各种更加炫酷的效果。
此实验的目的是在16x16点阵上循环向左滚动显示“振南电子,原创无限!点阵屏滚动显示实验~”这几个字。
实验硬件:
硬件特写:











实验原理图:
信号连接:
振南ZN-X开发板具有极强的扩展性,可以插接很多种模块,同时也可以兼容很多种CPU芯片。本实验使用的是STM32F103和基础资源模块。将基础资源模块插接到ZN-X基板的插座上,这样模块的信号便与CPU的IO进行了连接。
16x16点阵部分的信号连接如下表:
16x16点阵信号

与CPU IO连接


说明


595-DINH


PA7


用于控制“行”的两片级联HC595的串行数据输入


595-DINL


PA4


用于控制“列”的两片级联HC595的串行数据输入


595-LC


PB10


用于控制4片HC595的数据锁存


595-SCK


PA5


串行时钟


振南详解:
点阵滚动算法的根本思想可以由下图形象地表述:

上图所示过程的代码实现如下:
void DZ_Make_Rolling_Data(unsigned char p[16][2],unsigned char *pcode,unsigned char n)
{
int i=0;
for(i=0;i<16;i++)
{
  p[i][0]<<=1;
  if(p[i][1]&0x80) p[i][0]|=0x01;
  p[i][1]<<=1;
  if(pcode[2*i+(n>7?1:0)]&(0x80>>(n>7?(n-8):n))) p[i][1]|=0x01;
}
}


主要代码:
const unsigned char hz_code[20][32]= //汉字的字模数据
{
{
0x18,0x00,0x1B,0xFF,0x1B,0x00,0xFF,0x00,0x1B,0xFE,0x1F,0x00,0x1F,0xFF,0x1B,0xE0,
0x3B,0xF6,0xFB,0xF7,0x1B,0xDC,0x1B,0xCC,0x1E,0xCC,0x1E,0xF7,0x7C,0xE6,0x30,0xC0},/*"振",0*/
{
0x01,0x80,0x01,0x86,0xFF,0xFF,0x01,0x80,0x03,0x00,0x3F,0xFE,0x36,0x36,0x33,0x66,
0x3F,0xFE,0x31,0x86,0x3F,0xFE,0x31,0x86,0x31,0x86,0x31,0x9E,0x31,0x8C,0x00,0x00},/*"南",1*/
{
0x01,0x80,0x01,0x80,0x01,0x80,0x3F,0xFC,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x31,0x8C,0x01,0x83,0x01,0x83,0x00,0xFF,0x00,0x00},/*"电",2*/
{
0x00,0x00,0x3F,0xF8,0x00,0x30,0x00,0x60,0x00,0xC0,0x01,0x80,0x01,0x80,0x01,0x86,
0xFF,0xFF,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x07,0x80,0x03,0x00},/*"子",3*/
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x38,0x00,0x18,0x00,0x30,0x00,0x00,0x00},/*",",4*/
{
0x00,0x00,0x3F,0xFE,0x31,0xC0,0x31,0x80,0x37,0xF8,0x36,0x18,0x37,0xF8,0x36,0x18,
0x36,0x18,0x37,0xF8,0x30,0xC0,0x36,0xF0,0x67,0xDC,0x6C,0xCE,0xDB,0xCC,0xC1,0x80},/*"原",5*/
{
0x0C,0x03,0x0C,0x03,0x1E,0x1B,0x1B,0x9B,0x31,0xFB,0x60,0xDB,0xFF,0x9B,0x31,0x9B,
0x31,0x9B,0x37,0x9B,0x33,0x1B,0x30,0xC3,0x30,0xC3,0x30,0xCF,0x1F,0xC6,0x00,0x00},/*"创",6*/
{
0x00,0x00,0x3F,0xFE,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x7F,0xFF,0x01,0xC0,
0x03,0xC0,0x03,0xC0,0x06,0xC0,0x0C,0xC0,0x18,0xC3,0x30,0xC3,0xE0,0x7F,0x00,0x00},/*"无",7*/
{
0x00,0x00,0xFF,0xFC,0xDB,0x0C,0xDB,0xFC,0xF3,0x0C,0xF3,0x0C,0xDB,0xFC,0xCF,0xC0,
0xCF,0x6C,0xFF,0x78,0xDB,0x30,0xC3,0x30,0xC3,0x18,0xC3,0xCF,0xC3,0x86,0xC3,0x00},/*"限",8*/
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,
0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x00,0x00},/*"!",9*/
{
0x01,0x80,0x01,0x80,0x01,0xFC,0x01,0x80,0x01,0x98,0x1F,0xFC,0x18,0x18,0x18,0x18,
0x18,0x18,0x1F,0xF8,0x18,0x18,0x01,0x98,0x3C,0xCC,0x36,0x66,0x66,0x66,0x00,0x00},/*"点",10*/
{
0x00,0xC0,0xFC,0xC0,0xCC,0xC0,0xDF,0xFE,0xF1,0x80,0xD9,0xE0,0xCF,0x60,0xCF,0xFE,
0xCC,0x60,0xFC,0x60,0xDF,0xFF,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60},/*"阵",11*/
{
0x3F,0xFE,0x30,0x06,0x30,0x06,0x3F,0xFE,0x36,0x18,0x33,0x30,0x3F,0xFE,0x33,0x30,
0x33,0x30,0x3F,0xFF,0x33,0x30,0x33,0x30,0x66,0x30,0x66,0x30,0xCC,0x30,0x18,0x30},/*"屏",12*/
{
0x60,0xC0,0x30,0x60,0x3F,0xFF,0x01,0xB0,0xC3,0x1C,0x66,0xCC,0x79,0xB0,0x1B,0xF8,
0x18,0xD8,0x31,0xCC,0x33,0x78,0xF7,0x30,0x3F,0x18,0x33,0xCC,0x33,0x8F,0x33,0x06},/*"滚",13*/
{
0x00,0x30,0x00,0x30,0x7F,0x30,0x00,0x30,0x00,0xFE,0xFF,0xB6,0x18,0x36,0x18,0x36,
0x36,0x36,0x33,0x36,0x6F,0xE6,0xFF,0x66,0x60,0xC6,0x01,0x9E,0x03,0x0C,0x00,0x00},/*"动",14*/
{
0x00,0x00,0x1F,0xF8,0x18,0x18,0x1F,0xF8,0x18,0x18,0x1F,0xF8,0x06,0x60,0x06,0x60,
0x66,0x6C,0x36,0x6C,0x1E,0x78,0x1E,0x70,0x06,0x60,0xFF,0xFF,0x00,0x00,0x00,0x00},/*"显",15*/
{
0x00,0x00,0x1F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x01,0x80,0x01,0x80,
0x19,0xB0,0x19,0x98,0x31,0x8C,0x61,0x8E,0xC1,0x86,0x01,0x80,0x07,0x80,0x03,0x00},/*"示",16*/
{
0x01,0x80,0x00,0xC0,0x3F,0xFF,0x3C,0x06,0x67,0xCC,0x06,0xC0,0x0C,0xC0,0x07,0xC0,
0x06,0xC0,0x7F,0xFF,0x00,0xC0,0x01,0xE0,0x03,0x30,0x06,0x18,0x1C,0x1C,0x70,0x18},/*"实",17*/
{
0x00,0x00,0xFC,0x60,0x0C,0x60,0x6C,0xF0,0x6C,0xD8,0x6D,0x8F,0x6F,0xF8,0x7E,0x00,
0x06,0xC6,0x07,0x66,0x3F,0xEC,0xE7,0xEC,0x06,0x18,0x1F,0xFF,0x0C,0x00,0x00,0x00},/*"验",18*/
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x86,
0x60,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"~",19*/
};

unsigned char dz_buf1[16][2];

int main(void)
{      
         unsigned int index=0,i=0;


     ZNX_Board_Init(); //ZN-X开发板的板级初始化  

         delay_init();              //延时函数初始化      
         uart_init(38400);

         printf("******************************* \r\n");
         printf("This is LedMatrix Rolling Test  \r\n");
         printf("******************************* \r\n");

     DZ_Init();  //初始化点阵,启动点阵动态扫描

         while(1)
         {
                  DZ_Make_Rolling_Data(dz_buf1,hz_code[index],i++);

                  DZ_UpdateBuffer((unsigned char *)dz_buf1); //将汉字的字模数据更新到显示缓冲数组中

                  if(i==16) {i=0;index++;index%=20;}

                  delay_ms(30);
         }
}
注:有很多人询问程序中的汉字字模数据是如何获取的,其实很简单,是使用PCtoLCD软件获取的。这在视频教程中,以及振南的书中都有详细的说明。
书电子版的下载:http://www.znmcu.cn/znfat_support.html 中的第十章!
实验效果(在线视频演示):
  
实验代码下载:


相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:振南的znFAT -- 单片机上上的FAT32文件系统 www.znmcu.cn

4474

主题

5195

帖子

33

粉丝