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 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 I2C( NwazetDAQ daq, BasicTypeSerializerContext sendContext, BasicTypeDeSerializerContext receiveContext) { Daq = daq; SendContext = sendContext; ReceiveContext = receiveContext; }
public void Get(BasicTypeDeSerializerContext context) { An = BasicTypeDeSerializer.Get(context, An); Bn = BasicTypeDeSerializer.Get(context, Bn); Cn = BasicTypeDeSerializer.Get(context, Cn); Dn = BasicTypeDeSerializer.Get(context, Dn); En = BasicTypeDeSerializer.Get(context, En); Fn = BasicTypeDeSerializer.Get(context, Fn); Divider = BasicTypeDeSerializer.Get(context, Divider); }
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 Get(BasicTypeDeSerializerContext context) { byte count = BasicTypeDeSerializer.Get(context); if ((GpioId)count != GpioId.GpioCount) { throw new IndexOutOfRangeException("count"); } for (var i = 0; i < count; i++) { Counts[i] = BasicTypeDeSerializer.Get(context, Counts[i]); RollOverCounts[i] = BasicTypeDeSerializer.Get(context, RollOverCounts[i]); Updated[i] = BasicTypeDeSerializer.Get(context, Updated[i]); } }
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 string Name; // Short file name (8.3 format) public void Get(BasicTypeDeSerializerContext context) { UInt16 date = 0; UInt16 time = 0; Size = BasicTypeDeSerializer.Get(context, Size); date = BasicTypeDeSerializer.Get(context, date); time = BasicTypeDeSerializer.Get(context, time); Attribute = BasicTypeDeSerializer.Get(context); Name = BasicTypeDeSerializer.Get(context, Name); /* * FAT filestamp format: * [31:25] - year - 1980 * [24:21] - month 1..12 * [20:16] - day 1..31 * [15:11] - hour 0..23 * [10:5] - minute 0..59 * [4:0] - second/2 0..29 * so... midnight 2009 is 0x3a000000 */ }
public static DateTime Get(BasicTypeDeSerializerContext context) { byte year; byte month; byte day; byte weekDay; byte hour; byte minute; byte second; int subSecond = 0; year = BasicTypeDeSerializer.Get(context); month = BasicTypeDeSerializer.Get(context); day = BasicTypeDeSerializer.Get(context); weekDay = BasicTypeDeSerializer.Get(context); hour = BasicTypeDeSerializer.Get(context); minute = BasicTypeDeSerializer.Get(context); second = BasicTypeDeSerializer.Get(context); subSecond = BasicTypeDeSerializer.Get(context, subSecond); return(new DateTime((int)2000 + year, (int)month, (int)day, (int)hour, (int)minute, (int)second, (int)subSecond)); }
public void Get(BasicTypeDeSerializerContext context) { X = BasicTypeDeSerializer.Get(context, X); Y = BasicTypeDeSerializer.Get(context, Y); }
public Joystick() { ReceiveContext = new BasicTypeDeSerializerContext(); }
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 Get(BasicTypeDeSerializerContext context) { Time = TimeStamp.Get(context); Values = BasicTypeDeSerializer.Get(context, Values); }
public void Get(BasicTypeDeSerializerContext context) { DiskCapacityKB = BasicTypeDeSerializer.Get(context, DiskCapacityKB); FreeDiskSpaceKB = BasicTypeDeSerializer.Get(context, FreeDiskSpaceKB); }