Jump to content
43oh

2.2" Color LCD Booster Pack with Touch


Recommended Posts

  • 4 weeks later...
  • Replies 128
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

I am working on a new color LCD booster pack featuring 2.2" display. The board will work with two types of displays, one with touch screen and one without. TSC2046/ADS7846 controller or MCU's analog

Another test, this time some simple on/off buttons. Once I polish this a little, I will add it to GitHub so that users can contribute.  

If you're tight on budget, a cheap solution to using SD cards is soldering a  7 pin male header directly to the pins of a microSD-to-SD adapter. You can insert microSD cards just as you'd do normally.

Posted Images

  • 3 weeks later...
  • 1 month later...
  • 2 weeks later...
  • 4 weeks later...
  • 4 months later...

Looking for some help..... I just brought two 2.2 Touch LCD (marked was v4) from Tindie, and the display is great, but somehow the touch part is not quite working right. I tried the CCS hrd_spi_max posted by username, and the energia LCD22_Touch by RobG. X axis reading seems ok, but both got the Y axis reading screwed up. The Energia one seems got the Y upside down, and the hrd_spi_max just keep saying the Y is 7, with some random reading occasionally. Did I do something wrong?

 

And I'm using 2553 Launchpad.

Link to post
Share on other sites

v4 BoosterPacks use new display type, which has Y axis inverted when compared to the old one.

@@username, @@Rei Vilo, could you suggest changes to make this work?

So the Inverted Y is by design? If so I think I can just change the program to invert the Y value and make it work. Thanks.

 

Edit: Yup, the touch work wonderful after I changed the Y axis mapping from (y0, 195, 1859, LCD_HEIGHT, 0) to (y0, 195, 1859, 0, LCD_HEIGHT);

 

BTW, the X mapping seems a little bit off with the (311, 1632) input, but changed it to (195, 1859) sames as the values used for Y and it work perfectly. So, the touch input actually is a square instead of a rectangle? That's strange.

Link to post
Share on other sites

OK, I made some change to the Energia lib to get my v4 board work as what I want. Not sure what's the best way to get the lib updated, but here is what I changed, and may be someone more experienced on make lib can include that to the lib.

 

LCD22_Touch.h add the following:

 
// orientation
#define ORIENTATION_VERTICAL 0
#define ORIENTATION_HORIZONTAL 1
#define ORIENTATION_VERTICAL_ROTATED 2
#define ORIENTATION_HORIZONTAL_ROTATED 3
 
class LCD22_Touch {
public:
    void clear(uint8_t x1, uint8_t y1, uint8_t w, uint8_t h);
}
 
LCD22_Touch.cpp add/change the following
 
void LCD22_Touch::setArea(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
{
    if(_orientation == 0 || _orientation == 2) 
    {
        writeRegister(ILIGRAMHEA, x2 + LCD_OFFSET_WIDTH);
        writeRegister(ILIGRAMHSA, x1 + LCD_OFFSET_WIDTH);
    
        writeRegister(ILIGRAMVEA, y2 + LCD_OFFSET_HEIGHT);
        writeRegister(ILIGRAMVSA, y1 + LCD_OFFSET_HEIGHT);
    
        writeRegister(ILIGRAMADDRX, x1 + LCD_OFFSET_WIDTH);
        writeRegister(ILIGRAMADDRY, y1 + LCD_OFFSET_HEIGHT);
    
write(_commandLCD, ILIWRDATA);
    }
    else
    {
        writeRegister(ILIGRAMHEA, y2 + LCD_OFFSET_WIDTH);
        writeRegister(ILIGRAMHSA, y1 + LCD_OFFSET_WIDTH);
    
        writeRegister(ILIGRAMVEA, x2 + LCD_OFFSET_HEIGHT);
        writeRegister(ILIGRAMVSA, x1 + LCD_OFFSET_HEIGHT);
    
        writeRegister(ILIGRAMADDRX, y1 + LCD_OFFSET_WIDTH);
        writeRegister(ILIGRAMADDRY, x1 + LCD_OFFSET_HEIGHT);
    
        write(_commandLCD, ILIWRDATA);
    }
}
 
void LCD22_Touch::clear() {
    if(_orientation == 0 || _orientation == 2) 
        clear(0, 0, LCD_WIDTH, LCD_HEIGHT);
    else
        clear(0, 0, LCD_HEIGHT, LCD_WIDTH);
}
 
void LCD22_Touch::clear(uint8_t x, uint8_t y, uint8_t w, uint8_t h) {
setArea(x, y, x+w-1, y+h-1);
    
    uint16_t total = w * h;
    for (uint16_t k = 0; k < total; k++) {
        write(_dataLCD, 0x00);
        write(_dataLCD, 0x00);
    }
}
 
bool LCD22_Touch::getTouch(uint16_t &x, uint16_t &y, uint16_t &z) {
  uint16_t x0, y0, z0, z1, z2;
  uint8_t a, b;
 
  // Need for cleaning screen SPI communication for LM4F
#if defined(__LM4F120H5QR__)    
  point(0, 0);
#endif
 
  delay(10);
  digitalWrite(_pinTouchChipSelect, LOW);
 
#ifdef HARDWARE_SPI
  SPI.transfer(TOUCH_Z1 + 0x08);   // 8-bit
  a = SPI.transfer(0x00);
  b = SPI.transfer(0x00);
#else
  shiftOut(_pinSerialData, _pinSerialClock, MSBFIRST, TOUCH_Z1 + 0x08);
  a = shiftIn(_pinSerialData, _pinSerialClock, MSBFIRST);
  b = shiftIn(_pinSerialData, _pinSerialClock, MSBFIRST);
#endif
  z1 = a; 
 
#ifdef HARDWARE_SPI
  SPI.transfer(TOUCH_Z2 + 0x08);   // 8-bit
  a = SPI.transfer(0x00);
  b = SPI.transfer(0x00);
#else
  shiftOut(_pinSerialData, _pinSerialClock, MSBFIRST, TOUCH_Z2 + 0x08);
  a = shiftIn(_pinSerialData, _pinSerialClock, MSBFIRST);
  b = shiftIn(_pinSerialData, _pinSerialClock, MSBFIRST);
#endif
  z2 = 0x7f - a;
 
  z0 = z1 + z2;
  z = z0;
 
#ifdef HARDWARE_SPI
  SPI.transfer(TOUCH_X + 0x00); // 12-bit
  a = SPI.transfer(0x00) ;
  b = SPI.transfer(0x00);
#else
  shiftOut(_pinSerialData, _pinSerialClock, MSBFIRST, TOUCH_X + 0x00);
  a = shiftIn(_pinSerialData, _pinSerialClock, MSBFIRST);
  b = shiftIn(_pinSerialData, _pinSerialClock, MSBFIRST);
#endif
  x0 = (a << 8 | B) >> 4;
 
#ifdef HARDWARE_SPI
  SPI.transfer(TOUCH_Y + 0x00); // 12-bit
  a = SPI.transfer(0x00) ;
  b = SPI.transfer(0x00);
#else
  shiftOut(_pinSerialData, _pinSerialClock, MSBFIRST, TOUCH_Y + 0x00);
  a = shiftIn(_pinSerialData, _pinSerialClock, MSBFIRST);
  b = shiftIn(_pinSerialData, _pinSerialClock, MSBFIRST);
#endif
  y0 = 2047 - ((a << 8 | B) >> 4);
 
  digitalWrite(_pinTouchChipSelect, HIGH);
 
  if (z>TOUCH_TRIM) {
    //x0 = check(x0, 311, 1632);
    x0 = check(x0, 195, 1859);
    y0 = check(y0, 195, 1859);
 
    switch (_orientation)
    {
    case 1:
      {
        y = map(x0, 195, 1859, LCD_WIDTH, 0);
        x = map(y0, 195, 1859, 0, LCD_HEIGHT);
        break;
      }
    case 2:
      {
        x = map(x0, 195, 1859, LCD_WIDTH, 0);
        y = map(y0, 195, 1859, LCD_HEIGHT, 0);
        break;
      }
    case 3:
      {
        y = map(x0, 195, 1859, LCD_WIDTH, 0);
        x = map(y0, 195, 1859, 0, LCD_HEIGHT);
        break;
      }
    default:
      {
        //x = map(x0, 311, 1632, 0, LCD_WIDTH);
        x = map(x0, 195, 1859, 0, LCD_WIDTH);
        y = map(y0, 195, 1859, 0, LCD_HEIGHT);
        break;
      }
    }
    return true;
  }
  else {
    return false;
  }
}
 
void LCD22_Touch::setOrientation(uint8_t orientation)
{
  switch (orientation) {
  case 1:
    writeRegister(0x01, 0x031C);
    _orientation = 1;
    break;
  case 2:
    writeRegister(0x01, 0x021C);
    _orientation = 2;
    break;
  case 3:
    writeRegister(0x01, 0x001C);
    _orientation = 3;
    break;
  default:
    writeRegister(0x01, 0x011C);
    _orientation = 0;
    break;
  }
 
  writeRegister(0x02, 0x0100);
 
  switch (orientation) {
  case 1:
    writeRegister(0x03, 0x1038);
    _orientation = 1;
    break;
  case 2:
    writeRegister(0x03, 0x1040);
    _orientation = 2;
    break;
  case 3:
    writeRegister(0x03, 0x1048);
    _orientation = 3;
    break;
  default:
    writeRegister(0x03, 0x1030);
    _orientation = 0;
    break;
  }
}
 
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...