X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=app%2Fdemo%2Fdemo.c;h=dc0f79a2ff3f88a5b99cb3ba50a124992104fd54;hb=6b2099c56772961182353617a8d4b839f6a1a6db;hp=1e7ad2c43a6324678ea2194a33220ab5bcb35386;hpb=c49c99e64ee64ad490b2aea2d6c6d8f9f6d225db;p=bertos.git diff --git a/app/demo/demo.c b/app/demo/demo.c index 1e7ad2c4..dc0f79a2 100755 --- a/app/demo/demo.c +++ b/app/demo/demo.c @@ -14,6 +14,15 @@ /*#* *#* $Log$ + *#* Revision 1.4 2006/04/27 05:43:07 bernie + *#* Fix naming conventions. + *#* + *#* Revision 1.3 2006/04/11 00:07:32 bernie + *#* Implemenent MF_SAVESEL flag. + *#* + *#* Revision 1.2 2006/03/27 04:49:50 bernie + *#* Add bouncing logo demo. + *#* *#* Revision 1.1 2006/03/22 09:52:13 bernie *#* Add demo application. *#* @@ -32,7 +41,7 @@ #include #include #include -#include +#include #include #include @@ -41,27 +50,27 @@ static struct MenuItem settings_items[] = { - { (const_iptr_t)"settings_0", 0, (MenuHook)0, (iptr_t)0 }, - { (const_iptr_t)"settings_1", 0, (MenuHook)0, (iptr_t)0 }, - { (const_iptr_t)"settings_2", 0, (MenuHook)0, (iptr_t)0 }, - { (const_iptr_t)"settings_3", 0, (MenuHook)0, (iptr_t)0 }, - { (const_iptr_t)"settings_4", 0, (MenuHook)0, (iptr_t)0 }, - { (const_iptr_t)"settings_5", MIF_TOGGLE, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"System", 0, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"Mouse", 0, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"Keyboard", 0, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"Networking", 0, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"Date & Time",0, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"Power Saving", MIF_TOGGLE, (MenuHook)0, (iptr_t)0 }, { (const_iptr_t)0, 0, NULL, (iptr_t)0 } }; -static struct Menu settings_menu = { settings_items, "Settings Menu", MF_STICKY, &lcd_bitmap, 0 }; +static struct Menu settings_menu = { settings_items, "Settings Menu", MF_STICKY | MF_SAVESEL, &lcd_bitmap, 0 }; /*** DISPLAY MENU ****************************/ static struct MenuItem display_items[] = { - { (const_iptr_t)"display_0", 0, (MenuHook)0, (iptr_t)0 }, - { (const_iptr_t)"display_1", 0, (MenuHook)0, (iptr_t)0 }, - { (const_iptr_t)"display_2", 0, (MenuHook)0, (iptr_t)0 }, - { (const_iptr_t)"display_3", 0, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"Background", 0, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"Colors", 0, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"Style", 0, (MenuHook)0, (iptr_t)0 }, + { (const_iptr_t)"Icon Theme", 0, (MenuHook)0, (iptr_t)0 }, { (const_iptr_t)0, 0, NULL, (iptr_t)0 } }; -static struct Menu display_menu = { display_items, "Display Menu", MF_STICKY, &lcd_bitmap, 0 }; +static struct Menu display_menu = { display_items, "Display Menu", MF_SAVESEL, &lcd_bitmap, 0 }; /*** SETUP MENU ******************************/ @@ -74,7 +83,7 @@ static struct MenuItem setup_items[] = { (const_iptr_t)"Setup 3", 0, (MenuHook)NULL, (iptr_t)0 }, { (const_iptr_t)0, 0, NULL, NULL } }; -static struct Menu setup_menu = { setup_items, "Setup Menu", MF_STICKY, &lcd_bitmap, 0 }; +static struct Menu setup_menu = { setup_items, "Setup Menu", MF_STICKY | MF_SAVESEL, &lcd_bitmap, 0 }; /*** MAIN MENU *******************************/ @@ -103,20 +112,13 @@ Window root_win; void schedule(void) { // win_compose(&root_win); - lcd_blit_bitmap(root_win.bitmap); + lcd_blitBitmap(root_win.bitmap); emul_idle(); usleep(10000); } -int main(int argc, char *argv[]) +void hello_world(void) { - emul_init(&argc, argv); - timer_init(); - buz_init(); - kbd_init(); - lcd_init(); - proc_init(); - gfx_bitmapClear(&lcd_bitmap); extern const Font font_10x20; extern const Font font_helvB10; @@ -130,14 +132,61 @@ int main(int argc, char *argv[]) text_xprintf(&lcd_bitmap, 1, 0, STYLEF_BOLD | TEXT_FILL | TEXT_CENTER, "Hello, world!"); for (int i = 0; i < 1000; ++i) { - lcd_blit_bitmap(&lcd_bitmap); + lcd_blitBitmap(&lcd_bitmap); emul_idle(); } - gfx_blitRaster(&lcd_bitmap, 0, 0, customer_pw_logo, 122, 32, 4); - lcd_blit_bitmap(&lcd_bitmap); - emul_idle(); - sleep(1); - //timer_delay(1000); +} + +/** + * Show the splash screen + */ +void bouncing_logo(void) +{ + const long SPEED_SCALE = 1000; + const long GRAVITY_ACCEL = 10; + const long BOUNCE_ELASTICITY = 2; + long h = (long)(-project_grl_logo.height) * SPEED_SCALE; + long speed = 1000; + + /* Repeat until logo stands still on the bottom edge */ + while (!((speed == 0) && (h == 0))) + { + /* Move */ + h += speed; + + /* Gravity acceleration */ + speed += GRAVITY_ACCEL; + + if (h > 0 && speed > 0) + { + /* Bounce */ + speed = - (speed / BOUNCE_ELASTICITY); + + } + + /* Update graphics */ + gfx_bitmapClear(&lcd_bitmap); + gfx_blitImage(&lcd_bitmap, + (lcd_bitmap.width - project_grl_logo.width) / 2, + h / SPEED_SCALE, + &project_grl_logo); + lcd_blitBitmap(&lcd_bitmap); + + timer_delay(10); + } +} + +int main(int argc, char *argv[]) +{ + emul_init(&argc, argv); + timer_init(); + buz_init(); + kbd_init(); + lcd_init(); + proc_init(); + + hello_world(); + bouncing_logo(); const coord_t small_left = 45, small_top = 30, small_width = 50, small_height = 30; const coord_t large_left = -10, large_top = 10, large_width = 85, large_height = 41; @@ -216,7 +265,7 @@ int main(int argc, char *argv[]) win_raise(&large_win); win_compose(&root_win); - lcd_blit_bitmap(root_win.bitmap); + lcd_blitBitmap(root_win.bitmap); emul_idle(); usleep(10000); }