ILI9163V(ST7735のような)で遊ぶ3(2週間から2か月の長期記事)(洗濯ばさみ)ATM01177B3A


ILI9163V(ST7735のような)で遊ぶ3(2週間から2か月の長期記事)(洗濯ばさみ)ATM01177B3A


目的
カラー液晶のテスト

![o_cop828.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/06e2e389-ec66-0b34-5a78-4abbd682acdd.jpeg)


![o_cop826.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/5893a621-d9d3-a9a6-55e8-30c145b86757.jpeg)


![o_cop827.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/3562851e-0abd-5afa-a9cf-9a740aa5e33e.jpeg)



sentakubasami3.h


https://qiita.com/caa45040/items/ad58b94a94b4930c5957


ili9163v_test_test2_767_1


```c++:ili9163v_test_test2_767_1


//ili9163v_test_test2_767_1


//インクルド
#include "sentakubasami3.h"


//GPIO
#define GPIO_D13(s) digitalWrite(13,s)
#define GPIO_D12(s) digitalWrite(12,s) //未使用
#define GPIO_D11(s) digitalWrite(11,s)
#define GPIO_D10(s) digitalWrite(10,s)
#define GPIO_D9(s)  digitalWrite(9,s)
#define GPIO_D8(s)  digitalWrite(8,s)


void GPIO_D0_D7(int s)
{
  digitalWrite(13, 0);
  digitalWrite(11, (s >> 7) & 0x01);
  digitalWrite(13, 0);
  digitalWrite(13, 1);
  digitalWrite(13, 0);
  digitalWrite(11, (s >> 6) & 0x01);
  digitalWrite(13, 0);
  digitalWrite(13, 1);
  digitalWrite(13, 0);
  digitalWrite(11, (s >> 5) & 0x01);
  digitalWrite(13, 0);
  digitalWrite(13, 1);
  digitalWrite(13, 0);
  digitalWrite(11, (s >> 4) & 0x01);
  digitalWrite(13, 0);
  digitalWrite(13, 1);
  digitalWrite(13, 0);
  digitalWrite(11, (s >> 3) & 0x01);
  digitalWrite(13, 0);
  digitalWrite(13, 1);
  digitalWrite(13, 0);
  digitalWrite(11, (s >> 2) & 0x01);
  digitalWrite(13, 0);
  digitalWrite(13, 1);
  digitalWrite(13, 0);
  digitalWrite(11, (s >> 1) & 0x01);
  digitalWrite(13, 0);
  digitalWrite(13, 1);
  digitalWrite(13, 0);
  digitalWrite(11, s & 0x01);
  digitalWrite(13, 0);
  digitalWrite(13, 1);
  digitalWrite(13, 0);
} //GPIO_D0_D7


//ライト コマンド
void LCD_Write_CMD(int a)
{

  GPIO_D10(0);//CS=0; 12
  GPIO_D8(0); //A0=0; 9
  GPIO_D0_D7(a);//P1=a; data SPI SPI
  GPIO_D10(1);//CS=1; 12

} //LCD_Write_CMD


//ライト データ
void LCD_Write_Data(int a)
{

  GPIO_D10(0);//CS=0; 12
  GPIO_D8(1); //A0=1; 9
  GPIO_D0_D7(a);//P1=a; data SPI SPI
  GPIO_D10(1);//CS=1; 12

} //LCD_Write_Data


//画面の書き込み
void P_display(void)
{
  //画面の書き込み開始
  LCD_Write_CMD(0x2C); //memory write
  delay(1);

  unsigned char vg = 0;
  unsigned char hp[8] = {0x80, 0x40, 0x20, 0x10,  0x08, 0x04, 0x02, 0x01};
  for (int i = 0; i < ((128 / 8) * 160); i++) {
    vg = databytes[i];
    for (int k = 0; k < 8; k++) {

      if ( ( vg & hp[k]) == 0 ) {
        LCD_Write_Data(0x00);
        LCD_Write_Data(0x00);
      } else { //        12345678
        LCD_Write_Data(0b11111111);
        LCD_Write_Data(0b11111111);
      }//enf if

    }//k
  }//i
} //P_display


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

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

  GPIO_D9(1);//LCD_RESET=1;

  delay(1); //Delay 1ms

  GPIO_D9(0);//LCD_RESET=0;

  delay(1); //Delay 1ms

  GPIO_D9(1);//LCD_RESET=1;

  delay(120); //Delay 120ms

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

  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(0x36);//RGB-RGR format
  LCD_Write_Data(0x00);//RGB mode
  delay(100);

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

} //TXDT144TF_ST7735S_Init


//初期化
void setup() {

  //ポートのモード設定　アウトプットモード
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT); //未使用
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);


  //ポートの初期化
  GPIO_D13(1);//SPI_DATA=1
  GPIO_D11(0);//SPI_CLK=1

  GPIO_D10(1);//CS=1
  GPIO_D9(1);//RESET=1
  GPIO_D8(0);//RS=0


  delay(500); //0.5秒待つ

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

  //洗濯ばさみの絵の表示
  P_display();

} //setup


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


```