]> cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/example_lcd.c
Trying automagic version stuff
[proxmark3-svn] / armsrc / example_lcd.c
1 unsigned char somestring[25];
2
3 //*********************************************************************
4 //******************** SYSTERM HEARTBEAT @ 10 ms *********************
5 //*********************************************************************
6 void InitSPI (void)
7 {
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;
16
17
18 PMC_PCER |= 1 << 5; // Enable SPI timer clock.
19
20 /**** Fixed mode ****/
21 SPI_CR = 0x81; //SPI Enable, Sowtware reset
22 SPI_CR = 0x01; //SPI Enable
23
24
25
26 SPI_MR = 0x000E0011; //Master mode
27 SPI_CSR0 = 0x01010B11; //9 bit
28
29 }
30
31 //*********************************************************************
32 //*************************** Task 1 ********************************
33 //*********************************************************************
34 void Task_1(void *p)
35 {
36 char beat=0; // just flash the onboard LED for Heatbeat
37
38 while(1)
39 {
40 if(beat)
41 {
42 PIOA_SODR = BIT18;
43 beat=0;
44 }
45 else
46 {
47 PIOA_CODR = BIT18;
48 beat=1;
49 }
50
51 ctl_timeout_wait(ctl_get_current_time()+ 150);
52
53 }
54 }
55 //*********************************************************************
56 //*************************** Task 2 ********************************
57 //*********************************************************************
58 void Task_2(void *p)
59 {
60 unsigned long z;
61 unsigned int x,y;
62 unsigned char a,b,c,d,e;
63
64 char seconds,minutes,hours;
65
66 unsigned int nowold,tenths;
67
68
69 InitLCD();
70
71
72 /******* Put smiley face up in 4096 color mode *******/
73 LCD_Fill(0,0,132,132,Black);
74
75 LCD_Set_Resolution(HIGH_RES); // set 4096 color mode
76
77 // ShowImage_4096(0,0,smiley);
78 LCD_Set_Resolution(LOW_RES); // set 256 color mode
79
80 ctl_timeout_wait(ctl_get_current_time()+ 4000); // wait 4 seconds to view it
81
82 /******* Do some static on screen *******/
83
84 LCD_Fill(0,0,132,132,Black);
85
86 for(z=0;z<100000;z++)
87 {
88 while( (a = rand()) > 132);
89 while( (b = rand()) > 132);
90 c = rand();
91 LCD_PixelPut(a,b,c);
92 }
93
94 /******* Do some lines on screen *******/
95 LCD_Fill(0,0,132,132,Black);
96
97 for(z=1;z<300;z++)
98 {
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
104
105 LCD_Line(a,b,c,d,e);
106 ctl_timeout_wait(ctl_get_current_time()+ 10);
107 }
108
109 /******* Do some Boxes on screen *******/
110 LCD_Fill(0,0,132,132,Black);
111
112 for(z=0;z<300;z++)
113 {
114
115 while( (a = rand()) > 132);
116 while( (b = rand()) > 132);
117 while( (c = rand()) > 132);
118 while( (d = rand()) > 132);
119
120 e = rand(); // pick color
121 LCD_Box(a,b,c,d,e);
122
123 ctl_timeout_wait(ctl_get_current_time()+ 10);
124 }
125 /******* Do some Circles on screen *******/
126 LCD_Fill(0,0,132,132,Black);
127
128 for(z=0;z<100;z++)
129 {
130
131 while( (a = rand()) > 132);
132 while( (b = rand()) > 132);
133 while( (c = rand()) > 127); // diameter
134
135 d = rand(); // pick color
136 LCD_Circle(a,b,c,d);
137
138 ctl_timeout_wait(ctl_get_current_time()+ 10);
139 }
140
141 /******* Do some Thick Circles on screen *******/
142 LCD_Fill(0,0,132,132,Black);
143
144 for(z=0;z<25;z++)
145 {
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);
152
153 ctl_timeout_wait(ctl_get_current_time()+ 1);
154 }
155
156 /******* Do something funky to wipe screen *******/
157 b=0;
158
159 for(a=0;a<131;a++)
160 {
161 LCD_Line(a,b,65,65,0x62);
162 }
163 for(b=0;b<131;b++)
164 {
165 LCD_Line(a,b,65,65,0x62);
166 }
167 for(;a>1;a--)
168 {
169 LCD_Line(a,b,65,65,0x62);
170 }
171 for(;b>1;b--)
172 {
173 LCD_Line(a,b,65,65,0x62);
174 }
175
176 ctl_timeout_wait(ctl_get_current_time()+ 1000);
177
178 /******* Show Image scrolling *******/
179 LCD_Fill(0,0,132,132,Black);
180
181 ShowImage(0,50,sparkfun);
182
183 sprintf(somestring,"Thanks SparkFun");
184 LCD_String(somestring,&FONT8x8F[0][0],5,10,LightGreen,Black);
185
186 ctl_timeout_wait(ctl_get_current_time()+ 2000); // hold sparkfun image for a bit
187
188 for(y=50;y<140;y++)
189 {
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
193 }
194
195 /******* Run radar in loop with example fonts displayed *******/
196 LCD_Fill(0,0,132,132,Black);
197
198 LCD_Thick_Circle(66,66,30,2,DarkBlue);
199
200 y=0;
201
202 while (1)
203 {
204 LCD_Circle_Line(66,66,28,0,y,LightGreen);
205
206 ctl_timeout_wait(ctl_get_current_time()+ 1);
207
208 tenths = ctl_current_time / 1000;
209
210 if(tenths != nowold)
211 {
212 nowold = tenths;
213
214 if(++seconds == 60)
215 {
216 seconds = 0;
217
218 if(++minutes == 60)
219 {
220 minutes=0;
221 hours++;
222 }
223 }
224 }
225
226
227 printf("a=%6lu - b=%6lu - c=%6lu - d=%6lu : Time=%lu\r\n",a,b,c,d,ctl_current_time);
228
229 sprintf(somestring,"%05lu",y);
230 LCD_String(somestring,&FONT6x8[0][0],52,25,White,Black);
231
232 sprintf(somestring,"Time:%02u:%02u:%02u",hours,minutes,seconds);
233 LCD_String(somestring,&FONT8x8F[0][0],14,10,DarkRed,Black);
234
235 sprintf(somestring,"Time:%02u:%02u:%02u",hours,minutes,seconds);
236 LCD_String(somestring,&FONT8x16[0][0],14,115,LightGreen,Black);
237
238 LCD_Circle_Line(66,66,28,0,y,Black);
239
240 if(++y==360)
241 {
242 y=0;
243 }
244
245 ctl_timeout_wait(ctl_get_current_time()+ 10);
246
247 }
248 }
249
250 /*************************************************************************
251 ********************* Main Module *************************
252 ********************* *************************
253 ********************* Initialize Program *************************
254 ********************* Sequences *************************
255 ********************* *************************
256 *************************************************************************/
257 int main(void)
258 {
259 BoardInit();
260
261 InitSPI();
262
263 while (1)
264 {
265 Idle();
266 }
267
268 return 0;
269 }
Impressum, Datenschutz