Adding a repeat function

Hello Repetier,

Can you please help me in two questions:

1. How can i make the cursor to be NOT on the "back" point (first line of the Print menu), but straight on my first file? 
It is already realised in other submenus, where the cursor is on the second line of a menu, so i want it in Print menu as well.

2. I want to make a kind of function, which will reprint previous file. The idea is to mark last printed file as "last" and then add a function "Repeat last print" to the main menu, so it will print "last" file every time i choose this point in the main menu till another file will be printed using Print menu and will be marked as the new "last". Maybe there already exists a solution? Or you can give some advise?

Thank you in advance! 


  • 1. No option for that. It is also not easy since there is the chance that a directory is empty. You might set a flag and on first listing set index to 1 if files are present.

    2. Hope you are good at programming:-) First problem is that there is no flag indicating we have a last print, so add that. Then change the sd card handling to not close file and set the last print flag and if needed close file on next different print or reset position on reprint call and add teh according menu entries in the menu. I think it is doable but not so easy.
  • edited October 2017
    Thank you for fast answer!
    I would like to try first method first)

    Which function, massive or variable represents where the cusor appear in the Print menu (or any other)? Where to find it?
  • It's all in ui.h/cpp
    Variable uid contains the display settings and there

     uint16_t menuPos[UI_MENU_MAXLEVEL]; // Positions in menu

    has the menu positions currently active for all menu levels. You need to find the enter command to set it.

            case UI_ACTION_SD_PRINT:

                if(sd.sdactive) {

                    pushMenu(&ui_menu_sd_fileselector, false);



    is what starts the menu for printing. Problem is that sd files is very special since we can not stor ethe file list in ram (not enough) so it is continously reread from sd card. But maybe just setting pos to 1 afterwards already works.

  • Hi again!

    My experiments are going nice) I successfully implemented selecting first file (not back) in the Print menu. Just changing pos works. 

    So, now i want to try to add the second option I mentioned (repeating last file). I found a kind of a pattern: when you enter any menu and then press back there, you return not to the top of the previous menu, but to the line you entered from. 

    Now the idea: what if after finishing a print make the program not to stay in the "Printer ready." menu, but return to the previous menu (e.i. Print) right on the line with last printed file (like the program does if you press back in submenu)?
    What do you think? Maybe i can do it without any hard coding?

    P.S. If someone wants to make, what i've been talking about, look for this line in ui.cpp: 

    menuTop[menuLevel] = menuPos[menuLevel] = 0; 

    and then separate them like this:

    menuTop[menuLevel] = 0;
    menuPos[menuLevel] = 1; //Change to 1

    This works right fine even if you dismount and then mount the card again with changed data inside!
  • edited October 2017
    And one more quistion: if i want to connect a button, where should i add info in uiconfig or ui?
  • You can already add buttons in config setting these defines:

    #define USER_KEY1_PIN     UI_DISPLAY_D5_PIN      // D5 to display (not used for graphics controller), change to other pin if you use character LCD !


    #define USER_KEY2_PIN     UI_DISPLAY_D6_PIN      // D6 to display (not used for graphics controller)...


    #define USER_KEY3_PIN     UI_DISPLAY_D7_PIN      // D7 to display (not used for graphics controller)...


    #define USER_KEY4_PIN     -1


    They are assigned an action. In ui.h you have a list of possible actions and ui.cpp implements them.

    Your thoughts about remembering menu position is not really working. There is only storage per hierarchie level, not per menu. 0 is info screen, 1 = main menu, 2 = submenu. So if you have entered a submenu setting a pos in level 2 go back and into an other submenu it uses again that storage position. In addition navigating through directories in print menu keeps the level. The only real way is to remember the last file. So if you have no delta on 8 bit you might just store the file selector or path or better just do not close last opened file and just reset position to 0 on restart but still mark print as finished.

Sign In or Register to comment.