Last active
January 27, 2021 15:58
-
-
Save shikarunochi/3712aef9ab2a662617ea3c722a9575cd to your computer and use it in GitHub Desktop.
LGFX double LCD Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//本体 LCD と 外部 240x240小型液晶での出力。うまくいきました! | |
// https://twitter.com/shikarunochi/status/1354455285046231043?s=20 | |
#include <LovyanGFX.hpp> | |
#define LGFX_M5STACK | |
static LGFX lcd; | |
struct EXLCD_LGFX_Config | |
{ | |
static constexpr spi_host_device_t spi_host = HSPI_HOST; //本体LCDが VSPI を使っているので、別のピンで HSPI を使う。 | |
//VSPIでピンを共有する方法もあります。 | |
//https://gist.github.com/lovyan03/7e0cd8362d7252124ae281526d5eaac1 | |
//LovyanGFXでM5Stack本体内蔵LCDとSDカードとCS無しST7789とを共通のSPIバスで併用する例 | |
static constexpr int dma_channel = 2; //本体 VSPIが channel = 1 を使っているので別の channel | |
static constexpr int spi_sclk = 5; | |
static constexpr int spi_mosi = 2; | |
}; | |
static lgfx::LGFX_SPI<EXLCD_LGFX_Config> exLcd; | |
static lgfx::Panel_ST7789 panel; | |
void setup(){ | |
panel.spi_mode = 3; | |
panel.spi_read = false; | |
panel.spi_dc = 13; //ボトムには出ていないピン。BUSモジュールで繋いでいます。 | |
panel.gpio_rst = 12; //ボトムには出ていないピン。BUSモジュールで繋いでいます。 | |
panel.spi_cs = -1; | |
panel.gpio_bl = -1; | |
panel.pwm_ch_bl = -1; | |
panel.freq_write = 20000000; | |
panel.freq_fill = 20000000; | |
panel.freq_read = 20000000; | |
panel.invert = true; | |
exLcd.setPanel(&panel); | |
lcd.init(); | |
lcd.setFont(&fonts::Font4); | |
lcd.println("M5Stack!"); | |
lcd.println("M5Stack2!"); | |
exLcd.init(); | |
exLcd.setFont(&fonts::Font4); | |
exLcd.println("M5Stack Mini!"); | |
exLcd.println("M5Stack Mini2!"); | |
lcd.println("M5Stack3!"); | |
exLcd.println("M5Stack Mini3!"); | |
} | |
void loop(){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment