[mw_shl_code=c,true] while(RNG_Init()) //初始化随机数发生器
{
LCD_ShowString(30,130,200,16,16," RNG Error! ");
delay_ms(200);
LCD_ShowString(30,130,200,16,16,"RNG Trying...");
}
LCD_ShowString(30,130,200,16,16,"RNG Ready! ");
LCD_ShowString(30,150,200,16,16,"KEY0:Get Random Num");
LCD_ShowString(30,180,200,16,16,"Random Num:");
LCD_ShowString(30,200,200,16,16,"Random Num[5 Dgt]:");
LCD_ShowString(30,220,200,16,16,"Random Num[3 Dgt]:");
//LCD_ShowString(30,240,200,16,16,"Random Num[0-9]:");
POINT_COLOR=BLUE;
while(1)
{
delay_ms(10);
key=KEY_Scan(0);
/*if((t%20)==0)
{
LED1=!LED1; //每200ms,翻转一次LED0
random=RNG_Get_RandomRange(0,9);//获取[0,9]区间的随机数
LCD_ShowNum(30+8*16,240,random,1,16); //显示随机数
}*/
if(key==KEY0_PRES)
{
random=RNG_Get_RandomNum(); //获得随机数
seven=random%10000000;
five=seven/100;
three=five/100;
LCD_ShowNum(30+8*11,180,seven,7,16); //显示后7位随机数
LCD_ShowNum(30+8*18,200,five,5,16); //显示前5位随机数
LCD_ShowNum(30+8*18,220,three,3,16); //显示前3位随机数
}
delay_ms(10);
//t++;
}
}
[/mw_shl_code]
小白刚刚入stmf4坑不久,当前学习例程16.图上代码系部分main.c的修改版(从line31开始,其实就改了几句话)。打算做成一个能够同时生成排列3,排列5和7星彩的简易彩票机选器。但是当生成数的首位数为0的时候,前面的0显示不到tftlcd上……
---------------------------------
怎样改?
一周热门 更多>