I have no idea why someone would want to use a pain in the butt specialty IC to do something as simple as read an XY touchpanel. It's like using a specialty chip to read 2 pots.
The IC gives you both position and pressure data. It's also better for battery operated items since powering a uC's ADC takes power and it can't sleep during that time unless you poll over longer intervals. The touchscreen IC's are low power and provide wake up interrupts for a uC.
I've used low power with the PIC directly controlling touchscreen by using sleep/WDT and only reading one ADC after each wakeup. Then if Y>min the PIC knows the screen is touched and comes out of sleep to do both Y and X readings.
I know some people like using these peripherals ICs for every task imaginable but I guess I'm a bit "old school". I like it best if it can all be done by the one PIC .
Id rather use a ic for a couple reasons.. Less code for me.. Spi/i2c is simple as is and to have a external interrupt is nice. Also its more precise than what i would create...
I do use both software and hardware versions so im not saying to use a ic only but there are advantages... Like if you need more adc pins etc...
I do not understand well x,y reading function from edman222 : touchPress();
Could you please explain me the last lines of the function:
Code:
void touchPress (void)
{
...
pen = (pen>>7)&0x00FF;
yhi = (((yhi<<7)|ylo)&0x0FFF); // set it to a 0-1024 type thing
xhi = (((xhi<<7)|xlo)&0x0FFF);
}
I would like to use AR1020 with a 128x64 GLCD screen,
Once touchPress(); has been ran, how should i use the returned results : xhi , yhi, pen in order to compare them with a user defined area , i mean something like a button drawed in the GLCD ?
...
I would like to use AR1020 with a 128x64 GLCD screen,
Once touchPress(); has been ran, how should i use the returned results : xhi , yhi, pen in order to compare them with a user defined area , i mean something like a button drawed in the GLCD
...
I don't think so. If you need to draw on the screen and get the pen tip matching an exact pixel then maybe. But generally the TP output is fairly linear and if you glue the TP onto the GLCD straight it will always be within a couple pixels of the right value. For buttons and simple screen controls that is plenty accurate enough.
(To Crocu)- You PM'ed me, I will answer here as I don't like using PMs for stuff which already has it's own thread (and benefits everybody).
The answer is; Sorry I don't use the AR1020 controller, and don't have any code for it. I use the touch controller directly with 4 PIC pins as I never saw the need to buy a special chip when you can just use 4 PIC pins (two of them ADC inputs).
Maybe someone who uses the AR1020 can help you with the specifics for that controller IC?
Crocu, My code just takes the data and combines the two upper and lower bytes of the X1 X2 and Y1 Y2 position into one X Y... it is easier to handle a single int rather than two chars (X1 X2) ... that way you can scale it or put it into a dot drawing algorithm for the screen..
Calibration is necessary if you want to draw on the screen or have a touch screen keyboard... if you want large buttons it doesn't matter to much...