PowerShell / PowerShell-IoT

Interact with I2C, SPI & GPIO devices using PowerShell Core!
https://www.powershellgallery.com/packages/Microsoft.PowerShell.IoT
MIT License
129 stars 28 forks source link

Add more settings to SPI, and possibly add a Get-SPIDevice #54

Open DanielSSilva opened 4 years ago

DanielSSilva commented 4 years ago

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.

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()    
anmenaga commented 4 years ago

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.