1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Daniel Stenberg
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
27 #define ONE_KILOBYTE 1024
28 #define ONE_MEGABYTE (1024*1024)
30 /* The point of this function would be to return a string of the input data,
31 but never longer than 5 columns. Add suffix k and M when suitable...
32 Make sure to have space for 6 bytes in the buffer. 5 letters plus the
33 terminating zero byte. */
34 char *num2max5(unsigned int bytes
, char *max5
)
37 snprintf(max5
, 6, "%5d", bytes
);
40 if(bytes
< (9999*ONE_KILOBYTE
)) {
41 snprintf(max5
, 6, "%4dk", bytes
/ONE_KILOBYTE
);
44 if(bytes
< (100*ONE_MEGABYTE
)) {
45 /* 'XX.XM' is good as long as we're less than 100 megs */
46 snprintf(max5
, 6, "%2d.%0dM",
48 (bytes
%ONE_MEGABYTE
)/(ONE_MEGABYTE
/10) );
51 snprintf(max5
, 6, "%4dM", bytes
/ONE_MEGABYTE
);
55 /* Read (up to) a line of text from fd into buffer and return number of bytes
56 * read (which may be larger than the number of bytes stored in buffer). If
57 * an error occurs, -1 is returned (and buffer contains whatever could be
58 * read). A line is terminated by a LF char. Neither LF nor CR chars are
61 int read_line(int fd
, char* buffer
, int buffer_size
)
68 while (count
< buffer_size
)
72 if (1 != read(fd
, &c
, 1))
86 buffer
[MIN(count
, buffer_size
- 1)] = 0;
88 return errno
? -1 : num_read
;
92 int main(int argc
, char **argv
)
98 num2max5(atoi(argv
[1]), buffer
));
106 extern unsigned char lcd_framebuffer
[LCD_HEIGHT
/8][LCD_WIDTH
];
107 static unsigned char bmpheader
[] =
109 0x42, 0x4d, 0x3e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00,
110 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x40, 0x00,
111 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
112 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0x00, 0x00,
113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xd0, 0x80, 0x00, 0x00, 0x00,
117 static unsigned char buf
[112*8];
118 static unsigned char buf2
[112*8];
119 static char dummy
[2] = {0, 0};
120 static int fileindex
= 0;
122 void screen_dump(void)
127 char filename
[MAX_PATH
];
130 for(y
= 0;y
< LCD_HEIGHT
/8;y
++)
132 for(x
= 0;x
< LCD_WIDTH
;x
++)
134 buf
[i
++] = lcd_framebuffer
[y
][x
];
138 memset(buf2
, 0, sizeof(buf2
));
140 for(y
= 0;y
< 64;y
++)
144 for(x
= 0;x
< 112/8;x
++)
148 buf2
[y
*112/8+x
] |= ((buf
[y
/8*112+x
*8+i
] >> shift
)
154 snprintf(filename
, MAX_PATH
, "/dump%03d.bmp", fileindex
++);
155 f
= creat(filename
, O_WRONLY
);
158 write(f
, bmpheader
, sizeof(bmpheader
));
160 for(i
= 63;i
>= 0;i
--)
162 write(f
, &buf2
[i
*14], 14);