static bool draw_cover_art(struct file_info *current_file_info) { #if defined(SUPPORT_EMBEDDED_COVER_ARTS) && SUPPORT_EMBEDDED_COVER_ARTS == true bool err = true; // Draw the background since not all covers will have the perfect size if ( ram_files[AUDIO_PLAYER_IMAGE].start_addr) { et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr, ET024006_WIDTH, COVER_POS_X, COVER_POS_Y, COVER_POS_X, COVER_POS_Y, COVER_WIDTH, COVER_HEIGHT); } // Do we have a valid ID3 tag with image information if (current_file_info->image_data) { err = false; et024006_PutPixmap((unsigned short *) current_file_info->image_data, current_file_info->size.width, 0, 0, COVER_POS_X, COVER_POS_Y, Min(COVER_WIDTH, current_file_info->size.width), Min(COVER_HEIGHT, current_file_info->size.height)); } // show a default cover if we did not find one or an error occurred if(err) { if (ram_files[COVER].start_addr) { et024006_PutPixmap(ram_files[COVER].start_addr, COVER_WIDTH, 0, 0, COVER_POS_X, COVER_POS_Y, COVER_WIDTH, COVER_HEIGHT); } } #endif return true; }
static bool draw_device_not_supported(void) { if (ram_files[STARTUP_IMAGE].start_addr) et024006_PutPixmap(ram_files[STARTUP_IMAGE].start_addr, ET024006_WIDTH, STARTUP_MESSAGE_X, STARTUP_MESSAGE_Y, STARTUP_MESSAGE_X, STARTUP_MESSAGE_Y, STARTUP_MESSAGE_WIDTH, STARTUP_MESSAGE_HEIGHT); if (ram_files[NOT_SUPPORTED].start_addr) et024006_PutPixmap(ram_files[NOT_SUPPORTED].start_addr, STARTUP_MESSAGE_NOT_SUPPORTED_WIDTH, 0, 0, STARTUP_MESSAGE_X, STARTUP_MESSAGE_Y, STARTUP_MESSAGE_NOT_SUPPORTED_WIDTH, STARTUP_MESSAGE_HEIGHT); return true; }
static bool draw_device_present(void) { if (ram_files[STARTUP_IMAGE].start_addr) et024006_PutPixmap(ram_files[STARTUP_IMAGE].start_addr, ET024006_WIDTH, STARTUP_MESSAGE_X, STARTUP_MESSAGE_Y, STARTUP_MESSAGE_X, STARTUP_MESSAGE_Y, STARTUP_MESSAGE_WIDTH, STARTUP_MESSAGE_HEIGHT); if (ram_files[LOADING].start_addr) et024006_PutPixmap(ram_files[LOADING].start_addr, STARTUP_MESSAGE_LOADING_WIDTH, 0, 0, STARTUP_MESSAGE_X, STARTUP_MESSAGE_Y, STARTUP_MESSAGE_LOADING_WIDTH, STARTUP_MESSAGE_HEIGHT); return true; }
static void draw_background(int image_id, int offset_x, int offset_y) { int map_x, map_y; int x, y, width, height; map_x = 0; map_y = 0; x = 0; y = 0; height = ET024006_HEIGHT; if (offset_x < 0) map_x = -offset_x; else x = offset_x; width = ET024006_WIDTH - Abs(offset_x); if (offset_y < 0) map_y = -offset_y; else y = offset_y; height = ET024006_HEIGHT - Abs(offset_y); if (ram_files[image_id].start_addr) et024006_PutPixmap(ram_files[image_id].start_addr, ET024006_WIDTH, map_x, map_y, x, y, width, height); // Draw the device type draw_device_type(); }
static bool clear_in_progress(enum gui_update_view view) { et024006_color_t const *pixmap; switch (view) { case GUI_UPDATE_VIEW_IDLE: case GUI_UPDATE_VIEW_IDLE_TRANSITION: pixmap = ram_files[STARTUP_IMAGE].start_addr; break; case GUI_UPDATE_VIEW_NAVIGATION: case GUI_UPDATE_VIEW_NAVIGATION_TRANSITION: pixmap = ram_files[DISK_NAV_IMAGE].start_addr; break; case GUI_UPDATE_VIEW_PLAYBACK: case GUI_UPDATE_VIEW_PLAYBACK_TRANSITION: pixmap = ram_files[AUDIO_PLAYER_IMAGE].start_addr; break; case GUI_UPDATE_VIEW_CONFIG: case GUI_UPDATE_VIEW_CONFIG_TRANSITION: pixmap = ram_files[CONFIG_IMAGE].start_addr; break; default: pixmap = ram_files[DISK_NAV_IMAGE].start_addr; } if (pixmap) et024006_PutPixmap(pixmap, ET024006_WIDTH, 0, 0, 0, 0, IN_PROGRESS_SPRITE_WIDTH, IN_PROGRESS_SPRITE_HEIGHT); return true; }
/*! \brief Draws the elements that need periodic update in the play view. * * Updates the current play time. */ static bool draw_playtime_update(struct file_info *current_file_info) { uint32_t hours, minutes, seconds, tmp, time_ms; char time_elapsed[32]; // get the time and put it into a printable format time_ms = current_file_info->elapsed_time; tmp = time_ms; hours = tmp / (1000 * 60 * 60); tmp %= 1000 * 60 * 60; minutes = tmp / (1000 * 60); tmp %= 1000 * 60; seconds = tmp / 1000; sprintf(time_elapsed,"%02lu:%02lu:%02lu",hours, minutes, seconds); // draw background behind the play time if(ram_files[AUDIO_PLAYER_IMAGE].start_addr) { et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr, ET024006_WIDTH, ELAPSED_TIME_POS_X, ELAPSED_TIME_POS_Y, ELAPSED_TIME_POS_X, ELAPSED_TIME_POS_Y, ELAPSED_TIME_WIDTH, ELAPSED_TIME_HEIGHT); } else { et024006_DrawFilledRect( ELAPSED_TIME_POS_X, ELAPSED_TIME_POS_Y, ELAPSED_TIME_WIDTH, ELAPSED_TIME_HEIGHT, (et024006_color_t)APPLI_BG_COLOR); } // draw the playtime et024006_PrintString(time_elapsed, (unsigned char *) TIME_FONT, ELAPSED_TIME_POS_X, ELAPSED_TIME_POS_Y, APPLI_FG_COLOR, -1); draw_song_progress_bar(current_file_info); return true; }
/*! \brief Draws the file list on the disk navigation view. */ static bool draw_file_list(struct display_file_list *lst_str) { size_t i; uint16_t pos_x, pos_y; // Find the 1rst line updated. for(i=0; i<lst_str->nb_elts; i++) if (lst_str->list[i].updated) break; // Compute the Y position the string to display. pos_x = FILE_LIST_POS_X + FILE_LIST_ITEM_X; pos_y = FILE_LIST_POS_Y + FILE_LIST_SPACING * i; // If it is the last line, then clear the rest of the list. if (i == lst_str->nb_elts) { if (ram_files[DISK_NAV_IMAGE].start_addr) et024006_PutPixmap(ram_files[DISK_NAV_IMAGE].start_addr, ET024006_WIDTH, pos_x, pos_y, pos_x, pos_y, FILE_LIST_WIDTH - FILE_LIST_ITEM_X, FILE_LIST_SPACING * (MAX_DISPLAY_FILE - lst_str->nb_elts)); else et024006_DrawFilledRect(pos_x, pos_y, FILE_LIST_WIDTH - FILE_LIST_ITEM_X, FILE_LIST_SPACING * (MAX_DISPLAY_FILE - lst_str->nb_elts), (et024006_color_t) APPLI_BG_COLOR); return true; } // Invalidate the item. lst_str->list[i].updated = false; // Draw only the 1rst line updated. // Print the background. if (ram_files[DISK_NAV_IMAGE].start_addr) et024006_PutPixmap(ram_files[DISK_NAV_IMAGE].start_addr, ET024006_WIDTH, pos_x, pos_y, pos_x, pos_y, FILE_LIST_WIDTH - FILE_LIST_ITEM_X, FILE_LIST_ITEM_HEIGHT); else et024006_DrawFilledRect(pos_x, pos_y, FILE_LIST_WIDTH - FILE_LIST_ITEM_X, FILE_LIST_ITEM_HEIGHT, (et024006_color_t) APPLI_BG_COLOR); // Draw the string. et024006_PrintString((char*) lst_str->list[i].file_name, (unsigned char *) FILE_LIST_FONT, pos_x, pos_y, APPLI_FG_COLOR, APPLI_BG_COLOR); return false; }
static void ui_display_welcome_msg(void) { /* Clear Display */ et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, WHITE); /* Picture of Cellphone */ et024006_PutPixmap(pic_cellphone, 80, 0, 0, 0, 0, 80, 99); /* Picture of USB Part */ et024006_PutPixmap(pic_usb_connector, 160, 0, 0, 160, 120, 160, 120); /* Draw Welcome String */ et024006_PrintString((char *)"Atmel Android", (const uint8_t *)&FONT8x16, 180, 30, BLUE, WHITE); et024006_PrintString((char *)"Accessory Demo", (const uint8_t *)&FONT8x16, 180, 50, BLUE, WHITE); /* Draw Plugin Android */ et024006_PrintString((char *)"Please connect", (const uint8_t *)&FONT8x16, 20, 170, BLUE, WHITE); et024006_PrintString((char *)"an Android Device", (const uint8_t *)&FONT8x16, 20, 190, BLUE, WHITE); }
void gui_display_infobox(void) { int i; #if BOARD != EVK1100 // Draw info box et024006_DrawFilledRect(SCROLL_X, SCROLL_Y, SCROLL_W, SCROLL_H, infobox_contents.bg_color); for (i = 0; i < INFO_MAX_LINES; i++) { if (strlen(infobox_contents.lines[i])) { int x; x = 160 - ((strlen(infobox_contents.lines[i]) / 2)*10); if (x < 0) x = 10; et024006_PrintString(infobox_contents.lines[i], (const unsigned char*)&FONT8x8, x, (i+1)*12+SCROLL_Y, INFO_FG_COLOR, infobox_contents.bg_color); } } if (info_bitmap.data && info_bitmap.data_len) { printk("Displaying pixmap (size %d)\n", info_bitmap.data_len); et024006_PutPixmap( (et024006_color_t *)info_bitmap.data, info_bitmap.width, // Map width 0, // map_x 0, // map_y 40, // x 40, // y info_bitmap.width, // width info_bitmap.height); // height } else { printk("Not displaying picture\n"); } #else dip204_clear_display(); for (i = 0; i < INFO_MAX_LINES; i++) { int len = strlen(infobox_contents.lines[i]); int col = (MAX_LINE_LEN/2) - (len/2); if ( col <= 0) col = 1; dip204_set_cursor_position(col,i+1); /* col,line */ dip204_write_string(infobox_contents.lines[i]); dip204_hide_cursor(); } #endif }
static bool draw_in_progress(enum gui_update_view view) { static uint8_t sprite_index = 0; // if file exists in RAM, we load it if(ram_files[IN_PROGRESS].start_addr) { et024006_PutPixmap(ram_files[IN_PROGRESS].start_addr, IN_PROGRESS_SPRITE_NB * IN_PROGRESS_SPRITE_WIDTH, IN_PROGRESS_SPRITE_WIDTH * sprite_index, 0, 0, 0, IN_PROGRESS_SPRITE_WIDTH, IN_PROGRESS_SPRITE_HEIGHT); sprite_index = (sprite_index + 1) % IN_PROGRESS_SPRITE_NB; } return true; }
/*! \brief Draws the song progress bar on the screen. * * \param init If true the progress bar is initialized which should be done after a song change * or after a new draw of the play view. If the progress bar should just be updated call with false * \param ptime Current play time in milliseconds. * \param current_file_info contains the total play time length */ static bool draw_song_progress_bar(struct file_info *current_file_info) { int song_bar_width; song_bar_width = (current_file_info->elapsed_time * SONG_BAR_WIDTH) / current_file_info->total_time; song_bar_width = Min(SONG_BAR_WIDTH, song_bar_width); et024006_DrawFilledRect(SONG_BAR_POS_X, SONG_BAR_POS_Y, song_bar_width, SONG_BAR_HEIGHT, SONG_BAR_FILL_COLOR); if (ram_files[AUDIO_PLAYER_IMAGE].start_addr) et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr, ET024006_WIDTH, SONG_BAR_POS_X + song_bar_width, SONG_BAR_POS_Y, SONG_BAR_POS_X + song_bar_width, SONG_BAR_POS_Y, SONG_BAR_WIDTH - song_bar_width, SONG_BAR_HEIGHT); return true; }
static bool draw_play_view_print_title(struct file_info *current_file_info) { char string[TITLE_CHARS_MAX+2]; strncpy(string, (const char *) current_file_info->title, TITLE_CHARS_MAX); string[TITLE_CHARS_MAX+1] = '\0'; // draw background behind the text if(ram_files[AUDIO_PLAYER_IMAGE].start_addr) et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr, ET024006_WIDTH, TITLE_POS_X, TITLE_POS_Y, TITLE_POS_X, TITLE_POS_Y, TITLE_WIDTH, TITLE_HEIGHT); if(string[0] != '\0') { et024006_PrintString(string, (unsigned char *) TITLE_FONT, TITLE_POS_X, TITLE_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR); } return true; }
static bool draw_play_view_print_file(struct file_info *current_file_info) { char string[NAME_CHARS_MAX+2]; strncpy(string, (const char *) current_file_info->name, NAME_CHARS_MAX); string[NAME_CHARS_MAX+1] = '\0'; // draw background behind the text if(ram_files[AUDIO_PLAYER_IMAGE].start_addr) et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr, ET024006_WIDTH, FILE_NAME_POS_X, FILE_NAME_POS_Y, FILE_NAME_POS_X, FILE_NAME_POS_Y, FILE_NAME_WIDTH, FILE_NAME_HEIGHT); // if no artist data is available we print the file name if(string[0] != '\0') { et024006_PrintString(string, (unsigned char *) FILE_NAME_FONT, FILE_NAME_POS_X, FILE_NAME_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR); } return true; }
static bool draw_config_view_print_repeat(struct player_info *player) { int offset_y; // Clear the previous repeat message if (ram_files[CONFIG_IMAGE].start_addr) et024006_PutPixmap(ram_files[CONFIG_IMAGE].start_addr, ET024006_WIDTH, REPEAT_POS_X + 10*REPEAT_FONT_WIDTH, REPEAT_POS_Y, REPEAT_POS_X + 10*REPEAT_FONT_WIDTH, REPEAT_POS_Y, REPEAT_FONT_WIDTH, REPEAT_MESSAGE_HEIGHT); // Print the message et024006_PrintString("Repeat: [ ] Off", (unsigned char *) REPEAT_FONT, REPEAT_POS_X, REPEAT_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR); et024006_PrintString(" [ ] Track", (unsigned char *) REPEAT_FONT, REPEAT_POS_X, REPEAT_POS_Y + REPEAT_FONT_HEIGHT, APPLI_FG_COLOR, APPLI_BG_COLOR); et024006_PrintString(" [ ] Folder", (unsigned char *) REPEAT_FONT, REPEAT_POS_X, REPEAT_POS_Y + 2*REPEAT_FONT_HEIGHT, APPLI_FG_COLOR, APPLI_BG_COLOR); et024006_PrintString(" [ ] All", (unsigned char *) REPEAT_FONT, REPEAT_POS_X, REPEAT_POS_Y + 3*REPEAT_FONT_HEIGHT, APPLI_FG_COLOR, APPLI_BG_COLOR); switch (player->repeat) { case AUDIO_REPEAT_TRACK: offset_y = 1*REPEAT_FONT_HEIGHT; break; case AUDIO_REPEAT_FOLDER: offset_y = 2*REPEAT_FONT_HEIGHT; break; case AUDIO_REPEAT_ALL: offset_y = 3*REPEAT_FONT_HEIGHT; break; case AUDIO_REPEAT_OFF: default: offset_y = 0; } // Draw cursor et024006_PrintString("X", (unsigned char *) REPEAT_FONT, REPEAT_POS_X + 10*REPEAT_FONT_WIDTH, REPEAT_POS_Y + offset_y, APPLI_FG_COLOR, APPLI_BG_COLOR); return true; }
static bool draw_pause_button(void) { if(ram_files[AUDIO_PLAYER_IMAGE].start_addr) { et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr, ET024006_WIDTH, PLAY_BUTTON_POS_X, PLAY_BUTTON_POS_Y, PLAY_BUTTON_POS_X, PLAY_BUTTON_POS_Y, PLAY_BUTTON_WIDTH, PLAY_BUTTON_HEIGHT); } else { et024006_DrawFilledRect(PLAY_BUTTON_POS_X, PLAY_BUTTON_POS_Y, PLAY_BUTTON_WIDTH, PLAY_BUTTON_HEIGHT, (et024006_color_t)APPLI_BG_COLOR); } et024006_DrawFilledRect(PAUSE_BUTTON_POS_X, PAUSE_BUTTON_POS_Y, PAUSE_BUTTON_PART_WIDTH, PAUSE_BUTTON_HEIGHT, PAUSE_BUTTON_COLOR); et024006_DrawFilledRect(PAUSE_BUTTON_POS_X + PAUSE_BUTTON_PART_WIDTH + PAUSE_BUTTON_SPACING, PAUSE_BUTTON_POS_Y, PAUSE_BUTTON_PART_WIDTH, PAUSE_BUTTON_HEIGHT, PAUSE_BUTTON_COLOR); return true; }
static bool draw_play_view_print_total_time(struct file_info *current_file_info) { uint32_t hours, minutes, seconds, tmp; char time_string[32]; tmp = current_file_info->total_time; hours = tmp / (1000 * 60 * 60); tmp %= 1000 * 60 * 60; minutes = tmp / (1000 * 60); tmp %= 1000 * 60; seconds = tmp / 1000; sprintf(time_string, "%02u:%02u:%02u", (unsigned int) hours, (unsigned int) minutes, (unsigned int) seconds); // Draw background behind the text. if(ram_files[AUDIO_PLAYER_IMAGE].start_addr) et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr, ET024006_WIDTH, TOTAL_TIME_POS_X, TOTAL_TIME_POS_Y, TOTAL_TIME_POS_X, TOTAL_TIME_POS_Y, TOTAL_TIME_WIDTH, TOTAL_TIME_HEIGHT); et024006_PrintString(time_string, (unsigned char *) TIME_FONT, TOTAL_TIME_POS_X, TOTAL_TIME_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR); return true; }
static bool draw_config_view_print_cursor(struct display_file_list *lst_str) { // Clear the previous cursor position if (ram_files[CONFIG_IMAGE].start_addr) et024006_PutPixmap(ram_files[CONFIG_IMAGE].start_addr, ET024006_WIDTH, CURSOR_POS_X, REPEAT_POS_Y, CURSOR_POS_X, REPEAT_POS_Y, CURSOR_FONT_WIDTH, CURSOR_RANGE_HEIGHT); switch (lst_str->mode_pos) { case MODE_POS_REPEAT: et024006_PrintString(">", (unsigned char *) CURSOR_FONT, CURSOR_POS_X, REPEAT_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR); break; case MODE_POS_SHUFFLE: et024006_PrintString(">", (unsigned char *) CURSOR_FONT, CURSOR_POS_X, SHUFFLE_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR); break; } return true; }
static bool draw_play_button(void) { if(ram_files[AUDIO_PLAYER_IMAGE].start_addr) { et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr, ET024006_WIDTH, PAUSE_BUTTON_POS_X, PAUSE_BUTTON_POS_Y, PAUSE_BUTTON_POS_X, PAUSE_BUTTON_POS_Y, PAUSE_BUTTON_WIDTH, PAUSE_BUTTON_HEIGHT); } else { et024006_DrawFilledRect(PAUSE_BUTTON_POS_X, PAUSE_BUTTON_POS_Y, PAUSE_BUTTON_WIDTH, PAUSE_BUTTON_HEIGHT, PAUSE_BUTTON_COLOR); } et024006_DrawVertLine( PLAY_BUTTON_POS_X+2, PLAY_BUTTON_POS_Y +1, 14, PAUSE_BUTTON_COLOR); et024006_DrawVertLine( PLAY_BUTTON_POS_X+3, PLAY_BUTTON_POS_Y+2, 12, PAUSE_BUTTON_COLOR); et024006_DrawVertLine( PLAY_BUTTON_POS_X+4, PLAY_BUTTON_POS_Y+3, 10, PAUSE_BUTTON_COLOR); et024006_DrawVertLine( PLAY_BUTTON_POS_X+5, PLAY_BUTTON_POS_Y+4, 9, PAUSE_BUTTON_COLOR); et024006_DrawVertLine( PLAY_BUTTON_POS_X+6, PLAY_BUTTON_POS_Y+5, 7, PAUSE_BUTTON_COLOR); et024006_DrawVertLine( PLAY_BUTTON_POS_X+7, PLAY_BUTTON_POS_Y+5, 6, PAUSE_BUTTON_COLOR); et024006_DrawVertLine( PLAY_BUTTON_POS_X+8, PLAY_BUTTON_POS_Y+6, 4, PAUSE_BUTTON_COLOR); et024006_DrawVertLine( PLAY_BUTTON_POS_X+9, PLAY_BUTTON_POS_Y+7, 3, PAUSE_BUTTON_COLOR); return true; }
/*! \brief Draws the volume bar on the playing view. */ static bool draw_volume_bar(struct file_info *current_file_info) { uint8_t volume; // the volume is in dB and ranges from +6 to -72 and has an extra value for muted which is the // smallest int8_t value volume = current_file_info->volume; if(ram_files[AUDIO_PLAYER_IMAGE].start_addr) { et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr, ET024006_WIDTH, VOLUME_BAR_POS_X, VOLUME_BAR_POS_Y, VOLUME_BAR_POS_X, VOLUME_BAR_POS_Y, VOLUME_BAR_WIDTH, VOLUME_BAR_HEIGHT); } if(volume == VOLUME_MUTED) { } if(volume > VOLUME_LEVEL_1) { et024006_DrawFilledRect( VOLUME_BAR_POS_X, VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL1_HEIGHT, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL1_HEIGHT, VOLUME_BAR_COLOR); } if(volume > VOLUME_LEVEL_2) { et024006_DrawFilledRect( VOLUME_BAR_POS_X + VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING, VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL2_HEIGHT, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL2_HEIGHT, VOLUME_BAR_COLOR); } if(volume > VOLUME_LEVEL_3) { et024006_DrawFilledRect( VOLUME_BAR_POS_X + 2* (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING)+ 1, VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL3_HEIGHT, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL3_HEIGHT, VOLUME_BAR_COLOR); } if(volume > VOLUME_LEVEL_4) { et024006_DrawFilledRect( VOLUME_BAR_POS_X + 3 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +1, VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL4_HEIGHT, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL4_HEIGHT, VOLUME_BAR_COLOR); } if(volume > VOLUME_LEVEL_5) { et024006_DrawFilledRect( VOLUME_BAR_POS_X + 4 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +1, VOLUME_BAR_POS_Y +VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL5_HEIGHT, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL5_HEIGHT, VOLUME_BAR_COLOR); } if(volume > VOLUME_LEVEL_6) { et024006_DrawFilledRect( VOLUME_BAR_POS_X + 5 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +1, VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL6_HEIGHT, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL6_HEIGHT, VOLUME_BAR_COLOR); } if(volume > VOLUME_LEVEL_7) { et024006_DrawFilledRect( VOLUME_BAR_POS_X + 6 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +1, VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL7_HEIGHT, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL7_HEIGHT, VOLUME_BAR_COLOR); } if(volume > VOLUME_LEVEL_8) { et024006_DrawFilledRect( VOLUME_BAR_POS_X + 7 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +2, VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL8_HEIGHT, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL8_HEIGHT, VOLUME_BAR_COLOR); } if(volume > VOLUME_LEVEL_9) { et024006_DrawFilledRect( VOLUME_BAR_POS_X + 8 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +2, VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL9_HEIGHT, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL9_HEIGHT, VOLUME_BAR_COLOR); } if(volume >= VOLUME_LEVEL_10) { et024006_DrawFilledRect( VOLUME_BAR_POS_X + 9 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING)+2, VOLUME_BAR_POS_Y, VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL10_HEIGHT, VOLUME_BAR_COLOR); } return true; }
//! //! @brief This function displays the MMI interface and some static informations. //! static void mmi_display( void ) { #if (defined __GNUC__) || ((defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_SOFT_ADD_DEL_SAMPLES)) char tmp[64]; #endif if( mmi_state!=11 ) { if( mmi_state==0 ) { cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); mmi_state++; } else if( cpu_is_timeout(&timer) ) { switch( mmi_state++ ) { case 1: LED_On( LED0 ); cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); // Clear the display et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, WHITE ); // Display a logo. et024006_PutPixmap(avr32_logo, AVR32_LOGO_WIDTH, 0, 0 ,(ET024006_WIDTH - AVR32_LOGO_WIDTH)/2 ,(ET024006_HEIGHT - AVR32_LOGO_HEIGHT)/2, AVR32_LOGO_WIDTH, AVR32_LOGO_HEIGHT); et024006_PrintString(AUDIO_DEMO_STRING , (const unsigned char *)&FONT8x16, 30, 5, BLACK, -1); #if(defined USB_RESYNC_METHOD) #if (defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_EXT_CLOCK_SYNTHESIZER) et024006_PrintString("32/44.1/48 KHz, HID, CS2200" , (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+0*FONT_HEIGHT, BLUE, -1); #elif (defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_SOFT_ADAPTIF_SRC) et024006_PrintString("%32/44.1/48 KHz, HID, adaptive SRC", (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+0*FONT_HEIGHT, BLUE, -1); #elif (defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_SOFT_ADD_DEL_SAMPLES) sprintf( tmp, "%d.%d KHz, HID, Add/remove sample", SPEAKER_FREQUENCY/1000, SPEAKER_FREQUENCY%1000); et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+0*FONT_HEIGHT, BLUE, -1); #else #error Unknown synchronization method. #endif #endif // Display bargraph window. mmi_activity_display(true, (uint32_t)NULL); #if (defined __GNUC__) sprintf( tmp, "RAM (DATA): %ld bytes", (uint32_t)&_edata-(uint32_t)&_data); et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+10*FONT_HEIGHT, BLUE, -1); sprintf( tmp, "RAM (BSS): %ld bytes", (uint32_t)&end-(uint32_t)&__bss_start); et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+11*FONT_HEIGHT, BLUE, -1); sprintf( tmp, "RAM (STACK): %ld bytes", (uint32_t)&_estack-(uint32_t)&_stack); et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+12*FONT_HEIGHT, BLUE, -1); #endif #if (defined __GNUC__) et024006_PrintString("RAM (total used HEAP): bytes", (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+13*FONT_HEIGHT, BLUE, WHITE); et024006_PrintString("RAM (curr used HEAP): bytes", (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+14*FONT_HEIGHT, BLUE, WHITE); #elif (defined __ICCAVR32__) et024006_PrintString("RAM (free HEAP): bytes", (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+14*FONT_HEIGHT, BLUE, WHITE); #endif break; case 2: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_On( LED1 ); break; case 3: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_On( LED2 ); break; case 4: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_On( LED3 ); break; case 5: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_Off( LED0 ); break; case 6: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_Off( LED1 ); break; case 7: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_Off( LED2 ); break; case 8: LED_Off( LED3 ); cpu_stop_timeout(&timer); break; default: break; } } } }
/*! \brief Main function. Execution starts here. * * \retval 42 Fatal error. */ int main(void) { init_hmatrix(); // Configure standard I/O streams as unbuffered. #if (defined __GNUC__) && (defined __AVR32__) setbuf(stdin, NULL); #endif setbuf(stdout, NULL); #if (defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_EXT_CLOCK_SYNTHESIZER) // Initialize the TWI using the internal RCOSC init_twi_CS2200(AVR32_PM_RCOSC_FREQUENCY); // Initialize the CS2200 and produce a default 11.2896 MHz frequency cs2200_setup(11289600, FOSC0); #endif // Initializes the MCU system clocks init_sys_clocks(); // Initialize the TWI init_twi(FPBA_HZ); audio_mixer_enable_dacs(DEFAULT_DACS); audio_mixer_dacs_start(DEFAULT_DAC_SAMPLE_RATE_HZ, DEFAULT_DAC_NUM_CHANNELS, DEFAULT_DAC_BITS_PER_SAMPLE, DEFAULT_DAC_SWAP_CHANNELS); // Initialize the display et024006_Init( FCPU_HZ, FHSB_HZ); // Set Backlight gpio_set_gpio_pin(ET024006DHU_BL_PIN); // Clear the display et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, WHITE ); // Display a logo. et024006_PutPixmap(avr32_logo, AVR32_LOGO_WIDTH, 0, 0 ,(ET024006_WIDTH - AVR32_LOGO_WIDTH)/2 ,(ET024006_HEIGHT - AVR32_LOGO_HEIGHT)/2, AVR32_LOGO_WIDTH, AVR32_LOGO_HEIGHT); et024006_PrintString(AUDIO_DEMO_STRING, (const unsigned char *)&FONT8x16, 30, 5, BLACK, -1); et024006_PrintString("Please plug the USB.", (const unsigned char *)&FONT8x8, 30, 30, BLACK, -1); // Initialize USB task usb_task_init(); // Initialize Controller controller_init(FCPU_HZ, FHSB_HZ, FPBB_HZ, FPBA_HZ); #if USB_DEVICE_FEATURE == true // Initialize device audio USB task device_audio_task_init(); // Initialize the HID USB task device_hid_task_init(); #endif #if USB_HOST_FEATURE == true // Initialize host audio USB task host_audio_task_init(); #endif #ifdef FREERTOS_USED // Start OS scheduler vTaskStartScheduler(); portDBG_TRACE("FreeRTOS returned."); return 42; #else // No OS here. Need to call each task in round-robin mode. while (true) { usb_task(); #if USB_DEVICE_FEATURE == true device_audio_task(); device_hid_task(); #endif #if USB_HOST_FEATURE == true host_audio_task(); #endif } #endif // FREERTOS_USED }
//! //! @brief Entry point of the MMI task management //! void mmi_task(void) { uint32_t i; switch( mmi_state ) { case MMI_TOP_MENU_START: // Draw the background AVR32 logo. et024006_PutPixmap(avr32_logo, 320, 0, 0, 0, 0, 320, 240); // Display welcome string. et024006_PrintString("EVK1104 Demo", (const unsigned char *)&FONT8x8, 110, 220, BLACK, -1); mmi_state = MMI_TOP_MENU; break; case MMI_TOP_MENU: if( Is_usb_vbus_high() ) { mmi_state = MMI_MASS_STORAGE_START; } break; case MMI_MASS_STORAGE_START: // Draw the background AVR32 logo. et024006_PutPixmap(avr32_logo, 320, 0, 0, 0, 0, 320, 240); // Display USB key logo. et024006_DrawFilledRect(220-1, 20-1, 80+2, 42+2, BLACK ); et024006_PutPixmap(ms_key_logo, 80, 0, 0, 220, 20, 80, 42); // Display title. et024006_PrintString("U-Disk", (const unsigned char *)&FONT6x8, 240, 65, BLACK, -1); // Display Activity window. display_box(80, 180, 156, 16, WHITE, BLACK); // Display performances box. display_perf(120, 201, true, 0, 0); ms_old_cnt_read = ms_cnt_read =0; ms_old_cnt_write = ms_cnt_write =0; mmi_state = MMI_MASS_STORAGE; ms_cnt_screen = 0; for( i=0 ; i<MS_N_PROGRESS_BAR ; i++ ) { ms_progress_bar_level[i] = 1; ms_progress_bar_type[i] = BLACK; } mmi_ms_display(); cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_UPDATE, pm_freq_param.cpu_f), &ms_activity_timer); cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_CLEAR, pm_freq_param.cpu_f), &ms_clear_timer); break; case MMI_MASS_STORAGE: // Manage progress-bar shading. // if( cpu_is_timeout(&ms_clear_timer) ) { cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_CLEAR, pm_freq_param.cpu_f), &ms_clear_timer); mmi_ms_display(); } // Manage progress-bar box moving. // if( cpu_is_timeout(&ms_activity_timer) ) { cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_UPDATE, pm_freq_param.cpu_f), &ms_activity_timer); if( ms_old_cnt_write != ms_cnt_write ) { ms_cnt_screen = (unsigned char)(ms_cnt_screen-1)%MS_N_PROGRESS_BAR; ms_progress_bar_type[ms_cnt_screen] = RED; // Compute performances // perf_write = (U64)(ms_cnt_write - ms_old_cnt_write)*SD_MMC_SECTOR_SIZE/TIMER_MS_PROGRESS_BAR_UPDATE; display_perf(120, 201, false, perf_write, RED); ms_old_cnt_write = ms_cnt_write; ms_progress_bar_level[ms_cnt_screen] = (perf_write>10000) ? 31 : (perf_write> 7500) ? 29 : (perf_write> 5000) ? 27 : 25 ; } else if( ms_old_cnt_read != ms_cnt_read ) { ms_cnt_screen = (unsigned char)(ms_cnt_screen+1)%MS_N_PROGRESS_BAR; ms_progress_bar_type[ms_cnt_screen] = BLUE; // Compute performances // perf_read = (U64)(ms_cnt_read - ms_old_cnt_read)*SD_MMC_SECTOR_SIZE/TIMER_MS_PROGRESS_BAR_UPDATE; display_perf(120, 201, false, perf_read, BLUE); ms_old_cnt_read = ms_cnt_read; ms_progress_bar_level[ms_cnt_screen] = (perf_read>10000) ? 31 : (perf_read> 7500) ? 29 : (perf_read> 5000) ? 27 : 25 ; } else { display_perf(120, 201, true, 0, 0); } } // Detect USB unplug. // if( Is_usb_vbus_low() ) { mmi_state = MMI_TOP_MENU_START; } break; default: break; } }