[patch] splash screen progress bar version 2

From: Sacha Chua (sachac@iname.com)
Date: Thu Mar 07 2002 - 00:26:14 EST


Cleaned up the splash screen patch a bit.
- Added lcd_progress_bar(r1, c1, r2, c2, percent, direction, color) in
  lcd.c and lcd.h.
- Changed jffs2 to use the new progress bar.
- Added debug bootldr commands

And from the previous patch:
- lcd.c: lcd_fill_region(r1, c1, r2, c2, color) and
         lcd_clear_region(r1, c1, r2, c2, color)
  and corresponding debug bootldr commands.

lcd_bar is now pretty useless; should it be removed?

Once again, comments would be very helpful. =)
----- yet another patch -----
diff -r -u bootldr.orig/README.splash bootldr/README.splash
--- bootldr.orig/README.splash Wed Mar 6 21:11:49 2002
+++ bootldr/README.splash Thu Mar 7 13:10:02 2002
@@ -6,7 +6,22 @@
 
 So, please, BE CAREFUL.
 
-Also, for the accident prone, you can play with images by using
-$ make splashz_linux
+Picky people may also want to edit the LCD_PB_ constants in
+load_kernel/src/jffs2.c. #define LCD_PB_VERTICAL if you want a vertical
+progress bar; default is horizontal.
+
+If you want buttons highlighted properly when you press them, you need to
+edit aux_micro.c. Change the last 4 entries of the relevant key to
+start_row, start_col, end_row, end_col. Example:
+ {"calb", KIF_ENABLE_REBOOT_BUTTON,H3800_ASIC2_CAL_BUTTON,0,154,54,225,79},
+If you don't want visual feedback, set the coordinates to 0.
+
+Also, for the accident prone, you can play with images by
+
+ $ make splashz_linux
+
 and
-boot> lcdzimg <sizeof-splashz-file>
+
+ boot> lcdzimg <sizeof-splashz-file>
+
+Note that you'll need to enable the bootloader debugging commands, which you can do by #defining DEBUG_BOOTLDR_CMDS
diff -r -u bootldr.orig/bootldr.c bootldr/bootldr.c
--- bootldr.orig/bootldr.c Wed Mar 6 21:11:49 2002
+++ bootldr/bootldr.c Thu Mar 7 13:10:02 2002
@@ -347,7 +347,10 @@
   { "lcdt", command_lcd_test, "lcdt -- test lcd", BB_RUN_FROM_RAM },
   /* { "lcdpal", command_lcd_pal, "lcdpal -- set lcd pal", BB_RUN_FROM_RAM }, */
   { "lcdfill", command_lcd_fill, "lcdfill -- fill lcd display", BB_RUN_FROM_RAM },
+ { "lcdprogressbar", command_lcd_progress_bar, "lcdprogressbar <r1> <c1> <r2> <c2> <percent> <direction> <color> -- percent: 1..100, direction: 0 - horizontal, 1 - vertical", BB_RUN_FROM_RAM },
+ { "lcdfillregion", command_lcd_fill_region, "lcdfillregion <r1> <c1> <r2> <c2> <color> -- fill rectangle", BB_RUN_FROM_RAM },
+ { "lcdclearregion", command_lcd_clear_region, "lcdclearregion <r1> <c1> <r2> <c2> <color> -- clear rectangle", BB_RUN_FROM_RAM },
   { "lcdbar", command_lcd_bar, "lcdbar -- fill lcd bar with [color] to [percent] at [row offset]", BB_RUN_FROM_RAM },
   { "lcdinvertregion", command_lcd_invert_region,
     "lcdinvertregion -- invert region args:start_row start_col end_row end_col", BB_RUN_FROM_RAM },
   { "lcdimg", command_lcd_image, "lcdimg -- display image", BB_RUN_FROM_RAM },
@@ -369,7 +376,7 @@
   { "discover", discover_machine_type, "discover -- guess what machine i am see mach_type for result", BB_RUN_FROM_RAM },
   { "tdz", command_tdz, "tdz -- test decompress routines (best with ascii) pre flashing", BB_RUN_FROM_RAM },
 
-#endif // DEBUG_BOOTLDR_COMMANDS
+#endif // DEBUG_BOOTLDR_CMDS
 
   { NULL, NULL, NULL , BB_RUN_FROM_RAM },
 };
diff -r -u bootldr.orig/lcd.c bootldr/lcd.c
--- bootldr.orig/lcd.c Wed Mar 6 21:11:49 2002
+++ bootldr/lcd.c Thu Mar 7 13:12:33 2002
@@ -530,14 +530,35 @@
     int percent,
     int row_offset)
 {
- unsigned short row,col;
- for (row=row_offset; row < (row_offset+25); row++)
- for (col=0; col < LCD_XRES; col++)
- if ((col*100)/LCD_XRES < percent)
- set_pixel_value(row, col, color);
-
+ lcd_fill_region(color, row_offset, 0, row_offset + 25, (LCD_XRES * percent) / 100);
+}
 
-
+void
+lcd_progress_bar(
+ unsigned int start_row,
+ unsigned int start_col,
+ unsigned int end_row,
+ unsigned int end_col,
+ unsigned int percent,
+ unsigned int direction,
+ int color
+ )
+{
+ if (direction == LCD_VERTICAL) {
+ if (end_row > start_row)
+ lcd_fill_region(start_row + ((100 - percent) * (end_row - start_row)) / 100, start_col,
+ end_row, end_col, color);
+ else
+ lcd_fill_region(end_row + ((100 - percent) * (start_row - end_row)) / 100, start_col,
+ start_row, end_col, color);
+ } else if (direction == LCD_HORIZONTAL) {
+ if (end_col > start_col)
+ lcd_fill_region(start_row, start_col,
+ end_row, start_col + (percent * (end_col - start_col)) / 100, color);
+ else
+ lcd_fill_region(start_row, end_col,
+ end_row, end_col + (percent * (start_col - end_col)) / 100, color);
+ }
 }
 
 void
@@ -545,22 +566,51 @@
     int percent,
     int row_offset)
 {
- unsigned short color;
- unsigned short row,col;
- if (lcd_params->id == LCDP_3100)
- color = 0;
- else
- color = 0xffff;
-
- for (row=row_offset; row < (row_offset+25); row++)
- for (col=0; col < LCD_XRES; col++)
- if ((col*100)/LCD_XRES < percent)
- set_pixel_value(row, col, color);
+ lcd_bar((lcd_params->id == LCDP_3100) ? 0 : 0xffff, percent, row_offset);
+}
     
+unsigned int
+min(
+ unsigned int a,
+ unsigned int b)
+{
+ return (a < b) ? a : b;
+}
 
+unsigned int
+max(
+ unsigned int a,
+ unsigned int b)
+{
+ return (a > b) ? a : b;
+}
     
+void
+lcd_clear_region(
+ unsigned int start_row,
+ unsigned int start_col,
+ unsigned int end_row,
+ unsigned int end_col
+ )
+{
+ lcd_fill_region(start_row, start_col, end_row, end_col,
+ (lcd_params->id == LCDP_3100) ? 0 : 0xffff);
 }
 
+void
+lcd_fill_region(
+ unsigned int start_row,
+ unsigned int start_col,
+ unsigned int end_row,
+ unsigned int end_col,
+ int color
+ )
+{
+ unsigned int row, col;
+ for (col = min(start_col, end_col); col < max(start_col, end_col); col++)
+ for (row = min(start_row, end_row); row < max(start_row, end_row); row++)
+ set_pixel_value(row, col, color);
+}
 
 void
 lcd_invert_region(
@@ -747,6 +797,77 @@
     else
         putstr("Need args: color [percent] [row offset]\n\r");
 
+}
+
+void
+command_lcd_progress_bar(
+ int argc,
+ const char* argv[])
+{
+ int start_row;
+ int end_row;
+ int start_col;
+ int end_col;
+ int color;
+ int percent;
+ int direction;
+
+ if (argc < 8) {
+ putstr("Need args: start_row start_col end_row end_col percent direction color\n\r");
+ putstr("percent: 1 .. 100, direction: 0 - horizontal, 1 - vertical\n\r");
+ return;
+ }
+
+ start_row = strtoul(argv[1], NULL, 0);
+ start_col = strtoul(argv[2], NULL, 0);
+ end_row = strtoul(argv[3], NULL, 0);
+ end_col = strtoul(argv[4], NULL, 0);
+ percent = strtoul(argv[5], NULL, 0);
+ direction = strtoul(argv[6], NULL, 0);
+ color = strtoul(argv[7], NULL, 0);
+ lcd_progress_bar(start_row, start_col, end_row, end_col, percent, direction, color);
+}
+
+void
+command_lcd_fill_region(
+ int argc,
+ const char* argv[])
+{
+ int start_row;
+ int end_row;
+ int start_col;
+ int end_col;
+ int color;
+
+ if (argc < 6)
+ putstr("Need args: start_row start_col end_row end_col color\n\r");
+
+ start_row = strtoul(argv[1], NULL, 0);
+ start_col = strtoul(argv[2], NULL, 0);
+ end_row = strtoul(argv[3], NULL, 0);
+ end_col = strtoul(argv[4], NULL, 0);
+ color = strtoul(argv[5], NULL, 0);
+ lcd_fill_region(start_row,start_col,end_row,end_col,color);
+}
+
+void
+command_lcd_clear_region(
+ int argc,
+ const char* argv[])
+{
+ int start_row;
+ int end_row;
+ int start_col;
+ int end_col;
+
+ if (argc < 5)
+ putstr("Need args: start_row start_col end_row end_col\n\r");
+
+ start_row = strtoul(argv[1], NULL, 0);
+ start_col = strtoul(argv[2], NULL, 0);
+ end_row = strtoul(argv[3], NULL, 0);
+ end_col = strtoul(argv[4], NULL, 0);
+ lcd_clear_region(start_row,start_col,end_row,end_col);
 }
 
 void
diff -r -u bootldr.orig/lcd.h bootldr/lcd.h
--- bootldr.orig/lcd.h Wed Mar 6 21:11:49 2002
+++ bootldr/lcd.h Thu Mar 7 13:10:04 2002
@@ -331,6 +331,8 @@
 #define LCCR3_OutEnH (LCCR3_OEP*0) /* Output Enable active High */
 #define LCCR3_OutEnL (LCCR3_OEP*1) /* Output Enable active Low */
 
+#define LCD_VERTICAL 1
+#define LCD_HORIZONTAL 0
 
 typedef struct lcd_params_s
 {
@@ -417,6 +419,51 @@
           char offTime);
 
 extern void
+lcd_progress_bar(
+ unsigned int start_row,
+ unsigned int start_col,
+ unsigned int end_row,
+ unsigned int end_col,
+ unsigned int percent,
+ unsigned int direction,
+ int color
+ );
+
+extern void
+lcd_fill_region(
+ unsigned int start_row,
+ unsigned int start_col,
+ unsigned int end_row,
+ unsigned int end_col,
+ int color
+ );
+
+extern void
+lcd_clear_region(
+ unsigned int start_row,
+ unsigned int start_col,
+ unsigned int end_row,
+ unsigned int end_col
+ );
+
+extern void
+lcd_fill_region(
+ unsigned int start_row,
+ unsigned int start_col,
+ unsigned int end_row,
+ unsigned int end_col,
+ int color
+ );
+
+extern void
+lcd_clear_region(
+ unsigned int start_row,
+ unsigned int start_col,
+ unsigned int end_row,
+ unsigned int end_col
+ );
+
+extern void
 lcd_invert_region(
     unsigned short start_row,
     unsigned short start_col,
@@ -439,6 +486,9 @@
 void command_ser_con(int argc, const char* argv[]);
 void command_irda_con(int argc, const char* argv[]);
 void command_splash(int argc, const char* argv[]);
+void command_lcd_progress_bar(int argc,const char* argv[]);
+void command_lcd_fill_region(int argc,const char* argv[]);
+void command_lcd_clear_region(int argc,const char* argv[]);
 void command_lcd_invert_region(int argc,const char* argv[]);
 
 
diff -r -u bootldr.orig/load_kernel/src/jffs2.c bootldr/load_kernel/src/jffs2.c
--- bootldr.orig/load_kernel/src/jffs2.c Wed Mar 6 21:11:49 2002
+++ bootldr/load_kernel/src/jffs2.c Thu Mar 7 12:53:51 2002
@@ -68,6 +68,8 @@
 #include "load_kernel.h"
 #include "jffs2.h"
 #include "crc32.h"
+/* lcd.h has LCD_XRES and LCD_YRES */
+#include "../../lcd.h"
 
 //#define D_PUTSTR(x) putstr((x))
 #define D_PUTSTR(x)
@@ -75,7 +77,12 @@
 #define D_PUTLABELEDWORD(x,y)
 // for the lcd progress bar
 #define LCD_PB_COLOR 0xfff
-#define LCD_PB_ROW 177
+/* default Compaq bootloader splash */
+#define LCD_PB_START_ROW 177
+#define LCD_PB_START_COL 0
+#define LCD_PB_END_ROW 202
+#define LCD_PB_END_COL LCD_XRES
+#define LCD_PB_DIRECTION LCD_HORIZONTAL
 
 static struct jffs2_raw_dirent *find_inode(struct part_info *part, const char *name,
                                            u32 pino);
@@ -1183,7 +1190,15 @@
     while (offset < max) {
         if (!(counter++ % 10000)){
             putstr(".");
- lcd_bar(LCD_PB_COLOR,(offset*100)/max,LCD_PB_ROW);
+ lcd_progress_bar(
+ LCD_PB_START_ROW,
+ LCD_PB_START_COL,
+ LCD_PB_END_ROW,
+ LCD_PB_END_COL,
+ (offset * 100) / max,
+ LCD_PB_DIRECTION,
+ LCD_PB_COLOR);
+
             button_check();
             if (get_last_buttonpress() > 0){
                 // unhilite the old
@@ -1321,7 +1336,11 @@
     // give visual feedback that we are done scanning the flash
     led_blink(0x0,0x0,0x1,0x1); // off, forever, on 100ms, off 100ms
     //reset the screen
- lcd_bar_clear(100,LCD_PB_ROW);
+ lcd_clear_region(
+ LCD_PB_START_ROW,
+ LCD_PB_START_COL,
+ LCD_PB_END_ROW,
+ LCD_PB_END_COL);
     // exec whatever button was pressed and unhilite it.
     if (last_button > 0){
         hilite_button(last_button);

-- 
Sacha Chua <sachac@iname.com>                   3 BS CS geekette =)
Ateneo Cervini-Eliazo Networks (ACENT) tel: 63(2) 426-6001 loc 5925
BOFH excuse #305: IRQ-problems with the Un-Interruptable-Power-Supply


This archive was generated by hypermail 2.1.5 : Fri Jan 17 2003 - 17:47:03 EST