3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GC9A01丸型液晶とM5StampS3をLovyanGFXで使う方法

Posted at

以前「Waveshare RP2040-LCD-1.28」と内容はほぼ同じですが、今回は液晶単独+M5StampS3の備忘録

製品情報はこちら
ドライバ:GC9A01A
インターフェース:SPI

製品は、探しせばAliExpressとかでよく出てくるやつです。

IMG_4711.jpg

M5StampS3の使い方はこちらとかをご参考ください

LovyanGFXを使ってみる

GC9A01ドライバに対応するLGFX作ります。

前回記事にした「Waveshare RP2040-LCD-1.28」とほぼ同じなので、こちらのGC9A01ドライバを修正して対応します。

配線

1.27ピンなんて半田付けできないのです。
2.54ピンを使用。

image.png

変更点

ポート番号
GPIO TYPE
GP9 DC
GP7 CS
GP15 SCL
GP13 SDA
GP12 RST

バス制御の設定

auto cfg = _bus_instance.config();    // バス設定用の構造体を取得します
cfg.pin_sclk   = 15;
cfg.pin_miso   = -1;
cfg.pin_mosi   = 13;
cfg.pin_dc     = 9;
auto cfg = _panel_instance.config();    // 表示パネル設定用の構造体を取得します。
cfg.pin_cs           =    7;  // CSが接続されているピン番号   (-1 = disable)
cfg.pin_rst          =    5;  // RSTが接続されているピン番号  (-1 = disable)

LGFXクラス

ポート等を設定したLGFXクラスは以下の通り

class LGFX : public lgfx::LGFX_Device
{
    lgfx::Panel_GC9A01      _panel_instance;
    lgfx::Bus_SPI       _bus_instance;   // SPIバスのインスタンス
    lgfx::Light_PWM     _light_instance;
  public:
    LGFX(void)
    {
      { // バス制御の設定を行います。
        auto cfg = _bus_instance.config();    // バス設定用の構造体を取得します。
        cfg.spi_host   = SPI2_HOST;
        cfg.spi_mode   = 0;
        cfg.freq_write = 80000000;
        cfg.pin_sclk   = 15;
        cfg.pin_miso   = -1;
        cfg.pin_mosi   = 13;
        cfg.pin_dc     = 9;
        _bus_instance.config(cfg);
        _panel_instance.setBus(&_bus_instance);
      }

      { // 表示パネル制御の設定を行います。
        auto cfg = _panel_instance.config();    // 表示パネル設定用の構造体を取得します。
        cfg.pin_cs           =    7;  // CSが接続されているピン番号   (-1 = disable)
        cfg.pin_rst          =    5;  // RSTが接続されているピン番号  (-1 = disable)
        cfg.panel_width      =   240;  // 実際に表示可能な幅
        cfg.panel_height     =   240;  // 実際に表示可能な高さ
        cfg.offset_x         =     0;  // パネルのX方向オフセット量
        cfg.offset_y         =     0;  // パネルのY方向オフセット量
        cfg.readable         =  true;  // データ読出しが可能な場合 trueに設定
        cfg.invert           =  true;  // パネルの明暗が反転してしまう場合 trueに設定

        _panel_instance.config(cfg);
      }

      setPanel(&_panel_instance); // 使用するパネルをセットします。
    }
};

動かしてみる

こちらも時計を出す。やっぱり丸はかっこいいね。

IMG_4710.jpg

まとめ

9月にM5Stackから丸型がでるそうなので、丸型欲しい方はそっちを待ってもいいかも。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?