Exemple #1
0
//! This function goes to a position in filtered file list
//!
//! @param     u16_newpos     new position to select (0 is the first position)
//!
//! @return    false in case of error, see global value "fs_g_status" for more detail
//! @return    true otherwise
//!
bool  nav_filterlist_goto( uint16_t u16_newpos )
{
   if (u16_newpos == FS_NO_SEL)
     return nav_filterlist_reset();

   if( u16_newpos < (fs_g_nav.u16_pos_filterlist/2) )
   {
      // Restart at the beginning of list to accelerate search
      if( !nav_filterlist_reset() )
         return false;
   }
   if( FS_NO_SEL == fs_g_nav.u16_pos_filterlist )
      if( !nav_filterlist_next() )
         return false;  // No file available
   while( u16_newpos > fs_g_nav.u16_pos_filterlist )
   {
      if( !nav_filterlist_next() )
         break;
   }
   while( u16_newpos < fs_g_nav.u16_pos_filterlist )
   {
      if( !nav_filterlist_previous() )
         break;
   }
   return (u16_newpos == fs_g_nav.u16_pos_filterlist);
}
Exemple #2
0
//! This function goes to the previous position in filtered file list
//!
//! @return  false in case of error, see global value "fs_g_status" for more detail
//! @return  true otherwise
//!
bool  nav_filterflat_previous( void )
{
   uint16_t u16_save_current_pos;

   u16_save_current_pos = nav_filterlist_get();
   if( nav_filterlist_previous() )
   {
      while( 1 )
      {
         if( !nav_file_isdir() )
         {
            fs_g_nav.u16_flat_pos_offset = ((fs_g_nav.u16_flat_pos_offset +u16_save_current_pos) -nav_filterlist_get()) -1;
            return true;   // New position valid
         }
         // The file is a dir then enter in this
         if( !nav_dir_cd() )
            return false;
         if( !nav_filterlist_next() )
         {
            // Dir empty then goes to parent and dir is the new selection
            nav_filterlist_gotoparent();
            fs_g_nav.u16_flat_pos_offset = ((fs_g_nav.u16_flat_pos_offset +u16_save_current_pos) -nav_filterlist_get()) -1;
            return true;
         }
         fs_g_nav.u8_flat_dir_level++;
         // Go to end of the dir
         while( nav_filterlist_next() );
      }
   }
   // Beginning of current directory then goes to parent
   if( 0 == fs_g_nav.u8_flat_dir_level )
      return false;  // beginning of list FLAT
   if( !nav_filterlist_gotoparent() )
      return false;
   fs_g_nav.u8_flat_dir_level--;
   fs_g_nav.u16_flat_pos_offset -= (nav_filterlist_get()+1);
   return true;
}