「デカ文字」ST7735S(Parallel)に46とブロック文字を表示(Arduino UNO)


目的
ブロックデカ文字の表示


![o_coq114.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/d5df780e-417f-4084-3ac3-9aaa927dacd9.jpeg)

![o_coq112.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/bc12609e-8b7c-693b-aaca-6e1fc21d4a51.jpeg)



![o_coq115.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/54380848-835f-0bb4-6e74-0749e9373fd9.jpeg)



```c++



//ssd1306_block_0123456789_UNO_1


//インクルド
#include <Arduino.h>


//定義
//GPIO
#define GPIO1(s) digitalWrite( 2,s)  //RESET
#define GPIO2(s) digitalWrite(A5,s)  //A0
#define GPIO3(s) digitalWrite( 3,s)  //WR
#define GPIO4(s) digitalWrite(A4,s)  //RD

int s_color = 0xFFFF;

char s_dot[20][16];

//1234567890
uint8_t ch_data7[8 * 11] = {
  0x70, 0x88, 0x98, 0xa8, 0xc8, 0x70, 0x00, 0x00, //( 48) 0
  0x10, 0x30, 0x50, 0x10, 0x10, 0x10, 0x00, 0x00, //( 49) 1
  0x70, 0x88, 0x08, 0x30, 0x40, 0xf8, 0x00, 0x00, //( 50) 2
  0x70, 0x88, 0x30, 0x08, 0x88, 0x70, 0x00, 0x00, //( 51) 3
  0x18, 0x28, 0x48, 0x88, 0xf8, 0x08, 0x00, 0x00, //( 52) 4
  0xf8, 0x80, 0xf0, 0x08, 0x08, 0xf0, 0x00, 0x00, //( 53) 5
  0x78, 0x80, 0xf0, 0x88, 0x88, 0x70, 0x00, 0x00, //( 54) 6
  0xf8, 0x08, 0x10, 0x20, 0x20, 0x20, 0x00, 0x00, //( 55) 7
  0x70, 0x88, 0x70, 0x88, 0x88, 0x70, 0x00, 0x00, //( 56) 8
  0x70, 0x88, 0x78, 0x08, 0x88, 0x70, 0x00, 0x00, //( 57) 9
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  //(   ) ` `
};

//パラレルポートにデータをセットする。
void GPIO_8BIT(int s)
{
  digitalWrite(A0, (s >> 7) & 0x01); //DB7
  digitalWrite( 7, (s >> 6) & 0x01); //DB6
  digitalWrite(A1, (s >> 5) & 0x01); //DB5
  digitalWrite( 6, (s >> 4) & 0x01); //DB4
  digitalWrite(A2, (s >> 3) & 0x01); //DB3
  digitalWrite( 5, (s >> 2) & 0x01); //DB2
  digitalWrite(A3, (s >> 1) & 0x01); //DB1
  digitalWrite( 4,  s       & 0x01); //DB0
} //GPIO_8BIT

//コマンドの書き込み
void LCD_Write_CMD(int a)
{
  GPIO2(0); //A0=0;
  GPIO_8BIT(a);//P1=a; data
  GPIO3(0);//WRB=0;
  GPIO3(1);//WRB=1;
} //LCD_Write_CMD


//データ書き込み
void LCD_Write_Data(int a)
{
  GPIO2(1);//A0=1;
  GPIO_8BIT(a);//P1=a; data
  GPIO3(0);//WRB=0;
  GPIO3(1);//WRB=1;
} //LCD_Write_Data

//液晶の初期化処理
void ATM0177B5_ST7735S_Init(void)
{

  //----------  ST7735S Reset Sequence  --------//

  GPIO1(1);//LCD_RESET=1;

  delay(1); //Delay 1ms

  GPIO1(0);//LCD_RESET=0;

  delay(1); //Delay 1ms

  GPIO1(1);//LCD_RESET=1;

  delay(120); //Delay 120ms

  //----------  ST7735S Reset Sequence  --------//


  LCD_Write_CMD(0x01);//SOFTWARE RESET
  delay(50);

  LCD_Write_CMD(0x11);//SLEEP OUT
  delay(200);

  LCD_Write_CMD(0x29);//display on
  delay(100);

  LCD_Write_CMD(0x3a);//Interface pixel format
  LCD_Write_Data(0x05);//16bit mode
  delay(100);

  LCD_Write_CMD(0x36);//RGB-RGR format
  LCD_Write_Data(0x08);//RGB mode
  delay(100);


  // y,x
  for (int y = 0; y < 20; y++) {
    for (int x = 0; x < 16; x++) {
      s_dot[y][x] = 0;
    }//for x
  }//for y

  //s_dot[3][3]=0;//debug


} //ATM0177B5_ST7735S_Init


void set_color(int color) {

  s_color = color;

}//set_color

void refresh() {

  int color_h;
  int color_l;

  //画面の書き込み開始
  LCD_Write_CMD(0x2C); //memory write
  GPIO2(1);//A0=1;
  delay(2);

  color_h = (s_color >> 8) & 0xff;
  color_l =  s_color       & 0xff;
  for (int y = 0; y < 20; y++) {
    for (int k = 0; k < 7; k++) {
      for (int x = 0; x < 16; x++) {
        for (int i = 0; i < 7; i++) {
          if ( s_dot[y][x] != 0) {
            GPIO_8BIT( color_h );//P1=a; data
            GPIO3(0);//WRB=0;
            GPIO3(1);//WRB=1;

            GPIO_8BIT( color_l );//P1=a; data
            GPIO3(0);//WRB=0;
            GPIO3(1);//WRB=1;
          } else {
            GPIO_8BIT(0x00);//P1=a; data
            GPIO3(0);//WRB=0;
            GPIO3(1);//WRB=1;

            GPIO3(0);//WRB=0;
            GPIO3(1);//WRB=1;
          }//end if
        }//for 8
        GPIO_8BIT(0x00);//P1=a; data

        GPIO3(0);//WRB=0;
        GPIO3(1);//WRB=1;

        GPIO3(0);//WRB=0;
        GPIO3(1);//WRB=1;
      }//for 16
    }//for 7
    for (int i = 0; i < 128; i++) {
      GPIO3(0);//WRB=0;
      GPIO3(1);//WRB=1;

      GPIO3(0);//WRB=0;
      GPIO3(1);//WRB=1;
    }//for i
  }//for tt

}//refresh

//初期化
void setup() {

  //ポートのモード設定
  //アウトプットモード
  pinMode( 2, OUTPUT); //REST
  pinMode(A5, OUTPUT); //RS
  pinMode( 3, OUTPUT); //WR
  pinMode(A4, OUTPUT); //RD

  pinMode( 4, OUTPUT); //DB0
  pinMode(A3, OUTPUT); //DB1
  pinMode( 5, OUTPUT); //DB2
  pinMode(A2, OUTPUT); //DB3

  pinMode( 6, OUTPUT); //DB4
  pinMode(A1, OUTPUT); //DB5
  pinMode( 7, OUTPUT); //DB6
  pinMode(A0, OUTPUT); //DB7

  //ポートの初期化
  GPIO4(1);//RD=1
  GPIO3(0);//WR=0
  GPIO2(0);//RS=0
  GPIO1(1);//RESET=1

  delay(500); //0.5秒待つ

  //液晶の初期化処理
  ATM0177B5_ST7735S_Init();


  char st_p[2][8] = {
    {' ', '4', '6'},
    {' ', ' ', ' '}
  };

  int p;
  for (int jj = 0; jj < 2; jj++) {
    for (int ii = 0; ii < 3; ii++) {
      for (int y = 0; y < 6; y++) {
        if ( st_p[jj][ii] == ' ') {
          st_p[jj][ii] = ':';
        }
        p = ch_data7[ (  ( st_p[jj][ii] - '0' )   * 8) + y ];
        for (int x = 0; x < 5; x++) {
          s_dot[x + (ii * 6) + 1][(14 - (jj * 7)) - y] =  p & 0x80;
          p = p << 1;
        }//for x
      }//for y
    }//for ii
  }//for jj

  refresh();

} //setup


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

  delay(100); //ダミー

} //loop



```