Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigTreetech TFT 24 not working #2231

Closed
erik23de opened this issue Dec 1, 2019 · 121 comments
Closed

BigTreetech TFT 24 not working #2231

erik23de opened this issue Dec 1, 2019 · 121 comments
Labels

Comments

@erik23de
Copy link

erik23de commented Dec 1, 2019

Hi,

Tried to set up Klippy on an skr 1.3 (from the example- configs), copy & pasted the Preprap GLCD
into the config.
Usually, testet with 3 Boards, Marlin and Repetier, the BigTreetech TFT 24 (and 35) works as a 12864 GLDC like a charm (First Display I'm really happy with).
But it does not with Klipper, Screen stays empty (but reset switch works). Wiring is okay, it works with Marlin on the same board.
What did I wrong?

klippy.zip

@KevinOConnor
Copy link
Collaborator

I don't know of anyone that has attempted to use this device with Klipper. It appears the device is trying to emulate an st7920 device. As a guess, it may not fully emulate the device and thus not be compatible with Klipper. (Klipper uses some features of the st7920 - such as the character generator - that other firmware don't use.)

-Kevin

@erik23de
Copy link
Author

erik23de commented Dec 3, 2019

Thanks for the info.

You should give it a chance - it's a good & cheap Display and we'll see more of that around soon.
With more conventional firmware, it works quiete easy with the widespread RepRapDiscount GLCD configuration.

In meantime, maybe I'm luckier with Klipper and the fysetc display - with wich I had no chance on Marlin or Repetier.

@jalanjarosz
Copy link

@erik23de I have a Fysetc MKS Mini display with the NeoPixel LED's working though a RAMPS shield on an Adafruit Grand Central M4. Let me know if you need a hand with the config.

@RomRider
Copy link

RomRider commented Dec 6, 2019

Same here with TFT35, if you switch back and forth between the touch mode and the marlin mode, it will ultimately display a bunch of garbage after playing with the button:
image

@derBG
Copy link

derBG commented Dec 7, 2019

Iam also interested. Does anyone have a config that shows anything? My TFT24 connected to skr 1.3 shows in the 12864 mode only a blue display.

@MatthewRohrich
Copy link

I have a TFT24, neither the emulated screen nor the touch screen will connect. The screen defaults to 250k baud rate which does not connect. Changing the baud rate to 115k does nothing and when rebooting it resets to 250k. BTT have guides for Marlin, but I have not been able to work out if any of these settings can be configured with Klipper.

@KevinOConnor
Copy link
Collaborator

FYI, it appears that the tft24 (and similar) are emulating an st7920 chip:

https://github.com/bigtreetech/BIGTREETECH-TouchScreenFirmware/blob/e180179aa945cfcf4a5af5c71581138d4d87225d/TFT/src/User/API/UI/ST7920_Simulator.c

That emulation does not include the character generator, so it is not compatible with Klipper. However, if a developer is interested, it should be possible to add support to Klipper.

-Kevin

@softkannan
Copy link

  1. BTT and MKS TFT both emulates host (like octoprint), no config. The incoming serial data is GCODE commands and they listen for Ok and other serial command just like octoprint. Marlin tackled these displays by having more than one serial port can act as host.

  2. Anycubic TFT display also sends serial texts on high level but key difference is Anycubic TFT is not acting like host, its serial commands needs to be translated (requires intermediator).

  3. All the above 3 displays offer no config, means we cannot add new buttons or any other menus without compiling display firmware.

  4. to support above type of displays, on klipper we need
    on mcu side

    1. Generic serial text send
    2. Generic serial text recev
      on klippy side
    3. Generic gcode injector to queue and response, it has to emulate klippy virtual serial port functions, like sending ok, busy etc.
    4. Once above “Generic gcode injector to queue” is ready then we can customize for Anycubic TFT type displays.

Benefit
- It makes klipper deployment easy, no hardware modification required, except plugging in rpi.
- Above approach is not specific to any display (except anycubic, I believe that must be done on private), which also preserve future expandability.
Cons
It might increase some traffic, but I guess impact on performance is minimal.

Is above approach make sense ?

@alagerqvist
Copy link

alagerqvist commented Feb 23, 2020

What klipper display settings are you using while trying to get the TFT24/35 running.
Below is a try to get the Marlin mode working, but it would really make much more sense to get the touch screen version working by allowing additional serial port support for Klipper as that would reduce communication drastically.

This is my interpretation of how to set it up. (BTT SKR PRO)
[display]
lcd_type: st7920
cs_pin: PD11
sclk_pin: PG2
sid_pin: PD10
encoder_pins: PG10,PF11
click_pin: PA8

[output_pin beeper]
pin: PG4

[gcode_macro M300]
default_parameter_S=1000
default_parameter_P=100
gcode: SET_PIN PIN=beeper VALUE=1
G4 P{P}
SET_PIN PIN=beeper VALUE=0

Tested the M300 to get a beep from the display =D

Klipper Marlin (Edited as it was wrong)

cs_pin == LCD_PINS_ENABLE

sclk_pin == LCD_PINS_D4

sid_pin == LCD_PINS_RS

encoder_pins == BTN_EN1, BTN_EN2

click_pin == BTN_ENC

@DeviousPenguin
Copy link

@alagerqvist I agree serial communication with the screen in 'touch' mode would be nice, I'm currently experimenting with using a USB2TTL adaptor connected from the RPi directly to the Display, and while it connects, I'm unable to get it to do anything useful so far.

This way the USB link betweek Klipper and the MCU is totally unhindered, the Screen is on a different bus, and can even be a different baud rate, but the wiring for this is less clean if your RPi is not mounted to your printer.

Can I ask if you managed to get the 'marlin mode'/'12864 simulator' mode to get anything to appear on the screen? Or is it only the Beep that works?

@alagerqvist
Copy link

@DeviousPenguin
I have tried a bit of debugging but my problem is that I don't receive ANY serial communication from klipper, it is probably due to my display set-up in klipper, but the problem is that the documentation for setting up display for klipper is close to none.
In my previous comment I tried to describe my guess on how to map Marlin configurations to klipper as marlin configurations are easy to come by for any hardware.

So if someone could confirm/oppose the below I'd be happy: (Do I lack something?)
Klipper <==> Marlin:
cs_pin <==> LCD_PINS_RS
sclk_pin <==> LCD_PINS_D4
sid_pin <==> LCD_PINS_ENABLE
encoder_pins <==> BTN_EN1, BTN_EN2
click_pin <==> BTN_ENC

I have started on an implementation of "full 7920 display emulation" for the TFT24/35 (or other), but I really can't test until I get serial working against klipper.
It look quite straightforward to change the 7920 code in klipper but I'm not sure that is the way to go... (but serial multiplexing is a must have....)

@DeviousPenguin
Copy link

@alagerqvist I may be wrong but 7920 display emulation mode doesn't need serial in order to work.

I had a SKR v1.4 board turn up today, once I get it plugged up and flashed with Klipper, I'll see if I can confirm your pinouts and get some form of functionality with the TFT24

@alagerqvist
Copy link

alagerqvist commented Feb 29, 2020 via email

@alagerqvist
Copy link

@DeviousPenguin
I was a bit unclear, when I said serial wasn't working I actually meant the SPI communication to the display. So what I mean is that the screen gets no 7920 instructions over the configured pins, I added on screen debug info to see if the screen get any data.

The below might have some impact: (This is the setting that works against the display using Marlin)
#define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#define BOARD_ST7920_DELAY_3 DELAY_NS(600)
I have no idea if possible/how to set those delays for Klipper...

@alagerqvist
Copy link

@KevinOConnor
I took a look at the low-level specification for communicating with the 7920 and what Klipper does seems a bit of the spec for TS7920.
Setting the clock-pin to low before setting the data and then pulling clock up seems correct according to the data sheet. (So data is read on rising clk).
(According to the spec. page 38 "Serial interface timing diagram � MPU write data to ST7920")

The timing of Klipper looks strange and the clk is toggled instead of set.

Marlin does this: (Works with BTT code which isn't real 7920 HW)
WRITE(ST7920_CLK_PIN, LOW); ST7920_DELAY_1;
WRITE(ST7920_DAT_PIN, ST7920_DAT(val)); ST7920_DELAY_2;
WRITE(ST7920_CLK_PIN, HIGH); ST7920_DELAY_3; \

Klipper does:
if (data & 0x80) {
gpio_out_toggle(sid);
data = ~data;
}
ndelay(200);
gpio_out_toggle(sclk);
ndelay(200);
data <<= 1;
gpio_out_toggle(sclk);

@KevinOConnor
Copy link
Collaborator

I'm not aware of any issues with the Klipper bit banging interface to the st7920. What you're looking at is the low-level toggling that is done - it's different from Marlin, but I don't believe it is incorrect.

Separately, when I last looked at the BTT firmware running on the display (#2231 (comment)) it did not support the st7920 commands that Klipper issues. I'm pretty sure that's the root of the issue.

-Kevin

@alagerqvist
Copy link

alagerqvist commented Mar 2, 2020 via email

@4noxx
Copy link

4noxx commented Apr 6, 2020

hi, are there a solution now to run the bigtreetech tft-display (perhaps in marlin mode)
in klipper?
i use a SKR E3 MINI, and no Display runs on my Board (test bigtreetech tft35 and a reprap graph display and my old anet a8 display).

@JohnEdwa
Copy link

JohnEdwa commented Apr 6, 2020

AFAIK, no. Klipper requires the display to support the character generator, which the BTT emulator doesn't have. There is an open issue on the firmware page about it, but nobody has implemented it yet.
Also, as it's not needed by Marlin, only by Klipper and other misc projects, the chances are unless someone from here goes to implement it, it never will.

@DeviousPenguin
Copy link

Also, as it's not needed by Marlin, only by Klipper and other misc projects, the chances are unless someone from here goes to implement it, it never will.

I'm not the most experienced with C++ and Arduino type code, but can do the basics. Would you know the best place to start with implementing the character generator?

@trevjonez
Copy link
Contributor

Also, as it's not needed by Marlin, only by Klipper and other misc projects, the chances are unless someone from here goes to implement it, it never will.

I'm not the most experienced with C++ and Arduino type code, but can do the basics. Would you know the best place to start with implementing the character generator?

From the other thread just recently:
bigtreetech/BIGTREETECH-TouchScreenFirmware#290 (comment)

It sounds like they may not emulate the char generator, but use font files that are already present in the firmware.

@DeviousPenguin
Copy link

@trevjonez thanks it does look like BTT may be adding the char gen, by the looks of that thread, so we may not need to re-invent the wheel

@dushyantahuja
Copy link
Contributor

I've just got this TFT (a few minutes back), and see that there's a USB port behind it. Would it be possible to connect this to the pi and simply link the two serial port together (one from the TFT and /tmp/printer) - so that any commands the touch screen sends would get sent to klipper.

I'm no Linux expert - but it might be possible using socat. Will have to try once I get my board installed and have the printer running again.

http://technostuff.blogspot.com/2008/10/some-useful-socat-commands.html

@JohnEdwa
Copy link

JohnEdwa commented May 9, 2020

That port is only for connecting a USB flash drive to the printer instead of using the SD card slot. The serial port is on a different connection entirely, as that is indeed how the display communicates using the "touch screen mode" with the mainboard: purely by sending and receiving Gcode commands, just like OctoPrint does.

Connect that display to one of the serial ports on your Raspi instead of the mainboard and instruct Klipper to listen to that port, and you could, in theory, replace Octoprint with that touchscreen. With the caveat that it's almost guaranteed to use some Marlin specific commands that won't work with Klipper.

@dushyantahuja
Copy link
Contributor

Aah - too bad. Turned out when I shorted my previous control board, it also took the TMC drivers with it :(. Now to wait for the new ones to arrive, before I can experiment further. More thoughts:

  1. As Kevin mentioned, port Klipper directly to TFT and use it as another microcontroller. Since I have no experience in this, I'll leave it to the experts
  2. Connect to ESP8266 - and then use the Octoprint API to get / set data. It shouldn't be too difficult, let me see what I can do.

@HenrikPPersson
Copy link

Hi! New owner of Bigtreetech TFT24 and first poster on Github.
I looked through the source of the TFT24 firmware and discovered that the display only emulate the ST7920 graphics mode. Not the text or glyph mode. After modifying the st7920.py in klipper I sort of got it working.

When I start up the screen, it is blank, part from the "LCD12864 Simulator" text at the top. Once I switch over to Serial Touch Screen mode and then back again it starts to show things. With the patch below, it seems to be working (part from the animations).

@@ -126,7 +126,11 @@ class ST7920:
         if x + len(data) > 16:
             data = data[:16 - min(x, 16)]
         pos = [0, 32, 16, 48][y] + x
-        self.text_framebuffer[pos:pos+len(data)] = data
+        # self.text_framebuffer[pos:pos+len(data)] = data
+        for c in data:
+            for i, bits in enumerate(bytearray(font8x14.VGA_FONT[ord(c)])):
+                self.write_graphics(x, y, i, [bits])
+            x=x+1
     def write_graphics(self, x, y, row, data):
         if x + len(data) > 16:
             data = data[:16 - min(x, 16)]

@trevjonez
Copy link
Contributor

what kind of increased load does that put on the MCU? seems like a decent short term workaround while we wait for btt to finish the char generator.

@sagreen83
Copy link

sagreen83 commented Apr 6, 2021

Is anyone actively working on adding TFT35 support (native BTT touch firmware) to Klipper?

@moebis
Copy link

moebis commented Apr 17, 2021

Too bad it's not possible to bypass the marlin mode completely and built a nice color and touch interface for Klipper and TFT35

@Jhyrachy
Copy link

in theory is possible, the problem is the knowledge to do it

@Vybramo
Copy link

Vybramo commented May 10, 2021

Realy thank @Sineos and @teeminus
I do confirm that TFT24 is working as per your instructions.
At first (maybe very tired eyes) I did not find/saw the st7920.py in klipper/klippy/extras/display.

Modded and now it's showing clearly the screen text:

TFT24
For testing purposes I warmed the nozzle to 50°C but the TFTscreen remained at 21°

moreover The mainsail webgui is reporting me dirty Klipper version,I Suppose cause of the editing:
Schermata 2021-01-17 alle 11 20 59

How you let ur display work ? Its will be good for me just use it in marlin mode.

@SmartFabian
Copy link

SmartFabian commented Jun 26, 2021

Hello,

the mod is working for me, but I have the same flicker during printing as @teeminus.
Only during printing 80% of the display turns black for 1 sec and then show again everything for 1 sec during the hole print. Is there a workaround?

EDIT: I have the same issue if I now use the original ender 3 display. and again only during a printjob

Greetings from Germany

@pixeldoc2000
Copy link

pixeldoc2000 commented Jun 26, 2021

@teeminus

Did a Test on my BIQU B1 with the stock "BIGTREE TFT35 V3.0 B1 Touchscreen" flashed with your NoTouchFW v1.3 .

grafik

It works fine. Thank you for your awesome work!

fluidd: v1.15.0
klipper: v0.9.1-586-g8bce8924
moonraker: v0.6.0-160-gd3df568

printer.cfg

[display]
lcd_type: st7920
cs_pin: EXP1_4
sclk_pin: EXP1_5
sid_pin: EXP1_3
encoder_pins: ^EXP2_3, ^EXP2_5
click_pin: ^!EXP1_2

EDIT: The Display does not react to Input and does not Update after starting a print.

@ihrapsa
Copy link

ihrapsa commented Aug 16, 2021

Is anyone actively working on adding TFT35 support (native BTT touch firmware) to Klipper?

If anyone's interested in adding TFT touchscreen support for Klipper, check Desuuuu's work on the runtime-uart branch. He's been working on a sort of serial pass-through implementation that will allow dynamically control of TFTs from the klippy host through mainboard's secondary serial interface (in the same way Klipper already works with I²C and SPI). Maybe someone could use that to finally port the btt touchscreen TFT in Klipper 😄

@Plaethe
Copy link

Plaethe commented Oct 16, 2021

oooh, exciting! I'm a long-time Marlin user who converted his Artillery Sidewinder X1 to Klipper today, and the "idle" display really bothered me. Marlin Mode by itself is better than a touchscreen that's showing only wrong info.

AFAIK the SWX1 has a MKS TFT28 3.2 in there, i'm going to try your FW as soon as i'm done with all the Klipper tuning instructions.

Could please share the config for klipper? I am using the stock mks gen l and the stock tft screen. Many thanks!

@atomadog
Copy link

@teeminus

Did a Test on my BIQU B1 with the stock "BIGTREE TFT35 V3.0 B1 Touchscreen" flashed with your NoTouchFW v1.3 .

grafik

It works fine. Thank you for your awesome work!

fluidd: v1.15.0 klipper: v0.9.1-586-g8bce8924 moonraker: v0.6.0-160-gd3df568

printer.cfg

[display]
lcd_type: st7920
cs_pin: EXP1_4
sclk_pin: EXP1_5
sid_pin: EXP1_3
encoder_pins: ^EXP2_3, ^EXP2_5
click_pin: ^!EXP1_2

EDIT: The Display does not react to Input and does not Update after starting a print.

Use this

[display]
lcd_type: emulated_st7920
spi_software_miso_pin: EXP2_1
spi_software_mosi_pin: EXP1_3
spi_software_sclk_pin: EXP1_5
en_pin: EXP1_4
encoder_pins: ^EXP2_5, ^EXP2_3
click_pin: ^!EXP1_2

@pixeldoc2000
Copy link

pixeldoc2000 commented Nov 22, 2021

@atomadog

Thanks atomadog, but I have isssus with Both lcd_type: st7920 and lcd_type: emulated_st7920 on my BIQU B1 as the Display freezes or shows corrupted Image at random after starting a Print.

See teeminus/NoTouchScreenFirmware#47 and teeminus/NoTouchScreenFirmware#43

@hapklaar
Copy link

@pixeldoc2000

Currently I have the screen on the B1 working almost without issue (as in freezes or screen corruption). I use v 1.3.1 and the following config in printer.cfg.

[display]
lcd_type: emulated_st7920
spi_software_miso_pin: EXP2_1
spi_software_mosi_pin: EXP1_3
spi_software_sclk_pin: EXP1_5
spi_speed: 1000000
en_pin: EXP1_4
encoder_pins: ^EXP2_3, ^EXP2_5
click_pin: ^!EXP1_2

@pixeldoc2000
Copy link

@hapklaar

You are using a different spi_software_miso_pin: EXP2_1. I guess this is not by accident? How did you discover it?

With v1.3.1 you mean NoTouchFirmware i guess?

I will give it a try and Report back.

@hapklaar
Copy link

@pixeldoc2000 Can't remember where I got the miso_pin config. I do indeed mean the NoTouchFirmware 1.3.1

@teeminus
Copy link
Contributor

There has been a discussion of on how to choose the MISO here: teeminus/NoTouchScreenFirmware#25

@pixeldoc2000
Copy link

pixeldoc2000 commented Nov 26, 2021

@hapklaar
Still the same issus with NoTouchScreenFirmware FW 1.3.1 and different pins.

Starting to think it is an issus with my Printer or my Hardware Setup.

What Hardware Setup do you have?

I have an original BLTouch 3.1 and the Stock Filament Runout Sensor connected to the Mainboard instead of the Display. Latest Klipper and Firmware with fluiddpi.

@hapklaar
Copy link

@hapklaar Still the same issus with FW 1.3.1 and different pins.

Starting to think it is an issus with my Printer or my Hardware. What Hardware do you have connected? I have an original BLTouch 3.1 and the Stock Filament Runout Sensor connected to the Mainboard instead of the Display.

Also original BLTouch 3.1, filament runout sensor still connected to display. I replaced the tmc2208's at some point with 2209's. I run all the latest klipper software and firmware (updated with kiauh)

@pixeldoc2000
Copy link

pixeldoc2000 commented Nov 28, 2021

Tried BIGTREETECH-TouchScreenFirmware in Marlin Mode. I get the same issue as with NoTouchFirmware, so looks like it is a problem with my setup/hardware on my BIQU B1, not the Display Firmware.

@mlaci001
Copy link

The same is true with the E3 turbo and TFT35-E3-v3.
The screen is blank.
If the TFT button is held down for 3 seconds, the mode selection window will appear, here you have to select the Marlin mode (no matter what mode the screen is in).
The screen will still be blank, but if you press the button again, the menu will appear and work from there.
You have to do it again every time you start.
I don't know why it's not good at startup.
I can't use emulated_st7920 mode, the motherboard only has an EXP1 connector.

@pixeldoc2000
Copy link

@mlaci001
Did you try NoTouchFirmware with your Display ? Sound like you are still running the "Default" Firmware or BIGTREETECH-TouchScreenFirmware.

@mlaci001
Copy link

@pixeldoc2000
[Original firmware]:
The screen is blank.
If the TFT button is held down for 3 seconds, the mode selection window will appear, here you have to select the Marlin mode (no matter what mode the screen is in).
The screen will still be blank, but if you press the button again, the menu will appear and work from there.
[NoTouchFirmware]:
Cold boot ok, but after firmware restart (klipper) garbage characters come up.

@r00t4rd3d
Copy link

This is kinda unbelievable that the TFT35 and Klipper cant work together in touch screen mode. I dont get why the devs dont fix this themselves? BTT has their own version of Klipper so why the hell dont they fix this crap?

@lucasromeiro
Copy link

Any new about this. I have the same problem 😞

@miracuruzrh
Copy link

Hello

I had the same issue like others with the BTT TFT50v3 display. I use it together with the BTT SKR v1.4 turbo mainboard.
The issue was the same like the first screenshot with the cryptic lines and dots. What helped for me is to update the firmware of the TFT using the git firmware repository. After the update it suddenly worked.

Here is the printer.cfg section which works for me:

[board_pins]
aliases:
    # EXP1 header
    EXP1_1=P1.30, EXP1_3=P1.18, EXP1_5=P1.20, EXP1_7=P1.22, EXP1_9=<GND>, # XXX
    EXP1_2=P0.28, EXP1_4=P1.19, EXP1_6=P1.21, EXP1_8=P1.23, EXP1_10=<5V>, # XXX
    # EXP2 header
    EXP2_1=P0.17, EXP2_3=P3.26, EXP2_5=P3.25, EXP2_7=P1.31, EXP2_9=<GND>, # XXX
    EXP2_2=P0.15, EXP2_4=P0.16, EXP2_6=P0.18, EXP2_8=<RST>, EXP2_10=<NC>  # XXX
    # Pins EXP2_1, EXP2_6, EXP2_2 are also MISO, MOSI, SCK of bus "ssp0"
    
    [display]
lcd_type: emulated_st7920
encoder_pins: ^EXP2_3, ^EXP2_5
spi_software_miso_pin: EXP2_1
spi_software_mosi_pin: EXP1_3
spi_software_sclk_pin: EXP1_5
en_pin: EXP1_4
encoder_pins: ^EXP2_5, ^EXP2_3
click_pin: ^!EXP1_2
spi_speed: 1000000

# #display_group:
menu_timeout: 1

@Minims
Copy link

Minims commented May 17, 2023

@KevinOConnor Is it possible to run Klipper on this screen using a stm32 chip (I think yes) and use it like in [mcu] as display like the Voron V0 display does ? Maybe the issue is on lcd_type here ? Thanks.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests