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(); }
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) { 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 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(); }