public static void CalibrateTouchscreen(VirtualCanvas canvas) { var sd = new SDCardReader(); try { sd.Initialize(SDSocket); var calibrationDataFilename = @"SD\TouchscreenCalibration.bin"; if (File.Exists(calibrationDataFilename)) { using (var calibrationDataFile = new FileStream(calibrationDataFilename, FileMode.Open)) { var context = new BasicTypeDeSerializerContext(calibrationDataFile); var matrix = new CalibrationMatrix(); matrix.Get(context); canvas.SetTouchscreenCalibrationMatrix(matrix); } } else { using (var calibrationDataFile = new FileStream(calibrationDataFilename, FileMode.Create)) { var matrix = canvas.GetTouchscreenCalibrationMatrix(); var context = new BasicTypeSerializerContext(calibrationDataFile); matrix.Put(context); } } } catch (Exception e) { Debug.Print(e.Message); Debug.Print("SD Card or file I/O error: manual calibration required."); canvas.TouchscreenCalibration(); } sd.Dispose(); }
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); }
public static void RenderIcons(VirtualCanvas canvas) { // Cross/Failed canvas.DrawRectangleRounded(10, 190, 30, 210, ColorButton, 5, CornerStyle); canvas.DrawIcon16(12, 192, (ushort)BasicColor.Red, Icons16.Failed); canvas.DrawRectangleRounded(10, 220, 30, 240, ColorButton, 5, CornerStyle); canvas.DrawIcon16(12, 222, (ushort)BasicColor.Red, Icons16.Failed); canvas.DrawIcon16(12, 222, (ushort)BasicColor.White, Icons16.FailedInterior); canvas.DrawRectangleRounded(10, 250, 30, 270, ColorButton, 5, CornerStyle); canvas.DrawIcon16(12, 252, (ushort)BasicColor.White, Icons16.FailedInterior); // Alert canvas.DrawRectangleRounded(40, 190, 60, 210, ColorButton, 5, CornerStyle); canvas.DrawIcon16(42, 192, (ushort)BasicColor.Yellow, Icons16.Alert); canvas.DrawRectangleRounded(40, 220, 60, 240, ColorButton, 5, CornerStyle); canvas.DrawIcon16(42, 222, (ushort)BasicColor.Yellow, Icons16.Alert); canvas.DrawIcon16(42, 222, (ushort)BasicColor.White, Icons16.AlertInterior); canvas.DrawRectangleRounded(40, 250, 60, 270, ColorButton, 5, CornerStyle); canvas.DrawIcon16(42, 252, (ushort)BasicColor.White, Icons16.AlertInterior); // Checkmark/Passed canvas.DrawRectangleRounded(70, 190, 90, 210, ColorButton, 5, CornerStyle); canvas.DrawIcon16(72, 192, (ushort)BasicColor.Green, Icons16.Passed); canvas.DrawRectangleRounded(70, 220, 90, 240, ColorButton, 5, CornerStyle); canvas.DrawIcon16(72, 222, (ushort)BasicColor.Green, Icons16.Passed); canvas.DrawIcon16(72, 222, (ushort)BasicColor.White, Icons16.PassedInterior); canvas.DrawRectangleRounded(70, 250, 90, 270, ColorButton, 5, CornerStyle); canvas.DrawIcon16(72, 252, (ushort)BasicColor.White, Icons16.PassedInterior); // Info canvas.DrawRectangleRounded(100, 190, 120, 210, ColorButton, 5, CornerStyle); canvas.DrawIcon16(102, 192, (ushort)BasicColor.Blue, Icons16.Info); canvas.DrawRectangleRounded(100, 220, 120, 240, ColorButton, 5, CornerStyle); canvas.DrawIcon16(102, 222, (ushort)BasicColor.Blue, Icons16.Info); canvas.DrawIcon16(102, 222, (ushort)BasicColor.White, Icons16.InfoInterior); canvas.DrawRectangleRounded(100, 250, 120, 270, ColorButton, 5, CornerStyle); canvas.DrawIcon16(102, 252, (ushort)BasicColor.White, Icons16.InfoInterior); // Tools/Config canvas.DrawRectangleRounded(130, 190, 150, 210, ColorButton, 5, CornerStyle); canvas.DrawIcon16(132, 192, (ushort)BasicColor.Green, Icons16.Tools); // Pointer canvas.DrawRectangleRounded(160, 190, 180, 210, ColorButton, 5, CornerStyle); canvas.DrawIcon16(162, 192, (ushort)BasicColor.Magenta, Icons16.Pointer); canvas.DrawRectangleRounded(160, 220, 180, 240, ColorButton, 5, CornerStyle); canvas.DrawIcon16(162, 222, (ushort)BasicColor.Magenta, Icons16.Pointer); canvas.DrawIcon16(162, 222, (ushort)BasicColor.White, Icons16.PointerDot); canvas.DrawRectangleRounded(160, 250, 180, 270, ColorButton, 5, CornerStyle); canvas.DrawIcon16(162, 252, (ushort)BasicColor.White, Icons16.PointerDot); // Tag canvas.DrawRectangleRounded(190, 190, 210, 210, ColorButton, 5, CornerStyle); canvas.DrawIcon16(192, 192, (ushort)BasicColor.Cyan, Icons16.Tag); canvas.DrawRectangleRounded(190, 220, 210, 240, ColorButton, 5, CornerStyle); canvas.DrawIcon16(192, 222, (ushort)BasicColor.Cyan, Icons16.Tag); canvas.DrawIcon16(192, 222, (ushort)BasicColor.White, Icons16.TagDot); canvas.DrawRectangleRounded(190, 250, 210, 270, ColorButton, 5, CornerStyle); canvas.DrawIcon16(192, 252, (ushort)BasicColor.White, Icons16.TagDot); }
public static void Main() { Debug.EnableGCMessages(true); Debug.Print("Available RAM: " + Debug.GC(true).ToString() + " bytes."); Debug.EnableGCMessages(false); PowerUpDisplay(); var canvas = new VirtualCanvas(TouchEventHandler, WidgetClickedHandler); canvas.Initialize( displaySpi: SPI.SPI_module.SPI1, displayChipSelect: Pins.GPIO_PIN_D9, displayGPIO: Pins.GPIO_PIN_D8, speedKHz: 5000); CalibrateTouchscreen(canvas); BmpImageTest(canvas); BasicUITest(canvas); MultiWidgetTest(canvas); BasicTouchEventTest(canvas); NonBlockingTouchEventTest(canvas); TouchscreenAlphanumericDialogTest(canvas); canvas.Reboot(); Thread.Sleep(1000); canvas.Dispose(); }
public virtual void Draw(VirtualCanvas canvas) { if (!Dirty) { return; } if (Area.Radius == 0) { if (Clicked) { canvas.DrawRectangleFilled(Area.X, Area.Y, Area.X + Area.Width - 1, Area.Y + Area.Height - 1, (ushort)BasicColor.Red); } else { canvas.DrawRectangleFilled(Area.X, Area.Y, Area.X + Area.Width - 1, Area.Y + Area.Height - 1, (ushort)BasicColor.Black); } } else { if (Clicked) { canvas.DrawCircleFilled(Area.X, Area.Y, Area.Radius, (ushort)BasicColor.Red); } else { canvas.DrawCircleFilled(Area.X, Area.Y, Area.Radius, (ushort)BasicColor.Black); } } Dirty = false; }
public static void CalibrateTouchscreen(VirtualCanvas canvas) { try { //var sd = new SDCardReader(); //sd.Initialize(SPI.SPI_module.SPI1,Pins.GPIO_PIN_D10); var calibrationDataFilename = @"SD\TouchscreenCalibration.bin"; // If the touchscreen calibration data was previously retrieved from the display module and was stored to an SD card, // the calibration data can be sent to the display module instead of calling TouchscreenCalibration() before using // the touchscreen for the first time. if (File.Exists(calibrationDataFilename)) { using (var calibrationDataFile = new FileStream(calibrationDataFilename, FileMode.Open)) { var context = new BasicTypeDeSerializerContext(calibrationDataFile); var matrix = new CalibrationMatrix(); matrix.Get(context); canvas.SetTouchscreenCalibrationMatrix(matrix); } } else { // No pre-existing calibration data, create it... using (var calibrationDataFile = new FileStream(calibrationDataFilename, FileMode.Create)) { var matrix = canvas.GetTouchscreenCalibrationMatrix(); var context = new BasicTypeSerializerContext(calibrationDataFile); matrix.Put(context); } } //sd.Dispose(); } catch (Exception) { Debug.Print("SD Card or file I/O error: manual calibration required."); canvas.TouchscreenCalibration(); } }
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 }
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); } }
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(); }
public void DisplayJoystickInput(VirtualCanvas canvas, ushort x, ushort y) { string text = "X: " + x / 100 + ", " + " Y: " + y / 100; canvas.DrawRectangleFilled(0, 110, canvas.Width, 110 + 20, (ushort)BasicColor.White); canvas.DrawString(20, 110, (ushort)BasicColor.Black, VerdanaBold14.ID, text); canvas.Execute(); }
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); }
public static void TouchEventHandler(VirtualCanvas canvas, TouchEvent touchEvent) { Debug.Print("------------TouchEventHandler------------"); Debug.Print("X: " + touchEvent.X); Debug.Print("Y: " + touchEvent.Y); Debug.Print("Pressure: " + touchEvent.Pressure); lastTouchX = touchEvent.X; lastTouchY = touchEvent.Y; lastTouchIsValid = touchEvent.IsValid; }
public UIElement CreateVisual(VirtualCanvas parent) { if (_visual == null) { Ellipse e = new Ellipse(); e.Width = _bounds.Width; e.Height = _bounds.Height; e.Style = parent.Resources["MyEllipseStyle"] as Style; _visual = e; } return(_visual); }
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); } }
public void DrawGrid(VirtualCanvas canvas) { 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)); } }
public static void Main() { Debug.EnableGCMessages(true); Debug.Print("Available RAM: " + Debug.GC(true).ToString() + " bytes."); Debug.EnableGCMessages(false); var canvas = new VirtualCanvas(null, null); canvas.Initialize(DisplaySocket); CalibrateTouchscreen(canvas); var mainMenu = new MainMenu(canvas); mainMenu.Render(canvas, SDSocket); }
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(); }
public static void RenderPrimitiveShapes(VirtualCanvas canvas) { canvas.DrawLine(5, 65, 200, 65, (ushort)BasicColor.Red); canvas.DrawLine(5, 67, 200, 67, (ushort)BasicColor.Green); canvas.DrawLine(5, 69, 200, 69, (ushort)BasicColor.Blue); canvas.DrawCircleFilled(30, 105, 23, (ushort)ColorHelpers.GetRGB24toRGB565(0x33, 0x00, 0x00)); canvas.DrawCircleFilled(30, 105, 19, (ushort)ColorHelpers.GetRGB24toRGB565(0x66, 0x00, 0x00)); canvas.DrawCircleFilled(30, 105, 15, (ushort)ColorHelpers.GetRGB24toRGB565(0x99, 0x00, 0x00)); canvas.DrawCircleFilled(30, 105, 11, (ushort)ColorHelpers.GetRGB24toRGB565(0xCC, 0x00, 0x00)); canvas.DrawCircleFilled(30, 105, 7, (ushort)ColorHelpers.GetRGB24toRGB565(0xFF, 0x00, 0x00)); canvas.DrawRectangleFilled(80, 80, 180, 125, (ushort)GrayScaleValues.Gray_15); canvas.DrawRectangleFilled(85, 85, 175, 120, (ushort)GrayScaleValues.Gray_30); canvas.DrawRectangleFilled(90, 90, 170, 115, (ushort)GrayScaleValues.Gray_50); canvas.DrawRectangleFilled(95, 95, 165, 110, (ushort)GrayScaleValues.Gray_80); canvas.DrawRectangleFilled(100, 100, 160, 105, (ushort)GrayScaleValues.Gray_128); }
public static void RenderCompoundShapes(VirtualCanvas canvas, FontInfo fontInfo) { canvas.DrawProgressBar( 70, 140, 75, 12, CornerStyle, CornerStyle, (ushort)BasicColor.Black, (ushort)GrayScaleValues.Gray_128, (ushort)GrayScaleValues.Gray_30, (ushort)BasicColor.Green, 78); canvas.DrawString(5, 144, (ushort)BasicColor.Black, fontInfo.ID, "Progress"); canvas.DrawString(155, 144, (ushort)BasicColor.Black, fontInfo.ID, "78%"); canvas.DrawRectangleFilled(0, 275, 239, 319, (ushort)GrayScaleValues.Gray_80); }
public Size MeasureText(VirtualCanvas parent, String label) { if (_parent != parent) { FontFamily fontFamily = (FontFamily)parent.GetValue(TextBlock.FontFamilyProperty); FontStyle fontStyle = (FontStyle)parent.GetValue(TextBlock.FontStyleProperty); FontWeight fontWeight = (FontWeight)parent.GetValue(TextBlock.FontWeightProperty); FontStretch fontStretch = (FontStretch)parent.GetValue(TextBlock.FontStretchProperty); _fontSize = (Double)parent.GetValue(TextBlock.FontSizeProperty); _typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch); _parent = parent; } FormattedText ft = new FormattedText(label, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, _typeface, _fontSize, Brushes.Black); return(new Size(ft.Width, ft.Height)); }
public MainMenu(VirtualCanvas canvas) { TemperatureAndRelayButton = new ButtonWidget(10, 22, 250, 27, fontInfo.GetFontInfo(), "Temperature & Relay"); ImageGalleryButton = new ButtonWidget(10, 53, 250, 27, fontInfo.GetFontInfo(), "Image Gallery"); BasicUIButton = new ButtonWidget(10, 83, 250, 27, fontInfo.GetFontInfo(), "Basic UI"); LEDMarqueeButton = new ButtonWidget(10, 113, 250, 27, fontInfo.GetFontInfo(), "LED Marquee"); LEDRGBArtButton = new ButtonWidget(10, 143, 250, 27, fontInfo.GetFontInfo(), "LED RGB Art"); LEDCaptureTheDotButton = new ButtonWidget(10, 173, 250, 27, fontInfo.GetFontInfo(), "LED Capture The Dot"); LEDSignShowcaseButton = new ButtonWidget(10, 203, 250, 27, fontInfo.GetFontInfo(), "LED Sign Showcase"); canvas.RegisterWidget(TemperatureAndRelayButton); canvas.RegisterWidget(ImageGalleryButton); canvas.RegisterWidget(BasicUIButton); canvas.RegisterWidget(LEDMarqueeButton); canvas.RegisterWidget(LEDRGBArtButton); canvas.RegisterWidget(LEDCaptureTheDotButton); canvas.RegisterWidget(LEDSignShowcaseButton); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (ScrollViewer == null) { return; } VirtualCanvas virtualCanvas = ScrollViewer.Content as VirtualCanvas; if (virtualCanvas == null) { throw new Exception("DesignerCanvas must not be null!"); } _canvas = virtualCanvas; zoomThumb = Template.FindName("PART_ZoomThumb", this) as Thumb; if (zoomThumb == null) { throw new Exception("PART_ZoomThumb template is missing!"); } zoomCanvas = Template.FindName("PART_ZoomCanvas", this) as Canvas; if (zoomCanvas == null) { throw new Exception("PART_ZoomCanvas template is missing!"); } zoomSlider = Template.FindName("PART_ZoomSlider", this) as Slider; if (zoomSlider == null) { throw new Exception("PART_ZoomSlider template is missing!"); } virtualCanvas.ContentCanvas.LayoutUpdated += new EventHandler(DesignerCanvas_LayoutUpdated); zoomThumb.DragDelta += new DragDeltaEventHandler(Thumb_DragDelta); zoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler <double>(ZoomSlider_ValueChanged); scaleTransform = new ScaleTransform(); _canvas.LayoutTransform = scaleTransform; }
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); }
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(); }
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(); }
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); } }
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(); }
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."); } }
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(); }
public static void ColorButtonsClickedHandler(VirtualCanvas canvas, Widget widget, TouchEvent touchEvent) { widget.Dirty = true; canvas.DrawFill(((ButtonWidget)widget).FillColor); }