]> git.zerfleddert.de Git - proxmark3-svn/blame - armsrc/LCD.c
replaced strncasecmp with strcmp to get rid of compile errors
[proxmark3-svn] / armsrc / LCD.c
CommitLineData
6658905f 1#include <proxmark3.h>\r
2#include "apps.h"\r
3#include "LCD.h"\r
4\r
5void LCDSend(unsigned int data)\r
6{\r
7 // 9th bit set for data, clear for command\r
6949aca9 8 while ((AT91C_BASE_SPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); // wait for the transfer to complete\r
6658905f 9 // For clarity's sake we pass data with 9th bit clear and commands with 9th\r
10 // bit set since they're implemented as defines, se we need to invert bit\r
6949aca9 11 AT91C_BASE_SPI->SPI_TDR = data^0x100; // Send the data/command\r
6658905f 12}\r
13\r
14void LCDSetXY(unsigned char x, unsigned char y)\r
15{\r
16 LCDSend(PPASET); // page start/end ram\r
17 LCDSend(y); // Start Page to display to\r
18 LCDSend(131); // End Page to display to\r
19\r
20 LCDSend(PCASET); // column start/end ram\r
21 LCDSend(x); // Start Column to display to\r
22 LCDSend(131); // End Column to display to\r
23}\r
24\r
25void LCDSetPixel(unsigned char x, unsigned char y, unsigned char color)\r
26{\r
27 LCDSetXY(x,y); // Set position\r
28 LCDSend(PRAMWR); // Now write the pixel to the display\r
29 LCDSend(color); // Write the data in the specified Color\r
30}\r
31\r
32void LCDFill (unsigned char xs,unsigned char ys,unsigned char width,unsigned char height, unsigned char color)\r
33{\r
34 unsigned char i,j;\r
35\r
36 for (i=0;i < height;i++) // Number of horizontal lines\r
37 {\r
38 LCDSetXY(xs,ys+i); // Goto start of fill area (Top Left)\r
39 LCDSend(PRAMWR); // Write to display\r
40\r
41 for (j=0;j < width;j++) // pixels per line\r
42 LCDSend(color);\r
43 }\r
44}\r
45\r
46void LCDString (char *lcd_string, const char *font_style,unsigned char x, unsigned char y, unsigned char fcolor, unsigned char bcolor)\r
47{\r
48 unsigned int i;\r
49 unsigned char mask=0, px, py, xme, yme, offset;\r
50 const char *data;\r
51\r
52 data = font_style; // point to the start of the font table\r
53\r
54 xme = *data; // get font x width\r
55 data++;\r
56 yme = *data; // get font y length\r
57 data++;\r
58 offset = *data; // get data bytes per font\r
59\r
60 do\r
61 {\r
62 // point to data in table to be loaded\r
63 data = (font_style + offset) + (offset * (int)(*lcd_string - 32));\r
64\r
65 for (i=0;i < yme;i++) {\r
66 mask |=0x80;\r
67\r
68 for (px=x; px < (x + xme); px++) {\r
69 py= y + i;\r
70\r
71 if (*data & mask) LCDSetPixel (px,py,fcolor);\r
72 else LCDSetPixel (px,py,bcolor);\r
73\r
74 mask>>=1;\r
75 }\r
76 data++;\r
77 }\r
78 x+=xme;\r
79\r
80 lcd_string++; // next character in string\r
81\r
82 } while(*lcd_string !='\0'); // keep spitting chars out until end of string\r
83}\r
84\r
85void LCDReset(void)\r
86{\r
87 LED_A_ON();\r
88 SetupSpi(SPI_LCD_MODE);\r
6949aca9 89 LOW(GPIO_LRST);\r
6658905f 90 SpinDelay(100);\r
91\r
6949aca9 92 HIGH(GPIO_LRST);\r
6658905f 93 SpinDelay(100);\r
94 LED_A_OFF();\r
95}\r
96\r
97void LCDInit(void)\r
98{\r
99 int i;\r
100\r
101 LCDReset();\r
102\r
103 LCDSend(PSWRESET); // software reset\r
104 SpinDelay(100);\r
105 LCDSend(PSLEEPOUT); // exit sleep mode\r
106 LCDSend(PBSTRON); // booster on\r
107 LCDSend(PDISPON); // display on\r
108 LCDSend(PNORON); // normal on\r
109 LCDSend(PMADCTL); // rotate display 180 deg\r
110 LCDSend(0xC0);\r
111\r
112 LCDSend(PCOLMOD); // color mode\r
113 LCDSend(0x02); // 8bpp color mode\r
114\r
115 LCDSend(PSETCON); // set contrast\r
116 LCDSend(0xDC);\r
117 \r
118 // clear display\r
119 LCDSetXY(0,0);\r
120 LCDSend(PRAMWR); // Write to display\r
121 i=LCD_XRES*LCD_YRES;\r
122 while(i--) LCDSend(WHITE);\r
123}\r
Impressum, Datenschutz