Jump to content
Ultimaker Community of 3D Printing Experts

Sort array in displaying files on SD card


drayson

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

 

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

     

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

     

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

  • 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 :-)

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

     

  • 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: "

     

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

     

  • Link to post
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...