Code convert vb6 help

Hello,
I use this Function to convert the codes of the type: $80, $AB, $C2 ...
Can one help me has to adapt my Function for the codes of the type: $300+DIR ,$3AA ,$3F0 ...please?
Cordially
Hugolain
PS:
I use this Function to convert the codes of the type: $80, $AB, $C2 ...
- Code: Select all
Private Sub CcBtnConvert_Click()
CcTxtIRCode.Text = ByteToIRCode(Val("&H" & CcTxtHexa.Text))
End Sub
Public Function ByteToIRCode(ByVal vInput As Byte) As String
Const Header As String = "R08008104"
Const Bit0 As String = "2121"
Const Bit1 As String = "808221"
Do Until vInput = 0
If vInput Mod 2 = 1 Then
ByteToIRCode = ByteToIRCode & Bit1
Else
ByteToIRCode = ByteToIRCode & Bit0
End If
vInput = vInput \ 2
Loop
ByteToIRCode = Header & ByteToIRCode
End Function
Can one help me has to adapt my Function for the codes of the type: $300+DIR ,$3AA ,$3F0 ...please?
Cordially
Hugolain
PS:
The IR Carrier is 39.2kHz. Data is modulated using a space coded signal with 12 data bits (data clock is 1200Hz, but actual data rate varies depending on the data).
For modulating the signals yourself, the signal looks something like this:
Timing based on 1/1200 second clock (~.833ms)
Signal is normally high (idle, no IR).
Start: signal goes low for 8/1200 sec.
Data bits: for each of 12 data bits, space encoded signal depending on bit value
Sends the most significant data bit first
If the data bit is 0: signal goes high for 1/1200 sec, and low for 1/1200 sec.
If the data bit is 1: signal goes high for 4/1200 sec, and low for 1/1200 sec.
BTW: the first 4 bits are always "0011" for the Robosapien V2
When completed, signal goes high again.
No explicit stop bit. Minimal between signals is not known.