/*This file is prepared for Doxygen automatic documentation generation.*/
/*! \file ******************************************************************
 *
 * \brief uShell command line interpreter.
 *
 * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32
 * - Supported devices:  All AVR32 devices with a USB module can be used.
 * - AppNote:
 *
 * \author               Atmel Corporation: http://www.atmel.com \n
 *                       Support and FAQ: http://support.atmel.no/
 *
 ***************************************************************************/

/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. The name of Atmel may not be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * 4. This software may only be redistributed and used in connection with an Atmel
 * AVR product.
 *
 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
 *
 */

#ifndef _COM_TASK_H_
#define _COM_TASK_H_


//_____ I N C L U D E S ____________________________________________________

#include "conf_audio_player.h"
#include "audio_interface.h"

#define MAX_BUFFER_FILE   10
#define MAX_DISPLAY_FILE  10
#define STR_MAX_LENGTH    24

enum file_type
{
  FILE_TYPE_DIRECTORY,
  FILE_TYPE_FILE,
  FILE_TYPE_PLAYLIST
};

struct file_elt
{
  // File name.
  U8 file_name[STR_MAX_LENGTH];
  // Defines if the type of the file selected.
  enum file_type type;
  // This flag tells the GUI if this element has been updated.
  Bool updated;
};

struct file_list
{
  // File list.
  struct file_elt list[MAX_BUFFER_FILE];
  // File position of the 1rst element of the list.
  U16 file_pos;
  // The umber of valid entries on this list.
  U16 nb_valid_entries;
  // Number of files in the direcotory. This number is not always right and
  // it is calculated when the list has been fully explored.
  U16 nb_files;
};

struct display_file_list
{
  struct file_elt *list;
  union
  {
    U16 nb_elts;
    // Cursor selection of the mode configuration.
    enum
    {
      MODE_POS_REPEAT,
      MODE_POS_SHUFFLE
    } mode_pos;
  };
};

struct file_info
{
  U32 total_time;
  U32 elapsed_time;
  U16 file_pos;
  U8 volume;
  U8 name[STR_MAX_LENGTH];
  U8 artist[STR_MAX_LENGTH];
  U8 title[STR_MAX_LENGTH];
  ai_image_size_t size;
  void *image_data;
};

struct player_info
{
  Ai_player_flag_t flags;
  Ai_repeat_mode repeat;
  Ai_shuffle_mode shuffle;
};

void com_task_init(void);
void com_task(void);

#endif  // _COM_TASK_H_
