Jump to content
Sign in to follow this  
drayson

Sort array in displaying files on SD card

Recommended Posts

Posted · Sort array in displaying files on SD card

Hi communitiy!

Is there a way to influence the sorting (e.g. by alphabeth, newest file,...) of the files displayed at the ulticontroler?

Any hint appreciated :-)

 

Share this post


Link to post
Share on other sites
Posted · Sort array in displaying files on SD card

Sometimes I get the impression it depends on the color of the left wing of a butterfly at the other end of the universe... :wacko:

It can't be the filename (because it's chaos on my SD card) or the file date (sometimes new files show up on top, sometimes somewhere in the middle of other files).

 

Share this post


Link to post
Share on other sites
Posted · Sort array in displaying files on SD card

Same at my card...

As I'm not always deleating stuff, it's a bit anoying.

Do you think we should place this question as request in eric's marlin fork?

Share this post


Link to post
Share on other sites
Posted · Sort array in displaying files on SD card

I spent a little while looking at the code and trying to figure out the sort order, it has bugged me as well, and from my limited understanding no sorting at all is being performed (to preserve memory perhaps?). The files and directories are listed according to the index they receive in the Fat file system implementation on the Arduino. So the order is "random". If there's enough RAM available I'm sure it could be sorted but I imagine that is very low on the list of priorities.

I'm sure someone who is a better code monkey than I can explain that better.

My "workaround" is to dump old files in a directory I call, fittingly, "old" to keep the clutter down a bit.

 

Share this post


Link to post
Share on other sites
Posted · Sort array in displaying files on SD card

Yeah I noticed they are listed based on last item added to the card. Even folders aren't put in first.

 

Share this post


Link to post
Share on other sites
Posted · Sort array in displaying files on SD card

I actually save the gcode first to the harddisk and then copy it to the sdcard. From time to time I perform a clean sweep of the sdcard.

Share this post


Link to post
Share on other sites
Posted · Sort array in displaying files on SD card

Ok, never thought about the ram, but this sounds plausible...

Think I have to cleanup my card soon :-)

Share this post


Link to post
Share on other sites
Posted · Sort array in displaying files on SD card

The order on FAT devices, like our SD card, is the order in which the file was added to the directory structure. If you overwrite a file, it's sort position does not change. In order to sort the directory, you need to remove all the files and add them back in the order you wish them to be sorted.

There are some utilities which can sort the SD card directory for you (usually used for MP3 players that play songs in the default sort order on the SD card).

Here is a list someone compiled of the available options.

http://www.murraymoffatt.com/software-problem-0010.html

I looked at the firmware to see if there was an easy way to sort the directly list for user display, but reading the entire directory list at once in order to resorting it would take a lot of precious RAM.

 

Share this post


Link to post
Share on other sites
Posted · Sort array in displaying files on SD card

I looked at the firmware to see if there was an easy way to sort the directly list for user display, but reading the entire directory list at once in order to resorting it would take a lot of precious RAM.

 

You could sacrifice speed for RAM. As you could just keep indexes and sort those (reading the filename every time you need it). But that wouldn't improve the experience, as it would be slow.

So it's best to keep it at "it depends on the color of the left wing of a butterfly at the other end of the universe... :wacko: "

 

Share this post


Link to post
Share on other sites
Posted · Sort array in displaying files on SD card

OMG, that would take ages! :) I added a short delay in reading the file details (time, filament used, etc) when scrolling through the directory listing to make it more responsive -- I shudder at the idea of doing a list sort where it had to hit the SD card every time it did a comparison. :shock:

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Our picks

    • Ultimaker Cura 4.0 | Stable available!
      Ultimaker Cura 4.0 is mainly focused on the improved user interface and cloud integration.
      As always, we want to collect your user feedback for this release. If there are any improvements you can think of, feel free to mention it here and help us to shape the next release.
      • 98 replies
×
×
  • Create New...

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!