change MFPR version to 2.4.2 to fix install script fail
[proxmark3.git] / armsrc / example_lcd.c
bloba2267ba997f9b3e999df46f1beb66a9c6536b0d4
1 unsigned char somestring[25];
3 //*********************************************************************
4 //******************** SYSTERM HEARTBEAT @ 10 ms *********************
5 //*********************************************************************
6 void InitSPI (void)
8 //set functionalite to pins:
9 //port0.11 -> NPCS0
10 //port0.12 -> MISO
11 //port0.13 -> MOSI
12 //port0.14 -> SPCK
13 PIOA_PDR = BIT11 | BIT12 | BIT13 | BIT14;
14 PIOA_ASR = BIT11 | BIT12 | BIT13 | BIT14;
15 PIOA_BSR = 0;
18 PMC_PCER |= 1 << 5; // Enable SPI timer clock.
20 /**** Fixed mode ****/
21 SPI_CR = 0x81; //SPI Enable, Sowtware reset
22 SPI_CR = 0x01; //SPI Enable
26 SPI_MR = 0x000E0011; //Master mode
27 SPI_CSR0 = 0x01010B11; //9 bit
31 //*********************************************************************
32 //*************************** Task 1 ********************************
33 //*********************************************************************
34 void Task_1(void *p)
36 char beat=0; // just flash the onboard LED for Heatbeat
38 while(1)
40 if(beat)
42 PIOA_SODR = BIT18;
43 beat=0;
45 else
47 PIOA_CODR = BIT18;
48 beat=1;
51 ctl_timeout_wait(ctl_get_current_time()+ 150);
55 //*********************************************************************
56 //*************************** Task 2 ********************************
57 //*********************************************************************
58 void Task_2(void *p)
60 unsigned long z;
61 unsigned int x,y;
62 unsigned char a,b,c,d,e;
64 char seconds,minutes,hours;
66 unsigned int nowold,tenths;
69 InitLCD();
72 /******* Put smiley face up in 4096 color mode *******/
73 LCD_Fill(0,0,132,132,Black);
75 LCD_Set_Resolution(HIGH_RES); // set 4096 color mode
77 // ShowImage_4096(0,0,smiley);
78 LCD_Set_Resolution(LOW_RES); // set 256 color mode
80 ctl_timeout_wait(ctl_get_current_time()+ 4000); // wait 4 seconds to view it
82 /******* Do some static on screen *******/
84 LCD_Fill(0,0,132,132,Black);
86 for(z=0;z<100000;z++)
88 while( (a = rand()) > 132);
89 while( (b = rand()) > 132);
90 c = rand();
91 LCD_PixelPut(a,b,c);
94 /******* Do some lines on screen *******/
95 LCD_Fill(0,0,132,132,Black);
97 for(z=1;z<300;z++)
99 while( (a = rand()) > 132);
100 while( (b = rand()) > 132);
101 while( (c = rand()) > 132);
102 while( (d = rand()) > 132);
103 e = rand(); // pick color
105 LCD_Line(a,b,c,d,e);
106 ctl_timeout_wait(ctl_get_current_time()+ 10);
109 /******* Do some Boxes on screen *******/
110 LCD_Fill(0,0,132,132,Black);
112 for(z=0;z<300;z++)
115 while( (a = rand()) > 132);
116 while( (b = rand()) > 132);
117 while( (c = rand()) > 132);
118 while( (d = rand()) > 132);
120 e = rand(); // pick color
121 LCD_Box(a,b,c,d,e);
123 ctl_timeout_wait(ctl_get_current_time()+ 10);
125 /******* Do some Circles on screen *******/
126 LCD_Fill(0,0,132,132,Black);
128 for(z=0;z<100;z++)
131 while( (a = rand()) > 132);
132 while( (b = rand()) > 132);
133 while( (c = rand()) > 127); // diameter
135 d = rand(); // pick color
136 LCD_Circle(a,b,c,d);
138 ctl_timeout_wait(ctl_get_current_time()+ 10);
141 /******* Do some Thick Circles on screen *******/
142 LCD_Fill(0,0,132,132,Black);
144 for(z=0;z<25;z++)
146 while( (a = rand()) > 132);
147 while( (b = rand()) > 132);
148 while( (c = rand()) > 40); // diameter
149 while( (d = rand()) > 10); // wall thicknes
150 e = rand(); // pick color
151 LCD_Thick_Circle(a,b,c,d,e);
153 ctl_timeout_wait(ctl_get_current_time()+ 1);
156 /******* Do something funky to wipe screen *******/
157 b=0;
159 for(a=0;a<131;a++)
161 LCD_Line(a,b,65,65,0x62);
163 for(b=0;b<131;b++)
165 LCD_Line(a,b,65,65,0x62);
167 for(;a>1;a--)
169 LCD_Line(a,b,65,65,0x62);
171 for(;b>1;b--)
173 LCD_Line(a,b,65,65,0x62);
176 ctl_timeout_wait(ctl_get_current_time()+ 1000);
178 /******* Show Image scrolling *******/
179 LCD_Fill(0,0,132,132,Black);
181 ShowImage(0,50,sparkfun);
183 sprintf(somestring,"Thanks SparkFun");
184 LCD_String(somestring,&FONT8x8F[0][0],5,10,LightGreen,Black);
186 ctl_timeout_wait(ctl_get_current_time()+ 2000); // hold sparkfun image for a bit
188 for(y=50;y<140;y++)
190 LCD_Line(0,y-1,132,y-1,Black); // wipe the white line as it moves down
191 ShowImage(0,y,sparkfun); // move image to Y location
192 ctl_timeout_wait(ctl_get_current_time()+ 25); // wait a bit
195 /******* Run radar in loop with example fonts displayed *******/
196 LCD_Fill(0,0,132,132,Black);
198 LCD_Thick_Circle(66,66,30,2,DarkBlue);
200 y=0;
202 while (1)
204 LCD_Circle_Line(66,66,28,0,y,LightGreen);
206 ctl_timeout_wait(ctl_get_current_time()+ 1);
208 tenths = ctl_current_time / 1000;
210 if(tenths != nowold)
212 nowold = tenths;
214 if(++seconds == 60)
216 seconds = 0;
218 if(++minutes == 60)
220 minutes=0;
221 hours++;
227 printf("a=%6lu - b=%6lu - c=%6lu - d=%6lu : Time=%lu\r\n",a,b,c,d,ctl_current_time);
229 sprintf(somestring,"%05lu",y);
230 LCD_String(somestring,&FONT6x8[0][0],52,25,White,Black);
232 sprintf(somestring,"Time:%02u:%02u:%02u",hours,minutes,seconds);
233 LCD_String(somestring,&FONT8x8F[0][0],14,10,DarkRed,Black);
235 sprintf(somestring,"Time:%02u:%02u:%02u",hours,minutes,seconds);
236 LCD_String(somestring,&FONT8x16[0][0],14,115,LightGreen,Black);
238 LCD_Circle_Line(66,66,28,0,y,Black);
240 if(++y==360)
242 y=0;
245 ctl_timeout_wait(ctl_get_current_time()+ 10);
250 /*************************************************************************
251 ********************* Main Module *************************
252 ********************* *************************
253 ********************* Initialize Program *************************
254 ********************* Sequences *************************
255 ********************* *************************
256 *************************************************************************/
257 int main(void)
259 BoardInit();
261 InitSPI();
263 while (1)
265 Idle();
268 return 0;