diff options
author | Karl Kurbjun <kkurbjun@gmail.com> | 2009-04-11 07:23:56 +0000 |
---|---|---|
committer | Karl Kurbjun <kkurbjun@gmail.com> | 2009-04-11 07:23:56 +0000 |
commit | 5449b1ed1d241ad4bdbe5dd2cd8c65ecbfa5b6b1 (patch) | |
tree | 39c7a041edb844c30aea93333818e80d7b46af9b /firmware/target | |
parent | 9f19f33c418aa2703c3c83f0f7ba72a76d21d0c0 (diff) | |
download | rockbox-5449b1ed1d241ad4bdbe5dd2cd8c65ecbfa5b6b1.tar.gz rockbox-5449b1ed1d241ad4bdbe5dd2cd8c65ecbfa5b6b1.zip |
M:Robe 500: Start of proper remote support, touchscreen works without remote now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20684 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
5 files changed, 344 insertions, 9 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index 3e5be7c22f..bc163b1070 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | |||
@@ -128,12 +128,6 @@ inline bool button_hold(void) | |||
128 | return false; | 128 | return false; |
129 | } | 129 | } |
130 | 130 | ||
131 | static void remote_heartbeat(void) | ||
132 | { | ||
133 | char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; | ||
134 | uart1_puts(data, 5); | ||
135 | } | ||
136 | |||
137 | #define TOUCH_MARGIN 8 | 131 | #define TOUCH_MARGIN 8 |
138 | char r_buffer[5]; | 132 | char r_buffer[5]; |
139 | int r_button = BUTTON_NONE; | 133 | int r_button = BUTTON_NONE; |
@@ -142,13 +136,14 @@ int button_read_device(int *data) | |||
142 | int retval, calbuf; | 136 | int retval, calbuf; |
143 | static int oldbutton = BUTTON_NONE; | 137 | static int oldbutton = BUTTON_NONE; |
144 | 138 | ||
139 | static long last_touch = 0; | ||
140 | |||
145 | r_button=BUTTON_NONE; | 141 | r_button=BUTTON_NONE; |
146 | *data = 0; | 142 | *data = 0; |
147 | 143 | ||
148 | if (touch_available) | 144 | if (touch_available) |
149 | { | 145 | { |
150 | short x,y; | 146 | short x,y; |
151 | static long last_touch = 0; | ||
152 | bool send_touch = false; | 147 | bool send_touch = false; |
153 | tsc2100_read_values(&x, &y, &last_z1, &last_z2); | 148 | tsc2100_read_values(&x, &y, &last_z1, &last_z2); |
154 | if (TIME_BEFORE(last_touch + HZ/5, current_tick)) | 149 | if (TIME_BEFORE(last_touch + HZ/5, current_tick)) |
@@ -175,7 +170,14 @@ int button_read_device(int *data) | |||
175 | last_touch = current_tick; | 170 | last_touch = current_tick; |
176 | touch_available = false; | 171 | touch_available = false; |
177 | } | 172 | } |
178 | remote_heartbeat(); | 173 | else |
174 | { | ||
175 | /* Touch hasn't happened in a while, clear the bits */ | ||
176 | if(last_touch+3>current_tick) | ||
177 | { | ||
178 | oldbutton&=(0xFF); | ||
179 | } | ||
180 | } | ||
179 | 181 | ||
180 | if ((IO_GIO_BITSET0&0x01) == 0) | 182 | if ((IO_GIO_BITSET0&0x01) == 0) |
181 | { | 183 | { |
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c new file mode 100644 index 0000000000..5cdc00ce6a --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c | |||
@@ -0,0 +1,287 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2009 Karl Kurbjun | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "system.h" | ||
24 | #include "file.h" | ||
25 | #include "lcd-remote.h" | ||
26 | #include "adc.h" | ||
27 | #include "scroll_engine.h" | ||
28 | #include "uart-target.h" | ||
29 | |||
30 | static enum remote_control_states | ||
31 | { | ||
32 | REMOTE_CONTROL_IDLE, | ||
33 | REMOTE_CONTROL_NOP, | ||
34 | REMOTE_CONTROL_POWER, | ||
35 | REMOTE_CONTROL_MASK, | ||
36 | REMOTE_CONTROL_DRAW1, | ||
37 | REMOTE_CONTROL_DRAW_PAUSE1, | ||
38 | REMOTE_CONTROL_DRAW2, | ||
39 | REMOTE_CONTROL_DRAW_PAUSE2, | ||
40 | REMOTE_CONTROL_SLEEP | ||
41 | } remote_state_control = REMOTE_CONTROL_NOP; | ||
42 | |||
43 | bool remote_initialized=true; | ||
44 | |||
45 | unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING; | ||
46 | unsigned char remote_power=0x00; | ||
47 | |||
48 | /*** hardware configuration ***/ | ||
49 | |||
50 | int lcd_remote_default_contrast(void) | ||
51 | { | ||
52 | return DEFAULT_REMOTE_CONTRAST_SETTING; | ||
53 | } | ||
54 | |||
55 | void lcd_remote_sleep(void) | ||
56 | { | ||
57 | remote_state_control=REMOTE_CONTROL_SLEEP; | ||
58 | } | ||
59 | |||
60 | void lcd_remote_powersave(bool on) | ||
61 | { | ||
62 | if(on) | ||
63 | { | ||
64 | remote_power|=0xC0; | ||
65 | remote_state_control=REMOTE_CONTROL_POWER; | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | remote_power&=~(0xC0); | ||
70 | remote_state_control=REMOTE_CONTROL_POWER; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | void lcd_remote_set_contrast(int val) | ||
75 | { | ||
76 | remote_contrast=(char)val; | ||
77 | remote_state_control=REMOTE_CONTROL_POWER; | ||
78 | } | ||
79 | |||
80 | void lcd_remote_set_invert_display(bool yesno) | ||
81 | { | ||
82 | (void)yesno; | ||
83 | } | ||
84 | |||
85 | /* turn the display upside down (call lcd_remote_update() afterwards) */ | ||
86 | void lcd_remote_set_flip(bool yesno) | ||
87 | { | ||
88 | (void)yesno; | ||
89 | } | ||
90 | |||
91 | bool remote_detect(void) | ||
92 | { | ||
93 | return true; | ||
94 | } | ||
95 | |||
96 | void lcd_remote_on(void) | ||
97 | { | ||
98 | remote_power|=0x80; | ||
99 | remote_state_control=REMOTE_CONTROL_POWER; | ||
100 | } | ||
101 | |||
102 | void lcd_remote_off(void) | ||
103 | { | ||
104 | remote_power&=~(0x80); | ||
105 | remote_state_control=REMOTE_CONTROL_POWER; | ||
106 | } | ||
107 | |||
108 | unsigned char lcd_remote_test[16]= | ||
109 | {0x80,0xFF,0x80,0x00,0xFF,0x89,0x89,0x00,0xC1,0x89,0x8F,0x80,0xFF,0x80,0,0}; | ||
110 | |||
111 | /* Monitor remote hotswap */ | ||
112 | static void remote_tick(void) | ||
113 | { | ||
114 | unsigned char i; | ||
115 | unsigned char remote_payload[10], remote_payload_size; | ||
116 | unsigned char remote_check_xor, remote_check_sum; | ||
117 | |||
118 | switch (remote_state_control) | ||
119 | { | ||
120 | case REMOTE_CONTROL_IDLE: | ||
121 | |||
122 | remote_payload_size=0; | ||
123 | remote_state_control=REMOTE_CONTROL_IDLE; | ||
124 | break; | ||
125 | case REMOTE_CONTROL_NOP: | ||
126 | remote_payload[0]=0x11; | ||
127 | remote_payload[1]=0x30; | ||
128 | |||
129 | remote_payload_size=2; | ||
130 | remote_state_control=REMOTE_CONTROL_NOP; | ||
131 | break; | ||
132 | case REMOTE_CONTROL_POWER: | ||
133 | remote_payload[0]=0x31; | ||
134 | remote_payload[1]=remote_power; | ||
135 | remote_payload[2]=remote_contrast; | ||
136 | |||
137 | remote_payload_size=3; | ||
138 | remote_state_control=REMOTE_CONTROL_NOP; | ||
139 | break; | ||
140 | case REMOTE_CONTROL_MASK: | ||
141 | remote_payload[0]=0x41; | ||
142 | remote_payload[1]=0x94; | ||
143 | |||
144 | remote_payload_size=2; | ||
145 | remote_state_control=REMOTE_CONTROL_NOP; | ||
146 | break; | ||
147 | case REMOTE_CONTROL_DRAW1: | ||
148 | remote_payload[0]=0x51; | ||
149 | remote_payload[1]=0x80; | ||
150 | remote_payload[2]=14; | ||
151 | remote_payload[3]=0; | ||
152 | remote_payload[4]=0; | ||
153 | remote_payload[5]=14; | ||
154 | remote_payload[6]=8; | ||
155 | |||
156 | remote_payload_size=7; | ||
157 | remote_state_control=REMOTE_CONTROL_DRAW_PAUSE1; | ||
158 | break; | ||
159 | case REMOTE_CONTROL_DRAW_PAUSE1: | ||
160 | remote_payload[0]=0x11; | ||
161 | remote_payload[1]=0x30; | ||
162 | |||
163 | remote_payload_size=2; | ||
164 | remote_state_control=REMOTE_CONTROL_DRAW2; | ||
165 | break; | ||
166 | case REMOTE_CONTROL_DRAW2: | ||
167 | remote_payload[0]=0x51; | ||
168 | remote_payload[1]=0x80; | ||
169 | remote_payload[2]=14; | ||
170 | remote_payload[3]=0; | ||
171 | remote_payload[4]=8; | ||
172 | remote_payload[5]=14; | ||
173 | remote_payload[6]=16; | ||
174 | |||
175 | remote_payload_size=7; | ||
176 | remote_state_control=REMOTE_CONTROL_DRAW_PAUSE2; | ||
177 | break; | ||
178 | case REMOTE_CONTROL_DRAW_PAUSE2: | ||
179 | remote_payload[0]=0x11; | ||
180 | remote_payload[1]=0x30; | ||
181 | |||
182 | remote_payload_size=2; | ||
183 | remote_state_control=REMOTE_CONTROL_NOP; | ||
184 | break; | ||
185 | case REMOTE_CONTROL_SLEEP: | ||
186 | remote_payload[0]=0x71; | ||
187 | remote_payload[1]=0x30; | ||
188 | |||
189 | remote_payload_size=2; | ||
190 | remote_state_control=REMOTE_CONTROL_IDLE; | ||
191 | break; | ||
192 | default: | ||
193 | remote_payload_size=0; | ||
194 | break; | ||
195 | } | ||
196 | |||
197 | if(remote_payload_size==0) | ||
198 | { | ||
199 | return; | ||
200 | } | ||
201 | |||
202 | remote_check_xor=remote_payload[0]; | ||
203 | remote_check_sum=remote_payload[0]; | ||
204 | for(i=1; i<remote_payload_size; i++) | ||
205 | { | ||
206 | remote_check_xor^=remote_payload[i]; | ||
207 | remote_check_sum+=remote_payload[i]; | ||
208 | } | ||
209 | |||
210 | if(remote_payload[0]==0x51) | ||
211 | { | ||
212 | unsigned char offset; | ||
213 | unsigned char x; | ||
214 | |||
215 | if(remote_payload[4]==8) | ||
216 | { | ||
217 | offset=79; | ||
218 | } | ||
219 | else | ||
220 | { | ||
221 | offset=0; | ||
222 | } | ||
223 | |||
224 | for (x = 0; x < 14; x++) | ||
225 | { | ||
226 | remote_check_xor^=lcd_remote_test[x]; | ||
227 | remote_check_sum+=lcd_remote_test[x]; | ||
228 | } | ||
229 | |||
230 | uart1_puts(remote_payload, remote_payload_size); | ||
231 | lcd_remote_test[14]=remote_check_xor; | ||
232 | lcd_remote_test[15]=remote_check_sum; | ||
233 | uart1_puts(lcd_remote_test, 16); | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | remote_payload[remote_payload_size]=remote_check_xor; | ||
238 | remote_payload[remote_payload_size+1]=remote_check_sum; | ||
239 | |||
240 | uart1_puts(remote_payload, remote_payload_size+2); | ||
241 | } | ||
242 | } | ||
243 | |||
244 | void lcd_remote_init_device(void) | ||
245 | { | ||
246 | lcd_remote_clear_display(); | ||
247 | if (remote_detect()) | ||
248 | lcd_remote_on(); | ||
249 | |||
250 | /* put the remote control in the tick task */ | ||
251 | tick_add_task(remote_tick); | ||
252 | } | ||
253 | |||
254 | /* Update the display. | ||
255 | This must be called after all other LCD functions that change the display. */ | ||
256 | void lcd_remote_update(void) | ||
257 | { | ||
258 | if(remote_state_control!=REMOTE_CONTROL_DRAW1 | ||
259 | && remote_state_control!=REMOTE_CONTROL_DRAW_PAUSE1 | ||
260 | && remote_state_control!=REMOTE_CONTROL_DRAW2 | ||
261 | && remote_state_control!=REMOTE_CONTROL_DRAW_PAUSE2) | ||
262 | { | ||
263 | remote_state_control=REMOTE_CONTROL_DRAW1; | ||
264 | } | ||
265 | } | ||
266 | |||
267 | /* Update a fraction of the display. */ | ||
268 | void lcd_remote_update_rect(int x, int y, int width, int height) | ||
269 | { | ||
270 | (void)x; | ||
271 | (void)y; | ||
272 | (void)width; | ||
273 | (void)height; | ||
274 | lcd_remote_update(); | ||
275 | } | ||
276 | |||
277 | void _remote_backlight_on(void) | ||
278 | { | ||
279 | remote_power|=0x40; | ||
280 | remote_state_control=REMOTE_CONTROL_POWER; | ||
281 | } | ||
282 | |||
283 | void _remote_backlight_off(void) | ||
284 | { | ||
285 | remote_power&=~(0x40); | ||
286 | remote_state_control=REMOTE_CONTROL_POWER; | ||
287 | } | ||
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-target.h b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-target.h new file mode 100644 index 0000000000..bf52e80238 --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-target.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Karl Kurbjun | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef LCD_REMOTE_TARGET_H | ||
22 | #define LCD_REMOTE_TARGET_H | ||
23 | |||
24 | #define REMOTE_INIT_LCD 1 | ||
25 | #define REMOTE_DEINIT_LCD 2 | ||
26 | |||
27 | void lcd_remote_powersave(bool on); | ||
28 | void lcd_remote_set_invert_display(bool yesno); | ||
29 | //void lcd_remote_set_flip(bool yesno); | ||
30 | |||
31 | bool remote_detect(void); | ||
32 | void lcd_remote_init_device(void); | ||
33 | void lcd_remote_on(void); | ||
34 | void lcd_remote_off(void); | ||
35 | void lcd_remote_update(void); | ||
36 | void lcd_remote_update_rect(int, int, int, int); | ||
37 | |||
38 | void _remote_backlight_on(void); | ||
39 | void _remote_backlight_off(void); | ||
40 | |||
41 | extern bool remote_initialized; | ||
42 | |||
43 | void lcd_remote_sleep(void); | ||
44 | |||
45 | #endif | ||
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c index 9fd976ec10..777856dcfc 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c | |||
@@ -72,6 +72,7 @@ void power_off(void) | |||
72 | { | 72 | { |
73 | /* turn off backlight and wait for 1 second */ | 73 | /* turn off backlight and wait for 1 second */ |
74 | _backlight_off(); | 74 | _backlight_off(); |
75 | lcd_remote_sleep(); | ||
75 | lcd_sleep(); | 76 | lcd_sleep(); |
76 | sleep(HZ); | 77 | sleep(HZ); |
77 | /* Hard shutdown */ | 78 | /* Hard shutdown */ |
diff --git a/firmware/target/arm/tms320dm320/uart-dm320.c b/firmware/target/arm/tms320dm320/uart-dm320.c index 81076e81f2..5e2ad5e2be 100644 --- a/firmware/target/arm/tms320dm320/uart-dm320.c +++ b/firmware/target/arm/tms320dm320/uart-dm320.c | |||
@@ -123,7 +123,7 @@ void UART1(void) | |||
123 | panicf("UART1 buffer overflow"); | 123 | panicf("UART1 buffer overflow"); |
124 | else | 124 | else |
125 | { | 125 | { |
126 | if(uart1_recieve_write==RECIEVE_RING_SIZE) | 126 | if(uart1_recieve_write>=RECIEVE_RING_SIZE) |
127 | uart1_recieve_write=0; | 127 | uart1_recieve_write=0; |
128 | 128 | ||
129 | uart1_recieve_buffer_ring[uart1_recieve_write] = IO_UART1_DTRR & 0xff; | 129 | uart1_recieve_buffer_ring[uart1_recieve_write] = IO_UART1_DTRR & 0xff; |