Atmel Software Framework

applications/uc3-audio-player/nav_automatic.c File Reference
#include "compiler.h"
#include "wdt.h"
#include "conf_explorer.h"
#include "nav_automatic.h"
#include "file.h"
#include <LIB_CTRLACCESS>
#include <LIB_MEM>

Macros

#define FS_NAV_AUTOMATIC_NBFILE   DISABLE
 The FS_NAV_AUTOMATIC_NBFILE define changes the rule to create a file list from directories When this define is enabled, the files from a directory are included before files from sub directories. More...
 

Typedefs

typedef
navauto_mov_explorer_rec_t(* 
navauto_mov_explorer_process_fct_t )(bool)
 

Enumerations

enum  navauto_mov_explorer_rec_t {
  NAVAUTO_MOV_EXPLORER_OK,
  NAVAUTO_MOV_EXPLORER_ERROR,
  NAVAUTO_MOV_EXPLORER_RECURSIVE,
  NAVAUTO_MOV_EXPLORER_OK,
  NAVAUTO_MOV_EXPLORER_OK_LOOP,
  NAVAUTO_MOV_EXPLORER_EMPTY,
  NAVAUTO_MOV_EXPLORER_ERROR,
  NAVAUTO_MOV_EXPLORER_RECURSIVE
}
 

Functions

uint16_t navauto_close (void)
 This function closes the file list. More...
 
Navauto_mode navauto_getmode (void)
 This function returns the directory limitation of the file list. More...
 
uint16_t navauto_getnb (void)
 This function returns the file list size. More...
 
uint16_t navauto_getpos (void)
 This function returns the current position in the file list. More...
 
Navauto_rand navauto_getrand (void)
 This function returns the random state used. More...
 
void navauto_init (const FS_STRING sz_filterext)
 This function initializes the file extension filter used to create the file list. More...
 
Navauto_mov_state navauto_mov (bool b_direction, navauto_mov_options_t options)
 This function jumps to the next or previous file in file list. More...
 
Navauto_mov_state navauto_mov_explorer (bool b_direction, navauto_mov_options_t options)
 This function jumps to the next or previous file in file list included in directories. More...
 
static navauto_mov_explorer_rec_t navauto_mov_explorer_enterdir (bool b_direction)
 This function enters in a the selected directory. More...
 
static __inline__
navauto_mov_explorer_rec_t 
navauto_mov_explorer_is_dir (bool b_direction, navauto_mov_options_t options)
 
static __inline__
navauto_mov_explorer_rec_t 
navauto_mov_explorer_is_file (bool b_direction, navauto_mov_options_t options)
 
static navauto_mov_explorer_rec_t navauto_mov_explorer_limit (bool b_direction)
 This function sets the pointer to a limit. More...
 
static __inline__
navauto_mov_explorer_rec_t 
navauto_mov_explorer_new_dir (bool b_direction, navauto_mov_options_t options)
 
static uint8_t navauto_mov_explorer_rec (bool b_direction, navauto_mov_options_t options)
 This function selects a file in EXPLORER mode. More...
 
void navauto_mov_explorer_reset (void)
 This function goes to the beginning of file list. More...
 
static navauto_mov_explorer_rec_t navauto_mov_explorer_select_limit_dir_cur_folder (bool b_direction)
 This function selects the first or the last directory on the current folder and enters in it. More...
 
static navauto_mov_explorer_rec_t navauto_mov_explorer_select_limit_file_cur_folder (bool b_direction)
 This function selects the first or the last playable file on the current folder. More...
 
static navauto_mov_explorer_rec_t navauto_mov_explorer_updir (bool b_direction)
 This function moves back to the parent directory and selects this directory. More...
 
static __inline__
navauto_mov_explorer_rec_t 
navauto_mov_ok_loop (bool b_direction, navauto_mov_options_t options)
 
Navauto_mov_state navauto_mov_playlist (bool b_direction)
 This function jumps to the next or previous file in file list corresponding at a play list file. More...
 
bool navauto_open (bool b_playlist, uint16_t pos)
 This function opens a file list at the current position in navigator. More...
 
uint16_t navauto_rand_choose (uint16_t u16_current_pos, uint16_t u16_period)
 This function returns a random position not already used. More...
 
void navauto_rand_init (void)
 This function resets the random bit table. More...
 
bool navauto_setmode (Navauto_mode exp_mode)
 This function sets the directory limitation of the file list. More...
 
bool navauto_setpos (uint16_t u16_pos)
 This function selects a new position in file list. More...
 
void navauto_setrand (Navauto_rand rand)
 This function changes the random state. More...
 

Variables

static Navauto_mov_bitfield_status bitfield_status
 
bool g_navauto_b_playlist
 If true, then the file list contains files from play list file, else the file list contains files included in directories. More...
 
_MEM_TYPE_SLOW_ Navauto_mode g_navauto_exp_mode = NAVAUTO_MODE_DISKS
 Define the directory limitation of the file list (ignored if g_navauto_b_playlist = true ) More...
 
_MEM_TYPE_SLOW_ FS_STRING g_navauto_filter
 File extension filter used to create the file list (ignored if g_navauto_b_playlist = true ) More...
 
_MEM_TYPE_SLOW_ Navauto_rand g_navauto_rand = NAVAUTO_RAND_OFF
 Flag the random state. More...
 
_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_dir_level
 Directory level of selected file (if play list file used then always 0) More...
 
_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_dir_level_root
 
_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_nb = 0
 Number of file included in file list (correct only if define FS_NAV_AUTOMATIC_NBFILE enabled) More...
 
_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_pos
 Position of selected file in file list. More...
 
static const
navauto_mov_explorer_process_fct_t 
is_dir_process_fct [2]
 This table describes what to do once the navigator reaches a limit while browsing directories. More...
 
static const
navauto_mov_explorer_process_fct_t 
is_file_process_fct [2]
 This table describes what to do once the navigator reaches a limit while browsing files. More...
 
static uint16_t lcg_a
 
static uint16_t lcg_c
 
static uint16_t lcg_m
 
static const
navauto_mov_explorer_process_fct_t 
limit_process_fct [2]
 This table describes what to do once the navigator reaches the limit of the "playlist". More...
 
static const
navauto_mov_explorer_process_fct_t 
new_dir_process_fct []
 This table describes what the action list to process one a new folder is accessed. More...
 
static bool shuffle_set = false
 

#define FS_NAV_AUTOMATIC_NBFILE   DISABLE

The FS_NAV_AUTOMATIC_NBFILE define changes the rule to create a file list from directories When this define is enabled, the files from a directory are included before files from sub directories.

typedef navauto_mov_explorer_rec_t(* navauto_mov_explorer_process_fct_t)(bool)

Enumerator
NAVAUTO_MOV_EXPLORER_OK 
NAVAUTO_MOV_EXPLORER_ERROR 
NAVAUTO_MOV_EXPLORER_RECURSIVE 
NAVAUTO_MOV_EXPLORER_OK 
NAVAUTO_MOV_EXPLORER_OK_LOOP 
NAVAUTO_MOV_EXPLORER_EMPTY 
NAVAUTO_MOV_EXPLORER_ERROR 
NAVAUTO_MOV_EXPLORER_RECURSIVE 

uint16_t navauto_close ( void  )

This function closes the file list.

@return    If a play list file is open then it is the last position in the file list
           else it is the directory level corresponding at the last selected file
//! At the end of this routine, the selected file of current navigator is :
//! - the play list file (in case of a play list file has been opened)
//! - the last selected file (in other case)
//! 

References g_navauto_b_playlist, g_navauto_u16_dir_level, g_navauto_u16_pos, and pl_main_close().

Referenced by ai_usb_ms_audio_context_restore(), ai_usb_ms_audio_ctrl_resume(), ai_usb_ms_audio_nav_eof_occur(), ai_usb_ms_audio_nav_mov(), ai_usb_ms_audio_nav_playfile(), and ai_usb_ms_specific_audio_nav_playlist_play_link().

Navauto_mode navauto_getmode ( void  )

This function returns the directory limitation of the file list.

@return Used navigation mode  (NAVAUTO_MODE_DISKS, NAVAUTO_MODE_DIRONLY, NAVAUTO_MODE_DIRSUB)
//! This parameter is ignored then a play list file is selected
//! 

References g_navauto_exp_mode.

Referenced by ai_usb_ms_audio_context_save(), and ai_usb_ms_audio_nav_expmode_get().

uint16_t navauto_getnb ( void  )

This function returns the file list size.

References g_navauto_u16_nb.

Referenced by ai_usb_ms_audio_nav_nb().

uint16_t navauto_getpos ( void  )

This function returns the current position in the file list.

References g_navauto_u16_pos.

Referenced by ai_usb_ms_audio_nav_getpos(), and ai_usb_ms_specific_audio_nav_playlist_play_link().

Navauto_rand navauto_getrand ( void  )

This function returns the random state used.

Returns
random used

References g_navauto_rand.

Referenced by ai_usb_ms_specific_audio_nav_playlist_play_link(), navauto_open(), and navauto_setpos().

void navauto_init ( const FS_STRING  sz_filterext)

This function initializes the file extension filter used to create the file list.

@param sz_filterext    file extension filter
//! This parameter is ignored then a play list file is selected
//! 

References g_navauto_filter, g_navauto_u16_dir_level, g_navauto_u16_dir_level_root, and g_navauto_u16_nb.

Referenced by ai_usb_ms_init_drive().

Navauto_mov_state navauto_mov ( bool  b_direction,
navauto_mov_options_t  options 
)

This function jumps to the next or previous file in file list.

@param b_direction  jump direction (FS_FIND_NEXT or FS_FIND_PREV)
@param options  jump direction (FS_FIND_NEXT or FS_FIND_PREV)

@return    the status of the action
//! When the random is ON, the direction is ignored
//! 

References g_navauto_b_playlist, navauto_mov_explorer(), and navauto_mov_playlist().

Referenced by ai_usb_ms_audio_nav_eof_occur(), ai_usb_ms_audio_nav_mov(), navauto_open(), and navauto_setpos().

Navauto_mov_state navauto_mov_explorer ( bool  b_direction,
navauto_mov_options_t  options 
)

This function jumps to the next or previous file in file list included in directories.

@param b_direction  jump direction (FS_FIND_NEXT or FS_FIND_PREV)
@param options  define extra modes for this function

@return    the status of the action
//! This routine is not authorized then a play list file is opened
//! When the random is ON, the direction is ignored
//! 
static navauto_mov_explorer_rec_t navauto_mov_explorer_enterdir ( bool  b_direction)
static
static navauto_mov_explorer_rec_t navauto_mov_explorer_limit ( bool  b_direction)
static

This function sets the pointer to a limit.

Parameters
b_directiondirection of navigation (FS_FIND_NEXT or FS_FIND_PREV)
Returns
true if a file is selected false otherwise

References g_navauto_u16_dir_level, g_navauto_u16_dir_level_root, nav_filelist_reset(), NAVAUTO_MOV_EXPLORER_ERROR, NAVAUTO_MOV_EXPLORER_RECURSIVE, and navauto_mov_explorer_updir().

static uint8_t navauto_mov_explorer_rec ( bool  b_direction,
navauto_mov_options_t  options 
)
static

This function selects a file in EXPLORER mode.

Parameters
b_directiondirection of navigation (FS_FIND_NEXT or FS_FIND_PREV)
optionsdefine extra modes for this function
Returns
the status of the action

References nav_file_isdir(), nav_filelist_validpos(), NAVAUTO_MOV_EMPTY, NAVAUTO_MOV_EXPLORER_EMPTY, NAVAUTO_MOV_EXPLORER_ERROR, navauto_mov_explorer_is_dir(), navauto_mov_explorer_is_file(), navauto_mov_explorer_new_dir(), NAVAUTO_MOV_EXPLORER_OK, NAVAUTO_MOV_EXPLORER_OK_LOOP, NAVAUTO_MOV_EXPLORER_RECURSIVE, NAVAUTO_MOV_OK, NAVAUTO_MOV_OK_LOOP, and wdt_clear().

Referenced by navauto_mov_ok_loop().

void navauto_mov_explorer_reset ( void  )

This function goes to the beginning of file list.

//! This routine is not authorized then a play list file is opened
//! 
static navauto_mov_explorer_rec_t navauto_mov_explorer_select_limit_dir_cur_folder ( bool  b_direction)
static

This function selects the first or the last directory on the current folder and enters in it.

Parameters
b_directiondirection of navigation (FS_FIND_NEXT or FS_FIND_PREV)
Returns
The state of the function

References FS_DIR, FS_FIND_NEXT, nav_filelist_first(), nav_filelist_last(), navauto_mov_explorer_enterdir(), and NAVAUTO_MOV_EXPLORER_ERROR.

static navauto_mov_explorer_rec_t navauto_mov_explorer_select_limit_file_cur_folder ( bool  b_direction)
static

This function selects the first or the last playable file on the current folder.

Parameters
b_directiondirection of navigation (FS_FIND_NEXT or FS_FIND_PREV)
Returns
true if a file is selected false otherwise

References FS_FILE, FS_FIND_NEXT, g_navauto_filter, nav_file_checkext(), nav_filelist_first(), nav_filelist_last(), nav_filelist_set(), NAVAUTO_MOV_EXPLORER_ERROR, and NAVAUTO_MOV_EXPLORER_OK.

Referenced by navauto_mov_explorer_is_file(), and navauto_open().

Navauto_mov_state navauto_mov_playlist ( bool  b_direction)

This function jumps to the next or previous file in file list corresponding at a play list file.

@param b_direction  jump direction (FS_FIND_NEXT or FS_FIND_PREV)

@return    The status of the action
//! This routine is not authorized then a play list file is not opened
//! 
uint16_t navauto_rand_choose ( uint16_t  u16_current_pos,
uint16_t  u16_period 
)

This function returns a random position not already used.

References lcg_a, lcg_c, lcg_m, and NAVAUTO_GET_RAND.

void navauto_rand_init ( void  )

This function resets the random bit table.

bool navauto_setmode ( Navauto_mode  exp_mode)

This function sets the directory limitation of the file list.

@param exp_mode    mode to select (NAVAUTO_MODE_DISKS, NAVAUTO_MODE_DIRONLY, NAVAUTO_MODE_DIRSUB)

@return true, mode changed
@return false, mode can't be changed (note: the selected file must be close)
//! This parameter is ignored then a play list file is selected
//! When the mode change, the folder level is reseted at the current position.
//! 

References g_navauto_b_playlist, g_navauto_exp_mode, and navauto_open().

Referenced by ai_usb_ms_audio_context_restore(), and ai_usb_ms_audio_nav_expmode_set().

bool navauto_setpos ( uint16_t  u16_pos)

This function selects a new position in file list.

Parameters
u16_posnew position to select
Returns
false in case of error

References FS_FIND_NEXT, FS_FIND_PREV, g_navauto_u16_pos, navauto_getrand(), navauto_mov(), NAVAUTO_MOV_OK, NAVAUTO_MOV_OPTS_NONE, navauto_setrand(), state, and Navauto_mov_state::status.

Referenced by ai_usb_ms_audio_nav_setpos().

void navauto_setrand ( Navauto_rand  rand)

This function changes the random state.

Parameters
randrandom mode to use

References g_navauto_rand, navauto_rand_init(), and shuffle_set.

Referenced by ai_usb_ms_audio_nav_shuffle_set(), ai_usb_ms_new_connection(), ai_usb_ms_specific_audio_nav_playlist_play_link(), navauto_open(), and navauto_setpos().

Navauto_mov_bitfield_status bitfield_status
static
bool g_navauto_b_playlist

If true, then the file list contains files from play list file, else the file list contains files included in directories.

Define the directory limitation of the file list (ignored if g_navauto_b_playlist = true )

_MEM_TYPE_SLOW_ FS_STRING g_navauto_filter

File extension filter used to create the file list (ignored if g_navauto_b_playlist = true )

Flag the random state.

_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_dir_level

Directory level of selected file (if play list file used then always 0)

_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_dir_level_root
_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_nb = 0

Number of file included in file list (correct only if define FS_NAV_AUTOMATIC_NBFILE enabled)

_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_pos

Position of selected file in file list.

const navauto_mov_explorer_process_fct_t is_dir_process_fct[2]
static
Initial value:
= {
}
static navauto_mov_explorer_rec_t navauto_mov_explorer_select_limit_file_cur_folder(bool b_direction)
This function selects the first or the last playable file on the current folder.
Definition: applications/uc3-audio-player/nav_automatic.c:697
static navauto_mov_explorer_rec_t navauto_mov_explorer_updir(bool b_direction)
This function moves back to the parent directory and selects this directory.
Definition: applications/uc3-audio-player/nav_automatic.c:771

This table describes what to do once the navigator reaches a limit while browsing directories.


  • is_dir_process_fct[0] is the function called on a previous command.
  • is_dir_process_fct[1] is the function called on a next command.

Referenced by navauto_mov_explorer_is_dir().

const navauto_mov_explorer_process_fct_t is_file_process_fct[2]
static
Initial value:
= {
}
static navauto_mov_explorer_rec_t navauto_mov_explorer_select_limit_dir_cur_folder(bool b_direction)
This function selects the first or the last directory on the current folder and enters in it...
Definition: applications/uc3-audio-player/nav_automatic.c:721
static navauto_mov_explorer_rec_t navauto_mov_explorer_updir(bool b_direction)
This function moves back to the parent directory and selects this directory.
Definition: applications/uc3-audio-player/nav_automatic.c:771

This table describes what to do once the navigator reaches a limit while browsing files.


  • is_file_process_fct[0] is the function called on a previous command.
  • is_file_process_fct[1] is the function called on a next command.

Referenced by navauto_mov_explorer_is_file().

uint16_t lcg_a
static

Referenced by navauto_rand_choose().

uint16_t lcg_c
static

Referenced by navauto_rand_choose().

uint16_t lcg_m
static

Referenced by navauto_rand_choose().

const navauto_mov_explorer_process_fct_t limit_process_fct[2]
static
Initial value:
= {
}
static navauto_mov_explorer_rec_t navauto_mov_explorer_limit(bool b_direction)
This function sets the pointer to a limit.
Definition: applications/uc3-audio-player/nav_automatic.c:679

This table describes what to do once the navigator reaches the limit of the "playlist".

  • is_file_process_fct[0] is the function called on a previous command.
  • is_file_process_fct[1] is the function called on a next command.
const navauto_mov_explorer_process_fct_t new_dir_process_fct[]
static
Initial value:
= {
}
static navauto_mov_explorer_rec_t navauto_mov_explorer_select_limit_file_cur_folder(bool b_direction)
This function selects the first or the last playable file on the current folder.
Definition: applications/uc3-audio-player/nav_automatic.c:697
static navauto_mov_explorer_rec_t navauto_mov_explorer_select_limit_dir_cur_folder(bool b_direction)
This function selects the first or the last directory on the current folder and enters in it...
Definition: applications/uc3-audio-player/nav_automatic.c:721

This table describes what the action list to process one a new folder is accessed.


  • is_dir_process_fct[0] = first action
  • is_dir_process_fct[1] = second action if 1st failed
  • ...

Referenced by navauto_mov_explorer_new_dir().

bool shuffle_set = false
static

Referenced by navauto_setrand().