A guide to add a simple menu?

Hello all!
I trying to add a simple menu in to LCD which will active a Gcode (example: G32 S2;...) when clicked.
But the uimenu.h is total heating my brain.
Anyone here can tell me a simple example how to add a menu in to the LCD menu and assign a Gcode with it?
Thanks you very much!

Comments

  • If you want to add a function , there are several files affected.

    assign function to a  number in ui.h :

    #define UI_ACTION_Z_PROBE                139  //number is from my assignment

    generate function in ui.cpp :

     case UI_ACTION_Z_PROBE:
                if(!allowMoves) return UI_ACTION_Z_PROBE;
                UI_STATUS_UPD_F(Com::translatedF(UI_TEXT_Z_PROBE_ID));
                GCode::executeFString(PSTR("G29 S2\n"));       
                break;

    correct numbers in uilang.h

    #define NUM_TRANSLATED_WORDS 268 //original is 267


    //change numbers for TextID in uilang.h

    #define UI_TEXT_Z_OFFSET_ID 265  // original
    #define UI_TEXT_Z_PROBE_ID 266  // ADD
    #define UI_TEXT_DBG_ENDSTOP_ID 267 //     "EndStop:%dp"   //change number from 266 t0 267


    //add function text in uilang.h   !! for all languages !!

    #define UI_TEXT_Z_PROBE_EN "Start Z-Probe"   // last line of english translation
    #define UI_TEXT_Z_PROBE_DE "Start Z-Probe"   // last line of german translation

    //and so on for all languages

    //in uilang.cpp : !! also for all languages  dont forget the changes of ending _EN _DE and so on
    //add :
      TRANS(UI_TEXT_Z_PROBE_EN);

     FUI_TEXT_Z_OFFSET_EN, //keep original
     FUI_TEXT_Z_PROBE_EN,   // insert
     FUI_TEXT_DBG_ENDSTOP_EN  //keep original


    //in uimenu.h search for// **** Qick menu and insert :

    // **** Quick menu

    #if Z_PROBE_PIN>=0

    UI_MENU_ACTIONCOMMAND_T(ui_menu_z_probe, UI_TEXT_Z_PROBE_ID, UI_ACTION_Z_PROBE)
    #define MENU_Z_PROBE_COUNT 1
    #define MENU_Z_PROBE_ENTRY ,&ui_menu_z_probe
    #else
    #define MENU_Z_PROBE_COUNT 0
    #define MENU_Z_PROBE_ENTRY
    #endif


    //search for #define UI_MENU_QUICK and replace the text

    #define UI_MENU_QUICK {UI_MENU_ADDCONDBACK &ui_menu_home_all MENU_Z_PROBE_ENTRY BABY_ENTRY ,&ui_menu_quick_speedmultiply,&ui_menu_quick_flowmultiply  UI_TOOGLE_LIGHT_ENTRY UI_CHANGE_FIL_ENT,&ui_menu_quick_preheat_pla,&ui_menu_quick_preheat_abs,&ui_menu_quick_cooldown,&ui_menu_quick_origin,&ui_menu_quick_stopstepper MENU_PSON_ENTRY DEBUG_PRINT_EXTRA}
    UI_MENU(ui_menu_quick, UI_MENU_QUICK, 8 + BABY_CNT + UI_MENU_BACKCNT + MENU_PSON_COUNT + DEBUG_PRINT_COUNT + UI_TOGGLE_LIGHT_COUNT+MENU_Z_PROBE_COUNT  + UI_CHANGE_FIL_CNT)



    i hope i didn´t forget anything... it´s runnig great on my printer

    best regards

  • Great! I'll try as soon as i can.
    Thanks you very very muech!
    :D
  • If everything is ok you´ll find the z-probe in quick menu , should be menu point after homing
  • Thanks you!
    I just tried with a LCD controller and it worked like a charm. I'll test on my machine tomorrow!

    Thanks you, Ray!
  • Hello, RAyWB. Today i use repetier v0.92.9 with your modifications. The Z - Probing menu appear correct but when i use the menu, my Delta just go to Home and then restart.
    Do you have any ideal?
    Thanks!
  • i have no experience with delta , but i use also v 0.92.9  with that modification on cartesian machine and no problems.
    are you shure you did the modification correct?.
    what does your printer when you send G29 S2  by Host?
  • I send G32 S2 fine from Repetier Host. I created a gcode file in SD card with G32 S2 only for leveling from my Machine.

  • edited May 2016
    check code again if you did all modifications
    on my printer it works on 0.92.8 and 0.92.9

  • Hello, RayWB. Can you show me again where to put the:
    case UI_ACTION_Z_PROBE:
                if(!allowMoves) return UI_ACTION_Z_PROBE;
                UI_STATUS_UPD_F(Com::translatedF(UI_TEXT_Z_PROBE_ID));
                GCode::executeFString(PSTR("G29 S2\n"));        
                break;
    Thanks you :)
  • I tried again but still hang on when click on Z-Probe on LCD menu. I use 128x64 Full Graphic Smart Controller.
  • edited June 2016
    ok, so as i´m very busy at the moment i´ll check it on weekend
  • Thanks you. I'm looking for you :)
  • edited June 2016
    just take a look at the ui stuff from here :

    https://github.com/RAyWB/Giovanni_Due_050516

    it´s the code for my machine, Z.probe running well

    especially look at location of the  "case UI_ACTION_Z_PROBE:"

    i just don´t understand why you changed position from the running version you had...

    just compare your files( easiest is to use something like winmerge to compare files)

  • Thansk you, Raywb. I'll try soon ;)
  • Hi,

    I successfully implemented your code. Tanks for the guide!

    But I'm still wondering what the "MENU_Z_PROBE_COUNT "  in uimenu.h is up to...
    Could you please explain that?

    Thank you
Sign In or Register to comment.