Skewworks NuGet Packages

Hey everyone, I’m getting all the tools ported to 4.3 and up on NuGet. I’ll post here as packages become available.

First off HAL 2.0.0



This package exposes interfaces that are helpful for creating drivers that can be used on any board as well as a few common classes.

[b]Interfaces:[/b] ICursorHAL, IDisplayHAL, IFileSystemHAL, IGameControllerHAL, IMainBoardHAL (for Gadgeteer), IModuleHAL (for Gadgeteer), INetworkHAL, IPowerHAL, IRealTimeClockHAL, IRegistry, IRegistryKey, ISoundHAL, IToneHAL, ITouchHAL, IUSBHAL

[b]Classes:[/b] 

[b]Cursor[/b]
Defines both the image and hotspot for a cursor. Without a hotspot all "clicks" would take place at the top-left corner of a cursor. With a hotspot you can offset your render -Hotspot.X, -Hotspot.Y so that your hotspot is over the mouse location and you "click" with the right portion of your image.

[b]Driver[/b]
This is a wrapper to put around any of the above interfaces so they can be loaded directly into the AppDomain from a file system or resource. This is useful if you have an app that runs on multiple mainboards or with configurable hardware.

[b]DriverCollection[/b]
Collection of drivers for when you want to package more than one driver into a single file.

[b]LCDConfiguration[/b]
Exposed by IDisplayHAL so a mainboard can set its resolution to what the display requires. This is also helpful in the event of a full IFU where the display setting gets wiped, the driver will restore it.

[b]Socket[/b]
Used with Gadgeteer

[b]Tone[/b]
Used with piezo.
7 Likes

Type Classes 1.1.0



This package contains a few type classes that are helpful in almost any NETMF GUI Application. As always, all classes are AppDomain safe. All of these classes support .ToString()

[b]Point[/b]
A simple X/Y pair

[b]Rect[/b]
A rectangle. Supports methods to combine with another rectangle, check if a point is inside of the rectangle, check if the rectangle intersects another rectangle.

[b]Size[/b]
A simple Width/Height pair
1 Like

GUI 3.1.1



Ah, the meat and potatoes of Skewworks in NETMF. There's a good bit here, so let's dive in.

[b]Display[/b]
This is the [b]primary[/b] class in the package. A singleton, automatically creates a bitmap the size of the detected screen. If you use Display.FlushScreen() (which is the [b]recommended[/b] way to flush), ScreenFlushing and ScreenFlushed events will be raised by Display.Instance. This is perfect for things like drawing overlays or mouse cursors.

[b]Colors & AccentColors[/b]
Two sets of statically available colors. Colors contains FromString and FromValue methods. In addition to RGB and HEX values to can supply [Accent],[Background],etc to have the current value from Themes.Current returned.

[b]Themes[/b]
Singleton class that allows you to keep a collection of themes, get and set the currently active theme.

[b]Theme[/b]
Class containing a collection of colors (Accent,Background,Chrome,etc) with a name.

[b]Images[/b]
Allows you to quickly create an image from bytes (including a PNG), the image type is automatically detected by the magic number. You can also create shadows and perform a "ColorConvert", this action changes every non-transparent pixel to the supplied color; useful for creating Windows 8 style apps.

[b]Fonts[/b]
A class with a collection of fonts for different sizes. Also contains static methods GetRect and GetSize.
3 Likes

Native Touch 2.2.2



This is the simplest way to use touch in NETMF.

[b]NativeTouch.StartCollection()[/b]
Starts touch collection and stores configuration inside of EWR. A small font is already included all calibration is done for you and there is a confirmation screen.

[b]NativeTouch.StartCollection(string filename)[/b]
Starts touch collection and stores configuration inside of a file on SD or USB. This is very useful when using touch across multiple applications, namespaces, or devices.

[b]Gestures are included.[/b]
1 Like

Please note there were issues with GUI and NativeTouch packages. This was my first time creating NuGets with NETMF and there were some dependency errors. They have been corrected. If you are using these packages please update to the latest version.

Fixes have been tested in a black project.

1 Like

Hi Tom,
where can one find some example on how to use the new packages?

i’m kind of interested in knowing how would one implement a way to load drivers on the fly (Example Sensors) where they would be compatible and allow the main interface to hook into their events and so one. make sense?

Edit: I got the error below as soon as I installed your package ( PM> Install-Package SKW-NETMF-HAL ) on a blank NETMF Mountaineer board project.
looks like TypeClasses is missing from the package!

thank you :slight_smile:

Thanks, I’ve fixed HAL (2.0.1).

For a video driver example, create a new class library project name T43. The first class will have code as follows:

using System;
using Microsoft.SPOT;
using Skewworks.NETMF.HAL;

namespace T43
{
    [Serializable]
    public class T43Driver : Driver
    {

        private T43 _t43;

        public override string Company
        {
            get
            {
                return "Skewworks, Inc.";
            }
        }

        public override string Copyright
        {
            get
            {
                return "(c)2015 Skewworks, Inc.";
            }
        }

        public override object DriverObject
        {
            get
            {
                if (_t43 == null)
                    _t43 = new T43();

                return _t43;
            }
        }

        public override DriverType DriverType
        {
            get
            {
                return DriverType.Display;
            }
        }

        public override string Version
        {
            get
            {
                return "1.0.0.0";
            }
        } 

    }
}

Now add another class named T43 with the code below

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Skewworks.NETMF.HAL;
using System.Threading;

namespace T43
{
    [Serializable]
    public class T43 : MarshalByRefObject, IDisplayHAL
    {

        #region Variables

        private OutputPort _bkgLight;

        #endregion

        #region Constructors

        public T43()
        {
            GHI.Processor.Display.Type = GHI.Processor.Display.DisplayType.Lcd;

            GHI.Processor.Display.Width = 480;
            GHI.Processor.Display.Height = 272;

            // Only use if needed, see documentation.
            //GHI.Processor.Display.PriorityEnable = false;

            GHI.Processor.Display.OutputEnableIsFixed = false;
            GHI.Processor.Display.OutputEnablePolarity = true;

            GHI.Processor.Display.HorizontalSyncPolarity = false;
            GHI.Processor.Display.VerticalSyncPolarity = false;
            GHI.Processor.Display.PixelPolarity = false;

            GHI.Processor.Display.HorizontalSyncPulseWidth = 41;
            GHI.Processor.Display.HorizontalBackPorch = 2;
            GHI.Processor.Display.HorizontalFrontPorch = 2;
            GHI.Processor.Display.VerticalSyncPulseWidth = 10;
            GHI.Processor.Display.VerticalBackPorch = 2;
            GHI.Processor.Display.VerticalFrontPorch = 2;

            GHI.Processor.Display.PixelClockRateKHz = 22166;

            if (GHI.Processor.Display.Save())
            {
                Debug.Print("Display changed, resetting device");
                Thread.Sleep(500);
                PowerState.RebootDevice(true);
            }
        }

        #endregion

        #region Properties

        public bool BacklightOn
        {
            get
            {
                if (_bkgLight == null)
                    return true;
                return _bkgLight.Read();
            }
            set
            {
                if (_bkgLight != null)
                    _bkgLight.Write(value);
            }
        }

        #endregion
    }
}

To load the driver from the file system you can use these methods:

        static Exception LoadDriver(string filename)
        {
            try
            {
                Assembly asm = Assembly.Load(File.ReadAllBytes(filename));

                Type[] t = asm.GetTypes();
                for (int i = 0; i < t.Length; i++)
                {
                    if (t[i].BaseType != null && t[i].BaseType.FullName == "Skewworks.NETMF.HAL.Driver")
                    {
                        try
                        {
                            Driver d = (Driver)AppDomain.CurrentDomain.CreateInstanceAndUnwrap(asm.FullName, t[i].FullName);
                            LoadDriver(d.DriverType, d.DriverObject);
                            return null;
                        }
                        catch (Exception ex)
                        {
                            Debug.Print(ex.Message);
                            return ex;
                        }
                    }
                    else if (t[i].BaseType != null && t[i].BaseType.FullName == "Skewworks.NETMF.HAL.DriverCollection")
                    {
                        try
                        {
                            DriverCollection d = (DriverCollection)AppDomain.CurrentDomain.CreateInstanceAndUnwrap(asm.FullName, t[i].FullName);
                            for(int j =0; j < d.DriverTypes.Length; j++)
                                LoadDriver(d.DriverTypes[j], d.DriverObjects[j]);
                            return null;
                        }
                        catch (Exception ex)
                        {
                            Debug.Print(ex.Message);
                            return ex;
                        }
                    }
                }

                return new Exception("Interface not found");
            }
            catch (Exception ex)
            {
                return ex;
            }
        }


        static void LoadDriver(DriverType type, object driver)
        {
            switch (type)
            {
                case DriverType.Cursor:
                    CursorDriver = (ICursorHAL)driver;
                    break;
                case DriverType.Display:
                    DisplayDriver = (IDisplayHAL)driver;
                    if (Display.ScreenWidth == 0)
                        PowerState.RebootDevice(false);
                    break;
                case DriverType.FileSystem:
                    FileSystemDriver = (IFileSystemHAL)driver;
                    break;
                case DriverType.GameController:
                    GameController = (IGameControllerHAL)driver;
                    break;
                case DriverType.Network:
                    NetworkDriver = (INetworkHAL)driver;
                    break;
                case DriverType.Power:
                    PowerDriver = (IPowerHAL)driver;
                    break;
                case DriverType.RealTimeClock:
                    TimeDriver = (IRealTimeClockHAL)driver;
                    break;
                case DriverType.Registry:
                    Registry = (IRegistry)driver;
                    break;
                case DriverType.Sound:
                    SoundDriver = (ISoundHAL)driver;
                    break;
                case DriverType.Tone:
                    break;
                case DriverType.Touch:
                    TouchDriver = (ITouchHAL)driver;
                    TouchDriver.StartCollection();
                    break;
                case DriverType.USB:
                    USBDriver = (IUSBHAL)driver;
                    break;
            }
        }
2 Likes

GHI Native Gadgeteer Mainboards
[em]Cobra II, Hydra and Raptor[/em]

1 Like

HAL has been updated to version 2.0.2.

Release Notes
Added bool property RequiresGadgeteer
Added bool method InitializeGadgeteer

This allows you to create drivers for gadgeteer modules to run on any gadgeteer mainboard.

2 Likes

EXT Added



This will contain all the nice-to-haves outside of GUI/HAL/etc. Currently has:

[b]StringSorter[/b]
I think the name pretty much speaks for itself

[b]Strings[/b]
AbsolutePath - Returns an absolute path from a base & relative path pair
FitToCount - Returns array of strings to fit within a certain character count per line, takes \r and \n into account.
FormatDiskSize - Takes a long and returns appropriate size X.XX[B/MB/GB/TB], precision int available.
InQuotes - Lets you know if a certain character position is inside of a quote set.
MonthFromString - Int from month string
MonthToShortString - Jan,Feb,etc from int
MonthToString - January,February, etc from int
NormalizeDirectory - Forces string to end with \
PadZeroLeft - Pads left side of string with X zeros to fit a certain count
PadZeroRight - Pads right side of string with X zeros to fit supplied length
ParseDate - Returns data from string (still needs some work)
RelativePath - Relative path from absolute and base pair
Replace - Replacement
ReplaceEmptyOrNull - Self explanatory
SplitComponents - Splits string by deliminator when NOT inside quotes
Tokenize - Returns tokenized array for string
WeekdayToShortString - Mon,Tue,Wed,etc from int
1 Like

Skewworks.GUI 3.1.3
Added Border, ControlBottom, and ControlTop colors to Theme
Added .Instance to Themes
Made Fonts a singleton
Added new default theme
Made Type dependency non version specific

Skewworks.EXT 1.0.1
Added Clipboard

5 Likes

Skewworks.NETMF.GUI.Controls 4.0.0



It's here! There will be updates but the first round of controls for all is ready. Let's dig in.

[b]Helpers[/b]
[em]Navigation Service[/em] - Singleton that takes care of navigation between pages (GoBack included!) with a simple NavigationService.Navigate. Please remember to call NavigationService.Initialize before trying to use it!

You can also do Drag & Drop. Navigation service takes care of all the GUI for you.

[em]SelectionDialog[/em] - Allows you to display a list of options for the user with the selected item (if any) returned to you.

[b]Controls[/b]
Button, CheckBox (the rendering for CheckBox & RadioButton is pretty sexy. It uses multiple Image32s and your Theme to render glorious anti-aliased items), ContextMenu, DropDownList, Image, ListBox, MenuItem, ProgressBar, ProgressRing, RadioButton, TextBlock, TextBox and VirtualKeyboard (100% customizable!!!)

[b]Containers[/b]
Grid, Page, Panel, and StackPanel

[b]Base Controls/Containers[/b]
Container, Control, ScrollableContainer
4 Likes

@ Skewworks - Are the display classes just for RGB LCD displays, or will they work with displays like the N18 as well?

Currently native LCDs only. I’ll be adding support for serial LCDs in the future.

OK, stupid me just realized EXT and Controls were set to deploy to 4.2 even though they were 4.3. So if you’re using them just go under the updates tab and grab the latest (fixed) version.

Skewworks.NETMF.Applications 1.0.2


Contains the basics for launching applications in new AppDomains

[b]Skewworks.NETMF.Applications.Manager 1.0.0[/b]

```cs]PM> Install-Package SKW-NETMF-ADM[/code

The AppManager performs the actuall launching of applications and persists all instances of Display,Themes,Fonts,Etc across the AppDomains.

[b]Skewworks.NETMF.GUI 3.1.6[/b]
Replaced Display.Instance with Display.Current to keep with conventions
Themes.Current now returns the Themes instance
Themes.Active added to return current Theme (previously Themes.Current)

[b]Skewworks.NETMF.EXT 1.0.3[/b]
Added Clipboard.Current

[b]Skewworks.NETMF.HAL 2.0.4[/b]
Added DeviceManager singleton to keep all loaded drivers between AppDomains, classes and programs

[b]Skewworks.NETMF.Controls 4.0.2[/b]
Updated to work with new Themes interface.
2 Likes

Application Manager
Removed domain restriction on .Current
Fixed marshalling issue

HAL
Added SocketCount to IMainboard
Added RequiredSockets to Driver
Removed domain restriction on DeviceManager.Current

GHIMainboards
Added Spider mainboard

Skewworks GUI
Removed domain restriction on Themes.Current
Removed domain restriction on Display.Current
Removed domain restriction on Fonts.Current
Placed all fonts under Fonts.Current

Skewworks EXT
Added Strings.VersionFromString
Added IO.CompareVersions
Added XMLReaderEX and XMLNodeEX

Nice work Skewworks. Any plan to add line graphs to your GUI library in the near future? I remember them being in Tinkr. Thanks for all of your contributions! :clap:

Is there a video showing how to develop with this seemingly cool stuff?

@ Guerillah - Yeah more things are coming. I’m going to be spending the next month in hotels for work so its likely more will be out in April.

@ njbuch - Not yet, but that’s coming too.