]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/LCD.c
1 //-----------------------------------------------------------------------------
2 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
3 // at your option, any later version. See the LICENSE.txt file for the text of
5 //-----------------------------------------------------------------------------
7 //-----------------------------------------------------------------------------
10 void LCDSend(unsigned int data
)
12 // 9th bit set for data, clear for command
13 while ((AT91C_BASE_SPI
->SPI_SR
& AT91C_SPI_TXEMPTY
) == 0); // wait for the transfer to complete
14 // For clarity's sake we pass data with 9th bit clear and commands with 9th
15 // bit set since they're implemented as defines, se we need to invert bit
16 AT91C_BASE_SPI
->SPI_TDR
= data
^0x100; // Send the data/command
19 void LCDSetXY(unsigned char x
, unsigned char y
)
21 LCDSend(PPASET
); // page start/end ram
22 LCDSend(y
); // Start Page to display to
23 LCDSend(131); // End Page to display to
25 LCDSend(PCASET
); // column start/end ram
26 LCDSend(x
); // Start Column to display to
27 LCDSend(131); // End Column to display to
30 void LCDSetPixel(unsigned char x
, unsigned char y
, unsigned char color
)
32 LCDSetXY(x
,y
); // Set position
33 LCDSend(PRAMWR
); // Now write the pixel to the display
34 LCDSend(color
); // Write the data in the specified Color
37 void LCDFill (unsigned char xs
,unsigned char ys
,unsigned char width
,unsigned char height
, unsigned char color
)
41 for (i
=0;i
< height
;i
++) // Number of horizontal lines
43 LCDSetXY(xs
,ys
+i
); // Goto start of fill area (Top Left)
44 LCDSend(PRAMWR
); // Write to display
46 for (j
=0;j
< width
;j
++) // pixels per line
51 void LCDString (char *lcd_string
, const char *font_style
,unsigned char x
, unsigned char y
, unsigned char fcolor
, unsigned char bcolor
)
54 unsigned char mask
=0, px
, py
, xme
, yme
, offset
;
57 data
= font_style
; // point to the start of the font table
59 xme
= *data
; // get font x width
61 yme
= *data
; // get font y length
63 offset
= *data
; // get data bytes per font
67 // point to data in table to be loaded
68 data
= (font_style
+ offset
) + (offset
* (int)(*lcd_string
- 32));
70 for (i
=0;i
< yme
;i
++) {
73 for (px
=x
; px
< (x
+ xme
); px
++) {
76 if (*data
& mask
) LCDSetPixel (px
,py
,fcolor
);
77 else LCDSetPixel (px
,py
,bcolor
);
85 lcd_string
++; // next character in string
87 } while(*lcd_string
!='\0'); // keep spitting chars out until end of string
93 SetupSpi(SPI_LCD_MODE
);
108 LCDSend(PSWRESET
); // software reset
110 LCDSend(PSLEEPOUT
); // exit sleep mode
111 LCDSend(PBSTRON
); // booster on
112 LCDSend(PDISPON
); // display on
113 LCDSend(PNORON
); // normal on
114 LCDSend(PMADCTL
); // rotate display 180 deg
117 LCDSend(PCOLMOD
); // color mode
118 LCDSend(0x02); // 8bpp color mode
120 LCDSend(PSETCON
); // set contrast
125 LCDSend(PRAMWR
); // Write to display
127 while(i
--) LCDSend(WHITE
);
129 // test text on different colored backgrounds
130 LCDString(" The quick brown fox ", (char *)&FONT6x8
,1,1+8*0,WHITE
,BLACK
);
131 LCDString(" jumped over the ", (char *)&FONT6x8
,1,1+8*1,BLACK
,WHITE
);
132 LCDString(" lazy dog. ", (char *)&FONT6x8
,1,1+8*2,YELLOW
,RED
);
133 LCDString(" AaBbCcDdEeFfGgHhIiJj ", (char *)&FONT6x8
,1,1+8*3,RED
,GREEN
);
134 LCDString(" KkLlMmNnOoPpQqRrSsTt ", (char *)&FONT6x8
,1,1+8*4,MAGENTA
,BLUE
);
135 LCDString("UuVvWwXxYyZz0123456789", (char *)&FONT6x8
,1,1+8*5,BLUE
,YELLOW
);
136 LCDString("`-=[]_;',./~!@#$%^&*()", (char *)&FONT6x8
,1,1+8*6,BLACK
,CYAN
);
137 LCDString(" _+{}|:\\\"<>? ",(char *)&FONT6x8
,1,1+8*7,BLUE
,MAGENTA
);
140 LCDFill(0, 1+8* 8, 132, 8, BLACK
);
141 LCDFill(0, 1+8* 9, 132, 8, WHITE
);
142 LCDFill(0, 1+8*10, 132, 8, RED
);
143 LCDFill(0, 1+8*11, 132, 8, GREEN
);
144 LCDFill(0, 1+8*12, 132, 8, BLUE
);
145 LCDFill(0, 1+8*13, 132, 8, YELLOW
);
146 LCDFill(0, 1+8*14, 132, 8, CYAN
);
147 LCDFill(0, 1+8*15, 132, 8, MAGENTA
);