Skip to content

Gcode preview

ThomasToka edited this page Jan 11, 2024 · 78 revisions

As of v008 E3S1PROFORKBYTT supports gcode preview with 250 x 250 px.

As of v023 E3S1PROFORKBYTT print data is shown on the mainsite if a new preview printdata script is used.

Gcode preview is only possible if you print from SD up to v023. As of v024 its can be shown on the display with the OctoPrint-E3S1PROFORKBYTT_Thumbnails plugin which will be released with it.

This is how you make the gcode preview work in your slicer so it is persistant in your generated gcode files:

Prusaslicer:

  • "YOURUSER" is a placeholder for your real Windows User in the following. Change it to your user.

  • install python 3 over the Windows App Store

for Prusa Slicer 2.7:

  • install Pillow in your administrative cmd "pip install Pillow"

grafik

  • download the gcode manipulation script and put it in "C:\Users\YOURUSER\AppData\Roaming\PrusaSlicer\scripts"

E3S1PROFORKBYTT up to v022:

the script for version 2.6.x is here: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_prusa_thumbnail.py

the script for version 2.7.x is here: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_prusa_v27_thumbnail.py

E3S1PROFORKBYTT as of v023:

the script for version 2.7.x is here: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_printdata_prusaslicer_v27_thumbnail.py

  • in Printer Settings -> General set the following:

Prusa Slicer 2.6.x

grafik

Prusa Slicer 2.7.x

grafik

  • under Print Settings -> Output settings set the following:

grafik

Example for copy and paste (change accordingly for your user and python3.exe folder):

"C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe" "C:\Users\YOURUSER\AppData\Roaming\PrusaSlicer\scripts\E3S1PROFORKBYTT_printdata_prusaslicer_v27_thumbnail.py"

Sometimes Prusa makes the image for the thumbnail too big, file byte size. To help with this you can use a 1x1 pixel image to remove the background bed, which decreases the size of the generated thumbnail by a substantial amount. You can get this 1x1 pixel image here: https://github.com/ThomasToka/MarlinFirmware/blob/553a54ae4e9c2e1b01a47d55a67426968901d2f7/bed.png See below on how to set the image in Prusa.

image

Cura 5.x:

  • "YOURUSER" is a placeholder for your real Windows User in the following. Change it to your user.

  • add the new thumbnail script to your scripts folder under C:\Users\YOURUSER\AppData\Roaming\cura\5.4\scripts.

E3S1PROFORKBYTT up to v022:

the script is here: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_Thumbnail.py

E3S1PROFORKBYTT as of v023:

the script is here: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_printdata_cura_v5_thumbnail.py

  • add the new thumbnail generating script to your postprocessing of your gcode file:

grafik

Example for copy and paste (change accordingly for your user and python3.exe folder):

"C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe" "C:\Users\YOURUSER\AppData\Roaming\cura\5.5\scripts\E3S1PROFORKBYTT_printdata_cura_v5_thumbnail.py"

Creality Slicer 4.8.x

E3S1PROFORKBYTT as of v023

grafik

  • change density if needed for your filament

grafik

There is no M73 script needed. Its already inbuild and can be activated on demand over the displays M73 button.

E3S1PROFORKBYTT up to v022

  • open the generating script of the thumbnails under C:\Program Files\Creality Slicer 4.8.2\plugins\CrealityThumbnail\CrealityOutputDevice.py with your favorite editor with administrator rights.

  • change the order of generating thumbnails from 48 then 200 to 250 then 48 in line 145

Before:

                    ssnapshot = Snapshot.snapshot(48, 48)
                    bsnapshot = Snapshot.snapshot(200, 200)

After

                    bsnapshot = Snapshot.snapshot(250, 250)
                    ssnapshot = Snapshot.snapshot(48, 48)
  • the same in line 149

Before:

                save_file.write(self.add_screenshot(ssnapshot, 48, 48, 'jpg'))
                save_file.write('\n')
                save_file.write(self.add_screenshot(bsnapshot, 200, 200, 'jpg'))

After:

                save_file.write(self.add_screenshot(bsnapshot, 250, 250, 'jpg'))
                save_file.write('\n')
                save_file.write(self.add_screenshot(ssnapshot, 48, 48, 'jpg'))

Picture out of a text editor:

grafik

Orca Slicer:

  • "YOURUSER" is a placeholder for your real Windows User in the following. Change it to your user.

  • install python 3 over the Windows App Store

  • install Pillow in your administrative cmd "pip install Pillow"

grafik

  • download the gcode manipulation script and put it in "C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process"

E3S1PROFORKBYTT up to v022:

OrcaSlicer up to 1.7: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_orcaslicer_thumbnail.py

OrcaSlicer as of 1.8: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_orcaslicer_v18_thumbnail.py

E3S1PROFORKBYTT as of v023:

OrcaSlicer as of 1.8: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_printdata_orcaslicer_v18_thumbnail.py

  • under Printer Settings -> Basic information -> Advanced set the following:

Orca Slicer up to v1.7:

grafik

Orca Slicer as of v1.8:

grafik

Orca Slicer as of v1.9:

grafik

Additionally you need to add a ;AFTER_LAYER_CHANGE entry to the Machine G-Code:

;AFTER_LAYER_CHANGE
;[layer_z]

grafik

  • under Others set the postprocessing script:

grafik

Example for copy and paste (change accordingly for your user and python3.exe folder):

"C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe" "C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process\E3S1PROFORKBYTT_printdata_orcaslicer_v19_thumbnail.py"

Super Slicer:

  • "YOURUSER" is a placeholder for your real Windows User in the following. Change it to your user.

  • install python 3 over the Windows App Store

  • download the gcode manipulation script and put it in "C:\Users\YOURUSER\AppData\Roaming\SuperSlicer"

E3S1PROFORKBYTT up to v022:

the script is here: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_superslicer_thumbnail.py

E3S1PROFORKBYTT as of v023:

the script is here: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/E3S1PROFORKBYTT_printdata_superslicer_thumbnail.py

  • under Printer Settings -> General -> Firmware -> G-code flavor set the following:

grafik

  • under Printer Settings -> General -> Thumbnail set the following:

grafik

  • under Print-Settings -> Output Options -> Post-processing script set the postprocessing script:

grafik

Example for copy and paste (change accordingly for your user and python3.exe folder):

"C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe" "C:\Users\YOURUSER\AppData\Roaming\SuperSlicer\E3S1PROFORKBYTT_printdata_superslicer_thumbnail.py"

Appendix 1: Findings i made during the development:

added 11. November 2023:

i shed some light on the address space of the gcode preview function.

first: the address space for "display overlays" is 120KB for a single or all of those icons. we use only one of this kind -the gcode preview- picture so we would have theoretically 120KB (120000bytes) creality placed this icon on address 0xB000. right at the end of the space. here a little visualisation is handy:

our address space is 0x0000 to 0xFFFF

0x0000   0x40C6   0x6003   0x7000   0xA000   0xB000             0xFFFF
|-------|-------|--------|--------|--------|--------------------|
        ~7.81KB    ~4.0KB   12.0KB   4.0KB           ~20.0KB

second: creality did not add any check in their class to check the preview image size. this leads to the situation that too big preview images overflow the display. by design the display then overwrites this bytes from the beginn so from 0x0000.. this leads to overwriting used addresses what we have seen on some users display after for example loading a falsely generated png image from prusa slicer

third: i will move the gcode display icon to address 0xA000 adding 4KB more space for it

fourth: i added a "load check" for the gcode preview image with a size of 24500 (we could 24575 bytes exactly. but a little headroom is always good) bytes. with address 0XB000 20479 bytes were possible.. bigger preview images will simply not be loaded and the default icon appears.

we have this "myth" then also catched with concrete numbers and a definition of what happens and why

Appendix 2: Debugging steps in case of failures.

The scripts are also runnable directly with python3.exe to see the real error output.

  • generate a gcode setting like shown in those two pictures in your slicer without setting a postprocessing script.

  • export the gcode to the same folder where your printdata script is named test.gcode for simlicity so: C:\Users\YOURUSER\AppData\Roaming\PrusaSlicer\scripts and C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process

  • open cmd with administrative rights and navigate to the folder cd C:\Users\YOURUSER\AppData\Roaming\PrusaSlicer\scripts or cd C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process

  • execute the preview script with python pointing to the test.gcode

C:\Users\YOURUSER\AppData\Roaming\PrusaSlicer\scripts>python3.exe E3S1PROFORKBYTT_printdata_prusaslicer_v27_thumbnail.py test.gcode
Added 240 M117 commands.

or

C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process>python3.exe E3S1PROFORKBYTT_orcaslicer_v18_thumbnail.py test.gcode
Added 241 M117 commands.

show me the result.

Orcaslicer:

grafik

Prusaslicer:

grafik

Appendix 3: Gcode preview with Octoprint

I have forked and adjusted the Prusa Slicer Thumbnail plugin to support all our fileformats with Octoprint:

grafik

The Plugin is located here:

https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/OctoPrint-E3S1PROFORKBYTT_Thumbnails.zip

  • install the plugin
  • go to the plugin
  • scan your folder for thumbnails.
  • enjoy thumbnails in octoprint

Appendix 4: Dacai displays

The dacai displays need once a update with crealities "private" folder of the 2.0.8.28 firmware. Including the firmware.zlib file in the root directory of the screen micro sd card. Instructions are:

With this release it is mandatory for dacai users to update once to the creality release 28 cause the delivered firmware.zlib file needs to be installed in order to support gcode preview. With this also the sound toggle will be activated. So a fair deal to do it once.

I have uploaded the file here: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/Ender-3S1_Pro_HWv24S1_301_SWV2.0.8.28F4_F401_FDM_LASER.zip

Update the screen once (do not forget the firmware.zlib in the root of your sd card, it is important), then proceed with my firmware.

Appendix 5: Mac os

Postprocessing for orca and prusa slicer is entered like this:

python3 ~/Desktop/E3S1PROFORKBYTT_printdata_orcaslicer_v19_thumbnail.py