View previous topic :: View next topic |
Author |
Message |
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Wed May 30, 2018 4:50 pm Post subject: Lookupstr(idx , variable) |
|
|
Hi everybody,
I would like to use Lookupstr(touchx, myvar)
where myvar must be a label address and not the label
is it possible ?
I do a touch screen keyboard
so I receive touchY and touchx
I have put my keyboard in data :
Line1:
Data " " , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "0" , "-" , "+"
Linea:
Data " " , "A" , "Z" , "E" , "R" , "T" , "Y" , "U" , "I" , "O" , "P" , "x" , "/"
Lineq:
Data " " , "Q" , "S" , "D" , "F" , "G" , "H" , "J" , "K" , "L" , "M" , "=" , "@"
Linew:
Data " " , "W" , "X" , "C" , "V" , "B" , "N" , "?" , "," , "." , ":" , "g" , "d"
If Touchy < 480 And Touchy > 0 Then
Print "touchy: " ; Touchy
Touchy = 30 + Touchy
Touchy = Touchy \ 70
Print "intY:" ; Touchy
Select Case Touchy
Case 2
Ligne = Adr ligne1
Case 3
Ligne = Adr Lignea
Case 4
Ligne = Adr Ligneq
Case 5
Ligne = Adr Lignew
Case 6
'----
End Select
End If
and after I use
If Touchx < 800 And Touchx > 0 Then
Touchx = 65 + Touchx
Touchx = Touchx \ 66 ' 'dividion entiere de touchx give the idx in the data line
' Print "intx:" ; Touchx
Cle = Lookupstr(touchx , Ligne)
Call Lcd_text(cle , 10 , 80 , 1 , Red , White , 1)
End If
but ligne =adr ligne1 or ligne=adr (ligne1)
give an error : Error : 93 Line : 180 Variable not dimensioned [ADR(LIGNE1)]
my var ligne is a word
the help said :"The label where the data starts. A variable with the address is accepted as well."
JP
:roll:
(BASCOM-AVR version : 2.0.8.1 ) _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
|
Back to top |
|
|
laborratte
Joined: 27 Jul 2005 Posts: 299 Location: Berlin
|
Posted: Wed May 30, 2018 6:14 pm Post subject: |
|
|
or you can do something like
Code: | Line1:
Data " " , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "0" , "-" , "+"
Linea:
Data " " , "A" , "Z" , "E" , "R" , "T" , "Y" , "U" , "I" , "O" , "P" , "x" , "/"
Lineq:
Data " " , "Q" , "S" , "D" , "F" , "G" , "H" , "J" , "K" , "L" , "M" , "=" , "@"
Linew:
Data " " , "W" , "X" , "C" , "V" , "B" , "N" , "?" , "," , "." , ":" , "g" , "d"
lineadr:
adr2 Line1
adr2 Linea
adr2 Lineq
adr2 Linew
If Touchy < 480 And Touchy > 0 Then
Print "touchy: " ; Touchy
Touchy = 30 + Touchy
Touchy = Touchy \ 70
Print "intY:" ; Touchy
Touchy = Touchy - 2
Ligne = lookup(Touchy,lineadr)
End If
(...) |
so adr2 puts the address of the label as data in memory. But keep in mind what edc mentioned: word-vars can only access 64KB data space. on bigger avrs put data statements in the beginning of your code:
Code: | regfile ="...."
'here starts your program
goto MyProgram
labels:
data...
data....
MyProgram:
'lets start
|
|
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Thu May 31, 2018 9:55 am Post subject: |
|
|
EDC and laborratte
many thanks to your help
yes you right I must use code but here it is a too large program it fill 65% of a M2560
so I saw the help for adr2 and loadlabel and I saw the limit of 64ko... I'm looking for a B plan
The bestial way is to made a small macro
I let you know
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Thu May 31, 2018 10:06 am Post subject: |
|
|
The first you should share with us what is the used micro... |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Thu May 31, 2018 10:37 am Post subject: |
|
|
Hi EDC
finally I find a simple solution with only 5 lines of code !
It works :
on a graphic 'Display SSD1963 800x480
ATmega2560 with the routine of H.Kipnik (many thanks for him) and the AVR DOS of Vögel Franz Josef
Code: | '
Do
#if Use_touch = 1
If Touch_flag = 1 Then
Touchx = 0
Touchy = 0
Call Read_touch()
'Print "touchx: " ; Touchx
If Touchx < 800 And Touchx > 0 Then
Touchx = 65 + Touchx
Touchx = Touchx \ 66 'dividion entiere de touchx little swing {65+1} to be ok with the picture
End If
If Touchy < 480 And Touchy > 0 Then
Touchy = 30 + Touchy
Touchy = Touchy \ 70 'dividion entiere de touchx
Print "intY:" ; Touchy
Select Case Touchy
Case 2 'ligne 1
Cle = Lookupstr(touchx , Line1)
Case 3 'Lignea
Cle = Lookupstr(touchx , Linea)
Case 4 'Ligneq
Cle = Lookupstr(touchx , Lineq)
Case 5 'Lignew
Cle = Lookupstr(touchx , Linew)
Case 6 'ligne other
End Select
Sentence = Sentence + Cle
Call Lcd_text(sentence , 10 , 80 , 1 , Red , White , 1)
End If
End If
Waitms 20
#endif
loop
|
that the start of my work :
I design a French keyboard with draw8
I translate it in a bin file put on a sd card
I have to finish the prog but as usual I will share it
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|