How would I be able to repeat the array multiple times using .netmf (VB or C#)?
Below you'll find the function I used to build a Byte(). All it does is get an 8 char string (Ex.10101000) and phases each char replacing a 1 with 252 and 0 with 128 and dumps it to an array of bytes. Ex.
Dim bytes() as array = {252,128,252,128,252,128,128,128}
^^^^ Would be the equivalent.^^^^
So say I use my function and I pass it a string of 10101011
Dim N as integer = 3
Dim Teststring as string = "10101011"
Dim testbyte() as byte = Allbytes2send(Teststring , N)
Testbyte() should now be filled with the phase string 3 times
For each b in Testbyte
Debug.Print(b.tostring)
Next
'{252,128,252,128,252,128,252,252,252,128,252,128,252,128,252,252,252,128,252,128,252,128,252,252}
Function
Shared Function Allbytes2send(ByVal color As String) As Byte()
Dim bitcolor As String() = New String(color.Length - 1) {}
Dim b2sa As Byte() = New Byte(bitcolor.Length - 1) {}
For i As Integer = 0 To color.Length - 1
bitcolor(i) = color(i).ToString()
Next
For i As Integer = 0 To bitcolor.Length - 1
Dim data As String = bitcolor(i)
Select Case data
Case "0"
bitcolor(i) = "128"
Case "1"
bitcolor(i) = "252"
End Select
Next
For i As Integer = 0 To bitcolor.Length - 1
b2sa(i) = Byte.Parse(bitcolor(i))
Next
Return b2sa
End Function
Figured it out I wrapped it in another function. By using Array.copy and reassigning my byte array I was able to dynamically change the size of array and copy using predetermine number multiplied by any given number.
Shared Function SendAllLeds(ByVal LedsData As Byte(), ByVal LedCount As Integer) As Byte()
Dim testbyte2() As Byte = Nothing
Dim y, z As Integer
y = (24 * LedCount) - 1
z = 0
ReDim testbyte2(y)
While z <= y
Array.Copy(LedsData, 0, testbyte2, z, 24)
z += 24
End While
Return testbyte2
End Function