Skip to content

G-code console for LVGL UI#20755

Merged
thinkyhead merged 105 commits intoMarlinFirmware:bugfix-2.0.xfrom
X-Ryl669:AddGCodeMenu
Feb 1, 2021
Merged

G-code console for LVGL UI#20755
thinkyhead merged 105 commits intoMarlinFirmware:bugfix-2.0.xfrom
X-Ryl669:AddGCodeMenu

Conversation

@X-Ryl669
Copy link
Contributor

Description

This is an additional menu for LVGL based UI to allow inputing G-Code directly in the interface and getting answer
It's located in the "More" menu from the "Tool" menu. The flow is like this:

  1. Select the G-Code option in the More menu
    IMG_20210112_071906_HHT
  2. Click on "Enter G-Code" and enter your G-Code command
    IMG_20210112_071927
  3. Upon return, the result of the G-Code command is displayed
    IMG_20210112_071936_HHT

I don't expect this code to land as-is, but instead request for comments about how to improve it or to better integrate with it.

Requirements

This requires LVGL, and I've based this code above the pending PR #20191.
I hope the former will be merged soon and I think it's better not to append more UI change on this other PR.

Benefits

This opens a lot of possibilities to use your printer without a computer connected to it (in standalone mode). All the features of Marlin are now accessible via the LCD screen (albeit via technical & textual representation) even if a graphical menu is missing to deal with it (for example, getting the current position of all axis is not present by default in LVGL, and this is useful to calibrate a BLTouch sensor).

Configurations

No configuration required. It's enabled by default when LVGL is enabled.

Issues

Currently, as you'll discover, I had to add a hook to the serial's write function to capture the output of a G-Code command.
Looking at the code, there's already some kind of hooking function for ethernet but it's completely non-expandable for third party.
I think Marlin would benefit from a better hooking system (something more generic to capture anything that goes to serial output whatever the serial output selected). Looking at the code, this means either rewriting the SERIAL_CHAR et al. macros so that they can be switched at compile time and/or runtime.

I need to discuss with actual developers what would be the best solution. The solution in this PR is working for MarlinSerial's based on Hardware Serial, but not on USB serial, so it's far from perfect. It's using a pointer to a callback function that can be swapped to a null value to disable/enable hooking at runtime.

Another issue I have is to detect the end of a GCode command's answer. Some command ends with "ok" and I'm currently using this as a sentinel to unhook the serial capture, but I wonder if a signal could be added in the G-code processor to tells any hook that a command has completed processing.

Please let me know what you think, thanks!

makerbase-mks and others added 30 commits May 11, 2020 20:34
@X-Ryl669 X-Ryl669 marked this pull request as ready for review January 31, 2021 09:36
@X-Ryl669
Copy link
Contributor Author

X-Ryl669 commented Jan 31, 2021

Should be ready now for inclusion...
There is no more the spurious "ok" line anymore 👍

@thinkyhead thinkyhead merged commit c74f972 into MarlinFirmware:bugfix-2.0.x Feb 1, 2021
Jyers pushed a commit to Jyers/Marlin that referenced this pull request Feb 3, 2021
susisstrolch pushed a commit to susisstrolch/Marlin that referenced this pull request Feb 16, 2021
… into bugfix-2.0.x

* 'bugfix-2.0.x' of https://github.com/MarlinFirmware/Marlin: (121 commits)
  [cron] Bump distribution date (2021-02-04)
  [cron] Bump distribution date (2021-02-03)
  Add "more" menu in LVGL interface (MarlinFirmware#20940)
  Evaluate ANY_SERIAL_IS in place
  Note (MarlinUI) limit on PREHEAT settings (MarlinFirmware#20966)
  Update a UBL comment (MarlinFirmware#20931)
  STM32 Shared Media - USB Mass Storage Device (MarlinFirmware#20956)
  Multi-language pertains to Color UI (MarlinFirmware#20972)
  Touch Calibration Screen auto-save option (MarlinFirmware#20971)
  Include ui_common for MARLIN_LOGO_FULL_SIZE (MarlinFirmware#20963)
  Fix host_response_handler compile (MarlinFirmware#20962)
  [cron] Bump distribution date (2021-02-02)
  LVGL UI G-code console (MarlinFirmware#20755)
  [cron] Bump distribution date (2021-02-01)
  Refresh screen on M22 (detach) (MarlinFirmware#20958)
  Fix AutoReporter implementation (MarlinFirmware#20959)
  Serial refactor followup (MarlinFirmware#20932)
  Init serial ports first (MarlinFirmware#20944)
  Remove extra G29 V newlines (MarlinFirmware#20955)
  [cron] Bump distribution date (2021-01-31)
  ...
kpishere pushed a commit to kpishere/Marlin that referenced this pull request Feb 19, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 25, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 25, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 26, 2021
@thinkyhead thinkyhead changed the title [RFC] G-code console for LVGL UI G-code console for LVGL UI Feb 28, 2021
@thinkyhead thinkyhead removed Needs: Discussion Discussion is needed help wanted labels Feb 28, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Mar 11, 2021
W4tel-BiDi pushed a commit to W4tel-BiDi/Marlin that referenced this pull request Apr 5, 2021
thinkyhead pushed a commit that referenced this pull request Apr 30, 2021
@Valnar8
Copy link

Valnar8 commented Jun 19, 2021

I like the idea but I always get a blackscreen after pressing the check mark. I guess that's what you meant with the end detection issue. Even ok didn't help in my case.

However I have some more feedback to this: It's a bit of a pain to enter g-code with this Keyboard layout. Would be a lot better if the standard screen was a num-block, a dot and the most important letters (G, M, X, Y, Z, E and what else are common letters for G-code Parameters)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.