Saturday, May 26, 2012

Raspberry Pi: It arrived!

A mysterious package arrives...



Oh its beautiful! And tiny!

Flash is awesome on the iPhone 4S right?

When they said it was credit card sized they weren't lying!


All connected up:

All plugged in and ready to go.
The setup:

Sorry about the mess...

I'm a little afraid to plug my Razor peripherals into the Pi as they are high powered and backlit (my keyboard requires 2 USB ports but has a USB port on it) so I think i'll try it out tomorrow when I have some more time (as breaks in revision). It is a lovely little thing! 

I got the model B (so 2 USB ports and ethernet, with 256MB of RAM). Can't wait to get some real stuff done with it! I might try XBMC on it (for a media center) and some other distributions of Linux soon. I put Debian on the SD card for the moment as it was the recommended one from the Raspberry Pi foundation. I got a 16GB Sandisk SDHC card to put it on, and it works great from the looks of things!

I'll be doing more blog posts soon about the Pi and hopefully be showing some programming stuff soon!

Friday, May 4, 2012

Using C# in the Real World - LCD Studio

As I've been learning C#, I've been thinking "What could I possibly use C# for apart from coursework at this very moment?". Well last night, I came across a solution!

LCD Studio - a program that I have been using for nearly a year now for my Matrix Orbital GX Typhoon display - uses C# as its primary language! Granted you can also use VB and other .NET languages but the code samples were in C# by default.



So, wanting a couple more things on my display, I turned to the LCD Studio forums which are not used much any more but contain some great starting points. The program is a little old, so you have to do all kinds of things when starting a new project. What I wanted was a display of my CPU speed and also the current day of the week. Simple enough in C#, but getting it to display it is more complex, especially with legacy software (for example, the 16 GB you can see on the display above is just text, as the program is 32bit and could only see 4GB of my RAM).

Firstly, I looked at this post which gave me a good starting point. As the program is quite old, I had to change some things around in the program. When you create the project, it is easiest to create it with what you want to call the plugin for LCD Studio, otherwise you have to go around and change all of the properties of the project. Not that it is that big a deal.

Copied and pasted the default code from that post, and put it in a project (which was just called MyPlugin at the start), and then you need to add a reference to the LCD Studio CoreInterfaces.dll which is stored in the LCDStudio folder where it is installed (so for me, C:\Program Files(x86)\LCDStudio\CoreInterfaces.dll).



For my project I also had to add System.Management, which is in the default list of .dlls, as I wanted to get the CPU speed using it.

Then, right clicking on the solution and selecting Properties, I get to a screen where you need to change the target framework to .NET Framework 2.0. You have to do this as this was the latest framework that LCD Studio supported.




You can debug the program using LCD Studio too, if you go to Tools > Attach To Process... while LCD Studio is running, you can get warnings and errors for incorrect code and redundant parts of code. As I did that last night I don't have any screen shots but to be honest, its quite simple. Here is a screenshot of the Attach window and that is all you have to do.



And from there, I implemented the code in the Class1.cs file, put the Build Mode to Release, and pressed F6 to build the project. This creates the compiled .dll file for you to use and copy across to your LCD studio folder.



I have put up all my work for download here if you want to see it. I just worked out the code from the code sample that was there. To make it work, you also need to add a .plugin file to the LCD Studio folder which is a simple XML file, where the code is available at the same blog post as before. I have also put my entire Visual Studio project available for download here along with the plugin file and the .dll.

After I moved the .dll file and the .plugin file to the LCD studio folder, I had to restart it a couple of times before it would appear in the Options window in LCD Studio but it eventually came up, and to my delight it worked very well! (It says My Plugin due to my .plugin file I think but it doesn't seem to change - not really an issue for the moment!)




So that's my little intro to my experiences with C# in LCD studio. May end up releasing a more full featured plugin for BF3 or something in the near future, possibly over the summer when I have lots of time on my hands.