#LetsDriveLCD [16] – two 320×160 screens

2015-09-30

320160

I bought these screens some while ago. The small one have integrated controller while the bigger one doesn’t. Both were sold for $1.5 each.

The integrated controller on the small one is UC1698U, which is a CSTN controller instead of a STN controller. This do cause some trouble, since every pixel in the controller map to three pixels on the screen.

Sorry for the image quality, I should have waited till morning to take the photo.

Read more if you want to see the reverse engineered pinouts and driver source code (possibly useless).

How the photo was taken:

image

GY3216N1FRN6A

GY3216_A GY3216_B

Specification

Pinout

  1. FLM
  2. M
  3. LP
  4. XCK
  5. DISPOFF
  6. D0
  7. D1
  8. D2
  9. D3
  10. VDD
  11. GND
  12. VEE
  13. GND
  14. NC
  15. NC
  16. NC

Source code

void LCD_DispImg(unsigned char *d)
{
  unsigned char i,j;
  unsigned int p,q;
  unsigned char d1,d2,d3,d4;
  p = 0;
  q = 0;
  for (i=0;i<160;i++)
  {
    for (j=0;j<40;j++)
    {
      d1 = 0;
      d2 = 0;
      d3 = 0;
      d4 = 0;
      d1 = (d[q]&0x80)|((d[q]&0x08)<<3);
      d2 = ((d[q]&0x40)<<1)|((d[q]&0x04)<<4);
      d3 = ((d[q]&0x20)<<2)|((d[q]&0x02)<<5);
      d4 = ((d[q]&0x10)<<3)|((d[q]&0x01)<<6);
      q++;
      d1 |= ((d[q]&0x80)>>2)|((d[q]&0x08)<<1);
      d2 |= ((d[q]&0x40)>>1)|((d[q]&0x04)<<2);
      d3 |= ((d[q]&0x20))|((d[q]&0x02)<<3);
      d4 |= ((d[q]&0x10)<<1)|((d[q]&0x01)<<4);
      q++;
      d1 |= ((d[q]&0x80)>>4)|((d[q]&0x08)>>1);
      d2 |= ((d[q]&0x40)>>3)|((d[q]&0x04));
      d3 |= ((d[q]&0x20)>>2)|((d[q]&0x02)<<1);
      d4 |= ((d[q]&0x10)>>1)|((d[q]&0x01)<<2);
      q++;
      d1 |= ((d[q]&0x80)>>6)|((d[q]&0x08)>>3);
      d2 |= ((d[q]&0x40)>>5)|((d[q]&0x04)>>2);
      d3 |= ((d[q]&0x20)>>4)|((d[q]&0x02)>>1);
      d4 |= ((d[q]&0x10)>>3)|((d[q]&0x01));
      q++;
      LCD_FB_1[p] = d1;
      LCD_FB_2[p] = d2;
      LCD_FB_3[p] = d3;
      LCD_FB_4[p] = d4;
      p++;
    }
  }
}

void LCD_ReversePol()
{
  if ((GPIOD->IDR)&LCD_AC)
    LCD_AC_LOW();
  else
    LCD_AC_HIGH();
}

void LCD_RefreshI(unsigned char *fb)
{
  unsigned char i,j;

  LCD_FR_HIGH();
  for (i=0;i<160;i++)
  {
    for (j=0;j<40;j++)
    {
      LCD_XCK_HIGH();
      GPIOE->ODR=fb[i*40+j]>>4;
      LCD_XCK_LOW();
      LCD_XCK_HIGH();
      GPIOE->ODR=fb[i*40+j];
      LCD_XCK_LOW();
    }
    LCD_LP_HIGH();
    LCD_LP_LOW();
    LCD_FR_LOW();
  }
  for (i=0;i<4;i++)
  {

    for (j=0;j<40;j++)
    {
      LCD_XCK_HIGH();
      GPIOE->ODR=fb[159*40+j]>>4;
      LCD_XCK_LOW();
      LCD_XCK_HIGH();
      GPIOE->ODR=fb[159*40+j]>>4;
      LCD_XCK_LOW();
    }
    LCD_LP_HIGH();
    LCD_LP_LOW();
  }
  LCD_LP_HIGH();
  LCD_LP_LOW();
}

void LCD_Refresh()//7-4-2-1
{
  LCD_RefreshI(LCD_FB_1);//1
  LCD_RefreshI(LCD_FB_2);//1
  LCD_ReversePol();
  LCD_RefreshI(LCD_FB_1);//2
  LCD_RefreshI(LCD_FB_3);//1
  LCD_ReversePol();
  LCD_RefreshI(LCD_FB_1);//3
  LCD_RefreshI(LCD_FB_4);//1
  LCD_ReversePol();
  LCD_RefreshI(LCD_FB_1);//4
  LCD_RefreshI(LCD_FB_2);//2
  LCD_ReversePol();
  LCD_RefreshI(LCD_FB_1);//5
  LCD_RefreshI(LCD_FB_3);//2
  LCD_ReversePol();
  LCD_RefreshI(LCD_FB_1);//6
  LCD_RefreshI(LCD_FB_2);//3
  LCD_ReversePol();
}

S60715-1-V04-SA-090412

S60715

Specification

Pinout

  1. NC
  2. D7
  3. D6
  4. D5
  5. D4
  6. D3
  7. D2
  8. D1
  9. D0
  10. RD
  11. CS
  12. RST
  13. DC
  14. WR
  15. NC
  16. NC
  17. GND
  18. VCC
  19. VCAP1P
  20. VCAP2P
  21. VCAP2N
  22. VCAP1N
  23. VCAP3P
  24. VCAP3N
  25. VOUT
  26. NC

Source code

void LCD_Init()
{
  LCD_GPIO_Config();
  LCD_RST_LOW();
  Delayms(50);
  LCD_RST_HIGH();
  Delayms(300);

  LCD_WriteCmd(0xe2);//system reset
  Delayms(50);   
  LCD_WriteCmd(0x25);
  LCD_WriteCmd(0x2b);
  Delayms(20);
  LCD_WriteCmd(0xc4);
  LCD_WriteCmd(0xa1);
  LCD_WriteCmd(0xd1);
  LCD_WriteCmd(0xd5);
  LCD_WriteCmd(0xc8);
  LCD_WriteCmd(0x00);
  LCD_WriteCmd(0xeb);
  LCD_WriteCmd(0xa6);
  LCD_WriteCmd(0xa4);
  LCD_WriteCmd(0x81);
  LCD_WriteCmd(0x50);//80
  LCD_WriteCmd(0xd8);
  LCD_WriteCmd(0xaf);
  Delayms(50);
}

void LCD_SetXY(unsigned char x,unsigned char y)  //x<128(per 3Dot) , y<160
{
  x += 0x0b;      // This screen has a 11 column offset
  //LCD_WriteCmd( 0xf9 );      // Turn off window mode

  LCD_WriteCmd( 0x00 | (x&0x0f) );
  LCD_WriteCmd( 0x10 | (x>>4) );

  LCD_WriteCmd( 0x60 | (y&0x0f) );
  LCD_WriteCmd( 0x70 | (y>>4) );
}

void LCD_SetWindow(u8 wL,u8 wU,u8 wR,u8 wD)
{
  LCD_WriteCmd(0xf8);    // Enable window mode

  LCD_WriteCmd(0xf4);    // Window left border
  LCD_WriteCmd(wL);.

  LCD_WriteCmd(0xf5);    // Window upper border
  LCD_WriteCmd(wU);

  LCD_WriteCmd(0xf6);    // Window right border
  LCD_WriteCmd(wR);

  LCD_WriteCmd(0xf7);    // Window lower border
  LCD_WriteCmd(wD);

  LCD_SetXY(0,0) ;
}

void LCD_DispImg(unsigned char *d)
{
  unsigned i,j,p;

  p = 0;
  LCD_SetWindow(0x0b,0x00,0x75,0x9f);
  for (i=0;i<160;i++)
  {
    LCD_SetXY(0,i);
    LCD_WriteDat(0x00);//2 empty pixel
    for (j=0;j<160;j++)
      LCD_WriteDat(d[p++]);
  }
}