summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-03-26 10:06:28 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-03-26 10:06:28 +0000
commitd20e6eee0e483582a40968bff25108c3ed855195 (patch)
treeaec37196db49ed0dc957c2ae8dcb9c12354e7407
parent643542799e448dc03684efebff5ac61dcd602ee5 (diff)
downloadrockbox-d20e6eee0e483582a40968bff25108c3ed855195.tar.gz
rockbox-d20e6eee0e483582a40968bff25108c3ed855195.zip
generic and specific LCD functions
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--uisimulator/lcd-recorder.c174
-rw-r--r--uisimulator/lcd-x11.c23
-rw-r--r--uisimulator/lcd.c179
3 files changed, 376 insertions, 0 deletions
diff --git a/uisimulator/lcd-recorder.c b/uisimulator/lcd-recorder.c
new file mode 100644
index 0000000000..37f4d3b142
--- /dev/null
+++ b/uisimulator/lcd-recorder.c
@@ -0,0 +1,174 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/*
21 * Hardware-specific implementations for the Archos Recorder LCD.
22 *
23 * Archos Jukebox Recorder LCD functions.
24 * Solomon SSD1815Z controller and Shing Yih Technology G112064-30 LCD.
25 *
26 */
27
28/* LCD command codes */
29#define LCD_CNTL_RESET 0xe2 /* Software reset */
30#define LCD_CNTL_POWER 0x2f /* Power control */
31#define LCD_CNTL_CONTRAST 0x81 /* Contrast */
32#define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */
33#define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */
34#define LCD_CNTL_DISPON 0xaf /* Display on */
35
36#define LCD_CNTL_PAGE 0xb0 /* Page address */
37#define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */
38#define LCD_CNTL_LOWCOL 0x00 /* Lower column address */
39
40
41/*
42 * Initialize LCD
43 */
44void lcd_init (void)
45{
46 /* Initialize PB0-3 as output pins */
47 PBCR2 &= 0xff00; /* MD = 00 */
48 PBIOR |= 0x000f; /* IOR = 1 */
49
50 /* Initialize LCD */
51 lcd_write (TRUE, LCD_CNTL_RESET);
52 lcd_write (TRUE, LCD_CNTL_POWER);
53 lcd_write (TRUE, LCD_CNTL_SEGREMAP);
54 lcd_write (TRUE, LCD_CNTL_OUTSCAN);
55 lcd_write (TRUE, LCD_CNTL_CONTRAST);
56 lcd_write (TRUE, 0x30); /* contrast parameter */
57 lcd_write (TRUE, LCD_CNTL_DISPON);
58
59 lcd_clear();
60 lcd_update();
61}
62
63/*
64 * Update the display.
65 * This must be called after all other LCD funtions that change the display.
66 */
67void lcd_update (void)
68{
69 int row, col;
70
71 /* Copy display bitmap to hardware */
72 for (row = 0; row < DISP_Y/8; row++) {
73 lcd_write (TRUE, LCD_CNTL_PAGE | (row & 0xf));
74 lcd_write (TRUE, LCD_CNTL_HIGHCOL);
75 lcd_write (TRUE, LCD_CNTL_LOWCOL);
76
77 for (col = 0; col < DISP_X; col++)
78 lcd_write (FALSE, display[row][col]);
79 }
80}
81
82/*
83 * Display a string at current position
84 */
85void lcd_string (const char *text, BOOL invert)
86{
87 int ch;
88
89 while ((ch = *text++) != '\0') {
90 if (lcd_y > DISP_Y-CHAR_Y) {
91 /* Scroll (8 pixels) */
92 memcpy (display[0], display[1], DISP_X*(DISP_Y/8-1));
93 lcd_y -= 8;
94 }
95
96 if (ch == '\n')
97 lcd_x = DISP_X;
98 else {
99 lcd_char (ch, invert);
100 lcd_x += CHAR_X;
101 }
102
103 if (lcd_x > DISP_X-CHAR_X) {
104 /* Wrap to next line */
105 lcd_x = 0;
106 lcd_y += CHAR_Y;
107 }
108 }
109}
110
111/*
112 * Display a character.
113 * This writes a 5x8 character within a 6x8 cell.
114 * The cell does not have to be aligned to a display byte.
115 * The top left of the cell is displayed at the current position.
116 * invert is TRUE to display in reverse video.
117 */
118void lcd_char (int ch, BOOL invert)
119{
120 uchar (*dp)[DISP_X] = (void *) &display[lcd_y/8][lcd_x];
121 uint32 shift, mask, col;
122
123 /* Limit to char generation table */
124 if (ch < ASCII_MIN || ch > ASCII_MAX)
125 ch = ASCII_MAX;
126
127 /* Calculate shift and masks for cell bit position */
128 shift = (lcd_y & 0x7);
129 mask = ~(COL_MASK << shift);
130 if (invert)
131 invert = ~mask;
132
133 /* Write each char column */
134 for (col = 0; col < CHAR_X-1; col++) {
135 uint32 data = (char_gen[ch-ASCII_MIN][col] << shift) ^ invert;
136 dp[0][col] = (dp[0][col] & mask) | data;
137 if (lcd_y < DISP_Y-8)
138 dp[1][col] = (dp[1][col] & (mask >> 8)) | (data >> 8);
139 }
140
141 /* Column after char */
142 dp[0][CHAR_X-1] = (dp[0][CHAR_X-1] & mask) | invert;
143 if (lcd_y < DISP_Y-8)
144 dp[1][CHAR_X-1] = (dp[1][CHAR_X-1] & (mask >> 8)) | (invert >> 8);
145}
146
147/*
148 * Write a byte to LCD controller.
149 * command is TRUE if value is a command byte.
150 */
151static void lcd_write (BOOL command, int value)
152{
153 int i;
154
155 /* Read PBDR, clear LCD bits */
156 int pbdr = PBDR & ~(PBDR_LCD_CS1|PBDR_LCD_DC|PBDR_LCD_SDA|PBDR_LCD_SCK);
157 if (!command)
158 pbdr |= PBDR_LCD_DC; /* set data indicator */
159
160 /* Send each bit, starting with MSB */
161 for (i = 0; i < 8; i++) {
162 if (value & 0x80) {
163 /* Set data, toggle clock */
164 PBDR = pbdr | PBDR_LCD_SDA;
165 PBDR = pbdr | PBDR_LCD_SDA | PBDR_LCD_SCK;
166 }
167 else {
168 /* Clear data, toggle clock */
169 PBDR = pbdr;
170 PBDR = pbdr | PBDR_LCD_SCK;
171 }
172 value <<= 1;
173 }
174}
diff --git a/uisimulator/lcd-x11.c b/uisimulator/lcd-x11.c
new file mode 100644
index 0000000000..efd6c9e8bd
--- /dev/null
+++ b/uisimulator/lcd-x11.c
@@ -0,0 +1,23 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/*
21 * Specific implementations for X11, using the generic LCD functions and data.
22 */
23
diff --git a/uisimulator/lcd.c b/uisimulator/lcd.c
new file mode 100644
index 0000000000..0db77e09bb
--- /dev/null
+++ b/uisimulator/lcd.c
@@ -0,0 +1,179 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/*
21 * This file is meant for generic LCD defines and global variables etc.
22 */
23
24#define DISP_X 112 /* Display width in pixels */
25#define DISP_Y 64 /* Display height in pixels */
26
27#define CHAR_X 6 /* Character width in pixels */
28#define CHAR_Y 8 /* Character height in pixels */
29#define COL_MASK 0xff /* Character column pixels changed */
30
31/*
32 * ASCII character generation table
33 *
34 * This contains only the printable characters (0x20-0x7f).
35 * Each row in this table is a 5x8 pixel character pattern.
36 * Each byte is a column of pixels, with the top pixel in the LSB.
37 */
38#define ASCII_MIN 0x20 /* First char in table */
39#define ASCII_MAX 0x7f /* Last char in table */
40
41static const uchar char_gen[ASCII_MAX-ASCII_MIN+1][CHAR_X-1] =
42{
43 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x2f */
44 0x00, 0x00, 0x4f, 0x00, 0x00,
45 0x00, 0x07, 0x00, 0x07, 0x00,
46 0x14, 0x7f, 0x14, 0x7f, 0x14,
47 0x24, 0x2a, 0x7f, 0x2a, 0x12,
48 0x23, 0x13, 0x08, 0x64, 0x62,
49 0x36, 0x49, 0x55, 0x22, 0x50,
50 0x00, 0x05, 0x03, 0x00, 0x00,
51 0x00, 0x1c, 0x22, 0x41, 0x00,
52 0x00, 0x41, 0x22, 0x1c, 0x00,
53 0x14, 0x08, 0x3e, 0x08, 0x14,
54 0x08, 0x08, 0x3e, 0x08, 0x08,
55 0x00, 0xa0, 0x60, 0x00, 0x00,
56 0x08, 0x08, 0x08, 0x08, 0x08,
57 0x00, 0x60, 0x60, 0x00, 0x00,
58 0x20, 0x10, 0x08, 0x04, 0x02,
59
60 0x3e, 0x51, 0x49, 0x45, 0x3e, /* 0x30-0x3f */
61 0x00, 0x42, 0x7f, 0x40, 0x00,
62 0x42, 0x61, 0x51, 0x49, 0x46,
63 0x21, 0x41, 0x45, 0x4b, 0x31,
64 0x18, 0x14, 0x12, 0x7f, 0x10,
65 0x27, 0x45, 0x45, 0x45, 0x39,
66 0x3c, 0x4a, 0x49, 0x49, 0x30,
67 0x01, 0x71, 0x09, 0x05, 0x03,
68 0x36, 0x49, 0x49, 0x49, 0x36,
69 0x06, 0x49, 0x49, 0x29, 0x1e,
70 0x00, 0x6c, 0x6c, 0x00, 0x00,
71 0x00, 0xac, 0x6c, 0x00, 0x00,
72 0x08, 0x14, 0x22, 0x41, 0x00,
73 0x14, 0x14, 0x14, 0x14, 0x14,
74 0x00, 0x41, 0x22, 0x14, 0x08,
75 0x02, 0x01, 0x51, 0x09, 0x06,
76
77 0x32, 0x49, 0x79, 0x41, 0x3e, /* 0x40-0x4f */
78 0x7e, 0x11, 0x11, 0x11, 0x7e,
79 0x7f, 0x49, 0x49, 0x49, 0x36,
80 0x3e, 0x41, 0x41, 0x41, 0x22,
81 0x7f, 0x41, 0x41, 0x22, 0x1c,
82 0x7f, 0x49, 0x49, 0x49, 0x41,
83 0x7f, 0x09, 0x09, 0x09, 0x01,
84 0x3e, 0x41, 0x49, 0x49, 0x7a,
85 0x7f, 0x08, 0x08, 0x08, 0x7f,
86 0x00, 0x41, 0x7f, 0x41, 0x00,
87 0x20, 0x40, 0x41, 0x3f, 0x01,
88 0x7f, 0x08, 0x14, 0x22, 0x41,
89 0x7f, 0x40, 0x40, 0x40, 0x40,
90 0x7f, 0x02, 0x0c, 0x02, 0x7f,
91 0x7f, 0x04, 0x08, 0x10, 0x7f,
92 0x3e, 0x41, 0x41, 0x41, 0x3e,
93
94 0x7f, 0x09, 0x09, 0x09, 0x06, /* 0x50-0x5f */
95 0x3e, 0x41, 0x51, 0x21, 0x5e,
96 0x7f, 0x09, 0x19, 0x29, 0x46,
97 0x46, 0x49, 0x49, 0x49, 0x31,
98 0x01, 0x01, 0x7f, 0x01, 0x01,
99 0x3f, 0x40, 0x40, 0x40, 0x3f,
100 0x1f, 0x20, 0x40, 0x20, 0x1f,
101 0x3f, 0x40, 0x38, 0x40, 0x3f,
102 0x63, 0x14, 0x08, 0x14, 0x63,
103 0x07, 0x08, 0x70, 0x08, 0x07,
104 0x71, 0x51, 0x49, 0x45, 0x43,
105 0x00, 0x7f, 0x41, 0x41, 0x00,
106 0x02, 0x04, 0x08, 0x10, 0x20,
107 0x00, 0x41, 0x41, 0x7f, 0x00,
108 0x04, 0x02, 0x01, 0x02, 0x04,
109 0x40, 0x40, 0x40, 0x40, 0x40,
110
111 0x00, 0x01, 0x02, 0x04, 0x00, /* 0x60-0x6f */
112 0x20, 0x54, 0x54, 0x54, 0x78,
113 0x7f, 0x48, 0x44, 0x44, 0x38,
114 0x38, 0x44, 0x44, 0x44, 0x20,
115 0x38, 0x44, 0x44, 0x48, 0x7f,
116 0x38, 0x54, 0x54, 0x54, 0x18,
117 0x08, 0x7e, 0x09, 0x01, 0x02,
118 0x18, 0xa4, 0xa4, 0xa4, 0x7c,
119 0x7f, 0x08, 0x04, 0x04, 0x78,
120 0x00, 0x44, 0x7d, 0x40, 0x00,
121 0x40, 0x80, 0x84, 0x7d, 0x00,
122 0x7f, 0x10, 0x28, 0x44, 0x00,
123 0x00, 0x41, 0x7f, 0x40, 0x00,
124 0x7c, 0x04, 0x18, 0x04, 0x78,
125 0x7c, 0x08, 0x04, 0x04, 0x78,
126 0x38, 0x44, 0x44, 0x44, 0x38,
127
128 0xfc, 0x24, 0x24, 0x24, 0x18, /* 0x70-0x7f */
129 0x18, 0x24, 0x24, 0x24, 0xfc,
130 0x7c, 0x08, 0x04, 0x04, 0x08,
131 0x48, 0x54, 0x54, 0x54, 0x20,
132 0x04, 0x3f, 0x44, 0x40, 0x20,
133 0x3c, 0x40, 0x40, 0x20, 0x7c,
134 0x1c, 0x20, 0x40, 0x20, 0x1c,
135 0x3c, 0x40, 0x30, 0x40, 0x3c,
136 0x44, 0x28, 0x10, 0x28, 0x44,
137 0x1c, 0xa0, 0xa0, 0xa0, 0x7c,
138 0x44, 0x64, 0x54, 0x4c, 0x44,
139 0x00, 0x08, 0x36, 0x41, 0x00,
140 0x00, 0x00, 0x7f, 0x00, 0x00,
141 0x00, 0x41, 0x36, 0x08, 0x00,
142 0x04, 0x02, 0x04, 0x08, 0x04,
143 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
144};
145
146/*
147 * Memory copy of display bitmap
148 *
149 * This has the same format as the Recorder hardware:
150 * Bits within a byte are arranged veritcally, LSB at top.
151 * Byte 0 is top left, byte 1 is 2nd left, byte DISP_X starts 2nd row.
152 */
153static uchar display[DISP_Y/8][DISP_X];
154
155static uint16 lcd_y; /* Current pixel row */
156static uint16 lcd_x; /* Current pixel column */
157
158/*
159 * Set current x,y position
160 */
161void lcd_position (int x, int y)
162{
163 if (x >= 0 && x < DISP_X && y >= 0 && y < DISP_Y)
164 {
165 lcd_x = x;
166 lcd_y = y;
167 }
168}
169
170/*
171 * Clear the display
172 */
173void lcd_clear (void)
174{
175 lcd_x = 0;
176 lcd_y = 0;
177 memset (display, 0, sizeof display);
178}
179