]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/LCD.c
02c2f69624ae405ebc94d26805538c6dceef821b
5 void LCDSend(unsigned int data
)
7 // 9th bit set for data, clear for command
8 while ((SPI_STATUS
& SPI_STATUS_TX_EMPTY
) == 0); // wait for the transfer to complete
9 // For clarity's sake we pass data with 9th bit clear and commands with 9th
10 // bit set since they're implemented as defines, se we need to invert bit
11 SPI_TX_DATA
= data
^0x100; // Send the data/command
14 void LCDSetXY(unsigned char x
, unsigned char y
)
16 LCDSend(PPASET
); // page start/end ram
17 LCDSend(y
); // Start Page to display to
18 LCDSend(131); // End Page to display to
20 LCDSend(PCASET
); // column start/end ram
21 LCDSend(x
); // Start Column to display to
22 LCDSend(131); // End Column to display to
25 void LCDSetPixel(unsigned char x
, unsigned char y
, unsigned char color
)
27 LCDSetXY(x
,y
); // Set position
28 LCDSend(PRAMWR
); // Now write the pixel to the display
29 LCDSend(color
); // Write the data in the specified Color
32 void LCDFill (unsigned char xs
,unsigned char ys
,unsigned char width
,unsigned char height
, unsigned char color
)
36 for (i
=0;i
< height
;i
++) // Number of horizontal lines
38 LCDSetXY(xs
,ys
+i
); // Goto start of fill area (Top Left)
39 LCDSend(PRAMWR
); // Write to display
41 for (j
=0;j
< width
;j
++) // pixels per line
46 void LCDString (char *lcd_string
, const char *font_style
,unsigned char x
, unsigned char y
, unsigned char fcolor
, unsigned char bcolor
)
49 unsigned char mask
=0, px
, py
, xme
, yme
, offset
;
52 data
= font_style
; // point to the start of the font table
54 xme
= *data
; // get font x width
56 yme
= *data
; // get font y length
58 offset
= *data
; // get data bytes per font
62 // point to data in table to be loaded
63 data
= (font_style
+ offset
) + (offset
* (int)(*lcd_string
- 32));
65 for (i
=0;i
< yme
;i
++) {
68 for (px
=x
; px
< (x
+ xme
); px
++) {
71 if (*data
& mask
) LCDSetPixel (px
,py
,fcolor
);
72 else LCDSetPixel (px
,py
,bcolor
);
80 lcd_string
++; // next character in string
82 } while(*lcd_string
!='\0'); // keep spitting chars out until end of string
88 SetupSpi(SPI_LCD_MODE
);
103 LCDSend(PSWRESET
); // software reset
105 LCDSend(PSLEEPOUT
); // exit sleep mode
106 LCDSend(PBSTRON
); // booster on
107 LCDSend(PDISPON
); // display on
108 LCDSend(PNORON
); // normal on
109 LCDSend(PMADCTL
); // rotate display 180 deg
112 LCDSend(PCOLMOD
); // color mode
113 LCDSend(0x02); // 8bpp color mode
115 LCDSend(PSETCON
); // set contrast
120 LCDSend(PRAMWR
); // Write to display
122 while(i
--) LCDSend(WHITE
);