summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-06-30 13:31:14 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-06-30 13:31:14 +0000
commita8dab4c08af0e1d251ff633a2859c8b9b24efc7c (patch)
treebe8b66535d905e50319788f988f94ab008a48ba3
parent058302a4807e14d564195de9825e3aa970ea68f9 (diff)
downloadrockbox-a8dab4c08af0e1d251ff633a2859c8b9b24efc7c.tar.gz
rockbox-a8dab4c08af0e1d251ff633a2859c8b9b24efc7c.zip
New screen dump feature for recorders
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4817 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c13
-rw-r--r--apps/misc.c9
-rw-r--r--apps/misc.h5
-rw-r--r--firmware/drivers/serial.c51
-rw-r--r--firmware/usb.c67
-rw-r--r--uisimulator/win32/button.c10
-rw-r--r--uisimulator/x11/button-x11.c10
7 files changed, 89 insertions, 76 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 02b86feefc..0b4be9d72d 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1612,6 +1612,18 @@ static bool dbg_sound(void)
1612 return false; 1612 return false;
1613} 1613}
1614 1614
1615#ifdef HAVE_LCD_BITMAP
1616extern bool do_screendump_instead_of_usb;
1617
1618bool dbg_screendump(void)
1619{
1620 do_screendump_instead_of_usb = !do_screendump_instead_of_usb;
1621 splash(HZ, true, "Screendump %s",
1622 do_screendump_instead_of_usb?"enabled":"disabled");
1623 return false;
1624}
1625#endif
1626
1615bool debug_menu(void) 1627bool debug_menu(void)
1616{ 1628{
1617 int m; 1629 int m;
@@ -1635,6 +1647,7 @@ bool debug_menu(void)
1635#endif 1647#endif
1636#ifdef HAVE_LCD_BITMAP 1648#ifdef HAVE_LCD_BITMAP
1637 { "View battery", -1, view_battery }, 1649 { "View battery", -1, view_battery },
1650 { "Screendump", -1, dbg_screendump },
1638#endif 1651#endif
1639 { "View HW info", -1, dbg_hw_info }, 1652 { "View HW info", -1, dbg_hw_info },
1640 { "View partitions", -1, dbg_partitions }, 1653 { "View partitions", -1, dbg_partitions },
diff --git a/apps/misc.c b/apps/misc.c
index be1c3202fb..701f766a8d 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -23,6 +23,7 @@
23#include "sprintf.h" 23#include "sprintf.h"
24#include "errno.h" 24#include "errno.h"
25#include "system.h" 25#include "system.h"
26#include "timefuncs.h"
26 27
27#define ONE_KILOBYTE 1024 28#define ONE_KILOBYTE 1024
28#define ONE_MEGABYTE (1024*1024) 29#define ONE_MEGABYTE (1024*1024)
@@ -102,7 +103,7 @@ int main(int argc, char **argv)
102 103
103#endif 104#endif
104 105
105#ifdef SCREENDUMP 106#ifdef HAVE_LCD_BITMAP
106extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; 107extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
107static unsigned char bmpheader[] = 108static unsigned char bmpheader[] =
108{ 109{
@@ -117,7 +118,6 @@ static unsigned char bmpheader[] =
117static unsigned char buf[112*8]; 118static unsigned char buf[112*8];
118static unsigned char buf2[112*8]; 119static unsigned char buf2[112*8];
119static char dummy[2] = {0, 0}; 120static char dummy[2] = {0, 0};
120static int fileindex = 0;
121 121
122void screen_dump(void) 122void screen_dump(void)
123{ 123{
@@ -125,6 +125,7 @@ void screen_dump(void)
125 int i, shift; 125 int i, shift;
126 int x, y; 126 int x, y;
127 char filename[MAX_PATH]; 127 char filename[MAX_PATH];
128 struct tm *tm = get_time();
128 129
129 i = 0; 130 i = 0;
130 for(y = 0;y < LCD_HEIGHT/8;y++) 131 for(y = 0;y < LCD_HEIGHT/8;y++)
@@ -151,7 +152,9 @@ void screen_dump(void)
151 } 152 }
152 } 153 }
153 154
154 snprintf(filename, MAX_PATH, "/dump%03d.bmp", fileindex++); 155 snprintf(filename, MAX_PATH, "/dump %04d-%02d-%02d %02d-%02d-%02d.bmp",
156 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
157 tm->tm_hour, tm->tm_min, tm->tm_sec);
155 f = creat(filename, O_WRONLY); 158 f = creat(filename, O_WRONLY);
156 if(f >= 0) 159 if(f >= 0)
157 { 160 {
diff --git a/apps/misc.h b/apps/misc.h
index c8aa266d5f..329c62750c 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -30,3 +30,8 @@ char *num2max5(unsigned int bytes, char *max5);
30 * stored in buffer. 30 * stored in buffer.
31 */ 31 */
32int read_line(int fd, char* buffer, int buffer_size); 32int read_line(int fd, char* buffer, int buffer_size);
33
34#ifdef HAVE_LCD_BITMAP
35/* Save a .BMP file containing the current screen contents. */
36void screen_dump(void);
37#endif
diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c
index 2badf2e39f..11dadc6f19 100644
--- a/firmware/drivers/serial.c
+++ b/firmware/drivers/serial.c
@@ -35,12 +35,6 @@
35#define VOLUP 0xD0 35#define VOLUP 0xD0
36#define VOLDN 0xE0 36#define VOLDN 0xE0
37 37
38#ifdef SCREENDUMP
39#define SCRDMP 0xF0
40
41static void screen_dump(void);
42#endif
43
44void serial_setup (void) 38void serial_setup (void)
45{ 39{
46 /* Set PB10 function to serial Rx */ 40 /* Set PB10 function to serial Rx */
@@ -118,11 +112,6 @@ int remote_control_rx(void)
118 last_valid_button = BUTTON_RC_RIGHT; 112 last_valid_button = BUTTON_RC_RIGHT;
119 break; 113 break;
120 114
121#ifdef SCREENDUMP
122 case SCRDMP:
123 screen_dump();
124 break;
125#endif
126 default: 115 default:
127 last_valid_button = BUTTON_NONE; 116 last_valid_button = BUTTON_NONE;
128 break; 117 break;
@@ -144,43 +133,3 @@ int remote_control_rx(void)
144 133
145 return ret; 134 return ret;
146} 135}
147
148#ifdef SCREENDUMP
149static void serial_enable_tx(void)
150{
151 SCR1 |= 0x20;
152}
153
154static void serial_tx(unsigned char ch)
155{
156 while (!(SSR1 & SCI_TDRE))
157 {
158 ;
159 }
160
161 /*
162 * Write data into TDR and clear TDRE
163 */
164 TDR1 = ch;
165 SSR1 &= ~SCI_TDRE;
166}
167
168static void screen_dump(void)
169{
170 int x, y;
171 int level;
172
173 serial_enable_tx();
174
175 level = set_irq_level(HIGHEST_IRQ_LEVEL);
176 for(y = 0;y < LCD_HEIGHT/8;y++)
177 {
178 for(x = 0;x < LCD_WIDTH;x++)
179 {
180 serial_tx(lcd_framebuffer[y][x]);
181 }
182 }
183 set_irq_level(level);
184}
185
186#endif
diff --git a/firmware/usb.c b/firmware/usb.c
index 280ff22f02..5350a8575e 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -35,6 +35,11 @@
35 35
36extern void dbg_ports(void); /* NASTY! defined in apps/ */ 36extern void dbg_ports(void); /* NASTY! defined in apps/ */
37 37
38#ifdef HAVE_LCD_BITMAP
39bool do_screendump_instead_of_usb = false;
40void screen_dump(void); /* Nasty again. Defined in apps/ too */
41#endif
42
38#define USB_REALLY_BRAVE 43#define USB_REALLY_BRAVE
39 44
40#if !defined(SIMULATOR) && !defined(USB_NONE) 45#if !defined(SIMULATOR) && !defined(USB_NONE)
@@ -149,13 +154,24 @@ static void usb_thread(void)
149 switch(ev.id) 154 switch(ev.id)
150 { 155 {
151 case USB_INSERTED: 156 case USB_INSERTED:
152 /* Tell all threads that they have to back off the ATA. 157#ifdef HAVE_LCD_BITMAP
153 We subtract one for our own thread. */ 158 if(do_screendump_instead_of_usb)
154 num_acks_to_expect = 159 {
155 queue_broadcast(SYS_USB_CONNECTED, NULL) - 1; 160 screen_dump();
156 waiting_for_ack = true; 161 }
157 DEBUGF("USB inserted. Waiting for ack from %d threads...\n", 162 else
158 num_acks_to_expect); 163 {
164#endif
165 /* Tell all threads that they have to back off the ATA.
166 We subtract one for our own thread. */
167 num_acks_to_expect =
168 queue_broadcast(SYS_USB_CONNECTED, NULL) - 1;
169 waiting_for_ack = true;
170 DEBUGF("USB inserted. Waiting for ack from %d threads...\n",
171 num_acks_to_expect);
172#ifdef HAVE_LCD_BITMAP
173 }
174#endif
159 break; 175 break;
160 176
161 case SYS_USB_CONNECTED_ACK: 177 case SYS_USB_CONNECTED_ACK:
@@ -181,24 +197,31 @@ static void usb_thread(void)
181 break; 197 break;
182 198
183 case USB_EXTRACTED: 199 case USB_EXTRACTED:
184 if(usb_state == USB_INSERTED) 200#ifdef HAVE_LCD_BITMAP
201 if(!do_screendump_instead_of_usb)
185 { 202 {
186 /* Only disable the USB mode if we really have enabled it 203#endif
187 some threads might not have acknowledged the 204 if(usb_state == USB_INSERTED)
188 insertion */ 205 {
189 usb_slave_mode(false); 206 /* Only disable the USB mode if we really have enabled it
190 } 207 some threads might not have acknowledged the
208 insertion */
209 usb_slave_mode(false);
210 }
191 211
192 usb_state = USB_EXTRACTED; 212 usb_state = USB_EXTRACTED;
193 213
194 /* Tell all threads that we are back in business */ 214 /* Tell all threads that we are back in business */
195 num_acks_to_expect = 215 num_acks_to_expect =
196 queue_broadcast(SYS_USB_DISCONNECTED, NULL) - 1; 216 queue_broadcast(SYS_USB_DISCONNECTED, NULL) - 1;
197 waiting_for_ack = true; 217 waiting_for_ack = true;
198 DEBUGF("USB extracted. Waiting for ack from %d threads...\n", 218 DEBUGF("USB extracted. Waiting for ack from %d threads...\n",
199 num_acks_to_expect); 219 num_acks_to_expect);
200#ifdef HAVE_LCD_CHARCELLS 220#ifdef HAVE_LCD_CHARCELLS
201 lcd_icon(ICON_USB, false); 221 lcd_icon(ICON_USB, false);
222#endif
223#ifdef HAVE_LCD_BITMAP
224 }
202#endif 225#endif
203 break; 226 break;
204 227
diff --git a/uisimulator/win32/button.c b/uisimulator/win32/button.c
index c9bd1ad04e..4532727200 100644
--- a/uisimulator/win32/button.c
+++ b/uisimulator/win32/button.c
@@ -23,6 +23,7 @@
23#include "button.h" 23#include "button.h"
24#include "kernel.h" 24#include "kernel.h"
25#include "backlight.h" 25#include "backlight.h"
26#include "misc.h"
26 27
27/* how long until repeat kicks in */ 28/* how long until repeat kicks in */
28#define REPEAT_START 6 29#define REPEAT_START 6
@@ -89,6 +90,15 @@ void button_event(int key, bool pressed)
89 case VK_SPACE: 90 case VK_SPACE:
90 new_btn = BUTTON_PLAY; 91 new_btn = BUTTON_PLAY;
91 break; 92 break;
93
94 case VK_NUMPAD0:
95 case VK_F5:
96 if(pressed)
97 {
98 screen_dump();
99 return;
100 }
101 break;
92#else 102#else
93 case VK_RETURN: 103 case VK_RETURN:
94 new_btn = BUTTON_MENU; 104 new_btn = BUTTON_MENU;
diff --git a/uisimulator/x11/button-x11.c b/uisimulator/x11/button-x11.c
index eae55318ad..1b2c19232f 100644
--- a/uisimulator/x11/button-x11.c
+++ b/uisimulator/x11/button-x11.c
@@ -19,6 +19,7 @@
19#include "button.h" 19#include "button.h"
20#include "kernel.h" 20#include "kernel.h"
21#include "debug.h" 21#include "debug.h"
22#include "misc.h"
22 23
23#include "X11/keysym.h" 24#include "X11/keysym.h"
24 25
@@ -131,6 +132,15 @@ static int get_raw_button (void)
131 case XK_3: 132 case XK_3:
132 k = BUTTON_F3; 133 k = BUTTON_F3;
133 break; 134 break;
135
136 case XK_5:
137 if(!release)
138 {
139 screen_dump();
140 return 0;
141 }
142 break;
143
134#else 144#else
135 case XK_KP_Add: 145 case XK_KP_Add:
136 case XK_Q: 146 case XK_Q: