Exemplo n.º 1
0
        public static void BasicUITest(VirtualCanvas canvas)
        {
            canvas.SetOrientation(Orientation.Portrait);
            canvas.DrawFill(ColorBackground);
            canvas.DrawString(5, 10, (ushort)BasicColor.Black, DejaVuSansBold9.ID, "DejaVu Sans 9 Bold");
            canvas.DrawString(5, 30, (ushort)BasicColor.Black, DejaVuSans9.ID, "DejaVu Sans 9");
            canvas.DrawString(5, 50, (ushort)BasicColor.Black, DejaVuSansMono8.ID, "DejaVu Sans Mono 8");
            canvas.SetOrientation(Orientation.Landscape);
            canvas.DrawString(5, 10, (ushort)BasicColor.Black, DejaVuSans9.ID, "DejaVu Sans 9 (Rotated)");
            canvas.SetOrientation(Orientation.Portrait);
            RenderPrimitiveShapes(canvas);

            var fontInfo = new DejaVuSans9().GetFontInfo();

            RenderCompoundShapes(canvas, fontInfo);
            RenderIcons(canvas);

            var button = new ButtonWidget(20, 285, 200, 25, fontInfo, "Continue Demo");

            canvas.RegisterWidget(button);
            canvas.RenderWidgets();
            while (!button.Clicked)
            {
                canvas.TouchscreenWaitForEvent();
            }
            button.Dirty = true;
            canvas.RenderWidgets();
            canvas.Execute();
            canvas.UnRegisterWidget(button);
        }
Exemplo n.º 2
0
        public static void MultiWidgetTest(VirtualCanvas canvas)
        {
            canvas.SetOrientation(Orientation.Landscape);
            canvas.DrawFill(ColorHelpers.GetRGB24toRGB565(255, 255, 255));

            var fontInfo = new DejaVuSans9().GetFontInfo();

            var redButton = new ButtonWidget(10, 204, 44, 22, fontInfo, "Red");

            redButton.FillColor        = ColorHelpers.GetRGB24toRGB565(255, 0, 0);
            redButton.FillColorClicked = ColorHelpers.GetRGB24toRGB565(255, 255, 255);
            redButton.FontColorClicked = ColorHelpers.GetRGB24toRGB565(255, 0, 0);

            var greenButton = new ButtonWidget(60, 204, 44, 22, fontInfo, "Green");

            greenButton.FillColor        = ColorHelpers.GetRGB24toRGB565(0, 255, 0);
            greenButton.FillColorClicked = ColorHelpers.GetRGB24toRGB565(255, 255, 255);
            greenButton.FontColorClicked = ColorHelpers.GetRGB24toRGB565(0, 255, 0);

            var blueButton = new ButtonWidget(110, 204, 44, 22, fontInfo, "Blue");

            blueButton.FillColor        = ColorHelpers.GetRGB24toRGB565(0, 0, 255);
            blueButton.FillColorClicked = ColorHelpers.GetRGB24toRGB565(255, 255, 255);
            blueButton.FontColorClicked = ColorHelpers.GetRGB24toRGB565(0, 0, 255);

            var continueButton = new ButtonWidget(247, 204, 64, 22, fontInfo, "Continue");

            continueButton.FillColor        = ColorHelpers.GetRGB24toRGB565(255, 255, 255);
            continueButton.FontColorClicked = ColorHelpers.GetRGB24toRGB565(0, 0, 0);

            canvas.RegisterWidget(redButton);
            canvas.RegisterWidget(greenButton);
            canvas.RegisterWidget(blueButton);
            canvas.RegisterWidget(continueButton);

            canvas.WidgetClicked += ColorButtonsClickedHandler;

            canvas.RenderWidgets();

            while (!continueButton.Clicked)
            {
                canvas.ActivateWidgets(true);
                canvas.RenderWidgets();
                canvas.Execute();

                canvas.TouchscreenWaitForEvent();

                canvas.RenderWidgets(Render.All);
                canvas.Execute();
            }

            canvas.WidgetClicked -= ColorButtonsClickedHandler;

            continueButton.Dirty = true;
            continueButton.Draw(canvas);
            canvas.Execute();

            canvas.UnRegisterAllWidgets();
        }
Exemplo n.º 3
0
        public void Render(VirtualCanvas canvas, GoBus.GoSocket sdSocket)
        {
            Joystick.Initialize(GoSockets.Socket3, GoBusIRQHandler);
            Joystick.Get();
            while (true)
            {
                canvas.SetOrientation(Orientation.Landscape);
                canvas.DrawFill(ColorHelpers.GetRGB24toRGB565(255, 212, 42));
                canvas.DrawString(
                    10, 1,
                    ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                    VerdanaBold14.ID,
                    "[Nwazet Playground");
                canvas.RenderWidgets(Nwazet.Go.Imaging.Render.All);

                canvas.WidgetClicked += new WidgetClickedHandler(OnWidgetClicked);
                canvas.TouchscreenWaitForEvent();
                canvas.WidgetClicked -= new WidgetClickedHandler(OnWidgetClicked);

                canvas.RenderWidgets(Nwazet.Go.Imaging.Render.Dirty);

                if (TemperatureAndRelayButton.Clicked)
                {
                    var tempRelay = new TempRelay();
                    tempRelay.Render(canvas);
                }
                else if (ImageGalleryButton.Clicked)
                {
                    var imageGallery = new ImageGallery();
                    imageGallery.Render(canvas, sdSocket);
                }
                else if (BasicUIButton.Clicked)
                {
                    var basicUI = new BasicUI();
                    basicUI.Render(canvas);
                }
                else if (LEDMarqueeButton.Clicked)
                {
                    var ledMarquee = new LEDMarquee();
                    ledMarquee.Render(canvas);
                }
                else if (LEDRGBArtButton.Clicked)
                {
                    var ledRgbArt = new LEDRGBArt();
                    ledRgbArt.Render(canvas);
                }
                else if (LEDCaptureTheDotButton.Clicked)
                {
                    var ledCaptureTheDot = new LEDCaptureTheDot();
                    ledCaptureTheDot.Render(canvas, Joystick);
                }
                else if (LEDSignShowcaseButton.Clicked)
                {
                    var ledSignShowcase = new LEDSignShowcase();
                    ledSignShowcase.Render();
                }
                canvas.ActivateWidgets(true);
            }
        }
Exemplo n.º 4
0
        public static void BasicTouchEventTest(VirtualCanvas canvas)
        {
            var message      = "Touch Event Test";
            var fontInfo     = new DejaVuSansBold9().GetFontInfo();
            var stringLength = fontInfo.GetStringWidth(message);

            canvas.SetOrientation(Orientation.Portrait);
            canvas.DrawFill(ColorBackground);
            canvas.DrawString(
                (canvas.Width - stringLength) / 2, 150,
                (ushort)BasicColor.Black, fontInfo.ID, message);

            canvas.TouchscreenWaitForEvent();

            canvas.DrawCircleFilled(lastTouchX, lastTouchY, 4, (ushort)BasicColor.Red);
            canvas.Execute();

            Thread.Sleep(1000);
        }
Exemplo n.º 5
0
        public static void NonBlockingTouchEventTest(VirtualCanvas canvas)
        {
            var message      = "Touch To Continue";
            var fontInfo     = new DejaVuSansBold9().GetFontInfo();
            var stringLength = fontInfo.GetStringWidth(message);

            canvas.DrawFill(ColorBackground);
            canvas.DrawString(
                (canvas.Width - stringLength) / 2, 150,
                (ushort)BasicColor.Black, fontInfo.ID, message);

            var random = new Random(lastTouchX * lastTouchY);

            lastTouchIsValid = 0;
            while (lastTouchIsValid == 0)
            {
                canvas.DrawCircleFilled(random.Next(canvas.Width), random.Next(canvas.Height), 4, (ushort)BasicColor.Red);
                canvas.Execute();
                canvas.TouchscreenWaitForEvent(TouchScreenEventMode.NonBlocking);
            }
        }
Exemplo n.º 6
0
        public void Render(VirtualCanvas canvas)
        {
            Relay.Initialize(RelaySocket);
            ThermoCouple.Initialize(ThermoCoupleSocket);

            canvas.SetOrientation(Orientation.Landscape);
            canvas.DrawFill(BackgroundColor);
            canvas.DrawString(55, 4, 0, VerdanaBold14.ID, "Temperature & Relay");
            canvas.DrawString(32, 74, 0, VerdanaBold14.ID, "Celsius:");
            canvas.DrawString(32, 116, 0, VerdanaBold14.ID, "Fahrenheit:");
            canvas.DrawString(32, 154, 0, VerdanaBold14.ID, "Relay:");
            canvas.DrawButton(
                32, 197,
                250, 36,
                VerdanaBold14.ID, 20,
                ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                ColorHelpers.GetRGB24toRGB565(255, 255, 255),
                ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                "Click To Exit",
                RoundedCornerStyle.All);
            canvas.Execute();
            canvas.Touch += TouchEventHandler;
            while (LastTouchIsValid == 0)
            {
                ReadTemp();
                Thread.Sleep(100);
                canvas.DrawRectangleFilled(93, 153, 158, 176, BackgroundColor);
                canvas.DrawRectangleFilled(105, 69, 175, 94, BackgroundColor);
                canvas.DrawRectangleFilled(138, 112, 205, 137, BackgroundColor);
                canvas.DrawString(32, 74, 0, VerdanaBold14.ID, "Celsius: " + Shorten(ThermoCouple.Celsius.ToString()));
                canvas.DrawString(32, 116, 0, VerdanaBold14.ID, "Fahrenheit: " + Shorten(ThermoCouple.Farenheit.ToString()));
                canvas.DrawString(32, 154, 0, VerdanaBold14.ID, "Relay: " + ((RelayStatus) ? "ON" : "OFF"));
                canvas.Execute();
                canvas.TouchscreenWaitForEvent(TouchScreenEventMode.NonBlocking);
            }
            canvas.Touch -= TouchEventHandler;
            Relay.Dispose();
            ThermoCouple.Dispose();
        }
Exemplo n.º 7
0
 private static void DisplayBmpPicture(VirtualCanvas canvas, string pictureName)
 {
     canvas.DrawBitmapImage(0, 0, @"SD\" + pictureName);
     canvas.TouchscreenWaitForEvent();
 }
Exemplo n.º 8
0
        public void Render(VirtualCanvas canvas, Joystick Joystick)
        {
            canvas.SetOrientation(Orientation.Landscape);
            canvas.DrawFill(ColorHelpers.GetRGB24toRGB565(255, 255, 255));
            canvas.DrawString(80, 4, ColorHelpers.GetRGB24toRGB565(0, 0, 0), VerdanaBold14.ID, "Capture The Dot");
            canvas.DrawButton(
                32, 197,
                250, 36,
                VerdanaBold14.ID, 20,
                ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                ColorHelpers.GetRGB24toRGB565(255, 255, 255),
                ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                "Click To Exit",
                RoundedCornerStyle.All);
            canvas.Execute();

            var SendContext = new BasicTypeSerializerContext();
            var ComPort     = new SerialMessenger();

            ComPort.Messenger += OnMessage;
            ComPort.Initialize(bufferSize: 1024);

            int contentSize = 0;

            BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.RunPong);
            var buffer = SendContext.GetBuffer(out contentSize);

            ComPort.Send(buffer, 0, (byte)contentSize);

            UInt16 LeftX      = 0;
            UInt16 RightY     = 0;
            UInt16 LastLeftX  = 1;
            UInt16 LastRightY = 1;

            canvas.Touch += TouchEventHandler;
            while (LastTouchIsValid == 0)
            {
                var joystickData = Joystick.Get();
                //Debug.Print("RawX: " + joystickData.X + ", RawY: " + joystickData.Y);

                LeftX  = (UInt16)MapRange(50, 950, 0, 15, joystickData.X);
                RightY = (UInt16)MapRange(50, 950, 0, 9, joystickData.Y);
                //Debug.Print("LeftX: " + LeftX + ", RightY: " + RightY);

                if (LeftX != LastLeftX || RightY != LastRightY)
                {
                    BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.UpdateJoystick);
                    BasicTypeSerializer.Put(SendContext, (UInt16)LeftX);
                    BasicTypeSerializer.Put(SendContext, (UInt16)RightY);
                    buffer = SendContext.GetBuffer(out contentSize);
                    ComPort.Send(buffer, 0, (byte)contentSize);
                    Thread.Sleep(10);
                }
                canvas.TouchscreenWaitForEvent(TouchScreenEventMode.NonBlocking);
            }
            canvas.Touch      -= TouchEventHandler;
            ComPort.Messenger -= OnMessage;

            BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.Reset);
            buffer = SendContext.GetBuffer(out contentSize);
            ComPort.Send(buffer, 0, (byte)contentSize);

            ComPort.Dispose();
        }
Exemplo n.º 9
0
        public void Render(VirtualCanvas canvas)
        {
            var SendContext = new BasicTypeSerializerContext();
            var ComPort     = new SerialMessenger();

            ComPort.Messenger += OnMessage;
            ComPort.Initialize(bufferSize: 1024);

            int contentSize = 0;

            BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.Reset);
            var buffer = SendContext.GetBuffer(out contentSize);

            ComPort.Send(buffer, 0, (byte)contentSize);

            DrawPlayground(canvas);
            canvas.Touch += TouchEventHandler;
            var    exit = false;
            ushort r = 127, g = 0, b = 0;

            while (!exit)
            {
                LastTouchIsValid = 0;
                canvas.TouchscreenWaitForEvent(TouchScreenEventMode.NonBlocking);
                if (LastTouchIsValid != 0)
                {
                    if (LastTouchX >= 260 && LastTouchY >= 42 && LastTouchX <= 290 && LastTouchY <= 72)   // red
                    {
                        r         = 127;
                        g         = 0;
                        b         = 0;
                        LastColor = ColorHelpers.GetRGB24toRGB565(255, 0, 0);
                    }
                    else if (LastTouchX >= 260 && LastTouchY >= 77 && LastTouchX <= 290 && LastTouchY <= 107)   // green
                    {
                        r         = 0;
                        g         = 127;
                        b         = 0;
                        LastColor = ColorHelpers.GetRGB24toRGB565(0, 255, 0);
                    }
                    else if (LastTouchX >= 260 && LastTouchY >= 112 && LastTouchX <= 290 && LastTouchY <= 142)   // blue
                    {
                        r         = 0;
                        g         = 0;
                        b         = 127;
                        LastColor = ColorHelpers.GetRGB24toRGB565(0, 0, 255);
                    }
                    else if (LastTouchX >= 80 && LastTouchY >= 150 && LastTouchX <= 80 + 160 && LastTouchY <= 170)   // reset
                    {
                        canvas.DrawRectangleFilled(
                            79, 40,
                            241, 141,
                            ColorHelpers.GetRGB24toRGB565(255, 255, 255));
                        DrawGrid(canvas);
                        BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.Reset);
                        buffer = SendContext.GetBuffer(out contentSize);
                        ComPort.Send(buffer, 0, (byte)contentSize);
                        Thread.Sleep(250);
                    }
                    else if (LastTouchX >= 80 && LastTouchY >= 42 && LastTouchX < 240 && LastTouchY < 140)   // canvas
                    {
                        var x = (LastTouchX - 80) / 10;
                        var y = (LastTouchY - 42) / 10;
                        if (LastSquareX != x || LastSquareY != y)
                        {
                            LastSquareX = x;
                            LastSquareY = y;
                            canvas.DrawRectangleFilled(80 + (x * 10) + 1, 42 + (y * 10) + 1, 80 + (x * 10) + 1 + 8, 42 + (y * 10) + 1 + 8, LastColor);
                            canvas.Execute();
                            BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.SetPixel);
                            BasicTypeSerializer.Put(SendContext, (ushort)x);
                            BasicTypeSerializer.Put(SendContext, (ushort)y);
                            BasicTypeSerializer.Put(SendContext, r);
                            BasicTypeSerializer.Put(SendContext, g);
                            BasicTypeSerializer.Put(SendContext, b);
                            buffer = SendContext.GetBuffer(out contentSize);
                            ComPort.Send(buffer, 0, (byte)contentSize);
                        }
                    }
                    else if (LastTouchX >= 32 && LastTouchY >= 197 && LastTouchX <= 32 + 250 && LastTouchY <= 197 + 36)   // exit
                    {
                        exit = true;
                    }
                }
            }
            canvas.Touch -= TouchEventHandler;
            ComPort.Dispose();
        }
Exemplo n.º 10
0
        public void Render(VirtualCanvas canvas)
        {
            var Pot         = new NetduinoGo.Potentiometer(GoSockets.Socket1);
            var SendContext = new BasicTypeSerializerContext();
            var ComPort     = new SerialMessenger();

            ComPort.Messenger += OnMessage;
            ComPort.Initialize();

            int contentSize = 0;

            BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.Reset);
            var buffer = SendContext.GetBuffer(out contentSize);

            MessageReceivedEvent.Reset();
            ComPort.Send(buffer, 0, (byte)contentSize);
            MessageReceivedEvent.WaitOne(100, true);

            DrawPlayground(canvas);
            canvas.Touch += TouchEventHandler;
            var exit = false;

            while (!exit)
            {
                LastTouchIsValid = 0;
                canvas.TouchscreenWaitForEvent(TouchScreenEventMode.NonBlocking);
                ushort color = Wheel((ushort)MapRange(0, 1, 0, 384, Pot.GetValue()));
                if (color != LastColor)
                {
                    LastColor = color;
                    canvas.DrawRectangleFilled(184, 153, 213, 179, LastColor);
                    canvas.Execute();
                }
                if (LastTouchIsValid != 0)
                {
                    if (LastTouchX >= 80 && LastTouchY >= 42 && LastTouchX < 240 && LastTouchY <= 140)
                    {
                        var x = (LastTouchX - 80) / 10;
                        var y = (LastTouchY - 42) / 10;
                        canvas.DrawRectangleFilled(80 + (x * 10) + 1, 42 + (y * 10) + 1, 80 + (x * 10) + 1 + 8, 42 + (y * 10) + 1 + 8, LastColor);
                        canvas.Execute();
                        BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.SetPixel);
                        BasicTypeSerializer.Put(SendContext, (int)x);
                        BasicTypeSerializer.Put(SendContext, (int)y);
                        BasicTypeSerializer.Put(SendContext, (uint)LastColor);
                        buffer = SendContext.GetBuffer(out contentSize);

                        MessageReceivedEvent.Reset();
                        ComPort.Send(buffer, 0, (byte)contentSize);
                        MessageReceivedEvent.WaitOne(100, true);
                    }
                    else if (LastTouchX >= 32 && LastTouchY >= 197 && LastTouchX <= 32 + 250 && LastTouchY <= 197 + 36)
                    {
                        exit = true;
                    }
                }
            }
            canvas.Touch -= TouchEventHandler;
            ComPort.Dispose();
            Pot.Dispose();
        }