Merge branch 'master' of github.com:RfidResearchGroup/proxmark3
[RRG-proxmark3.git] / armsrc / LCD_disabled.c
blob97bf6da713c4c07c3902ac955b5249646ab91f0e
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
4 // the license.
5 //-----------------------------------------------------------------------------
6 // LCD code
7 //-----------------------------------------------------------------------------
8 #include "LCD_disabled.h"
10 void LCDSend(unsigned int data) {
11 // 9th bit set for data, clear for command
12 while ((AT91C_BASE_SPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); // wait for the transfer to complete
13 // For clarity's sake we pass data with 9th bit clear and commands with 9th
14 // bit set since they're implemented as defines, se we need to invert bit
15 AT91C_BASE_SPI->SPI_TDR = data ^ 0x100; // Send the data/command
18 void LCDSetXY(unsigned char x, unsigned char y) {
19 LCDSend(PPASET); // page start/end ram
20 LCDSend(y); // Start Page to display to
21 LCDSend(131); // End Page to display to
23 LCDSend(PCASET); // column start/end ram
24 LCDSend(x); // Start Column to display to
25 LCDSend(131); // End Column to display to
28 void LCDSetPixel(unsigned char x, unsigned char y, unsigned char color) {
29 LCDSetXY(x, y); // Set position
30 LCDSend(PRAMWR); // Now write the pixel to the display
31 LCDSend(color); // Write the data in the specified Color
34 void LCDFill(unsigned char xs, unsigned char ys, unsigned char width, unsigned char height, unsigned char color) {
35 unsigned char i, j;
37 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
42 LCDSend(color);
46 void LCDString(char *lcd_string, const char *font_style, unsigned char x, unsigned char y, unsigned char fcolor, unsigned char bcolor) {
47 unsigned int i;
48 unsigned char mask = 0, px, py, xme, yme, offset;
49 const char *data;
51 data = font_style; // point to the start of the font table
53 xme = *data; // get font x width
54 data++;
55 yme = *data; // get font y length
56 data++;
57 offset = *data; // get data bytes per font
59 do {
60 // point to data in table to be loaded
61 data = (font_style + offset) + (offset * (int)(*lcd_string - 32));
63 for (i = 0; i < yme; i++) {
64 mask |= 0x80;
66 for (px = x; px < (x + xme); px++) {
67 py = y + i;
69 if (*data & mask) LCDSetPixel(px, py, fcolor);
70 else LCDSetPixel(px, py, bcolor);
72 mask >>= 1;
74 data++;
76 x += xme;
78 lcd_string++; // next character in string
80 } while (*lcd_string != '\0'); // keep spitting chars out until end of string
83 void LCDReset(void) {
84 LED_A_ON();
85 SetupSpi(SPI_LCD_MODE);
86 LOW(GPIO_LRST);
87 SpinDelay(100);
89 HIGH(GPIO_LRST);
90 SpinDelay(100);
91 LED_A_OFF();
94 void LCDInit(void) {
95 int i;
97 LCDReset();
99 LCDSend(PSWRESET); // software reset
100 SpinDelay(100);
101 LCDSend(PSLEEPOUT); // exit sleep mode
102 LCDSend(PBSTRON); // booster on
103 LCDSend(PDISPON); // display on
104 LCDSend(PNORON); // normal on
105 LCDSend(PMADCTL); // rotate display 180 deg
106 LCDSend(0xC0);
108 LCDSend(PCOLMOD); // color mode
109 LCDSend(0x02); // 8bpp color mode
111 LCDSend(PSETCON); // set contrast
112 LCDSend(0xDC);
114 // clear display
115 LCDSetXY(0, 0);
116 LCDSend(PRAMWR); // Write to display
117 i = LCD_XRES * LCD_YRES;
118 while (i--) LCDSend(WHITE);
120 // test text on different colored backgrounds
121 LCDString(" The quick brown fox ", (char *)&FONT6x8, 1, 1 + 8 * 0, WHITE, BLACK);
122 LCDString(" jumped over the ", (char *)&FONT6x8, 1, 1 + 8 * 1, BLACK, WHITE);
123 LCDString(" lazy dog. ", (char *)&FONT6x8, 1, 1 + 8 * 2, YELLOW, RED);
124 LCDString(" AaBbCcDdEeFfGgHhIiJj ", (char *)&FONT6x8, 1, 1 + 8 * 3, RED, GREEN);
125 LCDString(" KkLlMmNnOoPpQqRrSsTt ", (char *)&FONT6x8, 1, 1 + 8 * 4, MAGENTA, BLUE);
126 LCDString("UuVvWwXxYyZz0123456789", (char *)&FONT6x8, 1, 1 + 8 * 5, BLUE, YELLOW);
127 LCDString("`-=[]_;',./~!@#$%^&*()", (char *)&FONT6x8, 1, 1 + 8 * 6, BLACK, CYAN);
128 LCDString(" _+{}|:\\\"<>? ", (char *)&FONT6x8, 1, 1 + 8 * 7, BLUE, MAGENTA);
130 // color bands
131 LCDFill(0, 1 + 8 * 8, 132, 8, BLACK);
132 LCDFill(0, 1 + 8 * 9, 132, 8, WHITE);
133 LCDFill(0, 1 + 8 * 10, 132, 8, RED);
134 LCDFill(0, 1 + 8 * 11, 132, 8, GREEN);
135 LCDFill(0, 1 + 8 * 12, 132, 8, BLUE);
136 LCDFill(0, 1 + 8 * 13, 132, 8, YELLOW);
137 LCDFill(0, 1 + 8 * 14, 132, 8, CYAN);
138 LCDFill(0, 1 + 8 * 15, 132, 8, MAGENTA);