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

add RA8875 Touch #605

Closed
wants to merge 2 commits into from
Closed

add RA8875 Touch #605

wants to merge 2 commits into from

Conversation

tobi807
Copy link
Contributor

@tobi807 tobi807 commented Aug 20, 2024

Added two header files to utilize the touch functionality of the RA8875 display driver. Copied from existing touch drivers, did'nt understand the meaning of all functions and variables but works so far.
display.calibrateTouch(...) and subsequent transfomation in display coordinates works nicely with the driver.

Sample Config

lgfx::Touch_RA8875  _touch_instance;

...

{ // タッチスクリーン制御の設定を行います。(必要なければ削除)
      auto cfg = _touch_instance.config();

      // SPI接続の場合
      cfg.bus_shared = true; // 画面と共通のバスを使用している場合 trueを設定
      cfg.spi_host = VSPI_HOST;// 使用するSPIを選択 (HSPI_HOST or VSPI_HOST)
      cfg.freq = 1000000;     // SPIクロックを設定
      cfg.pin_sclk = 18;
      cfg.pin_mosi = 23;
      cfg.pin_miso = 19;
      cfg.pin_cs   =  5;     //   CSが接続されているピン番号

      _touch_instance.config(cfg);
      _panel_instance.setTouch(&_touch_instance);  // タッチスクリーンをパネルにセットします。
}

@tobozo
Copy link
Collaborator

tobozo commented Aug 21, 2024

Hi, thanks for your contribution 👍

The test build failed for esp-idf, this is because digitalWrite() (an arduino-only function) is used in Touch_RA8875::init(void). Also digitalWrite() uses a hardcoded pin value.

    // enable Touch Panel
    // RA8875_TPCR0: RA8875_TPCR0_ENABLE | RA8875_TPCR0_WAIT_4096CLK | RA8875_TPCR0_WAKEENABLE | adcClk
    digitalWrite(4, HIGH);
    writeRegister8(0x70, 0x80 | 0x30 | 0x08 | 0x04); // 10mhz max!
    digitalWrite(4, LOW);

These two points should be addressed:

  1. assign GPIO pin 4 from the configuration block
    auto cfg = _touch_instance.config();
    cfg.pin_int = GPIO_NUM_4;
  1. use lgfx gpio functions instead of digitalWrite():
    lgfx::gpio_hi(_cfg.pin_int);
    lgfx::pinMode(_cfg.pin_int, pin_mode_t::output);
    writeRegister8(0x70, 0x80 | 0x30 | 0x08 | 0x04); // 10mhz max!
    lgfx::gpio_lo(_cfg.pin_int);

@tobozo tobozo self-requested a review August 21, 2024 13:18
@tobi807
Copy link
Contributor Author

tobi807 commented Aug 21, 2024

Ahh my bad. The digitalWrite is only used for my debugging. I'll remove it and create a new pull request

@tobi807 tobi807 closed this Aug 21, 2024
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