]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/LCD.c
f37aa894401dda7021b5fc99bfd4412806962b6a
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 //-----------------------------------------------------------------------------
13 void LCDSend(unsigned int data
)
15 // 9th bit set for data, clear for command
16 while ((AT91C_BASE_SPI
->SPI_SR
& AT91C_SPI_TXEMPTY
) == 0); // wait for the transfer to complete
17 // For clarity's sake we pass data with 9th bit clear and commands with 9th
18 // bit set since they're implemented as defines, se we need to invert bit
19 AT91C_BASE_SPI
->SPI_TDR
= data
^0x100; // Send the data/command
22 void LCDSetXY(unsigned char x
, unsigned char y
)
24 LCDSend(PPASET
); // page start/end ram
25 LCDSend(y
); // Start Page to display to
26 LCDSend(131); // End Page to display to
28 LCDSend(PCASET
); // column start/end ram
29 LCDSend(x
); // Start Column to display to
30 LCDSend(131); // End Column to display to
33 void LCDSetPixel(unsigned char x
, unsigned char y
, unsigned char color
)
35 LCDSetXY(x
,y
); // Set position
36 LCDSend(PRAMWR
); // Now write the pixel to the display
37 LCDSend(color
); // Write the data in the specified Color
40 void LCDFill (unsigned char xs
,unsigned char ys
,unsigned char width
,unsigned char height
, unsigned char color
)
44 for (i
=0;i
< height
;i
++) // Number of horizontal lines
46 LCDSetXY(xs
,ys
+i
); // Goto start of fill area (Top Left)
47 LCDSend(PRAMWR
); // Write to display
49 for (j
=0;j
< width
;j
++) // pixels per line
54 void LCDString (char *lcd_string
, const char *font_style
,unsigned char x
, unsigned char y
, unsigned char fcolor
, unsigned char bcolor
)
57 unsigned char mask
=0, px
, py
, xme
, yme
, offset
;
60 data
= font_style
; // point to the start of the font table
62 xme
= *data
; // get font x width
64 yme
= *data
; // get font y length
66 offset
= *data
; // get data bytes per font
70 // point to data in table to be loaded
71 data
= (font_style
+ offset
) + (offset
* (int)(*lcd_string
- 32));
73 for (i
=0;i
< yme
;i
++) {
76 for (px
=x
; px
< (x
+ xme
); px
++) {
79 if (*data
& mask
) LCDSetPixel (px
,py
,fcolor
);
80 else LCDSetPixel (px
,py
,bcolor
);
88 lcd_string
++; // next character in string
90 } while(*lcd_string
!='\0'); // keep spitting chars out until end of string
96 SetupSpi(SPI_LCD_MODE
);
111 LCDSend(PSWRESET
); // software reset
113 LCDSend(PSLEEPOUT
); // exit sleep mode
114 LCDSend(PBSTRON
); // booster on
115 LCDSend(PDISPON
); // display on
116 LCDSend(PNORON
); // normal on
117 LCDSend(PMADCTL
); // rotate display 180 deg
120 LCDSend(PCOLMOD
); // color mode
121 LCDSend(0x02); // 8bpp color mode
123 LCDSend(PSETCON
); // set contrast
128 LCDSend(PRAMWR
); // Write to display
130 while(i
--) LCDSend(WHITE
);