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

cleanup & fix st7920 simulator (add klipper support) #705

Merged
merged 3 commits into from
May 23, 2020
Merged

cleanup & fix st7920 simulator (add klipper support) #705

merged 3 commits into from
May 23, 2020

Conversation

Msq001
Copy link
Contributor

@Msq001 Msq001 commented May 23, 2020

Description

  • cleanup st7920, Fix occasional display offset bug
  • st7920 simulator add support for klipper(Now the support is not perfect, because the compatibility problem, default code is used with Marlin, and if you want to use with kipper needs additional modification code).
    • if you use TFT24 V1.1, modify stm32f10x hal
      if you use TFT35 V3.0 etc.., modify stm32f2xx hal
      from SPI_ReEnable(!!(GPIOB->IDR & (1<<13))); to SPI_ReEnable(0);(because Marlin lpc176x st7920 spi is mode 0, but avr & stm32 is mode3, so marlin need to adapt by itself, but klipper is mode0, and the logic of SCK seems abnormal, so it cannot adapt, please set to mode 0 directly)
    • please modify void ST7920_DrawGDRAM(uint8_t data) function from
void ST7920_DrawGDRAM(uint8_t data)
{
  if (st7920_reg.fs.g != 1) return; // Graphic display off
  for (uint8_t i = 0; i < 8; i++) {
    if (data & 0x80)
      ST7920_DrawPixel(st7920.x, st7920.y, true);
    else
      ST7920_DrawPixel(st7920.x, st7920.y, false);
    data <<= 1;
    st7920.x++;
  }
  if (st7920.x >= 128) {
    st7920.x = 0;
    st7920.y = (st7920.y + 32);
    if (st7920.y >= 64) st7920.y = (st7920.y + 1) & (64 - 1);
  }
}

to

void ST7920_DrawGDRAM(uint8_t data)
{
  if (st7920_reg.fs.g != 1) return; // Graphic display off
  for (uint8_t i = 0; i < 8; i++) {
    if (data & 0x80)
      ST7920_DrawPixel(st7920.x, st7920.y, true);
    data <<= 1;
    st7920.x++;
  }
  if (st7920.x >= 128) {
    st7920.x = 0;
    st7920.y = (st7920.y + 32);
    if (st7920.y >= 64) st7920.y = (st7920.y + 1) & (64 - 1);
  }
}
  • There are still some unsolved bugs in the parts supporting klipper
    • The dynamic display of fan is abnormal in CGRAM when fan speed not 0
    • When the temperature changes in the status menu, the symbol of ° will be covered by space
    • klipper st7920 fonts is stored in stm32 flash, this is temporary. next PR will move it to W25qxx, which is convenient for users to customize fonts

Benefits

Related Issues

#290

@bigtreetech bigtreetech merged commit e6d8218 into bigtreetech:master May 23, 2020
@vodic62
Copy link

vodic62 commented May 23, 2020

Hi, thank you a lot for this commit. I already updated my TFT24 firmware, but my display is black most of the time. Only some times (once a day) it draws graphics on the display (works ok with Marlin). Same beahaviour I had with previous version o TFT24 firmware. Is my Klipper printer.cfg configuration of Bigtreetech SKR 1.3 board ok?

[board_pins]
aliases:
# EXP1 header
EXP1_1=P1.30, EXP1_3=P1.18, EXP1_5=P1.20, EXP1_7=P1.22, EXP1_9=,
EXP1_2=P0.28, EXP1_4=P1.19, EXP1_6=P1.21, EXP1_8=P1.23, EXP1_10=<5V>,
# EXP2 header
EXP2_1=P0.17, EXP2_3=P3.26, EXP2_5=P3.25, EXP2_7=P1.31, EXP2_9=,
EXP2_2=P0.15, EXP2_4=P0.16, EXP2_6=P0.18, EXP2_8=, EXP2_10=
# Pins EXP2_1, EXP2_6, EXP2_2 are also MISO, MOSI, SCK of bus "ssp0"

[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
kill_pin: ^!EXP2_8

delwinbest added a commit to delwinbest/BIGTREETECH-TouchScreenFirmware that referenced this pull request May 25, 2020
* master:
  cleanup & fix st7920 simulator (add klipper support) (bigtreetech#705)
  Add detection of Mainboard firmware type( Marlin or Smoothieware), auto-detect LONG_FILENAME_HOST_SUPPORT, on-boardSD and serial_always_on option in config file & other bugfixes (bigtreetech#663)
  Aesthetics, language, configuration (bigtreetech#667)
  Fix send_cancel_gcode in abortPrinting (bigtreetech#672)
  Fix heater indexes (bigtreetech#670)
  RU language correction (bigtreetech#701)
  Fix a few typos and add missing translations (bigtreetech#694)
@dushyantahuja
Copy link

dushyantahuja commented May 25, 2020

Same here - just uploaded the latest firmware to my TFT24 (compiled from the latest source) - and have the following in my config - I have a BTT SKR1.4 Turbo:

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

[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
#kill_pin: ^!EXP2_8

Still doesn't work - I just get a blank screen with "LCD12864 simulator" on top
Has anyone got it working - can you please advise if I've got the pins wrong, or maybe something else.

@Msq001
Copy link
Contributor Author

Msq001 commented May 25, 2020

Hello have modify here

  • st7920 simulator add support for klipper(Now the support is not perfect, because the compatibility problem, default code is used with Marlin, and if you want to use with kipper needs additional modification code).
  • if you use TFT24 V1.1, modify stm32f10x hal
    if you use TFT35 V3.0 etc.., modify stm32f2xx hal
    from SPI_ReEnable(!!(GPIOB->IDR & (1<<13))); to SPI_ReEnable(0);(because Marlin lpc176x st7920 spi is mode 0, but avr & stm32 is mode3, so marlin need to adapt by itself, but klipper is mode0, and the logic of SCK seems abnormal, so it cannot adapt, please set to mode 0 directly)

it's very important!

bigtreetech pushed a commit that referenced this pull request May 25, 2020
fix st7920 bugs after #705
@vodic62
Copy link

vodic62 commented May 25, 2020

I have followed your instructions and made modifications of spi_slave.c and ST7920_Simulator.c and compiled. Last week with old revision (without font support) I had black screen with occasional draw of graphics without fonts. With this latest revision with modifications from description I have black screen also, but I had no graphics redraw ever till now. Only some garbage on screen with some changes when rotating encoder happened yesterday. I have TFT24 V1.1 and SKR 1.3.

@Msq001
Copy link
Contributor Author

Msq001 commented May 25, 2020

Hello, please try this .bin firmware.
BIGTREE_TFT24_V1.1.26.1.zip

if it's ok, please set SPI_ReEnable(!!(GPIOB->IDR & (1<<13))); to SPI_ReEnable(1) not SPI_ReEnable(0) for TFT24 V1.1

@dushyantahuja
Copy link

Great, thanks - this works great.

@vodic62
Copy link

vodic62 commented May 25, 2020

I can confirm that when I made fresh git clone and made instructed modification my display started to work. Thank you.

@Tygrys-1
Copy link
Contributor

Tygrys-1 commented Jun 1, 2020

Can this be related to #735 ?

@dushyantahuja
Copy link

hmmm - it's still not perfect - especially when you reset the printer using the reset button on the TFT. Refuses to show anything after that.

jeffeb3 pushed a commit to jeffeb3/BIGTREETECH-TouchScreenFirmware that referenced this pull request Jul 20, 2020
* fix bug
* improve st7920 simulator for klipper
jeffeb3 pushed a commit to jeffeb3/BIGTREETECH-TouchScreenFirmware that referenced this pull request Jul 20, 2020
@DroneMang
Copy link

DroneMang commented Oct 7, 2020

if it's ok, please set SPI_ReEnable(!!(GPIOB->IDR & (1<<13))); to SPI_ReEnable(1) not SPI_ReEnable(0) for TFT24 V1.1

With this mod and recompile from BTT display works!

@rizwansarwar
Copy link

It does not still work properly. My screen sometimes shows up, sometimes it disappears completely and sometimes it shows total garbage on the screen. I think your fix does not totally fix the real issue.

@DroneMang
Copy link

DroneMang commented Oct 9, 2020 via email

@bigtreetech bigtreetech mentioned this pull request Apr 12, 2021
8 tasks
@Bl00d0und4
Copy link

Someone have a Wire Diagramm Form TFT24 v1.1?

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.

8 participants