private async void Init() { await WS_ILI9488.InitILI9488DisplaySPI(display1, 0, 50000000, SpiMode.Mode0, "SPI0", "ms-appx:///assets/SPLASH1 480.png"); await TSC2046.InitTSC2046SPI(); initTimer(); if (!await TSC2046.CalibrationMatrix.LoadCalData(TSC2046CalFilename)) { calibrateTouch(); } }
private async Task loadImageToScreen(string imageName) { try { await WS_ILI9488.LoadBitmap(display1, 190, 10, 280, 220, imageName); var myBrush = new ImageBrush(); var image = new Image { Source = new BitmapImage(new Uri(imageName)) }; myBrush.ImageSource = image.Source; imageArea.Background = myBrush; } catch (Exception ex) { Status.Text = ex.Message; } }
private async void button1_Click(object sender, RoutedEventArgs e) { await WS_ILI9488.LoadBitmap(display1, "ms-appx:///assets/TEST.jpg"); WS_ILI9488.Flush(display1); }
private async Task doDemo() { int LoopDelay = 1000; try { WS_ILI9488.fillRect(display1, 190, 10, 280, 220, 0x0000); WS_ILI9488.fillRect(display1, 220, 40, 220, 160, 0xFFFF); WS_ILI9488.fillRect(display1, 250, 70, 160, 100, 0x0000); WS_ILI9488.fillRect(display1, 280, 100, 100, 40, 0xFFFF); await Task.Delay((int)LoopDelay); WS_ILI9488.fillRect(display1, 190, 10, 280, 220, 0x0000); for (UInt16 x = 0; x < 220 / 2; x += 4) { UInt16 x1 = (UInt16)(x + 190); UInt16 y1 = (UInt16)(x + 10); UInt16 x2 = (UInt16)((280 - x * 2)); UInt16 y2 = (UInt16)((220 - x * 2)); WS_ILI9488.LineDrawH(display1, x1, y1, x2, 0xFFFF); WS_ILI9488.LineDrawH(display1, x1, (UInt16)(y1 + y2), x2, 0xFFFF); WS_ILI9488.LineDrawV(display1, x1, y1, y2, 0xFFFF); WS_ILI9488.LineDrawV(display1, (UInt16)(x1 + x2), y1, y2, 0xFFFF); } await Task.Delay((int)LoopDelay); WS_ILI9488.fillRect(display1, 190, 10, 280, 220, 0x0000); for (int x = 0; x < 50; x++) { int x1 = (190 + GenerateRndNumber()); int y1 = (10 + GenerateRndNumber()); int x2 = (190 + GenerateRndNumber()); int y2 = (10 + GenerateRndNumber()); WS_ILI9488.drawLine(display1, (UInt16)x1, (UInt16)y1, (UInt16)x2, (UInt16)y2, 0xFe1F); } await Task.Delay((int)LoopDelay); WS_ILI9488.fillRect(display1, 190, 10, 280, 220, 0x0000); WS_ILI9488.Arc(display1, 275, 75, 120, 90, 180, 0xFFFF); WS_ILI9488.Arc(display1, 375, 175, 120, 270, 360, 0xFFFF); WS_ILI9488.Arc(display1, 275, 175, 120, 0, 90, 0xFFFF); WS_ILI9488.Arc(display1, 375, 75, 120, 180, 270, 0xFFFF); WS_ILI9488.DrawCircle(display1, 325, 125, 100, 0xF81F); await Task.Delay((int)LoopDelay); WS_ILI9488.fillRect(display1, 190, 10, 280, 220, 0x0000); WS_ILI9488.setCursor(display1, 195, 30); WS_ILI9488.write(display1, "Hello".ToCharArray(), 2, 0xFFFF); WS_ILI9488.setCursor(display1, 195, 47); WS_ILI9488.write(display1, "Hi There".ToCharArray(), 1, 0xFFFF); await Task.Delay((int)LoopDelay); WS_ILI9488.fillRect(display1, 190, 10, 280, 220, 0x0000); WS_ILI9488.setCursor(display1, 195, 30); WS_ILI9488.write(display1, "Hi There".ToCharArray(), 1, 0xFF00); WS_ILI9488.setCursor(display1, 195, 40); WS_ILI9488.write(display1, "Hi There".ToCharArray(), 2, 0x00FF); WS_ILI9488.setCursor(display1, 195, 70); WS_ILI9488.write(display1, "Hi There".ToCharArray(), 4, 0xFFFF); WS_ILI9488.setCursor(display1, 195, 120); WS_ILI9488.write(display1, "Hi There".ToCharArray(), 6, 0xF81F); await Task.Delay((int)LoopDelay); for (byte x = 1; x < 6; x++) { WS_ILI9488.fillRect(display1, 190, 10, 280, 220, 0x0000); WS_ILI9488.setCursor(display1, 195, 30); WS_ILI9488.write(display1, "Hi there".ToCharArray(), x, 0xFFFF); await Task.Delay((int)LoopDelay / 4); WS_ILI9488.setCursor(display1, 195, 30); WS_ILI9488.write(display1, "Hi there".ToCharArray(), x, 0x0000); } } catch (Exception ex) { throw new Exception(ex.Message); } }
private async void calibrateTouch() { //3 point calibration TouchPanels.CAL_POINT[] touchPoints = new CAL_POINT[3]; touchPoints[0] = new CAL_POINT(); touchPoints[1] = new CAL_POINT(); touchPoints[2] = new CAL_POINT(); TouchPanels.CAL_POINT[] screenPoints = new CAL_POINT[3]; screenPoints[0] = new CAL_POINT(); screenPoints[1] = new CAL_POINT(); screenPoints[2] = new CAL_POINT(); WS_ILI9488.fillRect(display1, 0, 0, 480, 320, 0x0000); WS_ILI9488.LineDrawH(display1, 50, 50, 50, 0xFFFF); WS_ILI9488.LineDrawV(display1, 75, 25, 50, 0xFFFF); while (TSC2046.pressure < 5) { TSC2046.CheckTouch(); } //wait for pen pressure screenPoints[0].x = 75; screenPoints[0].y = 50; touchPoints[0].x = TSC2046.tp_x; touchPoints[0].y = TSC2046.tp_y; while (TSC2046.pressure > 1) { TSC2046.CheckTouch(); } // wait for release of pen WS_ILI9488.LineDrawH(display1, 400, 50, 50, 0xFFFF); WS_ILI9488.LineDrawV(display1, 425, 25, 50, 0xFFFF); while (TSC2046.pressure < 5) { TSC2046.CheckTouch(); } //wait for pen pressure screenPoints[1].x = 425; screenPoints[1].y = 50; touchPoints[1].x = TSC2046.tp_x; touchPoints[1].y = TSC2046.tp_y; while (TSC2046.pressure > 1) { TSC2046.CheckTouch(); } // wait for release of pen WS_ILI9488.LineDrawH(display1, 225, 275, 50, 0xFFFF); WS_ILI9488.LineDrawV(display1, 250, 250, 50, 0xFFFF); while (TSC2046.pressure < 5) { TSC2046.CheckTouch(); } //wait for pen pressure screenPoints[2].x = 250; screenPoints[2].y = 275; touchPoints[2].x = TSC2046.tp_x; touchPoints[2].y = TSC2046.tp_y; while (TSC2046.pressure > 1) { TSC2046.CheckTouch(); } // wait for release of pen TSC2046.setCalibration(screenPoints, touchPoints); if (await TSC2046.CalibrationMatrix.SaveCalData(TSC2046CalFilename)) { Status.Text = TSC2046.CalibrationMatrix.message; } else { Status.Text = TSC2046.CalibrationMatrix.message; } WS_ILI9488.Flush(display1); }