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 void SerializeDutyCycle(BasicTypeSerializerContext context, GpioTimeBase timer) { UInt32 pulseLength = (UInt32)(dutyCycle * (float)(timer.TimerPeriod - 1)); BasicTypeSerializer.Put(context, (byte)Identifier); BasicTypeSerializer.Put(context, pulseLength); }
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 override void SerializeDefinition(BasicTypeSerializerContext context) { base.SerializeDefinition(context); BasicTypeSerializer.Put(context, (byte)((Enable == true) ? (byte)1 : (byte)0)); BasicTypeSerializer.Put(context, (byte)Trigger); BasicTypeSerializer.Put(context, (UInt32)RollOverCountLimit); }
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 I2C( NwazetDAQ daq, BasicTypeSerializerContext sendContext, BasicTypeDeSerializerContext receiveContext) { Daq = daq; SendContext = sendContext; ReceiveContext = receiveContext; }
public virtual void SerializeDefinition(BasicTypeSerializerContext context) { BasicTypeSerializer.Put(context, (byte)Identifier); BasicTypeSerializer.Put(context, (byte)Mode); BasicTypeSerializer.Put(context, (byte)Type); BasicTypeSerializer.Put(context, (byte)ResistorType); BasicTypeSerializer.Put(context, (byte)AlternateFunction); BasicTypeSerializer.Put(context, (byte)((State == true) ? (byte)1 : (byte)0)); }
public static void Put(BasicTypeSerializerContext context, DateTime dt) { BasicTypeSerializer.Put(context, (byte)(dt.Year - 2000)); BasicTypeSerializer.Put(context, (byte)dt.Month); BasicTypeSerializer.Put(context, (byte)dt.Day); BasicTypeSerializer.Put(context, (byte)dt.DayOfWeek); BasicTypeSerializer.Put(context, (byte)dt.Hour); BasicTypeSerializer.Put(context, (byte)dt.Minute); BasicTypeSerializer.Put(context, (byte)dt.Second); }
public void Put(BasicTypeSerializerContext context) { BasicTypeSerializer.Put(context, (Int32)An); BasicTypeSerializer.Put(context, (Int32)Bn); BasicTypeSerializer.Put(context, (Int32)Cn); BasicTypeSerializer.Put(context, (Int32)Dn); BasicTypeSerializer.Put(context, (Int32)En); BasicTypeSerializer.Put(context, (Int32)Fn); BasicTypeSerializer.Put(context, (Int32)Divider); }
public void Put(BasicTypeSerializerContext context) { if (DataBits == UsartDataBits.Nine) { throw new NotImplementedException("DataBits"); } BasicTypeSerializer.Put(context, BaudRate); BasicTypeSerializer.Put(context, DataBits); BasicTypeSerializer.Put(context, StopBits); BasicTypeSerializer.Put(context, Parity); BasicTypeSerializer.Put(context, HardwareFlowControl); BasicTypeSerializer.Put(context, TransmitTimeoutMs); BasicTypeSerializer.Put(context, ReceiveTimeoutMs); }
public VirtualCanvas(TouchEventHandler touchEventHandler, WidgetClickedHandler widgetClickedHandler) { TrackOrientation(Orientation.Portrait); _spiRxBuffer = new byte[MaxSpiRxBufferSize]; SendContext = new BasicTypeSerializerContext(MaxSpiTxBufferSize, SpiTxBufferHighWatermark, OnCanvasBufferNearlyFull); ReceiveContext = new BasicTypeDeSerializerContext(); GoBusIrqEvent = new ManualResetEvent(false); RegisteredWidgets = new ArrayList(); if (widgetClickedHandler != null) { WidgetClicked += widgetClickedHandler; } if (touchEventHandler != null) { Touch += touchEventHandler; } }
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(); }
public NwazetDAQ() { _spiRxBuffer = new byte[MaxSpiRxBufferSize]; SendContext = new BasicTypeSerializerContext(MaxSpiTxBufferSize); ReceiveContext = new BasicTypeDeSerializerContext(); GoBusIrqEvent = new ManualResetEvent(false); RegisterTimer(new GpioTimeBase(GpioTimerId.D0Timer, GpioId.D0)); RegisterTimer(new GpioTimeBase(GpioTimerId.D1Timer, GpioId.D1)); RegisterTimer(new GpioTimeBase(GpioTimerId.D2Timer, GpioId.D2)); RegisterTimer(new GpioTimeBase(GpioTimerId.D3Timer, GpioId.D3)); RegisterTimer(new GpioTimeBase(GpioTimerId.D4Timer, GpioId.D4_33v)); RegisterTimer(new GpioTimeBase(GpioTimerId.D5Timer, GpioId.D5)); RegisterTimer(new GpioTimeBase(GpioTimerId.D6Timer, GpioId.D6)); RegisterTimer(new GpioTimeBase(GpioTimerId.D7Timer, GpioId.D7)); FatFs = new FileSystem(this, SendContext, ReceiveContext); UsartPort = new Usart(this, SendContext, ReceiveContext); I2cPort = new I2C(this, SendContext, ReceiveContext); }
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 Main() { var contextSerializer = new BasicTypeSerializerContext(); BasicTypeSerializer.Put(contextSerializer, (byte)byte.MaxValue); BasicTypeSerializer.Put(contextSerializer, (UInt16)UInt16.MaxValue); BasicTypeSerializer.Put(contextSerializer, (Int16)Int16.MinValue); BasicTypeSerializer.Put(contextSerializer, (UInt32)UInt32.MaxValue); BasicTypeSerializer.Put(contextSerializer, (Int32)Int32.MinValue); BasicTypeSerializer.Put(contextSerializer, (UInt64)UInt64.MaxValue); BasicTypeSerializer.Put(contextSerializer, (Int64)Int64.MinValue); BasicTypeSerializer.Put(contextSerializer, (float)float.MaxValue); BasicTypeSerializer.Put(contextSerializer, (float)float.MinValue); BasicTypeSerializer.Put(contextSerializer, "Unicode String"); BasicTypeSerializer.Put(contextSerializer, "ASCII String", true); BasicTypeSerializer.Put(contextSerializer, new byte[] { byte.MinValue, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, byte.MaxValue }); BasicTypeSerializer.Put(contextSerializer, new ushort[] { ushort.MinValue, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, UInt16.MaxValue }); BasicTypeSerializer.Put(contextSerializer, new UInt32[] { UInt32.MinValue, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, UInt32.MaxValue }); BasicTypeSerializer.Put(contextSerializer, new UInt64[] { UInt64.MinValue, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, UInt64.MaxValue }); byte byteValue = 0; UInt16 UInt16Value = 0; Int16 Int16Value = 0; UInt32 UInt32Value = 0; Int32 Int32Value = 0; UInt64 UInt64Value = 0; Int64 Int64Value = 0; float floatValue = 0.0F; string UnicodeString = null; string AsciiString = null; byte[] byteArray = null; ushort[] ushortArray = null; UInt32[] UInt32Array = null; UInt64[] UInt64Array = null; Debug.Print("sizeof(byte)=" + sizeof(byte)); Debug.Print("sizeof(UInt16)=" + sizeof(UInt16)); Debug.Print("sizeof(Int16)=" + sizeof(Int16)); Debug.Print("sizeof(UInt32)=" + sizeof(UInt32)); Debug.Print("sizeof(Int32)=" + sizeof(Int32)); Debug.Print("sizeof(UInt64)=" + sizeof(UInt64)); Debug.Print("sizeof(Int64)=" + sizeof(Int64)); Debug.Print("sizeof(float)=" + sizeof(float)); Debug.Print("sizeof(double)=" + sizeof(double)); var contextDeserializer = new BasicTypeDeSerializerContext(contextSerializer.GetBuffer()); byteValue = BasicTypeDeSerializer.Get(contextDeserializer); if (byteValue != byte.MaxValue) { throw new ApplicationException("byteValue"); } UInt16Value = BasicTypeDeSerializer.Get(contextDeserializer, UInt16Value); if (UInt16Value != UInt16.MaxValue) { throw new ApplicationException("UInt16Value"); } Int16Value = BasicTypeDeSerializer.Get(contextDeserializer, Int16Value); if (Int16Value != Int16.MinValue) { throw new ApplicationException("Int16Value"); } UInt32Value = BasicTypeDeSerializer.Get(contextDeserializer, UInt32Value); if (UInt32Value != UInt32.MaxValue) { throw new ApplicationException("UInt32Value"); } Int32Value = BasicTypeDeSerializer.Get(contextDeserializer, Int32Value); if (Int32Value != Int32.MinValue) { throw new ApplicationException("Int32Value"); } UInt64Value = BasicTypeDeSerializer.Get(contextDeserializer, UInt64Value); if (UInt64Value != UInt64.MaxValue) { throw new ApplicationException("UInt64Value"); } Int64Value = BasicTypeDeSerializer.Get(contextDeserializer, Int64Value); if (Int64Value != Int64.MinValue) { throw new ApplicationException("Int64Value"); } floatValue = BasicTypeDeSerializer.Get(contextDeserializer, floatValue); if (floatValue != float.MaxValue) { throw new ApplicationException("floatValue"); } floatValue = BasicTypeDeSerializer.Get(contextDeserializer, floatValue); if (floatValue != float.MinValue) { throw new ApplicationException("floatValue"); } UnicodeString = BasicTypeDeSerializer.Get(contextDeserializer, ""); if (UnicodeString != "Unicode String") { throw new ApplicationException("UnicodeString"); } AsciiString = BasicTypeDeSerializer.Get(contextDeserializer, ""); if (AsciiString != "ASCII String") { throw new ApplicationException("AsciiString"); } byteArray = BasicTypeDeSerializer.Get(contextDeserializer, byteArray); if (byteArray[0] != byte.MinValue || byteArray[15] != byte.MaxValue) { throw new ApplicationException("byteArray"); } ushortArray = BasicTypeDeSerializer.Get(contextDeserializer, ushortArray); if (ushortArray[0] != ushort.MinValue || ushortArray[15] != ushort.MaxValue) { throw new ApplicationException("ushortArray"); } UInt32Array = BasicTypeDeSerializer.Get(contextDeserializer, UInt32Array); if (UInt32Array[0] != UInt32.MinValue || UInt32Array[15] != UInt32.MaxValue) { throw new ApplicationException("UInt32Array"); } UInt64Array = BasicTypeDeSerializer.Get(contextDeserializer, UInt64Array); if (UInt64Array[0] != UInt64.MinValue || UInt64Array[15] != UInt64.MaxValue) { throw new ApplicationException("UInt64Array"); } }
public void SerializeState(BasicTypeSerializerContext context) { BasicTypeSerializer.Put(context, (byte)Identifier); BasicTypeSerializer.Put(context, (byte)((State == true) ? (byte)1 : (byte)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(); }
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(); }
public void SerializeTimeBase(BasicTypeSerializerContext context) { BasicTypeSerializer.Put(context, (byte)GpioPinId); BasicTypeSerializer.Put(context, (UInt16)Period); BasicTypeSerializer.Put(context, (UInt16)Prescaler); }
public VirtualCanvas(BasicTypeSerializerContext context) { Context = context; }
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(); }