「デカ文字」M5NanoC6+SSD1306、8倍角「埼玉」と表示して遊ぶ。(ピコピコファクトリーあるよ621



参考
----

https://github.com/Tamakichi/Arduino-misakiUTF16



いろいろ注意
----

- 過去ログを見よ!!!


結果
----


![image_original(48).jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/26a2698f-ea69-4655-8e62-710b67c09b23.jpeg)



プログラム
----

```c++



//misaki_test_hatibai1_M5NanoC6
//8倍角「埼玉」を表示

//ヘッダーファイル
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <misakiUTF16.h>


//定義
#define SCREEN_WIDTH 128     // OLED display width, in pixels
#define SCREEN_HEIGHT 64     // OLED display height, in pixels
#define OLED_RESET -1        // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C  ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


//2倍角の文字列を表示
void k_print(int x, int y, char *ptr) {

  unsigned char font[8];        // フォント格納バッファ
  unsigned char font2[8 * 64];  // フォント格納バッファ

  while (*ptr) {                         // 文字列分ループ
    ptr = getFontData(font, ptr, true);  // 1文字分のフォント取得
    if (!ptr)
      break;  // エラーの場合は終了


    int j = 0;                     //8倍角出力フォントのカウンター
    for (int i = 0; i < 8; i++) {  //フォントの8倍角化ループ

      int al;
      int bk = font[i];  //入力フォントの読み出し
      int b1 = 0;
      int b2 = 0;
      int b3 = 0;
      int b4 = 0;
      int b5 = 0;
      int b6 = 0;
      int b7 = 0;
      int b8 = 0;


      //8bit
      al = bk;
      al = al >> 7;
      al = 1 - al;
      b8 = 0xff + al;


      //7bit
      al = bk;
      al = al >> 6;
      al = al & 0x01;
      al = 1 - al;
      b7 = 0xff + al;

      //6bit
      al = bk;
      al = al >> 5;
      al = al & 0x01;
      al = 1 - al;
      b6 = 0xff + al;

      //5bit
      al = bk;
      al = al >> 4;
      al = al & 0x01;
      al = 1 - al;
      b5 = 0xff + al;


      //eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee


      //4bit
      al = bk;
      al = al >> 3;
      al = al & 0x01;
      al = 1 - al;
      b4 = 0xff + al;

      //3bit
      al = bk;
      al = al >> 2;
      al = al & 0x01;
      al = 1 - al;
      b3 = 0xff + al;

      //2bit
      al = bk;
      al = al >> 1;
      al = al & 0x01;
      al = 1 - al;
      b2 = 0xff + al;

      //1bit
      al = bk;
      al = al & 0x01;
      al = 1 - al;
      b1 = 0xff + al;


      //1
      font2[j++] = b8;
      font2[j++] = b7;
      font2[j++] = b6;
      font2[j++] = b5;

      font2[j++] = b4;
      font2[j++] = b3;
      font2[j++] = b2;
      font2[j++] = b1;

      //2
      font2[j++] = b8;
      font2[j++] = b7;
      font2[j++] = b6;
      font2[j++] = b5;

      font2[j++] = b4;
      font2[j++] = b3;
      font2[j++] = b2;
      font2[j++] = b1;

      //3
      font2[j++] = b8;
      font2[j++] = b7;
      font2[j++] = b6;
      font2[j++] = b5;

      font2[j++] = b4;
      font2[j++] = b3;
      font2[j++] = b2;
      font2[j++] = b1;

      //4
      font2[j++] = b8;
      font2[j++] = b7;
      font2[j++] = b6;
      font2[j++] = b5;

      font2[j++] = b4;
      font2[j++] = b3;
      font2[j++] = b2;
      font2[j++] = b1;

      //5
      font2[j++] = b8;
      font2[j++] = b7;
      font2[j++] = b6;
      font2[j++] = b5;

      font2[j++] = b4;
      font2[j++] = b3;
      font2[j++] = b2;
      font2[j++] = b1;

      //6
      font2[j++] = b8;
      font2[j++] = b7;
      font2[j++] = b6;
      font2[j++] = b5;

      font2[j++] = b4;
      font2[j++] = b3;
      font2[j++] = b2;
      font2[j++] = b1;

      //7
      font2[j++] = b8;
      font2[j++] = b7;
      font2[j++] = b6;
      font2[j++] = b5;

      font2[j++] = b4;
      font2[j++] = b3;
      font2[j++] = b2;
      font2[j++] = b1;

      //8
      font2[j++] = b8;
      font2[j++] = b7;
      font2[j++] = b6;
      font2[j++] = b5;

      font2[j++] = b4;
      font2[j++] = b3;
      font2[j++] = b2;
      font2[j++] = b1;


    }  //for


    //ビットマップの表示
    display.drawBitmap(x, y, font2, 64, 64, WHITE);
    x = x + 64;

  }  //while

}  //k_print


//初期化
void setup() {

  // I2Cアドレスは使用するディスプレイに合わせて変更する
  display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);

}  //setup


//メインループ
void loop() {

  // 画面表示をクリア
  display.clearDisplay();


  //開始　2倍角の文字列の表示
  char *str = "埼玉";  // 文字列
  int x = 0;
  int y = 0;
  k_print(x, y, str);
  //終了


  // 描画バッファの内容を画面に表示
  display.display();

  delay(5000);  //5秒待つ

}  //loop




```