freemyipod r293 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r292‎ | r293 | r294 >
Date:23:27, 27 November 2010
Author:theseven
Status:new
Tags:
Comment:
UMSboot: Allow LCD console to not completely fill the LCD
Modified paths:
  • /umsboot/lcd.h (modified) (history)
  • /umsboot/lcdconsole.c (modified) (history)
  • /umsboot/lcdconsole.h (modified) (history)
  • /umsboot/target/ipodnano2g/target.h (modified) (history)

Diff [purge]

Index: umsboot/target/ipodnano2g/target.h
@@ -47,6 +47,8 @@
4848 #define LCD_HEIGHT 132
4949 #define LCD_FORMAT rgb565
5050 #define LCD_BYTESPERPIXEL 2
 51+#define FRAMEBUF_WIDTH 176
 52+#define FRAMEBUF_HEIGHT 132
5153
5254 #define HAVE_BACKLIGHT
5355
Index: umsboot/lcd.h
@@ -28,7 +28,7 @@
2929 #include "global.h"
3030
3131
32 -#define LCD_FRAMEBUFSIZE (LCD_WIDTH * LCD_HEIGHT * LCD_BYTESPERPIXEL)
 32+#define LCD_FRAMEBUFSIZE (FRAMEBUF_WIDTH * FRAMEBUF_HEIGHT * LCD_BYTESPERPIXEL)
3333
3434
3535 void lcd_init() INITCODE_ATTR;
Index: umsboot/lcdconsole.c
@@ -30,20 +30,20 @@
3131 #define OFFSETX LCDCONSOLE_OFFSETX
3232 #define OFFSETY LCDCONSOLE_OFFSETY
3333 #define PIXELBYTES (LCD_BYTESPERPIXEL)
34 -#define LINEBYTES (LCD_WIDTH * PIXELBYTES)
 34+#define LINEBYTES (FRAMEBUF_WIDTH * PIXELBYTES)
3535 #define COLBYTES (FONT_WIDTH * PIXELBYTES)
3636 #define ROWBYTES (FONT_HEIGHT * LINEBYTES)
3737 #define OFFSETBYTES (LINEBYTES * OFFSETY + PIXELBYTES * OFFSETX)
3838
3939
40 -static unsigned char framebuf[LCD_FRAMEBUFSIZE];
41 -static unsigned int current_row IBSS_ATTR;
42 -static unsigned int current_col IBSS_ATTR;
43 -static bool lcdconsole_needs_update IBSS_ATTR;
 40+static unsigned char framebuf[LCD_FRAMEBUFSIZE] IBSS_ATTR;
 41+static unsigned int current_row;
 42+static unsigned int current_col;
 43+static bool lcdconsole_needs_update;
4444
45 -
4645 void lcdconsole_init()
4746 {
 47+ displaylcd(0, LCD_WIDTH - 1, 0, LCD_HEIGHT - 1, (void*)0xffffffff, 0);
4848 memset(framebuf, -1, sizeof(framebuf));
4949 current_row = 0;
5050 current_col = -1;
@@ -80,7 +80,7 @@
8181 current_row = LCDCONSOLE_ROWS - 1;
8282 }
8383 renderchar(&framebuf[OFFSETBYTES + ROWBYTES * current_row + COLBYTES * current_col],
84 - fgcolor, bgcolor, string, LCD_WIDTH);
 84+ fgcolor, bgcolor, string, FRAMEBUF_WIDTH);
8585 }
8686
8787 void lcdconsole_puts_noblit(const char* string, int fgcolor, int bgcolor)
@@ -103,7 +103,11 @@
104104 return;
105105 }
106106 leave_critical_section(mode);
107 - displaylcd(0, LCD_WIDTH - 1, 0, LCD_HEIGHT - 1, framebuf, 0);
 107+ displaylcd((LCD_WIDTH - FRAMEBUF_WIDTH) / 2,
 108+ (LCD_WIDTH - FRAMEBUF_WIDTH) / 2 + FRAMEBUF_WIDTH - 1,
 109+ (LCD_HEIGHT - FRAMEBUF_HEIGHT) / 2,
 110+ (LCD_HEIGHT - FRAMEBUF_HEIGHT) / 2 + FRAMEBUF_HEIGHT - 1,
 111+ framebuf, 0);
108112 }
109113
110114 void lcdconsole_putc(char string, int fgcolor, int bgcolor)
@@ -128,7 +132,11 @@
129133 {
130134 if (lcdconsole_needs_update)
131135 {
132 - displaylcd(0, LCD_WIDTH - 1, 0, LCD_HEIGHT - 1, framebuf, 0);
 136+ displaylcd((LCD_WIDTH - FRAMEBUF_WIDTH) / 2,
 137+ (LCD_WIDTH - FRAMEBUF_WIDTH) / 2 + FRAMEBUF_WIDTH - 1,
 138+ (LCD_HEIGHT - FRAMEBUF_HEIGHT) / 2,
 139+ (LCD_HEIGHT - FRAMEBUF_HEIGHT) / 2 + FRAMEBUF_HEIGHT - 1,
 140+ framebuf, 0);
133141 lcdconsole_needs_update = false;
134142 }
135143 }
Index: umsboot/lcdconsole.h
@@ -30,10 +30,10 @@
3131 #include "lcd.h"
3232
3333
34 -#define LCDCONSOLE_COLS (LCD_WIDTH / FONT_WIDTH)
35 -#define LCDCONSOLE_ROWS (LCD_HEIGHT / FONT_HEIGHT)
36 -#define LCDCONSOLE_OFFSETX ((LCD_WIDTH - LCDCONSOLE_COLS * FONT_WIDTH) / 2)
37 -#define LCDCONSOLE_OFFSETY ((LCD_HEIGHT - LCDCONSOLE_ROWS * FONT_HEIGHT) / 2)
 34+#define LCDCONSOLE_COLS (FRAMEBUF_WIDTH / FONT_WIDTH)
 35+#define LCDCONSOLE_ROWS (FRAMEBUF_HEIGHT / FONT_HEIGHT)
 36+#define LCDCONSOLE_OFFSETX ((FRAMEBUF_WIDTH - LCDCONSOLE_COLS * FONT_WIDTH) / 2)
 37+#define LCDCONSOLE_OFFSETY ((FRAMEBUF_HEIGHT - LCDCONSOLE_ROWS * FONT_HEIGHT) / 2)
3838
3939
4040 void lcdconsole_init();