Hi,
I read the entire configuration and _adv file and I found no place where I can add a custom item to the LCD menu. So I ask you: where should I change the code of marlin to add a new menu entry right in the very first option? I want to create an entry labeled (for example) XXX and when I click it I want Marlin to start preheating the bed and start the bed level procedure.
I have a medium knowledge of arduino and I can change it if you just tell me where I could do that.
In ultralcd.cpp, Main Menu starts at about LN 805.
@Tannoo with your help I could finally add an entry to the very first position of my LCD \O/
Now I have one final question: I declared a function to be executed when this option is selected and I want to know what code should I put inside this function in order to it run a specific GCODE?
For example, if I want to home all axis when I click this option and right after I cilck this option it displays the INFO SCREEN in the LCD instead of showing a blank screen?
I tried this:
void lcd_iniciar() {
enqueue_and_echo_commands_P(PSTR("G28"));
}
It works, but it keeps a blank screen while homing. How can I fix this?
This will cause the machine to home, wait for bed to get to temp, then start bed leveling.
void my_function() {
char some_variable[20];
snprintf_P(some_variable, sizeof(some_variable), PSTR("G28\nM190 S50\nG29"));
enqueue_and_echo_command(some_variable);
}
I got everything to work thanks to @Tannoo
One final question, in the command "M140 S105\nG29" I would like the 105C temperature to be retrieved from the PREHEAT_2_TEMP_BED variable. How do I insert this value in the string?
I think this will work.
snprintf_P(some_variable, sizeof(some_variable), PSTR("G28\nM190 S%i\nG29"), PREHEAT_2_TEMP_BED);
enqueue_and_echo_commands_P(PSTR("G28"));
This does not display anything on the screen. This outputs to the command buffer and the serial output.
There is nothing to display. Not even to draw a blank screen.
@tanoo thanks! But its really strange cause I only managed to make the LCD screen to come back to the info screen if I use this:
lcd_return_to_status();
If I dont use this and I only use the enqueue_and_echo_commands_P() the screen will get completely blank and after 20 seconds it comes back to the status screen.
Also, I am using this:
enqueue_and_echo_commands_P(PSTR("M140 S105\nG28\nG29"));
You told me I shoudl use this below? Isnt anything wrong?
enqueue_and_echo_commands_P(snprintf_P(some_variable, sizeof(some_variable), PSTR("G28\nM190 S%i\nG29"), PREHEAT_2_TEMP_BED))
Post your full function.
hi, it is:
```
void lcd_iniciar() {
lcd_return_to_status();
enqueue_and_echo_commands_P(PSTR("M140 S105\nG28\nG29"));
}
```
But I would like the 105 temperatur to be retrieved from the PREHEAT_2_TEMP_BED.
void lcd_iniciar() {
enqueue_and_echo_commands_P(PSTR("M140 S%i\nG28\nG29"), PREHEAT_2_TEMP_BED);
lcd_return_to_status();
}
If that doesn't work. Use the snprintf_P() I posted earlier.
Why don't you use this instead?
void lcd_iniciar() {
char temp_gcode[20];
snprintf_P(temp_gcode, sizeof(temp_gcode), PSTR("M140 S%i\nG28\nG29"), PREHEAT_2_TEMP_BED);
enqueue_and_echo_command(temp_gcode);
lcd_return_to_status();
}
@Tannoo the code below worked perfectly (your code didnt work, so I added 2 more parenthesis and it worked perfectly)
enqueue_and_echo_commands_P((PSTR("M140 S%i\nG28\nG29"),PREHEAT_2_TEMP_BED));
Thanks, you were very kind and helpful! Hope other people find this thread and be able to add a menu entry easily, it's very useful being able to customize the LCD display adding some macros/shortcuts!
We could put a Custom Commands on the main menu for just this type of thing.
(Enabled in configuration_adv.h, of course.)
That is a brilliant idea! Great work guys!
Regards,
Ernesto.
On 27 May 2017, 09:36 +0800, Tannoo notifications@github.com, wrote:
We could put a Custom Commands on the main menu for just this type of thing.
(Enabled in configuration_adv.h, of course.)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
@Tannoo if you add this option I would love to use it!! You could just add an option to the user add a custom menu entry that runs some arbitrary GCODE. I think you guys putted so much effort in autog0 file structure and it would be much easier to allow a menu to be inserted and to run some gcode. Placing this menu entry right on the top of the others would be great and of easy acccess.
How would this work out?
Seems like it would be super useful but only if it could do things like return the text output of the command back to the LCD. I'm always wondering what the current K value is for LIN_ADVANCE so I have to go back and check on the slicer I used. Being able to report it with an M900 in my custom menu would be great. I'm sure users would come up with a 1,000,0001 uses for such a feature 👍
What I'm hearing you say is you want the LCD Panel to be available for generic output. And possibly echo the standard output that is sent to the host machines in a portion of the LCD Window. This will take some thought to work through.
Right now... There is some thinking going on how to allow the main part of Marlin to use the Encoder Wheel and buttons in a clean fashion. We should probably expand that thinking to also allow the main parts of Marlin to have easier access to the LCD Display. (UBL currently grabs control of them and takes them away from the LCD Code. This would be redone in a cleaner form.)
What would help is some clever thinking how the output of SERIAL_ECHO() macros gets temporarily displayed on the LCD in addition to being sent to the host program. Maybe it is something like when a custom command is executed, the LCD also displays all SERIAL_ECHO() data for 3 seconds, and then reverts to the Status Screen? I don't know the answer. But we would want some simple algorithm that was both backwards compatible and future safe. (Obviously... that might be too much to hope for.)
wow that would be awesome! Just let me add one thing, if the user defines "CUSTOM_USER_MENUS " I think the "USER COMMANDS" should be displayed at first, for easy/shortcut access. Otherwise the user would have to scroll down the LCD till the very last option is reached. If the user does not want to use this CUSTOM_USER_MENUS it will keep everything as it is today, nothing customized should show up.
Of course, adding the capability to display the output of the commands is great but I think you could start this in a easier way and then improve it.
My suggestion is this: when the user define the CUSTOM_USER_MENUS, he should assign a pair value of LABEL and GCODE. The label will the be the option label that will be displayed (some of you suggested 5 options max) and the gcode would be the gcode sequence that should be executed. I dont know if Arduino allows multidirectional arrays, but if so, this would be my suggestion:
#define CUSTOM_USER_MENUS array(array("BED LEVEL","M109\nG28\nG29"),array("OTHER STUFF","GCODE STUFF"))
After the user chooses an option, Marlin should show the status screen (the main screen where marlin shows temperatures, XYZ...) and at the very botom/left of the screen you could show the LABEL of the current GCODE that is being execute OR the current GCODE that is being executed.
Only later, you could add an option to display the result of the GCODE in the screen because I believe this would require much more thinking and clever solution to display data without outputing it to serial.
Here is something to start with. #6875
No arrays, yet... I don't know how to mess with multidirectional arrays.
I think that since this is an end user configuration item, maybe simplicity is best?
@Tannoo right, simplificty is better! Maybe you could do this:
#define CUSTOM_USER_MENUS_LABEL_1 CUSTOM_BED_LEVEL
#define CUSTOM_USER_MENUS_GCODE_1 G28\nG29
#define CUSTOM_USER_MENUS_LABEL_2 OTHER STUFF
#define CUSTOM_USER_MENUS_GCODE_2 M114
...
...
So the user can comment/enable only the custom menus he/she wants. This is the easiest it can get.
SORRY I AM an idiot! I see you already implemented a better aproach than mine in your commit! Do you know if I can already use that commit? If so, how? Should I just download that marlin version?
Why cant I use this -> https://github.com/MarlinFirmware/Marlin/tree/bugfix-1.1.x ?
You can, but it won't have this PR (#6875) in it.
Once (or if) the PR is merged, then everyone will have it in bugfix-1.1.x.
Thanks man! I am starting to learn about git recently! Could you tell me why didnt you merge it to the main branch of bugfix-1.1.x?
And if I download your PR, will it contain other's people most recent contribution or just your new feature on top of the latest stable version? I say this cause I opened https://github.com/MarlinFirmware/Marlin/tree/bugfix-1.1.x and an there are a few changes that were made AFTER the change you made here - > https://github.com/Tannoo/Marlin/tree/user_command_menu
So, do that recent changes are included in your branch?
My brach is a "snapshot" of when I copied the latest bugfix-1.1.x, then I made changes. I can update that branch with any new changes.
The PR branch is based on `bugfix-1.1.x as of yesterday afternoon.
I don' have the permisstions to merge any PR into Marlin.
PRs are usually generated to get feedback and testing before merging.
Great explanation! So I took the latest RCBUGFIX and migrate all my settings to the latest RCBUGFIX. After that I copied the file ultralcd.cpp, language_en.h and configuration_adv (from your repository) and added them to my RCBUGFIX. I compiled and it worked.
I will try it now on my printer. Just one advice: if I enable custom menus I need to enable all 5 custom menus! Cant I only use one custom menu and not use the others? Cause if I comment all the other 4 menus and keep only the first one the compiler says errors. This way I could save memory to use with other things instead of loading 4 menus that I will never use.
@Tannoo I just tested your version and it worked perfectly! Amazing! I added a custom command like this:
#define USER_DESC_2 "Second Script"
#define USER_GCODE_2 "M140 S105\nG28\nG29"
And it worked! But now I have to ask you again (cause I think the solution you pointed earlier will not work here): how do I replace the 105 value above with PREHEAT_2_TEMP_BED ?
I liked that the custom commands appeares at the TOP! I liked that when I clicked the option after a few seconds it comes back to the status page! Is it possible to make it come back right away to the status page after I select a custom command to be executed? Cause sometimes it takes 5 seconds, other times it takes 10 or even 20 seconds to come back to status page.
That would take more code... I was trying to keep this as a simple custom script option.
But, evolution does happen...
But now I have to ask you again (cause I think the solution you pointed earlier will not work here): how do I replace the 105 value above with PREHEAT_2_TEMP_BED ?
You are correct... give me some time.
thanks, I hope you could have taken that nap you said in another thread! You are doing a great job man, thanks a lot!
Hi guys. Hope someone can help. Have made a nice little menu with an adafruit tft... but having trouble getting messages back to the slave arduino from the ramps via i2c... i.e If I change the x axis it will show the new settings on the lcd connected to the ramps of X 10(etc)... but which function in (i.e. in ultralcd.cpp?) sends this to the connected lcd screen so I can send it via the i2c wires to the tft? Have spent days on just this :( I really hope someone can lead me in the right direction here...
ultraldc.cpp calls lcd_implementation_status_screen() in, depending on the display type included ultralcd_impl_HD44780.h or ultralcd_impl_DOGM.h. There in you can find cals to lcd.setCursor and _draw_axis_value();. Therein you'll find lcd.print() and lcd_print() what is a UTF8 wrapper for lcd.print().
So finally everything ends in one of the lcd-libraries. For the graphic displays in u8glib.
If you display has a 20x4, 16x4 or 16x2 HD44780 type display, or a 128x64 graphic display, all you need is a wrapper for your displays library. For others you have to start at the (ultralcd_impl_HD44780.h or ultralcd_impl_DOGM.h) level.
Thanks for helping AnH :) The function I was actually looking for is lcd_move_get_x_amount, y, z, etc... :) It's nice when a community does it's best to help out :) Thanks again. Lucky.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.