Simple test

Testing a little WPF screen and getting time and weather from the internet. It takes about 30 seconds to get an IP address from DHCP.

I couldn’t figure out how to make JSON deserializing work so I just parsed the returned data to get what I needed. Looking forward to more documentation and examples as they become available.


Nice work.

Does WPF give us anything other than flat buttons with no visual feedback.

WPF is new to me so I am trying to work out how to come up with a nice visual looking GUI. My old oven controller based on the G120 and Glide is crying out for a new and faster front end and a 7" LCD instead of the old one with the 5".



Seems to be pretty basic. Just flat buttons, no style option or anything. There might be a way to use bitmap images as buttons but I haven’t dug that deep. I tried to give the button some feedback by changing the color on the TouchDown and TouchUp events but I couldn’t get the TouchUp event to fire.
(The touch controller fired it but it didn’t bubble up to the button.TouchUp handler.) Getting those to work correctly will be necessary to build a responsive UI.

I haven’t done a multi-screen app yet. This app was just and extension of the examples given. That will be the true test when trying to move between multiple screens and use the on-screen keyboard.

I did run into a problem where the DispatcherTimer that updates the window every 500ms stop firing. I am not sure yet if its a bug or if I am doing something wrong. Runs for a few minutes then stops updating. Code is still running, screen just stops.

1 Like

@skeller nice little demo app!

You can create custom buttons in WPF using bitmaps. We will have more code samples in docs very soon. These bitmap images are buttons.


A button is just an element like everything else. I think if they community invest in improving the current graphics support they will be better off than glide in the long run.

Glide is just very easy to use so I understand

1 Like

Here is a little bit to get you started. You need the TinyCLR.UI NuGet

using GHIElectronics.TinyCLR.UI.Media.Imaging;
using GHIElectronics.TinyCLR.UI.Controls;

touch.TouchDown += (s, e) => { app.InputProvider.RaiseTouch(e.X, e.Y, GHIElectronics.TinyCLR.UI.Input.TouchMessages.Down, System.DateTime.Now); };
touch.TouchUp += (s, e) => { app.InputProvider.RaiseTouch(e.X, e.Y, GHIElectronics.TinyCLR.UI.Input.TouchMessages.Up, System.DateTime.Now); };

var customButtonBmp = Resources.GetBitmap(Resources.BitmapResources.rightArrow);

var customButtonImage = new GHIElectronics.TinyCLR.UI.Controls.Image{
Source = BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(customButtonBmp))
var customButton = new Button{
Child = customButtonImage

I only create one of the buttons here in the snippet


Thanks Greg!

Now I’ll spend the rest of the day deciding if I should push the left or the right button. . . Life is difficult at times.


Once we figure out how to have an image for the down state and disabled etc and this changes when you press the button, we should be looking good.

1 Like

Should be able to change the image in the TouchDown and TouchUp events. Its extra work but it should work. It would be nice to assign up, down and disabled when element is created.

1 Like

I am considering create a GUI class to handle all of this instead of coding it each time. Need to get more play time this weekend on it as I have to main C# control systems to develop so my time with the modules is limited. If only they had arrived 2 months ago when I was quiet.

I wrote a test and I can get the down button state to work but the TouchUp never fires. I can see the touch screen driver handler being called and I do pass the TouchMessage.Up to the Application. Looks like there may be a bug in there somewhere. :slight_smile:

Here is my test code.

using System;
using System.Drawing;
using System.Diagnostics;
using GHIElectronics.TinyCLR.Devices.Display;
using GHIElectronics.TinyCLR.Drivers.FocalTech.FT5xx6;
using GHIElectronics.TinyCLR.Devices.I2c;
using GHIElectronics.TinyCLR.Devices.Gpio;
using GHIElectronics.TinyCLR.Pins;
using GHIElectronics.TinyCLR.UI;
using GHIElectronics.TinyCLR.UI.Media;
using GHIElectronics.TinyCLR.UI.Controls;
using GHIElectronics.TinyCLR.UI.Input;
using GHIElectronics.TinyCLR.UI.Threading;
using GHIElectronics.TinyCLR.UI.Media.Imaging;

using Color = GHIElectronics.TinyCLR.UI.Media.Color;
using Image = GHIElectronics.TinyCLR.UI.Controls.Image;

namespace IPSLCDTest
    public sealed class Program : Application
        static FT5xx6Controller touch = new FT5xx6Controller(I2cController.GetDefault().GetDevice(FT5xx6Controller.GetConnectionSettings()), GpioController.GetDefault().OpenPin(SC20260.GpioPin.PJ14));

        public static DisplayController disp;

        static Image customButtonImageUp;
        static Image customButtonImageDn;

        public Program(DisplayController d) : base(d)

        static Font font;

        static void Main()
            disp = DisplayController.GetDefault();

            // Enter the proper display configurations
            disp.SetConfiguration(new ParallelDisplayControllerSettings
                Width = 1024,
                Height = 600,
                DataFormat = DisplayDataFormat.Rgb565,
                HorizontalBackPorch = 160,
                HorizontalFrontPorch = 160,
                HorizontalSyncPolarity = true,
                HorizontalSyncPulseWidth = 48,
                DataEnableIsFixed = false,
                DataEnablePolarity = false,
                PixelClockRate = 60000000,
                PixelPolarity = false,
                VerticalBackPorch = 23,
                VerticalFrontPorch = 12,
                VerticalSyncPolarity = true,
                VerticalSyncPulseWidth = 10


            touch.TouchDown += Touch_TouchDown;
            touch.TouchUp += Touch_TouchUp;
            touch.TouchMove += Touch_TouchMove;

            font = Resource.GetFont(Resource.FontResources.arial24);

            var app = new Program(disp);

        private static void Touch_TouchMove(FT5xx6Controller sender, GHIElectronics.TinyCLR.Drivers.FocalTech.FT5xx6.TouchEventArgs e)
            Application.Current.InputProvider.RaiseTouch(e.X, e.Y, TouchMessages.Move, DateTime.UtcNow);
            Debug.WriteLine("Touch move");

        private static void Touch_TouchUp(FT5xx6Controller sender, GHIElectronics.TinyCLR.Drivers.FocalTech.FT5xx6.TouchEventArgs e)
            Application.Current.InputProvider.RaiseTouch(e.X, e.Y, TouchMessages.Up, DateTime.UtcNow);
            Debug.WriteLine("Touch up");

        private static void Touch_TouchDown(FT5xx6Controller sender, GHIElectronics.TinyCLR.Drivers.FocalTech.FT5xx6.TouchEventArgs e)
            Application.Current.InputProvider.RaiseTouch(e.X, e.Y, TouchMessages.Down, DateTime.UtcNow);
            Debug.WriteLine("Touch down");

        private static Window CreateWindow(DisplayController disp)
            var window = new Window
                Height = (int)disp.ActiveConfiguration.Height,
                Width = (int)disp.ActiveConfiguration.Width
            window.Background = new SolidColorBrush(Color.FromRgb(5, 5, 5)); 
            window.Visibility = Visibility.Visible;

            window.Child = Elements();

            return window;

        private static UIElement Elements()
            var panel = new Panel();

            panel.HorizontalAlignment = HorizontalAlignment.Center;
            panel.VerticalAlignment = VerticalAlignment.Center;

            var customButtonBmpUp = Resource.GetBitmap(Resource.BitmapResources.PushMeBluUp);
            var customButtonBmpDn = Resource.GetBitmap(Resource.BitmapResources.PushMeBluDn);

            customButtonImageUp = new GHIElectronics.TinyCLR.UI.Controls.Image
                Source = BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(customButtonBmpUp))
            customButtonImageDn = new GHIElectronics.TinyCLR.UI.Controls.Image
                Source = BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(customButtonBmpDn))
            var customButton = new Button
                Child = customButtonImageUp
//            customButton.TouchDown += CustomButton_TouchDown;
            customButton.TouchUp += CustomButton_TouchUp;
            customButton.Click += CustomButton_Click;

            return panel;

        private static void CustomButton_Click(object sender, RoutedEventArgs e)
            Button who = (Button)sender;

        private static void CustomButton_TouchUp(object sender, GHIElectronics.TinyCLR.UI.Input.TouchEventArgs e)
            Button who = (Button)sender;

            who.Child = customButtonImageUp;

        private static void CustomButton_TouchDown(object sender, GHIElectronics.TinyCLR.UI.Input.TouchEventArgs e)
            Button who = (Button)sender;

            who.Child = customButtonImageDn;

I found that if I draw the image in the Click callback, the image is drawn as the click itself is actually triggered when the button is released not pressed.

BUT, I also found that I could not use the same Image for another button. I got a element has parent error.

var customButton2 = new Button
    Child = customButtonImage2Up

An unhandled exception of type ‘System.ArgumentException’ occurred in GHIElectronics.TinyCLR.UI.dll
Additional information: element has parent

1 Like

Weird, never more than 10 seconds on my two routers.

There is a pin to Reset PHY PG3. Try to pull that pin low then high before initialize network to see if it help.