void show_osd(int played, int duration, char* title) { if (MAIN_OSD == NULL) { // Calling ``init_osd`` everytime seems wasteful, but it is needed to // ensure that the OSD is visible. The main issue is that if the player // is stopped and then restarted, the graphics library needs to be // reinitalized, otherwise the OSD is not drawn ontop of the video. init_osd(); } OSD* osd = MAIN_OSD; if (played > duration) { played = duration; } osd->duration = duration; osd->played = played; osd->title = title; Start(osd->width, osd->height); Fill(255,255,255,1); Text(32, 120+82+20, "PAUSED", OpenSansBold, 16); // Main OSD background Fill(0, 0, 0, 0.5); Roundrect(22, 82, osd->width-44, 120, 15, 15); /////////////////////////////////////////////////////////////////////// // Header /////////////////////////////////////////////////////////////////////// Fill(0, 0, 0, 1); Roundrect(22, 120+82-20, osd->width-44, 20, 15, 15); // Top of the header Rect(22, 120+82-(54+10), osd->width-44, 54); // Bottom of header // Current time get_time(osd->time_now, 0); Fill(102, 102, 102, 1); Text(46, 162, osd->time_now, OpenSansSemiBold, 14); // End time if (duration > 0) { get_time(osd->time_end, osd->duration-osd->played); TextEnd(osd->width-46, 162, osd->time_end, OpenSansSemiBold, 14); } // Title text Fill(255, 255, 255, 1); int title_width = TextWidth(osd->title, OpenSansSemiBold, 20); Text((osd->width/2)-(title_width/2), 162, osd->title, OpenSansSemiBold, 20); /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Progress Bar /////////////////////////////////////////////////////////////////////////// if (duration > 0) { int pbar_width = osd->width-288; float pct_player = (float)played/duration; Fill(255, 255, 255, 0.2); // Transparent bg Roundrect(142, 102, pbar_width, 12, 10, 10); // Centered Fill(209, 125, 30, 1); // Orange bar (progress) Roundrect(142, 102, pbar_width*pct_player, 12, 10, 10); // Left justified // Progress text seconds_to_str(osd->pos_now, osd->played); seconds_to_str(osd->pos_end, osd->duration-osd->played); // Text shadow Fill(0, 0, 0, 1); Text(46-1, 102-1, osd->pos_now, OpenSansSemiBold, 12); TextEnd(osd->width-46-1, 102-1, osd->pos_end, OpenSansSemiBold, 12); // Actual text Fill(255,255,255,1); Text(46, 102, osd->pos_now, OpenSansSemiBold, 12); TextEnd(osd->width-46, 102, osd->pos_end, OpenSansSemiBold, 12); } ////////////////////////////////////////////////////////////////////// End(); }
/* ======================================================================== Name: initFtaLib Description: Initialize all IO peripherals related to FTA ======================================================================== */ void initFtaLib(void) { U32 flag = 0; I8 *env; I8 selftest = SELFTEST_ON; I8 selfstart = SELFSTART_V2F; I8 *arg[] = {"run", "bootcmd"}; /* We are "saving" the current configuration, because it is not valid after a setenv() */ env = getenv("selftest"); if(env) selftest = env[0]; env = getenv("selfstart"); if(env) selfstart = env[0]; #if defined(USE_DISPLAY) /* Init the use of the video */ init_display(); setVideoPio(); /* Display something on screen */ init_osd(); display = TRUE; #endif splash_update(64); /* Go to the prompt (Do not start automatically any application) */ if( (getKeyPressed() & FP_KEY_DOWN) || (selfstart == SELFSTART_UBOOT) ) { setenv("bootcmd", NULL); return; } splash_update(128); /* U-Boot Self test */ if(selftest == SELFTEST_ON) { if( test_fta() ) { hang(); } else { setenv("selftest","0"); saveenv(); } } if( getKeyPressed() & FP_KEY_POWER ) { usbApp(); } splash_update(256); if(selfstart == SELFSTART_NFS) { /* Set the Kernel (DEV) as the main application */ setenv("bootcmd","bootm 0x80000"); } else { /* Set the V2F as the main application * The address provided is in the RAM, so clear it to avoid confusion * (in case of some remaining data) */ memset((void *)0x80801000, 0, sizeof(ssa_header_t)); setenv("bootcmd","bootm 0x80801000"); } /* Set the Loader as the main application */ if( getKeyPressed() & FP_KEY_UP ) { setenv("bootcmd","bootm 0x2C0000"); } /* Set the Loader as the main application */ if (!eeprom_read(CFG_I2C_EEPROM_ADDR, EEPROM_SSD_REG, (unsigned char*)&flag, sizeof(flag))) { if(flag == FORCE_UPDATE_CODE) { setenv("bootcmd","bootm 0x2C0000"); } } do_run (NULL, 0, 2, arg); }
int main() { long int delay; int brg; // Call the various initialization functions. init_osd(); setup_pll(); setup_io(); setup_int(); init_gfx(1); // Turn on doze, with a 1:1 ratio. CLKDIVbits.DOZEN = 0; CLKDIVbits.DOZE = 0b000; // Start in console mode. Print startup messages. con_init(); con_rolling = 0; con_puts("Super OSD v3.2-lite", 0); con_puts("dsPIC33F side", 0); con_puts("Copr. 2010 Tom O.", 0); ; con_puts("COMPILED FOR: ENGLISH", 0); con_puts("", 0); con_puts("Booting kernel [ OK ]", 0); con_puts("Verify 24F [ OK ]", 0); con_puts("Verify 33F [ OK ]", 0); con_puts("Switch to hi res [ OK ]", 0); init_gfx(0); if(mem_test_full()) { con_puts("VRAM test [ OK ]", 0); } else { con_puts("VRAM test [FAIL]", 0); con_puts("Check memory soon! ", 0); // Show warning for some time delay = 2000000; while(delay--); } // Clear graphics buffers of any memory test data remaining. init_gfx(0); con_puts("Init UART [ OK ]", 0); // BUG: occasionally resets processor on start up //interface_init_uart(); //brg = interface_set_baudrate(1843200); //sprintf(temp, "BRG=%d", brg); //con_puts(temp, 0); /* con_puts("PC detect... [FAIL]", 0); con_puts("GPS detect... [ OK ]", 0); con_puts("SPI initialized [ OK ]", 0); con_puts("Found flash mem [ OK ]", 0); con_puts(" Size: 2048 KB [ OK ]", 0); con_puts("USB not supported [SKIP]", 0); con_puts("Init GPS [ OK ]", 0); con_puts("Test I2C [ OK ]", 0); con_puts(" Xbee Adap. 2.0 [ OK ]", 0); con_puts(" LSM303 acc [ OK ]", 0); con_puts(" LSM303 mag [ OK ]", 0); con_puts(" ITG3200 gyro [FAIL]", 0); con_puts("Loading settings [ OK ]", 0); con_puts("Init splash [ OK ]", 0); */ // Demo HUD. //buffer_mode(0); con_puts("Launching hud_demo", 0); delayhowlong = 10000; hud_demo(); }