Department of InformatiX
Microsoft .NET Micro Framework Tools & Resources

Working classes for reuse

ButtonTextBoxDemo.zip Saturday, December 6, 2008, .zip, 25.4 kB

ButtonTextBox Screenshot

The first user control allowing users to enter any text data into your application, using buttons. Features TextChanged event, selection, insert/overtype mode, input length and numbers-only limit, or characters masking for password entering. Although it is also possible to align the text to the center and to the right, in these cases text longer than the control is not rendered very well. Neither multiline text nor wrapping is supported. The project contains fully commented source code of the text box and some helper classes, and demo application for standard Microsoft's emulator. You can check the ButtonTextBox class itself here.

Updates: works in both 3.0 and 2.x, demo project updated to 3.0.

DayTime.cs Wednesday, April 16, 2008, .cs, 29.4 kB

This struct is for representing day time, ranging 00:00 - 24:00 with milisecond precision. Methods for simple operations like AddHour() make the value easily controllable by small number of buttons. XML comments so far in Czech.

Dcf77Decoder.zip Saturday, December 6, 2008, .zip, 5.5 kB

Most of boards currently available do not have back-uped time source, which results in having the system time (Utility.GetMachineTime()) reseted to 1.1.2004 on every restart. There are two ways how to get the current time nowadays - either from GPS or using some signal available at radio frequency (complete list on wikipedia). There are serious problems with signals inhouse, the more without any antenna, so you might find handy to sync with some radio signal.

One of such signals is the DCF-77, transmitted from the location near Frankfurt (cca 2500 km coverage). The Conrad company sells a small board (part no. 641138) with demodulator, which can be connected directly (the inverted DCF output) to the processor's pull-uped input. This class is able to decode the DCF signal, as well as check the parity. As a bonus, you can easily find whether the DCF board is working by supplying output pin for LED as well.

Updates: works in 3.0, implemented pull-up resistors option.

Logarithm Tuesday, July 22, 2008, .cs, 4.4 kB

(you will need IEEE.Single.cs as well) Although we have two Math classes, none of them contains the logarithm. After several hard days I've successfully implemented an algorithm described by Keith Larson in the Fast Logarithms on a Floating-Point Device application note. It uses binary format of the floating-point number and processor's floating-point ALU to speed-up the computation. The class contains Log2, Log, Log10 methods for computing logarithms of base 2, e (natural) and 10 respectively, and then a FastLog2 method for very fast approximation of the logarithm value (in constant time). Unfortunately we can't use unsafe code, so I had to use a little serialization trick which I hope is not too slow. The logarithm is computed in single-precision (i.e. float type), which is native to the processors. You can further adjust the precision by undefining the HIGH_PRECISION symbol, which reduces the computation time about one fourth and drops precision from full 23 bits to 21 bits. Let me know if anybody needs to compute logarithm of the double type, but keep in mind that this type is emulated by the runtime and the performance will thus likely suffer.

Matrix keyboard pack Saturday, December 6, 2008, .zip, 6.4 kB

A simple matrix keyboard driver and input manager allowing you to use matrix keyboards in .NET Micro Framework. Unfortunately, the classes are not commented yet, but there is an article describing their fundamentals.

Updates: works in 3.0.

NoritakeDisplay.zip Saturday, December 6, 2008, .zip, 10.6 kB

The Noritake-Itron company produces really cool, VFD displays (Vacuum Fluorescent Display). They have various resolutions, features and communication interfaces, you can even connect multiple of them to one bus. The best thing is that the commands are common for all of them. And I've wrapped the most of them in this class for you - remain user settings, macro and GPIO support, which requires the more expensive display series anyway. If anybody would be interested in implementation, no problem to complete it. Includes XML comments according to datasheets.

Updates: works in 3.0.

Panels.zip Tuesday, April 8, 2008, .zip, 4.1 kB

As you have probably already noted, .NET Micro Framework comes with only minimal amount of Panels. I have a suspicion this is due to lack of real dependency and attached properties.

With a help of Reflector I'm putting together the basic panels missing in the .NET Micro Framework. Meanwhile, DockPanel and WrapPanel are available, we can try others as well if there will be demand from you. Important note to using DockPanel: The HorizontalAlignment and VericalAlignment being set to Stretch aren't always fulfilled (I think this is quite a bug). So if you want the last control to fill the remaining panel space, you would likely have to derive from its class and override the ArrangeOverride method.

SerialInterruptPort.cs (2.x runtime) Sunday, May 11, 2008, .cs, 36.6 kB

Fully commented class, which is trying to fill some deficiencies in the SerialPort in framework version 2.5. Features:

If you just need to read and write lines, I suggest to use the Pavel's class. Hopefully similar classes will not be needed anymore in the upcoming version of framework.

UrlDecode Sunday, July 20, 2008, .cs, 2.9 kB

Even on the simplest web server it is necessary to decode URLs during request processing, because browsers do encode addresses and form values. There is a System.Web.HttpUtility class in the .NET Framework, which we unfortunately don't have. So I had to wrote a lighter version of the UrlDecode method. It works the same as the big one, but supports only UTF8 encoding and for simplicity the conversion runs without the help of an UrlDecoder.

Experminetal classes - just ideas!

AnimatedCanvas.cs Wednesday, June 17, 2009, .cs, 2.5 kB

Simple class demonstrating how you can animate a background-less control's background using separate images from resources. You pass the interval between frames to the constructor as well as first and last frames IDs. The resource bitmaps are required to have sequential IDs, see this article on how to do that. And don't forget to call Play()! If you however have all frames in one bitmap, you might find Pavel's animation example more useful.

WPF emulator with display support Sunday, March 29, 2009, .zip, 102.2 kB

There is only one component, which has to be implemented differently than with the Windows Forms technology - the LCD display. A sample WPF emulator with display support (only), fully commented class and some ideas how could one use the data binding feature in emulators. This example does not follow any sophisticated model, just the easiest working way. The emulator does not register itself, it is more for reference - you have to set a command line arguments to load a .NET Micro Framework project in order to run it.

Console window Friday, January 11, 2008, .zip, 96.3 kB

If you are developing an application for display-less device, but the development board has the display attached, or if you need to test the device without having Visual Studio attached, you might find this console window (with clocks) helpful. Simply add a reference and use Console.WriteLine(string). The file contains source code and an example project. Warning: it is not yet possible to use this "console" in other windows application.

Oscilloscope user control Saturday, December 6, 2008, .zip, 13.2 kB

Oscilloscope screenshot

An example of how to plot signals on the display. The user control allows redrawing the signal periodicaly, scroll and zoom indepently in both axes, set the axes coordinates, grid intervals and display some description. You can use anything what derives from the SignalSource abstract class and implements the GetValue(float x) method as a signal source. Each signal can have its own name, color/pen, visibility and image and domain ranges. I've implemented four types of such signals for you:

There is a test project in the file, from which the screenshot was taken. These are the button assignments on Microsoft's standard emulator:

Updates: demo project updated to 3.0.

ParallelOutputPort.cs Saturday, December 6, 2008, .cs, 2.5 kB

Allows you to join several pins into one "parallel" port, and thus write out numbers in bit representation (by default requires PortStore class below). Unfortunately, the pin toggle speed in managed code is so slow, that even with serial interface you could get better data throughput. In addition to standard implementations (eg. Pavel's here), this has one dedicated input signal to interrupt data writing (busySignal) as well as special output to indicate that all pins have set the desired value (dataReady). If you need join pins for reading, see Pavel's MultiInputPort class.

Updates: works in 3.0 version, added PortStore-less equivalent code in comments.

PortStore.cs Tuesday, April 15, 2008, .cs, 3.7 kB

If you can't get used to the declaring and disposing ports during application execution, you can use a principle sketched in this static class. The output and input ports are usually fixed in the real applications. This class has a GetInput(Cpu.Pin), GetOutput(Cpu.Pin) and GetTristate(Cpu.Pin) methods, which either returns an InputPort, OutputPort resp. TristatePort instance if already instantiated, or creates a new one. Interrupt port can be easily added in a similar way, but that's not usually needed. This class can be used to comfortably manipulate ports from multiple threads simultaneously.

Comments
Sign in using Live ID to be able to post comments.