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 Main()
        {
            tft.Initialize();

#if DRAWTOFILE
            StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
            var file    = new FileStream(@"SD\VirtualCanvas.bin", FileMode.Create);
            var context = new BasicTypeSerializerContext(file);
#else
            var context = new BasicTypeSerializerContext();
#endif
            var virtualCanvas       = new VirtualCanvas(context);
            var fontDejaVuSansBold9 = new DejaVuSansBold9();
            var fontDejaVuSans9     = new DejaVuSans9();
            var fontDejaVuSansMono8 = new DejaVuSansMono8();

            virtualCanvas.DrawFill(ColorBackground);

            virtualCanvas.DrawString(5, 10, BasicColor.Black, fontDejaVuSansBold9.GetFontInfo(), "DejaVu Sans 9 Bold");
            virtualCanvas.DrawString(5, 30, BasicColor.Black, fontDejaVuSans9.GetFontInfo(), "DejaVu Sans 9");
            virtualCanvas.DrawString(5, 50, BasicColor.Black, fontDejaVuSansMono8.GetFontInfo(), "DejaVu Sans Mono 8");

            // Check if the screen orientation can be changed
            if (tft.GetProperties().Orientation == true)
            {
                // Change the orientation
                virtualCanvas.SetOrientation(LCD.Orientation.Landscape);
                // Render some text in the new orientation
                virtualCanvas.DrawString(5, 10, BasicColor.Black, new DejaVuSans9().GetFontInfo(), "DejaVu Sans 9 (Rotated)");
                // Change the orientation back
                virtualCanvas.SetOrientation(LCD.Orientation.Portrait);
            }

            RenderPrimitiveShapes(virtualCanvas);
            RenderCompoundShapes(virtualCanvas, fontDejaVuSans9.GetFontInfo());
            RenderIcons(virtualCanvas);

            var localCanvas = new Canvas(tft);

#if DRAWTOFILE
            file.Flush();
            file.Close();
            localCanvas.Replay(new BasicTypeDeSerializerContext(new FileStream(@"SD\VirtualCanvas.bin", FileMode.Open)));
            StorageDevice.Unmount("SD");
#else
            //localCanvas.Replay(new BasicTypeDeSerializerContext(context.GetBuffer()));

            StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
            var file = new FileStream(@"SD\VirtualCanvas.bin", FileMode.Create);

            int    contentSize = 0;
            byte[] buffer      = context.GetBuffer(ref contentSize);

            file.Write(buffer, 0, contentSize);
            file.Flush();
            file.Close();
            StorageDevice.Unmount("SD");
#endif
        }
Exemplo n.º 3
0
        public static void TouchscreenAlphanumericDialogTest(VirtualCanvas canvas)
        {
            canvas.SetOrientation(Orientation.Landscape);
            var response = canvas.TouchscreenShowDialog(DialogType.Alphanumeric);

            Debug.Print("User Input: " + response);
            canvas.SetOrientation(Orientation.Portrait);
            response = canvas.TouchscreenShowDialog(DialogType.Alphanumeric);
            Debug.Print("User Input: " + response);
        }
Exemplo n.º 4
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.º 5
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.º 6
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);
     }
 }
Exemplo n.º 7
0
        public void Render(VirtualCanvas canvas, GoBus.GoSocket SDSocket)
        {
            var sd = new SDCardReader();

            try {
                sd.Initialize(SDSocket);
                canvas.SetOrientation(Orientation.Portrait);
                DisplayBmpPicture(canvas, @"Nwazet\03.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\05.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\09.bmp");
                canvas.SetOrientation(Orientation.Landscape);
                DisplayBmpPicture(canvas, @"Nwazet\00.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\01.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\02.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\04.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\06.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\07.bmp");
                DisplayBmpPicture(canvas, @"Nwazet\08.bmp");
            } catch (Exception e) {
                Debug.Print(e.Message);
                Debug.Print("You need an SD card loaded with the demo photos to run this part of the demo.");
            }
            sd.Dispose();
        }
Exemplo n.º 8
0
        protected void DrawPlayground(VirtualCanvas canvas)
        {
            canvas.SetOrientation(Orientation.Landscape);
            canvas.DrawFill(ColorHelpers.GetRGB24toRGB565(255, 255, 255));
            canvas.DrawString(
                50, 4,
                ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                VerdanaBold14.ID,
                "RGB Pixel Drawing");
            DrawGrid(canvas);
            // red
            canvas.DrawRectangleFilled(
                260, 42,
                290, 72,
                ColorHelpers.GetRGB24toRGB565(255, 0, 0));
            // green
            canvas.DrawRectangleFilled(
                260, 77,
                290, 107,
                ColorHelpers.GetRGB24toRGB565(0, 250, 0));
            // blue
            canvas.DrawRectangleFilled(
                260, 112,
                290, 142,
                ColorHelpers.GetRGB24toRGB565(0, 0, 255));
            // Reset
            canvas.DrawButton(
                80, 150,
                160, 20,
                Verdana9.ID, 12,
                ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                ColorHelpers.GetRGB24toRGB565(255, 255, 255),
                ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                "Reset Drawing",
                RoundedCornerStyle.All);
            // Exit
            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();
        }
Exemplo n.º 9
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.º 10
0
        protected void DrawPlayground(VirtualCanvas canvas)
        {
            canvas.SetOrientation(Orientation.Landscape);
            canvas.DrawFill(ColorHelpers.GetRGB24toRGB565(255, 255, 255));
            canvas.DrawString(
                50, 4,
                ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                VerdanaBold14.ID,
                "Rainbow Pixel Drawing");
            for (var i = 0; i < 110; i += 10)
            {
                canvas.DrawLine(
                    80, 42 + i, 240, 42 + i,
                    ColorHelpers.GetRGB24toRGB565(0, 0, 0));
            }
            for (var i = 0; i < 170; i += 10)
            {
                canvas.DrawLine(
                    80 + i, 42, 80 + i, 142,
                    ColorHelpers.GetRGB24toRGB565(0, 0, 0));
            }
            canvas.DrawString(
                110, 161,
                ColorHelpers.GetRGB24toRGB565(0, 0, 0),
                DejaVuSansBold9.ID,
                "Pixel Color");
            canvas.DrawRectangle(
                182, 151,
                215, 181,
                ColorHelpers.GetRGB24toRGB565(0, 0, 0));
            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();
        }
Exemplo n.º 11
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();
        }
Exemplo n.º 12
0
 public static void BmpImageTest(VirtualCanvas canvas)
 {
     try {
         //var sd = new SDCardReader();
         //sd.Initialize(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
         DisplayBmpPicture(canvas, @"Nwazet\03.bmp");
         DisplayBmpPicture(canvas, @"Nwazet\05.bmp");
         DisplayBmpPicture(canvas, @"Nwazet\09.bmp");
         canvas.SetOrientation(Orientation.Landscape);
         DisplayBmpPicture(canvas, @"Nwazet\00.bmp");
         DisplayBmpPicture(canvas, @"Nwazet\01.bmp");
         DisplayBmpPicture(canvas, @"Nwazet\02.bmp");
         DisplayBmpPicture(canvas, @"Nwazet\04.bmp");
         DisplayBmpPicture(canvas, @"Nwazet\06.bmp");
         DisplayBmpPicture(canvas, @"Nwazet\07.bmp");
         DisplayBmpPicture(canvas, @"Nwazet\08.bmp");
         //sd.Dispose();
     } catch (Exception e) {
         Debug.Print(e.Message);
         Debug.Print("You need an SD card loaded with the demo photos to run this part of the demo.");
     }
 }
Exemplo n.º 13
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.º 14
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.º 15
0
        public static void Main()
        {
            daq.Initialize(GoSockets.Socket4);

            var state = daq.GetClockState();

            if (state == NwazetDAQ.ClockState.Invalid)
            {
                daq.SetDateTime(new DateTime(2012, 10, 05, 20, 39, 00));
            }

            var usartConfig = new UsartConfig();

            usartConfig.BaudRate = UsartBaudRate.Baud57600;
            daq.UsartPort.SetConfig(usartConfig);

            daq.UsartPort.Write("\r\n\r\nNwazet DAQ Pro Kit - demo\r\n");

            canvas.Initialize(GoSockets.Socket5);
            canvas.SetOrientation(Orientation.Landscape);

            InitDisplay();

            seg.SetBrightness(.1f);
            seg.SetColon(true);

            while (true)
            {
                var hih    = new HIH613x(daq.I2cPort);
                var bmp085 = new BoschBmp085(daq.I2cPort);
                var taos   = new TaosTSL256x(daq.I2cPort);

                var       pressure = 0;
                AdcSample sample   = null;
                try {
                    while (true)
                    {
                        try {
                            seg.SetBrightness(pot.GetValue());
                            sample = daq.ReadAnalogInputs();
                            ShowTime(sample.Time);
                            hih.Read();
                            pressure = bmp085.ReadPressurePascals();
                            taos.Read();
                        } catch (I2cException e) {
                            Debug.Print("I2C transaction failed: " + e.Message);
                            daq.I2cPort.BusReset();
                        }
                        UpdateDisplay(hih.TemperatureCelsius, hih.RelativeHumidityPercent, pressure, taos.Lux, taos.InfraredSpectrum, sample);

                        daq.UsartPort.Write(
                            sample.Time.ToString() + "," +
                            hih.TemperatureCelsius + "," +
                            hih.RelativeHumidityPercent + "," +
                            pressure + "," +
                            taos.Lux + "," +
                            taos.InfraredSpectrum + "," +
                            sample.Values[(int)ADC.A0].ToString()
                            + "\r\n");
                    }
                } catch (Exception e) {
                    Debug.Print("Other exception: " + e.Message);
                    hih.Dispose();
                    bmp085.Dispose();
                    taos.Dispose();
                }
            }
        }