SERIN issues when recieving data from a LCD / Keypad device
Loki008
Posts: 19
I am using the crystalfontz CFA633 display which is a serial display with 6 buttons. I am attempting to read the button presses using the SERIN command but i am getting less that stellar results. I was hoping someone would be able to provide any suggestions on what could be causing an issue with this approach
Here is the code i am using, it is borrowed from the thread below from the crystalfontz forums that i found.
·What is happening is when the·button press works, i get the correct value, say "4" for left. When it doesnt work i get the value of·"64" through the debug console.
Below are·links to the spec sheet for the display, as well as where i found the source code for interfacing with the basic stamp.
http://www.crystalfontz.com/products/633/datasheets/1139/CFA633-RMC_v2.0.pdf
http://www.crystalfontz.com/forum/archive/index.php/t-6229.html
Here is the code i am using, it is borrowed from the thread below from the crystalfontz forums that i found.
' {$STAMP BS2} ' {$PBASIC 2.5} 'Notes; Any change in commands to Display means CRC must be recalculated BAUD CON $4020 'Set Baud rate to 19200 inverted packetstring VAR Byte(10) packettest VAR Byte Main: begin: SEROUT 0,BAUD,[noparse][[/noparse]7,16,"Ready to Start? ",$B7,$8E] ' waits for user to press GO button. SEROUT 0,BAUD,[noparse][[/noparse]8,16," ",$59,$E7] SERIN 1,BAUD,[noparse][[/noparse]WAIT($80),STR packetstring\3] PAUSE 20 DEBUG DEC packetstring SEROUT 0,BAUD,[noparse][[/noparse]7,16,"Packet Received ",$C6,$16] PAUSE 1000 IF packetstring(0)=$0 THEN GOSUB buttonpressed ELSEIF packetstring(0)=$1 THEN GOSUB pressedup ELSEIF packetstring(0)=$2 THEN GOSUB presseddown ELSEIF packetstring(0)=$3 THEN GOSUB pressedleft ELSEIF packetstring(0)=$4 THEN GOSUB pressedright ELSEIF packetstring(0)=$5 THEN GOSUB pressedenter ELSEIF packetstring(0)=$6 THEN GOSUB pressedcancel ENDIF GOTO Main buttonpressed: SEROUT 0,BAUD,[noparse][[/noparse]7,16,"Pressed a Button",$01,$3D] PAUSE 2500 RETURN pressedup: SEROUT 0,BAUD,[noparse][[/noparse]7,16,"Up ",$2E,$01] PAUSE 2500 RETURN presseddown: SEROUT 0,BAUD,[noparse][[/noparse]7,16,"Down ",$0F,$9B] PAUSE 2500 RETURN pressedleft: SEROUT 0,BAUD,[noparse][[/noparse]7,16,"Left ",$32,$DE] PAUSE 2500 RETURN pressedright: SEROUT 0,BAUD,[noparse][[/noparse]7,16,"Right ",$CE,$32] PAUSE 2500 RETURN pressedenter: SEROUT 0,BAUD,[noparse][[/noparse]7,16,"Enter ",$97,$BD] PAUSE 2500 RETURN pressedcancel: SEROUT 0,BAUD,[noparse][[/noparse]7,16,"Cancel ",$45,$41] PAUSE 2500 RETURN END
·What is happening is when the·button press works, i get the correct value, say "4" for left. When it doesnt work i get the value of·"64" through the debug console.
Below are·links to the spec sheet for the display, as well as where i found the source code for interfacing with the basic stamp.
http://www.crystalfontz.com/products/633/datasheets/1139/CFA633-RMC_v2.0.pdf
http://www.crystalfontz.com/forum/archive/index.php/t-6229.html
Comments