说明:本帖程序通过移植
http://blog.csdn.net/flx413/article/details/52014008 实现
linux有个cmatrix可以实现数字雨的效果,满满的黑客帝国既视感,我的开发板是阿波罗F7,7寸屏幕。但是通过修改一点点代码可以实现任意原子开发板移植。
首先在带屏幕驱动的工程里,加入下面头文件
[mw_shl_code=applescript,true]#include "stdlib.h"
#include "time.h"
#include "stdio.h"[/mw_shl_code]
[mw_shl_code=applescript,true]#define SCREEN_WIDTH 400
#define SCREEN_HEIGHT 600
#define DEF_RAIN_NUM 70 [/mw_shl_code]
SCREEN_WIDTH 和 SCREEN_HEIGHT 个人感觉改变的是数字雨密集程度,大家可以自己改改看
DEF_RAIN_NUM 是雨的列数,
如果下载到开发板,屏幕不滚动,需要把这个值改小
下面就是大段的复制粘贴
[mw_shl_code=applescript,true]int g_nRainPos[DEF_RAIN_NUM] = { 0 };
char g_strRain[DEF_RAIN_NUM][10] = { 0 };
char CreateRandomNum()
{
char nRandomNum = 0;
while( 1 )
{
nRandomNum = rand() % 123;
if( ( nRandomNum >= 65 && nRandomNum <= 90 ) || nRandomNum >= 97 )
{
return nRandomNum;
}
}
}
void InitPos()
{
int i = 0;
for( i = 0; i < DEF_RAIN_NUM; i++ )
{
g_nRainPos
= rand() % SCREEN_HEIGHT;
}
}
void InitNumRain()
{
int i = 0,j = 0;
for( i = 0; i < DEF_RAIN_NUM; i++ )
{
for( j = 0; j < 10; j++ )
{
g_strRain[j] = CreateRandomNum();
}
}
}
void ShowNumRain()
{
int i = 0,j = 0;
for( i = 0; i < DEF_RAIN_NUM; i++ )
{
POINT_COLOR=WHITE;
for( j = 0; j < 10; j++ )
{
LCD_ShowChar(i * 15,g_nRainPos - 15 * j,g_strRain[j],16,1);
POINT_COLOR=GREEN;
}
}
for( i = 0; i < DEF_RAIN_NUM; i++ )
{
g_nRainPos += 15;
}
for( i = 0; i < DEF_RAIN_NUM; i++ )
{
if( g_nRainPos - 10 * 15 >= SCREEN_HEIGHT )
{
g_nRainPos = 0;
}
}
}[/mw_shl_code]
main函数的while(1)
[mw_shl_code=applescript,true]InitNumRain();
LCD_Clear(BLACK);
ShowNumRain();
delay_ms(50);[/mw_shl_code]
一周热门 更多>