Add more settings to SPI, and possibly add a Get-SPIDevice
This is an initial commit so that we can discuss if such changes can make sense. This comes in sequence of issue #53. In my case, I have the neopixels which I can use to test the SPI, basing my implementation on dotnet IoT binding sample for the WS2812b.
-
Why a Get-SPIDevice - For this binding, they are passing the SPI device as a parameter (which was one of the reasons why I've decided to try an implementation of a Get-SPIDevice). It also seems, as I've pointed on the issue, that "this seems that the SPI device could be created once and used many times", which would make more sense than creating a device for each time we send some data.
-
Why more settings - Again, basing my implementation on their sample, there were some settings that seemed to be mandatory for it to work properly. Because it seems they are not mandatory, they can be created with default values.
Here's an example:
$device = Get-SPIDevice -Frequency 2400000 -Mode Mode0 -DataBitLength 8 -BusId 0 -ChipSelectLine 0
$neo = [Iot.Device.Ws28xx.Ws2812b]::new($device,1)
$img = $neo.Image
$img.SetPixel(0,0, [System.Drawing.Color]::DarkRed)
$neo.Update()
Also, a general comment: using SPI for neopixels is a hack that exploits the high-frequency of SPI bus to emulate (relatively)low-frequency of neopixel protocol.
This hack is a valid scenario, but it can't be used as verification that our SPI cmdlets actually work correctly for real SPI communications between devices.