Jump to content
Ultimaker Community of 3D Printing Experts
Sign in to follow this  
drayson

Sort array in displaying files on SD card

Recommended Posts

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

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

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

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

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  

×

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!