Monday, December 28, 2015

Interface I2C touch screen with Bus Pirate and Python

The goal

Check if touch screen is working.

Usability

Diagnostic

Parts

  • Bus Pirate (I've got v 3.6)
  • Some cables
  • 7" touchscreen from Prestigo PMP3270B tablet: A1102070020_V03 G705AU MTC-1221

Code


Description


When I repaired my oscilloscope, by replacing display backlight (you can find it here), 7" touchscreen frame previously mounted in tablet stay unused. After a while I was wondering can I use it for something else.

I was searching on the net to find some description about this TS or chip that was in it, but I found nothing useful. I found chip specification for similar frame and wanted to check if this will work.

Recently I've bought Bus Pirate, so it was nice opportunity to use it right now :)


7" touchscreen from Prestigo PMP3270B tablet

Fortunately, manufacturer left additional soldering points

Bus Pirate v3.6

Bus Pirate and touchscreen connected by I2C

When you touch the glass, one of the additional output pin (INT) goes low, then you need to read touch coordinates by I2C and that's all.

Coordinates contain:
  • how many fingers are touching the glass (max 2)
  • XY of first finger
  • XY of second finger

Finger register is 8 bit (1 byte), but XY coordinates are 2 byte wide, they are sent as lower and higher half of 16 bit number.

Data comes in this order, one byte each:
  • how_many_fingers_one_byte
  • finger_1_x_position_lower_half
  • finger_1_x_position_higher_half
  • finger_1_y_position_lower_half
  • finger_1_y_position_higher_half
  • finger_2_x_position_lower_half
  • finger_2_x_position_higher_half
  • finger_2_y_position_lower_half
  • finger_2_y_position_higher_half

To get proper XY coordinates you need to:

real_x_pos = (finger_1_x_position_lower_half | finger_1_x_position_higher_half << 8)

This is output from python script, that reads this through Bus Pirate, I used only I2C pins and GND/3.3v, normally you should connect INT pin to your microcontroller and then after high-to-low state read I2C data. That's why I have reads from the chip even if I release touch.

First I've touched glass with one finger, then with two fingers and at the end released all pressure from TS.
{'f2_y': 0, 'f2_x': 0, 'fingers': 1, 'f1_x': 677, 'f1_y': 85}
{'f2_y': 0, 'f2_x': 0, 'fingers': 1, 'f1_x': 677, 'f1_y': 85}
{'f2_y': 0, 'f2_x': 0, 'fingers': 1, 'f1_x': 677, 'f1_y': 85}
{'f2_y': 437, 'f2_x': 229, 'fingers': 3, 'f1_x': 676, 'f1_y': 85}
{'f2_y': 437, 'f2_x': 226, 'fingers': 3, 'f1_x': 676, 'f1_y': 86}
{'f2_y': 438, 'f2_x': 223, 'fingers': 3, 'f1_x': 676, 'f1_y': 86}
{'f2_y': 438, 'f2_x': 222, 'fingers': 0, 'f1_x': 675, 'f1_y': 88}
{'f2_y': 438, 'f2_x': 222, 'fingers': 0, 'f1_x': 675, 'f1_y': 88}
{'f2_y': 438, 'f2_x': 222, 'fingers': 0, 'f1_x': 675, 'f1_y': 88}
I run this chip only on 3.3V, don't know if it's 5V tolerant - rather not.

3 comments: