EasyAVR5A Touchscreen example

General discussion on mikroBasic for AVR.
Post Reply
Author
Message
JazzD
Posts: 4
Joined: 15 Aug 2007 13:29
Location: Germany
Contact:

EasyAVR5A Touchscreen example

#1 Post by JazzD » 08 Aug 2008 13:43

hi,
i bought the EasyAVR5A with a glcd and a touchscreen. I read the values from the touchscreen in my own program yet but i'm just learning and would like to have a simple example to try it.

Has anyone got a very basic example for mikrobasic that uses the glcd and the touchscreen? Everything i find here is for pic. thanks

User avatar
milan
mikroElektronika team
Posts: 1013
Joined: 04 May 2006 16:36
Contact:

#2 Post by milan » 12 Aug 2008 12:33

Hi,

we are currently writing new version of AVR compilers.

This is a big revision and we are changing compiler concept radically.
Large amount of bugs will be solved and it will be easier to write complex examples.

New compliers will include Touch panel examples.
Sorry for the inconvenience and thank you for your patience.

newMan
Posts: 5
Joined: 12 Aug 2008 20:54

#3 Post by newMan » 13 Aug 2008 14:40

Hello!
Here it is_

program testSUBS
dim x, y as char[5]
rx, ry as word
main:
ddrC = $24 ' configure RA0 and RA1 as analog pins,
' RA2 and RA5 as digital pins
portC = $24 ' configure RA2 and RA5 as ouputs
Glcd_Init(PORTD, 2, 3, 4, 5, 7, 6, PORTB) ' Glcd initialization
Glcd_Set_Font(font5x7,5,8,32)
Glcd_Fill(0)
Glcd_Write_Text("Test", 30, 5, 1)
label0:
PORTC.2 = 1 ' DRIVEA = 1 (LEFT drive on, RIGHT drive on, TOP drive off)
PORTC.5 = 0 ' DRIVEB = 0 (BOTTOM drive off)
ry = ADC_read(0) ' reading X value from RA0 (BOTTOM)

Delay_ms(50)
PORTC.2 = 0 ' DRIVEA = 0 (LEFT drive off, RIGHT drive off, TOP drive on)
PORTC.5 = 1 ' DRIVEB = 1 (BOTTOM drive on)
rx = ADC_read(1) ' reading Y value from RA1 (from LEFT)
Delay_ms(50)

wordToStr(rx, x)
wordToStr(ry, y)

if ((rx > 190) and (rx < 250) and (ry > 160) and (ry <180)) then
Glcd_Write_Text(x, 30, 6, 0)
Glcd_Write_Text(y, 30, 7, 0)
else
Glcd_Write_Text(x, 30, 6, 1)
Glcd_Write_Text(y, 30, 7, 1)
end if
Delay_ms(100)
goto label0
end.

this program for atmega8, but U can convert it to, for example, for mega16 by changing the ports.
I use easyAVR5 - on this board portA on mega16 used for data transfer between CPU and GLCD. But the portA is only ADC port in mega16. That's why I build this on mega8. In mega8 U must use the internal oscillator and connect pin OSC to portA6, NC on portA7.
easyAVR5 board is not a good idea with this pins of mega8. Ingeneers of mikroe may use a jumpers to connect this pins for external oscillator or to any other port (portB for example)

JazzD
Posts: 4
Joined: 15 Aug 2007 13:29
Location: Germany
Contact:

#4 Post by JazzD » 13 Aug 2008 16:59

hey thanks you for the great example, im going to try it :)

newMan
Posts: 5
Joined: 12 Aug 2008 20:54

#5 Post by newMan » 14 Aug 2008 11:24

always yours))))

JazzD
Posts: 4
Joined: 15 Aug 2007 13:29
Location: Germany
Contact:

#6 Post by JazzD » 15 Aug 2008 15:48

hey i was trying the code and the measuring works but the conversion from adc values to pixel is totally weird. Y-Values seem to jump to arround 700 while X stays very low. Also why do you check for pixels > 190? The display only has 128 pixel (at least my display).

newMan
Posts: 5
Joined: 12 Aug 2008 20:54

#7 Post by newMan » 16 Aug 2008 18:43

I check touchscreen resolution, but not pixels
Analog touchscreen is not a good idea to use with microcontrollers. Because very big noise on analog lines. I suggest U to use matrix touchscreen like a this one...

TS240128BMNO#

it for 240x128 display

But the big noise may be because the compiller is bad. Try to create code like this on BASCOM.

User avatar
marko.ziv
mikroElektronika team
Posts: 531
Joined: 06 Dec 2007 10:11
Contact:

#8 Post by marko.ziv » 15 Dec 2008 16:23

Hi,

as promised we released a new compiler for AVR.
http://www.mikroe.com/forum/viewtopic.php?t=17514

Right now it is still in beta testing phase, but you are more than welcome to give our touch
panel example a try. We are confident you will be satisfied with results.

Regards

Post Reply

Return to “mikroBasic for AVR General”