I managed to get it working for the first number only. The incoming
serial data looks like this:
"T 55
T 100
T 129" etc
Followed your advice and my code looks like below.
It's working perfectly. Now, the first number after the T is the x
position of the object being tracked, the second is confidence value
of the tracking (number of pixels or something).
I'll work on getting the second number later today, shouldn't be a
problem now that I got the first.
Do
LCD.Clear
LCD.Locate(0,0)
LCD.VString = Str$(xpos)
Delay = 300
Loop
End Sub
Sub serialReceive_Event_Code()
While(cmu.Received = cvTrue)
rxBuff.Value=cmu.Value
If rxBuff.Value = 13
processPacket()
rxBuff.Location=0
Else
rxBuff.Location = rxBuff.Location + 1
EndIf
Wend
End Sub
Sub processPacket()
rxBuff.Location = 2
c1 = rxBuff.Value
rxBuff.Location = 3
If (rxBuff.Value = 13)
a = 1
Else
c2 = rxBuff.Value
a=2
EndIf
If (a!=1)
rxBuff.Location = 4
If (rxBuff.Value = 13)
a = 2
Else
c3 = rxBuff.Value
a = 3
EndIf
EndIf
Delay = 300
c1 = c1 - 48
Select Case a
Case 1
xpos = c1
Case 2
c2 = c2 - 48
xpos = 10*c1 + c2
Case 3
c2 = c2 - 48
c3 = c3 - 48
xpos = 100*c1 + 10*c2 + c3
End Select
End Sub
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
No comments:
Post a Comment