Ejemplo n.º 1
0
 public void Render(VirtualCanvas canvas, SerialMessenger M)
 {
     ComPort.Initialize();
     Joystick.Initialize(JoystickSocket, JoystickIRQHandler);
     canvas.SetOrientation(Orientation.Landscape);
     canvas.DrawFill((ushort)BasicColor.White);
     while (true)
     {
         var input = Joystick.Get();
         SendJoystickInput(input);
         DisplayJoystickInput(canvas, input.X, input.Y);
     }
 }
Ejemplo n.º 2
0
        public void Render()
        {
            var SendContext = new BasicTypeSerializerContext();
            var ComPort     = new SerialMessenger();

            ComPort.Initialize();
            int contentSize = 0;

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

            ComPort.Send(buffer, 0, (byte)contentSize);
            Thread.Sleep(1000);
            ComPort.Dispose();
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            ComPort.Initialize();
            ComPort.Messenger += new SerialMessengerHandler(OnMessage);

            ComPort.Send("Running.\r\n");

            Temp.Initialize(GoSockets.Socket6);

            while (true)
            {
                ReadTemp();
                Thread.Sleep(2);
            }
        }
Ejemplo n.º 4
0
        public void Render(VirtualCanvas canvas)
        {
            var SendContext = new BasicTypeSerializerContext();
            var ComPort     = new SerialMessenger();

            ComPort.Initialize();
            canvas.SetOrientation(Orientation.Landscape);
            var text = canvas.TouchscreenShowDialog(DialogType.Alphanumeric);

            Debug.Print("User text: " + text);
            int contentSize = 0;

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

            ComPort.Send(buffer, 0, (byte)contentSize);
            Thread.Sleep(1000);
            ComPort.Dispose();
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
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();
        }