Atmel Software Framework

services/fs/fat/nav_automatic.c File Reference
#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 __inline__ uint8_t navauto_mov_explorer_is_dir (bool b_direction, navauto_mov_options_t options)
 
static __inline__ uint8_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__ uint8_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__ uint8_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 (void)
 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_ uint8_t g_navauto_rand_tab [NAVAUTO_MAX_RANGE_RAND]
 Bit table used to random the file list. This one flag each files already selected. 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...
 
_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_rand_pos
 Offset of bit table "g_navauto_rand_tab" 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 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...
 

#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().

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.

uint16_t navauto_getnb ( void  )

This function returns the file list size.

References g_navauto_u16_nb.

uint16_t navauto_getpos ( void  )

This function returns the current position in the file list.

References g_navauto_u16_pos.

Navauto_rand navauto_getrand ( void  )

This function returns the random state used.

Returns
random used

References g_navauto_rand.

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_root, and g_navauto_u16_nb.

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().

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
//! 

References Navauto_mov_bitfield_status::all, Navauto_mov_state::bitfield, FS_FILE, FS_FIND_NEXT, FS_FIND_PREV, g_navauto_exp_mode, g_navauto_rand, g_navauto_u16_nb, g_navauto_u16_pos, limit_process_fct, nav_filelist_nb(), NAVAUTO_MODE_DIRONLY, NAVAUTO_MOV_EMPTY, navauto_mov_explorer_rec(), NAVAUTO_MOV_EXPLORER_RECURSIVE, NAVAUTO_MOV_OK, NAVAUTO_MOV_OK_LOOP, NAVAUTO_MOV_OPTS_STAY_CURRENT_DIR, navauto_rand_choose(), navauto_rand_init(), NAVAUTO_RAND_ON, state, and Navauto_mov_state::status.

Referenced by navauto_mov(), and navauto_open().

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_explorer_is_dir(), navauto_mov_explorer_is_file(), and navauto_mov_explorer_new_dir().

Referenced by navauto_mov_explorer(), navauto_mov_explorer_is_dir(), navauto_mov_explorer_is_file(), navauto_mov_explorer_new_dir(), and 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
//! 

References g_navauto_exp_mode, g_navauto_u16_dir_level, g_navauto_u16_dir_level_root, g_navauto_u16_nb, g_navauto_u16_pos, nav_dir_root(), nav_drive_set(), NAVAUTO_MODE_DISK, and NAVAUTO_MODE_DISKS.

Referenced by navauto_open().

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 Navauto_mov_bitfield_status::folder_change, FS_DIR, FS_FIND_NEXT, g_navauto_u16_dir_level, nav_dir_cd(), nav_filelist_first(), nav_filelist_last(), NAVAUTO_MOV_EXPLORER_ERROR, and NAVAUTO_MOV_EXPLORER_RECURSIVE.

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().

static navauto_mov_explorer_rec_t navauto_mov_explorer_updir ( bool  b_direction)
static

This function moves back to the parent directory and selects this directory.

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

References Navauto_mov_bitfield_status::folder_change, g_navauto_exp_mode, g_navauto_u16_dir_level, g_navauto_u16_dir_level_root, nav_dir_gotoparent(), NAVAUTO_MODE_DIRONLY, NAVAUTO_MODE_DIRSUB, NAVAUTO_MOV_EXPLORER_ERROR, and NAVAUTO_MOV_EXPLORER_RECURSIVE.

Referenced by navauto_mov_explorer_is_dir(), navauto_mov_explorer_is_file(), navauto_mov_explorer_limit(), and navauto_mov_explorer_new_dir().

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
//! 

References Navauto_mov_bitfield_status::all, Navauto_mov_state::bitfield, FS_FIND_NEXT, g_navauto_rand, g_navauto_u16_pos, nav_filelist_validpos(), NAVAUTO_MOV_DISKERROR, NAVAUTO_MOV_OK, NAVAUTO_MOV_OK_LOOP, navauto_rand_choose(), navauto_rand_init(), NAVAUTO_RAND_ON, pl_nav_getnbfile(), pl_nav_getpos(), pl_nav_setpos(), state, and Navauto_mov_state::status.

Referenced by navauto_mov().

bool navauto_open ( bool  b_playlist,
uint16_t  pos 
)

This function opens a file list at the current position in navigator.

Parameters
b_playlistif true then the current selected file is a play list file to open else create a file list with files included in a disk part
posIf b_playlist true, then position in the play list to start else folder level of the current position
Returns
false, in case of error or file list empty

References FS_FIND_NEXT, FS_FIND_PREV, g_navauto_b_playlist, g_navauto_filter, g_navauto_u16_dir_level, g_navauto_u16_dir_level_root, g_navauto_u16_nb, g_navauto_u16_pos, index, nav_dir_gotoparent(), nav_file_checkext(), nav_filelist_reset(), nav_filelist_set(), nav_filelist_validpos(), nav_getindex(), nav_gotoindex(), navauto_getrand(), navauto_mov(), navauto_mov_explorer(), navauto_mov_explorer_reset(), NAVAUTO_MOV_OK, NAVAUTO_MOV_OK_LOOP, NAVAUTO_MOV_OPTS_NONE, navauto_rand_init(), NAVAUTO_RAND_OFF, navauto_setrand(), pl_main_open(), pl_nav_getnbfile(), pl_nav_setpos(), state, status, Navauto_mov_state::status, Fs_index::u16_entry_pos_sel_file, Fs_index::u32_cluster_sel_dir, and Fs_index::u8_lun.

uint16_t navauto_rand_choose ( void  )

This function returns a random position not already used.

References g_navauto_rand_tab, g_navauto_u16_nb, g_navauto_u16_pos, g_navauto_u16_rand_pos, NAVAUTO_GET_RAND, and NAVAUTO_MAX_RANGE_RAND.

Referenced by navauto_mov_explorer(), and navauto_mov_playlist().

void navauto_rand_init ( void  )
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().

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.

void navauto_setrand ( Navauto_rand  rand)

This function changes the random state.

Parameters
randrandom mode to use

References g_navauto_rand, g_navauto_rand_tab, g_navauto_u16_pos, NAVAUTO_MAX_RANGE_RAND, and navauto_rand_init().

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.

Referenced by ai_usb_ms_audio_context_save(), navauto_close(), navauto_mov(), navauto_open(), and navauto_setmode().

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

Referenced by navauto_getmode(), navauto_mov_explorer(), navauto_mov_explorer_is_file(), navauto_mov_explorer_reset(), navauto_mov_explorer_updir(), navauto_mov_ok_loop(), navauto_open(), and navauto_setmode().

_MEM_TYPE_SLOW_ FS_STRING g_navauto_filter

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

Referenced by navauto_init(), navauto_mov_explorer_is_file(), navauto_mov_explorer_select_limit_file_cur_folder(), and navauto_open().

_MEM_TYPE_SLOW_ uint8_t g_navauto_rand_tab[NAVAUTO_MAX_RANGE_RAND]

Bit table used to random the file list. This one flag each files already selected.

Referenced by navauto_rand_choose(), navauto_rand_init(), and navauto_setrand().

_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)

Referenced by navauto_getnb(), navauto_init(), navauto_mov_explorer(), navauto_mov_explorer_reset(), navauto_open(), and navauto_rand_choose().

_MEM_TYPE_SLOW_ uint16_t g_navauto_u16_rand_pos

Offset of bit table "g_navauto_rand_tab" in file list.

Referenced by navauto_rand_choose(), and navauto_rand_init().

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: services/fs/fat/nav_automatic.c:622
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: services/fs/fat/nav_automatic.c:668

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: services/fs/fat/nav_automatic.c:646
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: services/fs/fat/nav_automatic.c:668

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().

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: services/fs/fat/nav_automatic.c:604

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.

Referenced by navauto_mov_explorer().

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_dir_cur_folder(bool b_direction)
This function selects the first or the last directory on the current folder and enters in it...
Definition: services/fs/fat/nav_automatic.c:646
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: services/fs/fat/nav_automatic.c:622

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
  • ...

Referenced by navauto_mov_explorer_new_dir().