i am working with sifive-Hifive1 microcontroller (Arduino compatible), i have interfaced Adafruit 2.8" tft lcd resistive touch breakout board with my MCU i need to use the touch functionality,so i used ADC MCP3008 as my MCU does not have analog input header pins.I am struggling with the pin connections and also i am using TOUCHSCREEN.H (I port it in C language, made some changes for hifive1 support).How to give connections between the ADC , MCU & Display unit in breadboard and also how to calculate the z coordinate in general? i tried my level best but the touch functionality is not working properly it prints somewhere else( i tried breakout paint example).Kindly help me out.
2nd question: what is the use of these two functions
Post a link to the tutorial or guide you are following and also the library which you are using.
The two definitions you have included appear to overload the operators == and != so these operators can by used to compare two TSPoint objects.
Incidentally, I had never heard of the sifive-Hifive1 MCU but from a picture I found, it does appear to be of "UNO" format although much better specified (32Bit processor, 16kB Ram etc.) and I'll spend a few minutes trying to figure out the specification.
The library that i am using is TouchScreen.H,i will make some changes in the library to run it for Hifive1.
i will show you the picture ,in which it will display the temperature (my recent project).Now i want to enable touch functionality, for that it requires an ADC ,so I chose MCP3008 .
I do not know how to give pin connections in breadboard for X+,X-,Y+ and Y-.
OK. The specific touch screen you have does require 2 analog pins.
I do not know how to give pin connections in breadboard for X+,X-,Y+ and Y-.
I'm not sure I understand your problem here, but the pin mappings for the touch screen are in the constructor for TouchScreen (taken from an example in the library) :
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A3 // must be an analog pin, use "An" notation!
#define YM 8 // can be a digital pin
#define XP 9 // can be a digital pin
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
So, for example, Y- is connected to digital pin 8
Your problem is going to be the two analog pins which are, in effect, on the MCP3008.
Maybe it is as simple as finding the analogRead() statements in the library and the replacing the statements so these obtain their values from the MCP3008.
Yeah , i did that . I am getting the values also for x and y , but the problem is while calculating Z value, I am not sure about the pin connection , in arduino uno i guess it is capable to do digitalWrite() on analog pins also , but here in Hifive1 i will give 2 pins as analog input to the 2 channels in the ADC , then how could i do digitalWrite() to those pins? since i will be having 2 digital pins from display unit for touch and spi pins from adc in my Hifive1
if you go through the TouchScreen.cpp code in getPoint() you could see that digitalWrite() for analog pins.
Yes. it does appear that digitalWrite()/pinmode() are also set for the analog pins for XM and YP.
From your sketch, it looks like you are using the following connection for the touch screen
Y+ HiFive pin6 and MCP3008 Chan 1
Y- HiFive pin7
X+ HiFive pin9
X- HiFive pin8 and MCP3008 Chan 0
So, for example, in the case of touchscreen pin Y+, you have two connection to it. One to the HiFive and one to the ADC. Is guess that is right and should work.
I didn't look in too much detail at your code except to work out the pin mappings. I personally would simply have made a copy of the library in the sketch folder and hacked it to add in the "analogRead()" statements as you have e.g.
int z1 = mcp3008_value(0,_sclk_pin,_miso_pin,_mosi_pin,_cs_pin);; // mcp3008read
but keeping the structure otherwise intact, then writing a minimal sketch to test the touch screen part. You have a large monolithic sketch to debug.
Incidentally, you can throw anything dependent on USE_FAST_PINIO out because this is for the AVR architecture:
DanielKirubakaran:
Then should i buy STMPE610 breakout controller instead of using ADC ?
I have no experience here of how easy it would be to integrate with your chosen display. May be you could also ask this question in the "Display" forum here.