LoginSignup
0
0

Waveshare RP2040-LCD-0.96で日本語表示

Last updated at Posted at 2023-04-21

概要

何かマイコンで物作りをしたいと思ったときディスプレイ表示があると便利です。
用途にもよりますがスペースに余裕があればI/Oも多い方が良いです。

そこで今回、ディスプレイ付きで比較的安価な製品である「Waveshare RP2040-LCD-0.96」を購入しました。
日本語表示で苦労したので記録として残しておきます。

スクリーンショット 2023-04-21 152854.png

環境

エディタ:VisualStudioCode(拡張機能:PlatformIO IDE)
ライブラリはPlatformIOで以下の2つをインストールしました
 1. U8g2_for_Adafruit_GFX
 2. Adafruit ST7735 and ST7789 Library

コード

#include <Arduino.h>
#include <U8g2_for_Adafruit_GFX.h>
#include <Adafruit_ST7735.h>

//ピン番号設定
#define TFT_DC      8   // DC
#define TFT_CS      9   // CS
#define TFT_SCLK    10  // Clock
#define TFT_MOSI    11  // MOSI
#define TFT_RST     12  // Reset 

Adafruit_ST7735 tft = Adafruit_ST7735(&SPI1, TFT_CS, TFT_DC, TFT_RST);
U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx;

void setup() {
    SPI1.setTX(TFT_MOSI);                      
    SPI1.setSCK(TFT_SCLK);
    tft.initR(INITR_GREENTAB);
    tft.initR(INITR_MINI160x80);                
    tft.invertDisplay(true);
    tft.setRotation(3);
    tft.fillScreen(ST77XX_BLACK);
    u8g2_for_adafruit_gfx.begin(tft);
}

void loop() {
  u8g2_for_adafruit_gfx.setFontMode(0);             
  u8g2_for_adafruit_gfx.setFontDirection(0);   
  u8g2_for_adafruit_gfx.setForegroundColor(ST77XX_MAGENTA);
  u8g2_for_adafruit_gfx.setFont(u8g2_font_b12_t_japanese1);
  u8g2_for_adafruit_gfx.setCursor(40, 40);               
  u8g2_for_adafruit_gfx.print("日本語表示");
  delay(1000);
}

参考サイト

0
0
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
0
0