 |
| Guru |
Joined: Sun Jan 03, 2010 8:01 am Posts: 55 Location: Eau Claire, WI
|
Hey Guys, I'm working on one of the final steps of my project which is centered around a Nano-40 and I've hit a really hard and tall wall. I am working with an LCD that uses a serial input from a company called 4D Systems ( http://www.4dsystems.com.au/prod.php?id=113). I am able to communicate with the display without any issues (which means that I can establish communication and send commands for text and buttons without any issues, any commands sent require an acknowledgement which $06) but I am unable to read the current position of the touch screen. I have had several posts with the Forum Moderator for this product at 4D Systems but oddly enough there are a number of limited Stamp users who frequent the 4D Systems forum let alone any posts regarding how to interface the Touch Screen part of the LCD....this lack of content on this subject makes me believe that one of the two are true: 1) That this process is easy and no one has encountered any issues 2) I am breaking new ground So...here is my problem (plus I've added a few comments): When I ask the touch screen register to report "what is going on" the display will response with a 0 which indicates no activity in which case you keep reading the touch screen register until some type of touch screen activity is registered. This issue is that after anywhere from 1 to 5 reads of the touch screen register the HSERIN command will execute my timeout code. Is there anything else I can add to the HSERIN (or HSEROUT) command that may help with troubleshooting serial comm issues. I will also admit that it is very hard to interface devices to a stamp when you are not an expert in how all of the commands work the the Atoms! Here is the code example (if nothing else people will see how to use the LCD display from 4D Sytems). 4D Systems tech support stated that the reads for a touch should take less than 50mS. Thanks in advance for anyone that can give me some advice on what to do next! RST CON 2
X VAR WORD Y VAR WORD
TSTATUS VAR WORD XLSB VAR BYTE XMSB VAR BYTE YLSB VAR BYTE YMSB VAR BYTE
CLEAR
DEBUG [0] LCDSTAT VAR WORD LOW RST 'This is the reset routine for the LCD display PAUSE 500 HIGH RST PAUSE 1000
DEBUG ["Sending Auto-Baud Command",13] 'This command must be sent within 1 to 5 seconds of the LCD being turned on or reset SETHSERIAL1 H9600 HSEROUT [$55] GOSUB NAK
DEBUG ["Turn on touch screen",13] 'This is a key command because by default the touch screen is turned off! HSEROUT [$59,$05,$00] GOSUB NAK
DEBUG ["Reset touch screen",13] HSEROUT [$59,$05,$02] GOSUB NAK
DEBUG ["Detecting touch...",13]
TOUCH X=X+1 PAUSE 750 HSEROUT [$6F,$04] 'This gets the value of the touch screen register PAUSE 200 'Have not used this command and have also varied the time...no difference in the end result RETRY HSERIN TY,100,[TSTATUS] ' I have verified with tech support that this is a single byte status returned DEBUG [DEC X," TSTATUS is:",HEX TSTATUS,13]
IF TSTATUS=$00 THEN DEBUG ["No Touch!",13] HSEROUT [$6F,$00] DEBUG ["Reading Touch cords",13] 'HSERIN TY,100,[XMSB,XLSB,YMSB,YLSB] 'The results are the same if I do or don't use this command 'GOSUB NAK DEBUG ["Cords are:",DEC XMSB,DEC XLSB,DEC YMSB, DEC YLSB,13] ENDIF IF TSTATUS=$01 THEN DEBUG ["Touch Press!",13] HSEROUT [$6F,$01] HSERIN TY,100,[XMSB,XLSB,YMSB,YLSB] DEBUG ["Cords are:",DEC XMSB,DEC XLSB,DEC YMSB, DEC YLSB,13] ENDIF
IF TSTATUS=$02 THEN DEBUG ["Touch release!",13] HSEROUT [$6F,$02] HSERIN TY,100,[XMSB,XLSB,YMSB,YLSB] DEBUG ["Cords are:",DEC XMSB,DEC XLSB,DEC YMSB, DEC YLSB,13] ENDIF
IF TSTATUS=$03 THEN DEBUG ["Touch moving!",13] HSEROUT [$6F,$03] HSERIN TY,100,[XMSB,XLSB,YMSB,YLSB] DEBUG ["Cords are:",DEC XMSB,DEC XLSB,DEC YMSB, DEC YLSB,13] ENDIF
GOTO TOUCH
END
NAK HSERIN [LCDSTAT] IF LCDSTAT=$15 THEN DEBUG ["Command Error:",HEX LCDSTAT,13] ENDIF IF LCDSTAT=$06 THEN DEBUG ["Command OK:",HEX LCDSTAT,13] ELSE DEBUG ["Command returned: ",HEX LCDSTAT,13] ENDIF RETURN
TY DEBUG ["!!!!! RX PROBLEM !!!!!",13] GOTO RETRY
|
|