Raspberry Pi Sense Hat or Astro Pi has a LED Matrix to display an 8x8 pixel of image. If you using Python to run the Sense Hat, you even can have horizontal scrolling text which is fun to play around with. What if we are using .NET? Do we have a library for that?
In .NET, to control Sense Hat, we can use Iot.Device.Bindings under .NET IoT Libraries. A lot of functions are already available inside the library such as drawing some pixels to the LED matrix, getting temperature and humidity and etc. But it seems like it doesn't have the horizontal scrolling text like what we found in python-sense-hat. Therefore, a new .NET library has been created. It supports scrolling text with vertical scrolling which is something not available in python-sense-hat. It is implemented using a pure .NET library using Iot.Device.Bindings
without any native or python interop. Please watch the video below for the scrolling text demo.
To use the library, you just need to add the dotnet-sense-hat-text package in nuget.
dotnet add package SenseHatText
After that, you can refer to code below to use the library or refer to the sample folder in the github repository.
using System; using System.Drawing; using System.Threading; using Iot.Device.SenseHat; using Iot.Device.SenseHatText; namespace TestSenseHatText { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); using var ledMatrix = new SenseHatLedMatrixSysFs(); ledMatrix.ShowMessage("HELLO WORLD!", 90, Color.DarkBlue, Color.DarkRed); ledMatrix.ShowMessage("WELCOME TO .NET!", 90, Color.Yellow, Color.Black, true); ledMatrix.ShowLetter("A"); Thread.Sleep(2500); ledMatrix.Clear(); } } }
As you can see at the code above, basically you just need to declare the SenseHatLedMatrixSysFs
and then call the ShowMessage
to use the library. Hope you will enjoy the library and has fun.
Finally, if you are interested in how to implement the library, please head to the Github repository. Basically, it just uses the idea from python-sense-hat with some modification by using a pure array to rotate and thank you python-sense-hat for the brilliance idea.
Github Repository:
https://github.com/sanme98/dotnet-sense-hat-text
Nuget Package:
https://www.nuget.org/packages/SenseHatText/
Credit:
https://github.com/astro-pi/python-sense-hat
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.