arm的lcd屏保動圓
阿新 • • 發佈:2019-01-27
#include "stdio.h" #include "s5pv210.h" unsigned int *fbuf = (unsigned int *)0x42000000; void lcd_PortInit() { rGPF0CON = 0x22222222; rGPF1CON = 0x22222222; rGPF2CON = 0x22222222; rGPF3CON = 0x22222222; } void lcd_Init() { //VIDCON0[0:1]=3;[2]=0;[4]=1;[6:13]=4;[26:28]=000 rVIDCON0 &=0xffffffff; rVIDCON0 |=(0x13<<0); rVIDCON0 |=(4<<6); //VIDCON1[5:6]=3; rVIDCON1 |=(3<<5); //VIDTCON0[0:7]=19;[8:15]=21;[16:23]=2; rVIDTCON0 |=(19<<0); rVIDTCON0 |=(21<<8); rVIDTCON0 |=(2<<16); //VIDTCON1[0:7]=;[8:15]=;[16:23]=; rVIDTCON1 |=(39<<0); rVIDTCON1 |=(0xd1<<8); rVIDTCON1 |=(5<<16); //VIDTCON2[0:10] = 799;[11:21]=479; rVIDTCON2 |=(799<<0); rVIDTCON2 |=(479<<11); //WINCON0[0]=1;[2:5]=0xb;[15]=1; rWINCON0 |=1; rWINCON0 |=(0xb<<2); rWINCON0 |=(1<<15); //SHADOWCON[0]=1; rSHADOWCON |=1; //VIDOSD0A[0:10]=0;[11:21]=0; rVIDOSD0A &=0; //VIDOSD0B[0:10]=479;[11:21]=799; rVIDOSD0B |=(479<<0); rVIDOSD0B |=(799<<11); //VIDOSD0C [23:0]=800*480; rVIDOSD0C |=(800*480); //VIDW00ADD0B0[31:0] = 0X42000000 rVIDW00ADD0B0=0x42000000; //VIDW00ADD1B0[31:0] = 0X42000000 + 800*480*4 rVIDW00ADD1B0=(0x42000000 + 800*480*4); //VIDW00ADD2[0:12]=800;[13:25]=0 rVIDW00ADD2 &=0; rVIDW00ADD2 |=800; //DISPLAY_CONTROL[1:0]= 2 rDISPLAY_CONTROL |=2; } //circle void circle(const unsigned int a,const unsigned int b){ int x,y,s,s1; for(y = 0;y < 480 ;y++) { for(x = 0;x < 800; x++) { s=(a-x)*(a-x)+(b-y)*(b-y); s1=(a-x)*(a-x)+(b-y)*(b-y); if (s<=28*28&&s1>16*16) { *(fbuf + (800*y + x)) = 0xf; }else{ *(fbuf + (800*y + x)) = 0xffffffff; } } } } void move_r(int a,int b){//不要用char 會加到255就會停 int border=1;//1->rdown;2->ldown;3->rup;4->lup //移動時不需要延時,因為在畫圓時就有很多迴圈暫用時間了 if (a>27&&a<773&&b>27&&b<453)//判斷傳參的正確性 { circle(a,b); while(1){//迴圈判斷方向以及有沒到達邊 while(border==1){ if (a==772) { border=2; } else if (b==452) { border=3; } else { a++;b++; circle(a,b); } } while(border==2){ if (a==28) { border=1; } else if (b==452) { border=4; } else { a--;b++; circle(a,b); } } while(border==4){ if (a==28) { border=3; } else if (b==28) { border=2; } else { a--;b--; circle(a,b); } } while(border==3){ if (a==772) { border=4; } if (b==28) { border=1; } else { a++;b--; circle(a,b); } } } } } int fimd_lcd() { lcd_PortInit(); lcd_Init(); move_r(28,28); //move_r(18,18);加上可能會產生一定的小動畫效果 //while(1); return 0; }