Unity UI for DeskCycle Arduino Speedometer

[Updated, see end of article]

Since my last post I’ve improved the Arduino speedo code to respond to requests and also tweaked the gear ration to be a bit closer to my road bike.  I’ve also implemented a simple speedo interface using Unity.

Unity DeskCycle Speedometer
Unity DeskCycle Speedometer

The Unity application also automatically searches the COM ports on the machine until it finds the Arduino speedo, it’s a bit hacky but works and means I don’t have to implement a COM port selection UI.

I’m going to add functionality to save off the readings to CSV log files too, at a later date I’ll add some kind of analysis in but getting the data saved is the important thing for now.

Update:  CSV functionality has been added and I’ve tweaked the interface too.

DeskCycle Arduino Speedo
DeskCycle Arduino Speedo Interface

For the Arduino portion of this weekend long hack, see here.

Generating a C# Class from XML

After a two week hiatus from work and blogging, spent mostly at the ever excellent Reading Beer Festival, I’m back at work and doing something so simple I’ve utterly forgotten how to do it.  As this blog started as a way for me to keep track of random things I learn over the years, it’s time to write this one down.

Here’s the issue; I’ve created an XML file and want to create a C# class library to work with it in code.  It’s really easy once you remember how, through the use of xsd.exe.

  1. Create xml file
  2. Run “xsd.exe filename.xml” to create an XSD file
  3. Run “xsd.exe /classes /language:CS filename.xsd” to generate a .CS file

One thing that always makes me chuckle is this line that is included at the top of each CS file;
“This code was generated by a tool.”

In this case, a forgetful one at that.