Z-position Display hack
October 05, 2020 09:58PM
It's been a while since I last hacked on Marlin software, probably when I built my first printer back in 2013...

I recently got a new printer (ender 3 v2) and noticed that it perpetually displays the Z offset in the display's status area. I'm used to the X,Y,Z display on the old LCD, and especially miss the current Z height.

This past weekend I pulled Marlin 2.0.7 and started digging through motion.cpp and the DWIN display code to see how it ticks.

I've created a feature called DWIN_ZPOS_DISPLAY_OVERRIDE which, when defined, writes out the current_position.z value from the motion planner, instead of the Z offset. I personally think this is more informative, but it's an option. I'll put it up in github in case others want it.

I've got two questions for others who are more familiar with the current firmware.
1) Is there documentation about the DWIN color display, regarding icons, what the rendering model is, etc? It looks like the firmware sends it drawing commands over a UART, which means the display unit has reference images to copy rectangles from for rendering.

2) The motion planner has the variable I mentioned above, current_position, which is actually the current target position. Is it correct to say that this value doesn't change say, while a motion command is being processed? I.e., that the value is "correct" at the end of the motion command?
Re: Z-position Display hack
October 06, 2020 03:52PM
And I think I have answers for both questions now after doing more tinkering yesterday.

1) No real documentation that I can find. The values defined in dwin.h (icon numbers) and the coordinates used in dwin.cpp are strictly tied to the images (and subregions) of the DWIN_SET/*.jpg and *.ico files. Yes, the firmware sends drawing commands over the uart to perform rendering by the display.

The DWIN displays have areas of memory set as image caches. The default files 0_start.jpg, 1_English.jpg, and 2_Chinese.jpg are copied from the sdcard (inside the display) into these memory regions. The 9.ICO file contains 91 individual JPG icons. Some of the DWIN sources that describe the font sizes allude to the font bank being section 3. There is no hint as to the layout of that image which I assume is a gridded image of all the fonts and printable chars, nor how to get it.

See this thread for DWIN ICO tools.

2) It looks like current_position is it, short of looking at intermediate stepper counts which I don't want to mess with. For displaying z-position, current_position is fine.
Sorry, only registered users may post in this forum.

Click here to login