Skip to content

Feature bed mesh viewer - #28507

Open
fanXbox wants to merge 9 commits into
MarlinFirmware:bugfix-2.1.xfrom
fanXbox:feature-bed-mesh-viewer
Open

Feature bed mesh viewer#28507
fanXbox wants to merge 9 commits into
MarlinFirmware:bugfix-2.1.xfrom
fanXbox:feature-bed-mesh-viewer

Conversation

@fanXbox

@fanXbox fanXbox commented Jul 29, 2026

Copy link
Copy Markdown

Description

This Pull Request introduces BED_MESH_VIEWER, a highly optimized 2D grid viewer designed specifically for standard 12864 monochrome LCDs. It is universally compatible with Mesh Bed Leveling, Bilinear Bed Leveling, and Unified Bed Leveling (UBL).

Key architectural and UI implementations include:

  1. Stational-Barycentric Visual Scale: Positive points expand from the center using a custom pixel vector map. Negative points collapse symmetrically from a predefined 9x9 outer bounding frame using an inverted specular matrix. Each pixel drawn corresponds exactly to a single step adjustment defined by MESH_EDIT_Z_STEP (e.g., 25 microns per pixel). This approach keeps each coordinate anchor centered on its grid cell without any geometric drift.
  2. Pixel-Perfect Text Inversion: In numeric mode (VIS), negative micron values are printed as dark text over an automatically calculated white solid bounding box. This avoids the visual clutter of multiple minus signs (-) on dense screens and eliminates overlaps by downscaling the font to u8g_font_4x6 for 6x6/7x7 meshes and using u8g_font_5x7 for configurations up to 5x5.
  3. Universal Infographic Info Screen: The INF button triggers a full-screen, textless layout displaying a smooth section view of a warped bed, direct mathematical scale matching (1 Px = [MESH_EDIT_Z_STEP] µm), and an embedded international vertical icon structure (Knob -> Arrow -> Click text -> Open Door) for exit instructions. This design makes the help page completely international and free from string translation requirements.
nuovo menù

Requirements

  • LCD: A graphical LCD compatible with the U8glib library (e.g., MINI12864_2X_HAL or similar monochrome screens).
  • Firmware: Requires at least one leveling system enabled (MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_UBL).

Benefits

  • Improves User Experience: Provides manual and automatic leveling users with an immediate, high-density visual and numeric feedback of their bed typography directly on basic 12864 LCD screens.
  • Zero Multi-Language Overhead: The info screen relies entirely on an international infographic layout, preventing string file inflation or missing localization errors across different languages.
  • Memory Optimized: Built around an isolated exclusive hardware loop that completely blocks default vertical menu injections, preventing any footer/status bar overlap while using minimal Flash space.

Configurations

  • Configured and fully tested on an Artillery Hornet (Artillery Ruby 32-bit mainboard).
  • Mesh configuration used during evaluation: Manual Mesh Bed Leveling (5x5 and 7x7 grid testing).

Configuration.zip

Related Issues

  • Fulfills a general Feature Request for an integrated, lightweight 2D mesh map visualizer on standard graphical monochrome LCD controllers without requiring a color touch screen or host interface.

fanXbox added 5 commits July 29, 2026 16:45
Introduced the core implementation file for BED_MESH_VIEWER. It provides a pixel-optimized 2D stationary-barycentric visual layout and real-time numeric scale feedback (with automatic font downscaling and background inversion for negative values) tailored for standard 12864 U8glib monochrome LCDs.
Integrated the sub-menu activation button for the 2D mesh map visualizer inside menu_probe_level.cpp. The conditional call is placed right under the mesh edit option and is protected using native preprocessor guards to maintain cross-platform safety.
Updated default Configuration.h and Configuration_adv.h with reference definitions to enable BED_MESH_VIEWER. Added structural macro anchors and specified MESH_EDIT_Z_STEP boundaries to provide a fully functional testbed for automated validation runners and simulators.
Registered the official `MSG_BED_MESH_VIEWER` localization labels using the native `LSTR` variable structure. Added explicit translations for both English and Italian dictionaries to ensure clean cross-compilation across core display modules.
@fanXbox

fanXbox commented Jul 29, 2026

Copy link
Copy Markdown
Author

Hi maintainers,

My code implementation for the bed mesh viewer is complete and isolated. Local compilation on my machine passes successfully with a green SUCCESS.

Please note that the current GitHub Actions failures on the rambo target (and the subsequent cancellation of the rest of the matrix) are caused by a pre-existing upstream Marlin bug: 'MSG_MOTION_DISTANCE_MM' is not a member of 'Language_en' inside menu_advanced.cpp. This regression is entirely unrelated to this PR.

I will leave the branch as is for your review. Thank you!

@ellensp

ellensp commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

That is not the CI test issue in rambo. It has this error

Marlin/src/HAL/AVR/../../inc/SanityCheck.h:1735:6: error: #error "MESH_EDIT_MENU requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_UBL."
     #error "MESH_EDIT_MENU requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_UBL."

Due to permanently enabling MESH_EDIT_MENU in Configuration.h

You currently have these two lines in Configuration.h.

  //#define MESH_EDIT_MENU        // Add a menu to edit mesh points
  #define MESH_EDIT_MENU        // Add a menu to edit mesh points

Are you sure this wasn't meant to be?

  //#define MESH_EDIT_MENU        // Add a menu to edit mesh points
  //#define BED_MESH_VIEWER       // Activate the stable center graphic and numerical plate map

@fanXbox

fanXbox commented Jul 29, 2026

Copy link
Copy Markdown
Author

Hi @ellensp,

Thank you so much for catching that! You were absolutely right.

I accidentally pasted two identical lines for MESH_EDIT_MENU instead of inserting the new definition for the viewer. I guess the summer heatwave is severely throttling my brain's processing performance lately!

I have just pushed a clean fix to correct the typo and restore the proper definitions. Thanks again for your time and review!

Upgraded the bottom scale legend inside menu_bed_mesh.cpp to use the official u8g_font_6x12 typeface for enhanced legibility. Replaced the manual pixel-by-pixel micro-drawing block of the 'µ' symbol with a clean string interpolation using the native '\xB5' hex escape sequence, preventing duplicate byte UTF-8 rendering artifacts.
@fanXbox

fanXbox commented Jul 29, 2026

Copy link
Copy Markdown
Author

Hi everyone,

Following some offline user feedback, it was pointed out that the scale legend text at the bottom was a bit too small to read comfortably, and the manual pixel-drawn rendering of the measurement unit (µm) was somewhat hard to decipher on standard screens.

To address this, I have just pushed an update upgrading the scale typography to the official u8g_font_6x12 font. This significantly improves legibility and allows us to use a native, clean string format with the strict \xB5 hex escape for the micro symbol, deprecating the custom pixel-drawing lines completely.

… compromise

Upgraded the bottom mathematical scale display inside menu_bed_mesh.cpp to u8g_font_7x14 to maximize text size and character sharpness. This specific typeface was selected as the optimal engineering compromise: it provides the highest possible visual legibility on 12864 screens while guaranteeing a strict hardware clearance zone, preventing any potential lateral collision or overlapping with the adjacent exit icon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants