HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
LINK
BACK
 

2023/08/14

72x40の OLEDの画面表示が出るまでに時間が掛かるのを修正する方法 OLED SSD1306 0.42'

(How to fix OLED 0.42' 72x40 screen display slow to appear)

Tags: [電子工作]




● 72x40の OLEDの画面表示が出るまでに時間が掛かるのを修正する方法 OLED SSD1306 0.42'
 How to fix OLED 0.42' 72x40 screen display slow to appear

 U8g2のライブラリの下記の issueに解決方法が書いて有ります。

Request for SSD1306 72x40 oled support #1047

 72x40 0.42'の OLEDは制御 ICに SSD1306Bを使用しており、IREFコマンドで IREFの設定が必要です。(ノーマルの SSD1306には同コマンドは無い)

SSD1306B v1.1
https://www.mouser.com/datasheet/2/127/W064048_XALG-1275539.pdf
https://www.digikey.de/htmldatasheets/production/3647274/5/0/1/ea-oleds102-6lwa.pdf

・IREFコマンドで IREFの設定が必要
IREFコマンドで IREFの設定が必要



 SSD1306B用に IREFコマンドを指定しない場合、下記の動画の様に表示の立ち上がりが遅いです。
QMK VIA RP2040 Keyboard Quantizer with Audio (Piezo Buzzer) Handwired



● Arduinoの場合

2023/08/04
【ソースコード有】Arduino RP2040で I2C接続の OLED SSD1306 72x40 0.42をサクッと動かす方法
【ソースコード有】Arduino RP2040で I2C接続の OLED SSD1306 72x40 0.42をサクッと動かす方法

  Arduino RP2040 I2C OLED SSD1306 72x40 0.42 tutorial


● QMKファームフェアの OLEDドライバの改変例

 最近の QMKファームフェアは PRE_CHARGE_PERIODに関しては define定義で対応が可能です。

 黄色行が 72x40 0.42' SSD1306Bに特有の行です。

/* [2] pre-charge period 0x022/f1, 0.42 OLED datasheet: 0x22 */
#define OLED_PRE_CHARGE_PERIOD 0x22

      static const uint8_t PROGMEM display_setup1[] = {
        0x00, // I2C_CMD
        0x0ad, 0x010, /* Internal IREF Setting for the 0.42 OLED, see also issue https://github.com/olikraus/u8g2/issues/1047 */
      };

      if (!oled_send_cmd_P(display_setup1, ARRAY_SIZE(display_setup1))) {
          print("oled_init cmd set 1 failed\n");
          return false;
      }

oled_driver.c
    static const uint8_t PROGMEM display_setup1[] = {
        I2C_CMD,
        DISPLAY_OFF,
        DISPLAY_CLOCK,
        OLED_DISPLAY_CLOCK,
        MULTIPLEX_RATIO,
#if OLED_IC_COM_PINS_ARE_COLUMNS
        OLED_DISPLAY_WIDTH - 1,
#else
        OLED_DISPLAY_HEIGHT - 1,
#endif
#if OLED_IC == OLED_IC_SH1107
        SH1107_DISPLAY_START_LINE,
        0x00,
#else
        DISPLAY_START_LINE | 0x00,
#endif

        0x0ad, 0x030, /* Internal IREF Setting for the 0.42 OLED, see also issue https://github.com/olikraus/u8g2/issues/1047 */

        CHARGE_PUMP,
        0x14,
#if OLED_IC_HAS_HORIZONTAL_MODE
        // MEMORY_MODE is unsupported on SH1106 (Page Addressing only)
        MEMORY_MODE,
        0x00, // Horizontal addressing mode
#elif OLED_IC == OLED_IC_SH1107
        // Page addressing mode
        SH1107_MEMORY_MODE_PAGE,
#endif
    };


● QMKファームフェアの OLEDドライバの改変例

 古いバージョンの QMKファームフェアは OLEDドライバの ssd1306_sh1106.cのソースコードを直接編集する必要が有ります。

 黄色行が 72x40 0.42' SSD1306Bに特有の行です。

ssd1306_sh1106.c
    static const uint8_t PROGMEM display_setup1[] = {
        I2C_CMD,

        DISPLAY_OFF,
        DISPLAY_CLOCK,
        0x80,
        MULTIPLEX_RATIO,
        OLED_DISPLAY_HEIGHT - 1,
        DISPLAY_OFFSET,
        0x00,
        DISPLAY_START_LINE | 0x00,

        0x0ad, 0x030, /* Internal IREF Setting for the 0.42 OLED, see also issue https://github.com/olikraus/u8g2/issues/1047 */

        CHARGE_PUMP,
        0x14,
#if (OLED_IC != OLED_IC_SH1106)
        // MEMORY_MODE is unsupported on SH1106 (Page Addressing only)
        MEMORY_MODE,
        0x00,  // Horizontal addressing mode
#endif
    };

    static const uint8_t PROGMEM display_setup2[] = {I2C_CMD,
        COM_PINS, OLED_COM_PINS,
        CONTRAST, OLED_BRIGHTNESS,
        // PRE_CHARGE_PERIOD, 0xF1,
        PRE_CHARGE_PERIOD, 0x022, /* [2] pre-charge period 0x022/f1, 0.42 OLED datasheet: 0x22 */
        VCOM_DETECT, 0x20,
        DISPLAY_ALL_ON_RESUME,
        NORMAL_DISPLAY,
        DEACTIVATE_SCROLL,
        DISPLAY_ON
    };


● U8g2ライブラリを使った 0.42 OLEDのサンプル

RP2040-GraphicsTest.ino

 U8G2_SSD1306_72X40_ER_F_HW_I2Cを使用します。
U8G2_SSD1306_72X40_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);   // EastRising 0.42" OLED

 GPIOの定義は下記を書き換える。
 OLED
  Wire.setSDA(22);
  Wire.setSCL(23);

 WS2812 RGB LED
#define LED_PIN 12
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);

  uint32_t colors[] = {RED, GREEN}; // create an array of colors
  ws2812fx.setSegment(0, 0, LED_COUNT-1, FX_MODE_FADE, colors, 1000, NO_OPTIONS);

RP2040 I2C OLED 72x40 0.42 SSD1306 setContrast demo





Tags: [電子工作]



[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c) 2023 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/hardware/oled_72x40_fix_start_up/