Jim, you can use the See Munkey with VB6 quite easily.  Just go to components 
and add Microsoft Comm Control 6.0 and add one to your project.  Toss this code 
into form_load just to set things up.

If MSComm1.PortOpen Then MSComm1.PortOpen = False
MSComm1.Settings = "115200,N,8,1"
MSComm1.DTREnable = True
MSComm1.RTSEnable = True
MSComm1.RThreshold = 1
MSComm1.SThreshold = 0
'set the active serial port
MSComm1.CommPort = 2
MSComm1.PortOpen = True

When you want to send data to the device you just run the single line of code:
MSComm1.Output = "p"

All commands you send to the device are a single lowercase character.  "v" 
requests the device firmware version, "w" requests raw sensor data, "p" 
requests processed sensor data (recommended at first), "c" is the command to 
center the device, "u","d","l","r","7", and "9" are the calibration commands.  
And that's it.

When the See Munkey sends data back to your program, it shows up in the OnCOmm 
section of MSComm1.  Because there is a chance that the data won't arrive in a 
single message (just like when doing multiplayer coding for games) I have it 
store incoming messages into a separate variable that will keep being added to 
until it has everything I've requested.

tempm$ = MSComm1.Input
incomingmessage$ = incomingmessage$ & tempm$

For when you request the version, the message will be contained between a set 
of brackets ( ).
If InStr(1, incomingmessage$, "(") <> 0 And InStr(1, incomingmessage$, ")") <> 
0 Then 'we have the version
    tempm2$ = Left(incomingmessage$, InStr(1, incomingmessage$, ")") - 1) 
    deviceversion$ = Right(tempm2$, Len(tempm2$) - (InStr(1, tempm2$, "("))) 
    msgbox "The version is " & tempm2$
    incomingmessage$ = ""
End If

'For when we request processed data, the message is 3 numbers separated by 
commas, held between square brackets [ ].
If InStr(1, incomingmessage$, "[") <> 0 And InStr(1, incomingmessage$, "]") <> 
0 Then 'we have a full piece
    tempm2$ = Left(incomingmessage$, InStr(1, incomingmessage$, "]") - 1) 'full 
reading
    tempm2$ = Right(tempm2$, Len(tempm2$) - (InStr(1, tempm2$, "["))) 'full 
reading
    incomingmessage$ = ""
    myyaw = Left(tempm2$, InStr(1, tempm2$, ",") - 1): myyaw = Round(myyaw, 2)
    tempm2$ = Right(tempm2$, Len(tempm2$) - InStr(1, tempm2$, ","))
    mypitch = Left(tempm2$, InStr(1, tempm2$, ",") - 1): mypitch = 
Round(mypitch, 2)
    tempm2$ = Right(tempm2$, Len(tempm2$) - InStr(1, tempm2$, ","))
    myroll = Left(tempm2$, InStr(1, tempm2$, ",") - 1): myroll = Round(myroll, 
2)
    tempm2$ = Right(tempm2$, Len(tempm2$) - InStr(1, tempm2$, ","))
    'here is where I decide what to do with those 3 values.
    Call process
    'to keep the data coming, I request another set of sensor data from the 
device so that we always have another updated message coming in to update our 
head position.
    sendcom "p"
    DoEvents
End If

To the non programmers or the non-VB programmers, I apologize for the long code 
themed message.  :D  But yeah, that's basically it.  This example hard codes 
COM port 2 as the port the devices is plugged in to, but that's just because I 
recently found that my auto-detect method is broken and doesn't always get the 
right one.  I hope this made at least some sense Jim, since I don't comment my 
code and tried to just toss a few comments in after I pasted it into the email.


--- On Mon, 5/20/13, Jim Kitchen <j...@kitchensinc.net> wrote:

> From: Jim Kitchen <j...@kitchensinc.net>
> Subject: Re: [Audyssey] A See Munkey in my house!
> To: "Jeremy Kaldobsky" <Gamers@audyssey.org>
> Date: Monday, May 20, 2013, 4:53 AM
> Hi Jeremy,
> 
> May I ask, will I be able to develop games in VB6 that will
> be able to take advantage of your See Munkey?
> 
> Thanks.
> 
> BFN
> 
>     Jim


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to