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
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
are you shure you did the modification correct?.
what does your printer when you send G29 S2 by Host?
on my printer it works on 0.92.8 and 0.92.9
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;
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)