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