void DrawTitleAndFrame() { graphics.Clear(); graphics.DrawRectangle(0, 0, 240, 240); graphics.DrawText(24, 15, "Morse Code Coach"); graphics.DrawHorizontalLine(24, 41, 196, Color.White); graphics.Show(); }
public void ShowSplashScreen() { canvas.CurrentFont = new Font4x6(); canvas.Clear(); canvas.DrawRectangle(0, 0, canvas.Width, canvas.Height); canvas.DrawText(canvas.Width / 2, 2, "OnAir", alignment: TextAlignment.Center); canvas.Show(); canvas.CurrentFont = new Font4x8(); }
void LoadScreen() { Console.WriteLine("LoadScreen..."); graphics.Clear(true); graphics.Stroke = 1; graphics.DrawRectangle( x: 0, y: 0, width: graphics.Width, height: graphics.Height, color: Color.White); graphics.DrawRectangle( x: 5, y: 5, width: graphics.Width - 10, height: graphics.Height - 10, color: Color.White); graphics.DrawCircle( centerX: graphics.Width / 2, centerY: graphics.Height / 2, radius: (graphics.Width / 2) - 10, color: Color.FromHex("#EF7D3B"), filled: true); DisplayJPG(55, 40); graphics.CurrentFont = new Font8x12(); string textMotion = "MOTION"; graphics.DrawText( (graphics.Width - textMotion.Length * 16) / 2, 140, textMotion, Color.Black, ScaleFactor.X2); string textDetector = "DETECTOR"; graphics.DrawText( (graphics.Width - textDetector.Length * 16) / 2, 165, textDetector, Color.Black, ScaleFactor.X2); graphics.Show(); }
async Task Start() { while (true) { DateTime clock = DateTime.Now.AddHours(-8); graphics.Clear(); graphics.DrawText(0, 1, $"{clock:hh}"); graphics.DrawText(0, 9, $"{clock:mm}"); graphics.DrawText(0, 17, $"{clock:ss}"); graphics.DrawText(0, 25, $"{clock:tt}"); if (showDate) { graphics.Clear(); graphics.DrawText(0, 1, $"{clock:dd}"); graphics.DrawText(0, 9, $"{clock:MM}"); graphics.DrawText(0, 17, $"{clock:yy}"); graphics.DrawHorizontalLine(0, 24, 7, true); var temperature = await analogTemperature.Read(); graphics.DrawText(0, 26, $"{(int) temperature.Celsius}"); } graphics.Show(); Thread.Sleep(1000); } }
void Draw() { int angle = 160; int increment = 4; int x, y = 0; while (true) { graphics.Clear(); DrawRadar(); graphics.DrawLine(120, 170, 105, (float)(angle * Math.PI / 180), Color.Yellow); if (angle >= 180) { increment = -4; } if (angle <= 0) { increment = 4; } angle += increment; servo.RotateTo(new Angle(angle, AU.Degrees)); graphics.DrawText(0, 0, $"{180 - angle}°", Color.Yellow); if (sensor.Distance != null && sensor.Distance >= new Length(0, LU.Millimeters)) { graphics.DrawText(170, 0, $"{sensor.Distance?.Millimeters}mm", Color.Yellow); radarData[angle] = (float)(sensor.Distance?.Millimeters / 2); } else { radarData[angle] = 0; } for (int i = 0; i < 180; i++) { x = 120 + (int)(radarData[i] * MathF.Cos(i * MathF.PI / 180f)); y = 170 - (int)(radarData[i] * MathF.Sin(i * MathF.PI / 180f)); graphics.DrawCircle(x, y, 2, Color.Yellow, true); } graphics.Show(); Thread.Sleep(100); } }
public MeadowApp() { Console.WriteLine("Tetris"); Initialize(); graphics.Clear(); graphics.DrawText(0, 0, "Meadow Tetris"); graphics.DrawText(0, 10, "v0.0.2"); graphics.Show(); Thread.Sleep(1000); StartGameLoop(); }
public void UpdateMoisturePercentage(double newValue, double oldValue) { if (newValue > 1) { newValue = 1f; } else if (newValue < 0) { newValue = 0f; } graphics.DrawText(0, 208, $"{(int)(oldValue * 100)}%", Color.White, ScaleFactor.X2); graphics.DrawText(0, 208, $"{(int)(newValue * 100)}%", Color.Black, ScaleFactor.X2); graphics.Show(); }
void DrawTetrisField() { graphics.DrawText(0, 0, $"{game.LinesCleared}"); int yOffset = 8; //draw current piece for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (game.IsPieceLocationSet(i, j)) { graphics.DrawPixel((game.CurrentPiece.X + i), game.CurrentPiece.Y + j + yOffset); } } } //draw gamefield for (int i = 0; i < game.Width; i++) { for (int j = 0; j < game.Height; j++) { if (game.IsGameFieldSet(i, j)) { graphics.DrawPixel(i, j + yOffset); } } } }
void DrawTitleMenu() { Console.WriteLine("Draw title"); graphics.Clear(); graphics.Show(); Thread.Sleep(400);//pause for video recording graphics.DrawLine(0, 0, 127, 0, true); graphics.Show(); for (int i = 1; i < 63; i++) { graphics.DrawPixel(0, i); graphics.DrawPixel(127, i); graphics.Show(); } graphics.DrawLine(0, 63, 127, 63, true); graphics.Show(); Thread.Sleep(400); graphics.DrawText(22, 20, "Frogger"); graphics.Show(); Thread.Sleep(400); for (int i = 0; i < 5; i++) { DrawFrog(20 * (i + 1), 50, 1); graphics.Show(); Thread.Sleep(400); } }
async Task Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); var display = new Max7219( device: Device, spiBus: Device.CreateSpiBus(), csPin: Device.Pins.D01, deviceCount: 4, maxMode: Max7219.Max7219Type.Display); graphics = new MicroGraphics(display); graphics.CurrentFont = new Font4x8(); graphics.Rotation = RotationType._180Degrees; graphics.Clear(); graphics.DrawText(0, 1, "WI"); graphics.DrawText(0, 9, "FI"); graphics.DrawText(0, 17, "TI"); graphics.DrawText(0, 25, "ME"); graphics.Show(); pushButton = new PushButton(Device, Device.Pins.D04, ResistorMode.InternalPullUp); pushButton.Clicked += PushButtonClicked; analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); var connectionResult = await Device.WiFiAdapter.Connect(Secrets.WIFI_NAME, Secrets.WIFI_PASSWORD); if (connectionResult.ConnectionStatus != ConnectionStatus.Success) { throw new Exception($"Cannot connect to network: {connectionResult.ConnectionStatus}"); } onboardLed.StartPulse(Color.Green); }
void DisplayText(string text, int x = 12) { graphics.Clear(); graphics.CurrentFont = new Font8x12(); graphics.DrawRectangle(0, 0, 128, 32); graphics.DrawText(x, 12, text); graphics.Show(); }
public MeadowApp() { Console.WriteLine("Span 4"); connectGame = new Span4Game(); Initialize(); graphics.Clear(); graphics.DrawText(0, 0, "Meadow Span4!"); graphics.DrawText(0, 10, "v0.0.4"); graphics.Show(); Thread.Sleep(250); StartGameLoop(); }
void AnalogTemperatureTemperatureUpdated(object sender, IChangeResult <Meadow.Units.Temperature> e) { graphics.DrawRectangle( x: 48, y: 160, width: 144, height: 40, color: colors[colors.Length - 1], filled: true); graphics.DrawText( x: 48, y: 160, text: $"{e.New.Celsius:00.0}°C", color: Color.White, scaleFactor: ScaleFactor.X2); graphics.Show(); }
public DisplayController(St7789 display) { graphics = new MicroGraphics(display); graphics.CurrentFont = new Font12x20(); graphics.Stroke = 3; graphics.Clear(); graphics.DrawRectangle(0, 0, 240, 240, Color.White, true); string plant = "Plant"; string monitor = "Monitor"; graphics.CurrentFont = new Font12x16(); graphics.DrawText((240 - (plant.Length * 24)) / 2, 80, plant, Color.Black, ScaleFactor.X2); graphics.DrawText((240 - (monitor.Length * 24)) / 2, 130, monitor, Color.Black, ScaleFactor.X2); graphics.Show(); }
public void UpdateDisplay(WeatherViewModel model) { graphics.Clear(); graphics.DrawRectangle(0, 0, graphics.Width, graphics.Height, Color.White, true); DisplayJPG(model.WeatherCode, 5, 5); graphics.DrawText(134, 143, "Outdoor", Color.Black); string outdoorTemp = model.OutdoorTemperature.ToString("00°C"); graphics.DrawText(128, 178, outdoorTemp, Color.Black, ScaleFactor.X2); graphics.DrawText(23, 143, "Indoor", Color.Black); string indoorTemp = model.IndoorTemperature.ToString("00°C"); graphics.DrawText(11, 178, indoorTemp, Color.Black, ScaleFactor.X2); graphics.Show(); }
void DrawTexts() { graphics.Clear(true); int indent = 20; int spacing = 20; int y = 5; graphics.CurrentFont = new Font12x16(); graphics.DrawText(indent, y, "Meadow F7 SPI ST7789!!"); graphics.DrawText(indent, y += spacing, "Red", Color.Red); graphics.DrawText(indent, y += spacing, "Purple", Color.Purple); graphics.DrawText(indent, y += spacing, "BlueViolet", Color.BlueViolet); graphics.DrawText(indent, y += spacing, "Blue", Color.Blue); graphics.DrawText(indent, y += spacing, "Cyan", Color.Cyan); graphics.DrawText(indent, y += spacing, "LawnGreen", Color.LawnGreen); graphics.DrawText(indent, y += spacing, "GreenYellow", Color.GreenYellow); graphics.DrawText(indent, y += spacing, "Yellow", Color.Yellow); graphics.DrawText(indent, y += spacing, "Orange", Color.Orange); graphics.DrawText(indent, y += spacing, "Brown", Color.Brown); graphics.Show(); Thread.Sleep(5000); }