Clean up the Fuze LCD driver. The only functional change is to write 0x7030 instead...
[kugel-rb.git] / apps / logfdisp.c
blobbfe37bc3fb239ce26ef323e958204ab53498a9b9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 Daniel Stenberg
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "config.h"
23 #ifdef ROCKBOX_HAS_LOGF
24 #include <file.h>
25 #include <sprintf.h>
26 #include <timefuncs.h>
27 #include <string.h>
28 #include <kernel.h>
29 #include <action.h>
31 #include <lcd.h>
32 #include "menu.h"
33 #include "logf.h"
34 #include "settings.h"
35 #include "logfdisp.h"
37 #ifdef HAVE_LCD_BITMAP
38 bool logfdisplay(void)
41 int w, h;
42 int lines;
43 int columns;
44 int i;
46 bool lcd = false; /* fixed atm */
47 int index;
49 lcd_getstringsize("A", &w, &h);
50 lines = (lcd?
51 #ifdef HAVE_REMOTE_LCD
52 LCD_REMOTE_HEIGHT
53 #else
55 #endif
56 :LCD_HEIGHT)/h;
57 columns = (lcd?
58 #ifdef HAVE_REMOTE_LCD
59 LCD_REMOTE_WIDTH
60 #else
62 #endif
63 :LCD_WIDTH)/w;
65 if (columns > MAX_LOGF_ENTRY)
66 columns = MAX_LOGF_ENTRY;
68 if(!lines)
69 return false;
71 lcd_clear_display();
73 do {
74 index = logfindex;
75 for(i = lines-1; i>=0; i--) {
76 unsigned char buffer[columns + 1];
78 if(--index < 0) {
79 if(logfwrap)
80 index = MAX_LOGF_LINES-1;
81 else
82 break; /* done */
85 memcpy(buffer, logfbuffer[index], columns);
86 buffer[columns]=0;
87 lcd_puts(0, i, buffer);
89 lcd_update();
90 } while(!action_userabort(HZ));
92 return false;
94 #else /* HAVE_LCD_BITMAP */
95 bool logfdisplay(void)
98 /* TODO: implement a browser for charcell bitmaps */
99 return false;
101 #endif /* HAVE_LCD_BITMAP */
103 /* Store the logf log to logf.txt in the .rockbox directory. The order of the
104 * entries will be "reversed" so that the most recently logged entry is on the
105 * top of the file */
106 bool logfdump(void)
108 int fd;
110 if(!logfindex && !logfwrap)
111 /* nothing is logged just yet */
112 return false;
114 fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC);
115 if(-1 != fd) {
116 unsigned char buffer[MAX_LOGF_ENTRY +1];
117 int index = logfindex-1;
118 int stop = logfindex;
121 while(index != stop) {
122 if(index < 0) {
123 if(logfwrap)
124 index = MAX_LOGF_LINES-1;
125 else
126 break; /* done */
129 memcpy(buffer, logfbuffer[index], MAX_LOGF_ENTRY);
130 buffer[MAX_LOGF_ENTRY]=0;
131 fdprintf(fd, "%s\n", buffer);
132 index--;
134 close(fd);
136 return false;
139 #endif /* ROCKBOX_HAS_LOGF */