Merge pull request #2593 from Akury83/master
[RRG-proxmark3.git] / armsrc / LCD_disabled.c
blob67b0f3de9f67035f435cc8370f504e75c15ca3b6
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // LCD code
17 //-----------------------------------------------------------------------------
18 #include "LCD_disabled.h"
20 void LCDSend(unsigned int data) {
21 // 9th bit set for data, clear for command
22 while ((AT91C_BASE_SPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); // wait for the transfer to complete
23 // For clarity's sake we pass data with 9th bit clear and commands with 9th
24 // bit set since they're implemented as defines, se we need to invert bit
25 AT91C_BASE_SPI->SPI_TDR = data ^ 0x100; // Send the data/command
28 void LCDSetXY(unsigned char x, unsigned char y) {
29 LCDSend(PPASET); // page start/end ram
30 LCDSend(y); // Start Page to display to
31 LCDSend(131); // End Page to display to
33 LCDSend(PCASET); // column start/end ram
34 LCDSend(x); // Start Column to display to
35 LCDSend(131); // End Column to display to
38 void LCDSetPixel(unsigned char x, unsigned char y, unsigned char color) {
39 LCDSetXY(x, y); // Set position
40 LCDSend(PRAMWR); // Now write the pixel to the display
41 LCDSend(color); // Write the data in the specified Color
44 void LCDFill(unsigned char xs, unsigned char ys, unsigned char width, unsigned char height, unsigned char color) {
45 unsigned char i, j;
47 for (i = 0; i < height; i++) { // Number of horizontal lines
48 LCDSetXY(xs, ys + i); // Goto start of fill area (Top Left)
49 LCDSend(PRAMWR); // Write to display
51 for (j = 0; j < width; j++) // pixels per line
52 LCDSend(color);
56 void LCDString(const char *lcd_string, const char *font_style, unsigned char x, unsigned char y, unsigned char fcolor, unsigned char bcolor) {
57 unsigned int i;
58 unsigned char mask = 0, px, py, xme, yme, offset;
59 const char *data;
61 data = font_style; // point to the start of the font table
63 xme = *data; // get font x width
64 data++;
65 yme = *data; // get font y length
66 data++;
67 offset = *data; // get data bytes per font
69 do {
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++) {
74 mask |= 0x80;
76 for (px = x; px < (x + xme); px++) {
77 py = y + i;
79 if (*data & mask) LCDSetPixel(px, py, fcolor);
80 else LCDSetPixel(px, py, bcolor);
82 mask >>= 1;
84 data++;
86 x += xme;
88 lcd_string++; // next character in string
90 } while (*lcd_string != '\0'); // keep spitting chars out until end of string
93 void LCDReset(void) {
94 LED_A_ON();
95 SetupSpi(SPI_LCD_MODE);
96 LOW(GPIO_LRST);
97 SpinDelay(100);
99 HIGH(GPIO_LRST);
100 SpinDelay(100);
101 LED_A_OFF();
104 void LCDInit(void) {
105 int i;
107 LCDReset();
109 LCDSend(PSWRESET); // software reset
110 SpinDelay(100);
111 LCDSend(PSLEEPOUT); // exit sleep mode
112 LCDSend(PBSTRON); // booster on
113 LCDSend(PDISPON); // display on
114 LCDSend(PNORON); // normal on
115 LCDSend(PMADCTL); // rotate display 180 deg
116 LCDSend(0xC0);
118 LCDSend(PCOLMOD); // color mode
119 LCDSend(0x02); // 8bpp color mode
121 LCDSend(PSETCON); // set contrast
122 LCDSend(0xDC);
124 // clear display
125 LCDSetXY(0, 0);
126 LCDSend(PRAMWR); // Write to display
127 i = LCD_XRES * LCD_YRES;
128 while (i--) LCDSend(WHITE);
130 // test text on different colored backgrounds
131 LCDString(" The quick brown fox ", (char *)&FONT6x8, 1, 1 + 8 * 0, WHITE, BLACK);
132 LCDString(" jumped over the ", (char *)&FONT6x8, 1, 1 + 8 * 1, BLACK, WHITE);
133 LCDString(" lazy dog. ", (char *)&FONT6x8, 1, 1 + 8 * 2, YELLOW, RED);
134 LCDString(" AaBbCcDdEeFfGgHhIiJj ", (char *)&FONT6x8, 1, 1 + 8 * 3, RED, GREEN);
135 LCDString(" KkLlMmNnOoPpQqRrSsTt ", (char *)&FONT6x8, 1, 1 + 8 * 4, MAGENTA, BLUE);
136 LCDString("UuVvWwXxYyZz0123456789", (char *)&FONT6x8, 1, 1 + 8 * 5, BLUE, YELLOW);
137 LCDString("`-=[]_;',./~!@#$%^&*()", (char *)&FONT6x8, 1, 1 + 8 * 6, BLACK, CYAN);
138 LCDString(" _+{}|:\\\"<>? ", (char *)&FONT6x8, 1, 1 + 8 * 7, BLUE, MAGENTA);
140 // color bands
141 LCDFill(0, 1 + 8 * 8, 132, 8, BLACK);
142 LCDFill(0, 1 + 8 * 9, 132, 8, WHITE);
143 LCDFill(0, 1 + 8 * 10, 132, 8, RED);
144 LCDFill(0, 1 + 8 * 11, 132, 8, GREEN);
145 LCDFill(0, 1 + 8 * 12, 132, 8, BLUE);
146 LCDFill(0, 1 + 8 * 13, 132, 8, YELLOW);
147 LCDFill(0, 1 + 8 * 14, 132, 8, CYAN);
148 LCDFill(0, 1 + 8 * 15, 132, 8, MAGENTA);