ST7735S(Parallel)に全画面ブロックを表示(Arduino UNO)


X 過去ログを見よ!!


目的
もじを表示を出来たらいいなーーーー


![o_coq113.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/820b7586-176f-6079-0ef8-8ccd27899e67.jpeg)

![o_coq112.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/fb3564f0-ef94-0380-3855-53b5759e3cc0.jpeg)

![o_coq115.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/e5200bd5-5f07-f142-a49c-ded1916435fa.jpeg)


```c++



//GPIO_ST7735_TEST1_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


//パラレルポートにデータをセットする。
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
  char s_dot[20][16];
  for (int y = 0; y < 20; y++) {
    for (int x = 0; x < 16; x++) {
      s_dot[y][x] = 1;
    }//for x
  }//for y

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

  int s_color = 0xFFFF;
  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

} //ATM0177B5_ST7735S_Init


//初期化
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();

} //setup


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

  delay(100); //ダミー

} //loop



```