Monday, March 6, 2017

2.4 Inch TFT Touchscreen module


I came across this awesome module on Ebay and I did not hesitate to buy it for under $10. Currently I'm having a little bit of a problem with my controller since the analog readout from my microcontroller is non that great. It uses its built in 10 bit ADC which converts 5V analog from the joysticks to digital levels. The biggest problem is that it will ouput the maximum level at 1023 at around 4V (supposed to be 5V). This is a pretty big deal and it causes the joystick to be extra sensitive. One light touch on the joystick with cause it move to maximum. Which is hard to control variable speed motor. 

A digital touchscreen could be the solution to all of this.  The genuine touchscreen module out there is probably the one from Adafruit. They're fairly pricey too. I would suggest that one if you are manufacture your products. For me since this is a prototype I'm okay with using the one on Ebay. Save me the cost. 

This touchscreen module is running  spfd5408 controller which no longer supported. There is only one library/driver for this controller and it is from Adafruit. Here is the link to that library:
https://github.com/JoaoLopesF/SPFD5408

One thing that you should note when using this library is that when you upload the code and start your touchscreen module. You might notice that your touchscreen is not working. Don't panic it is probably because the pins are not correct. The pins were changed around a little so in my case. In your Arduino touchscreen sketch change the pins as below:
#define YP A3
#define XM A2
#define YM 9
#define  XP 8

you can also look at the schematic (if provided) for the pinout on the module that you bought.

The next problem I ran into is that the coordinates are messed up for my module. Luckily, you can change the configuration by editing this file : SPDF5408_Touchscreen.cpp. In there locate this line of code: return TSPoint(1023 - x, 1023 - y, z);
for me it got it working with this settings: return TSPoint(x,y-50,z); you can play around with these values to get your desired result.

And that should get you up and running. This is a great little module. I wish it is a little bigger so I make a wall display. That'll be really cool. 









No comments:

Post a Comment