public void DisplayImageSmallTest() { using var result = new Epd7In5Bc(); result.Initialize(m_EPaperDisplayHardwareMock.Object); var image = CommonTestData.CreateSampleBitmap(result.Width / 2, result.Height / 2); var validBuffer = new List <byte> { (byte)Epd7In5BcCommands.DataStartTransmission1 }; m_DataBuffer.Clear(); validBuffer.AddRange(BitmapToData(image, result.Width, result.Height)); validBuffer.Add((byte)Epd7In5BcCommands.DataStop); validBuffer.Add((byte)Epd7In5BcCommands.PowerOn); validBuffer.Add((byte)Epd7In5BcCommands.GetStatus); validBuffer.Add((byte)Epd7In5BcCommands.DisplayRefresh); validBuffer.Add((byte)Epd7In5BcCommands.GetStatus); m_DataBuffer.Clear(); var bitmapEPaperDisplay = new SKBitmapLoader(result); bitmapEPaperDisplay.DisplayImage(image, false); Assert.AreEqual(validBuffer.Count, m_DataBuffer.Count, "Data Length is wrong"); Assert.IsTrue(m_DataBuffer.SequenceEqual(validBuffer), "Command Data Sequence is wrong"); }
public void DisplayImageSmallTest() { using var result = new Epd7In5Bc(); result.Initialize(m_EPaperDisplayHardwareMock.Object); var image = CreateSampleBitmap(result.Width / 2, result.Height / 2); m_DataBuffer.Clear(); result.DisplayImage(image); var imageData = result.BitmapToData(image); var validBuffer = new List <byte> { (byte)Epd7In5BcCommands.DataStartTransmission1 }; validBuffer.AddRange(imageData); validBuffer.Add((byte)Epd7In5BcCommands.DataStop); validBuffer.Add((byte)Epd7In5BcCommands.PowerOn); validBuffer.Add((byte)Epd7In5BcCommands.GetStatus); validBuffer.Add((byte)Epd7In5BcCommands.DisplayRefresh); validBuffer.Add((byte)Epd7In5BcCommands.GetStatus); Assert.IsTrue(m_DataBuffer.SequenceEqual(validBuffer), "Command Data Sequence is wrong"); }
public void ClearBlackTest() { using var result = new Epd7In5Bc(); result.Initialize(m_EPaperDisplayHardwareMock.Object); m_DataBuffer.Clear(); result.ClearBlack(); const int pixelPerByte = 2; var displayBytes = result.Width / pixelPerByte * result.Height; const byte black = 0x00; var twoBlackPixel = result.MergePixelDataInByte(black, black); var validBuffer = new List <byte> { (byte)Epd7In5BcCommands.DataStartTransmission1 }; for (int i = 0; i < displayBytes; i++) { validBuffer.Add(twoBlackPixel); } validBuffer.Add((byte)Epd7In5BcCommands.DataStop); validBuffer.Add((byte)Epd7In5BcCommands.PowerOn); validBuffer.Add((byte)Epd7In5BcCommands.GetStatus); validBuffer.Add((byte)Epd7In5BcCommands.DisplayRefresh); validBuffer.Add((byte)Epd7In5BcCommands.GetStatus); Assert.IsTrue(m_DataBuffer.SequenceEqual(validBuffer), "Command Data Sequence is wrong"); }
//######################################################################################## #region Private Methods /// <summary> /// Create a instance of a internal E-Paper Display /// </summary> /// <param name="displayType"></param> /// <returns></returns> internal static IEPaperDisplayInternal CreateEPaperDisplay(EPaperDisplayType displayType) { IEPaperDisplayInternal display; switch (displayType) { case EPaperDisplayType.WaveShare7In5Bc: display = new Epd7In5Bc(); break; case EPaperDisplayType.WaveShare7In5_V2: display = new Epd7In5_V2(); break; case EPaperDisplayType.WaveShare7In5b_V2: display = new Epd7In5b_V2(); break; case EPaperDisplayType.WaveShare5In65f: display = new Epd5in65f(); break; default: display = null; break; } display?.Initialize(EPaperDisplayHardware.Value); return(display); }
public void DoubleDisposeTest() { var result = new Epd7In5Bc(); result.Initialize(m_EPaperDisplayHardwareMock.Object); result.Dispose(); result.Dispose(); }
public void FinalizerNoHardwareTest() { var result = new Epd7In5Bc(); Assert.NotNull(result, "Object should not be null"); // ReSharper disable once RedundantAssignment result = null; GC.Collect(); GC.WaitForPendingFinalizers(); }
public void FinalizerNoHardwareTest() { var result = new Epd7In5Bc(); Assert.NotNull(result, "Object should not be null"); // ReSharper disable once RedundantAssignment #pragma warning disable IDE0059 // Unnecessary assignment of a value result = null; #pragma warning restore IDE0059 // Unnecessary assignment of a value GC.Collect(); GC.WaitForPendingFinalizers(); }
public void FinalizerTest() { var result = new Epd7In5Bc(); result.Initialize(m_EPaperDisplayHardwareMock.Object); Assert.NotNull(result, "Object should not be null"); // ReSharper disable once RedundantAssignment result = null; GC.Collect(); GC.WaitForPendingFinalizers(); }
public void TestMergePixelDataInByte() { using var result = new Epd7In5Bc(); var random = new Random(); for (int i = 0; i < 200; i++) { var b1 = (byte)random.Next(0, 0x0F); var b2 = (byte)random.Next(0, 0x0F); var oldResult = MergePixelDataInByte(b1, b2); var newResult = result.MergePixelDataInByte(b1, b2); Assert.AreEqual(oldResult, newResult, $"Merged Byte Run {i} is wrong. Expected {oldResult}, Returned {newResult}"); } }
public void PowerOffTest() { using var result = new Epd7In5Bc(); result.Initialize(m_EPaperDisplayHardwareMock.Object); m_DataBuffer.Clear(); result.PowerOff(); var validBuffer = new List <byte> { (byte)Epd7In5BcCommands.PowerOff, (byte)Epd7In5BcCommands.GetStatus }; Assert.IsTrue(m_DataBuffer.SequenceEqual(validBuffer), "Command Data Sequence is wrong"); }
//######################################################################################## #region Public Methods /// <summary> /// Create a instance of a E-Paper Display /// </summary> /// <param name="displayType"></param> /// <returns></returns> public static IEPaperDisplay Create(EPaperDisplayType displayType) { IEPaperDisplayInternal display; switch (displayType) { case EPaperDisplayType.WaveShare7In5Bc: display = new Epd7In5Bc(); break; default: display = null; break; } display?.Initialize(EPaperDisplayHardware.Value); return(display); }
public void WakeUpTest() { using var result = new Epd7In5Bc(); result.Initialize(m_EPaperDisplayHardwareMock.Object); m_DataBuffer.Clear(); result.WakeUp(); var validBuffer = new List <byte> { (byte)Epd7In5BcCommands.PowerSetting, 0x37, 0x00, (byte)Epd7In5BcCommands.PanelSetting, 0xCF, 0x08, (byte)Epd7In5BcCommands.PllControl, 0x3A, (byte)Epd7In5BcCommands.VcmDcSetting, 0x28, (byte)Epd7In5BcCommands.BoosterSoftStart, 0xc7, 0xcc, 0x15, (byte)Epd7In5BcCommands.VcomAndDataIntervalSetting, 0x77, (byte)Epd7In5BcCommands.TconSetting, 0x22, (byte)Epd7In5BcCommands.SpiFlashControl, 0x00, (byte)Epd7In5BcCommands.TconResolution, (byte)(result.Width >> 8), // source 640 (byte)(result.Width & 0xff), (byte)(result.Height >> 8), // gate 384 (byte)(result.Height & 0xff), (byte)Epd7In5BcCommands.FlashMode, 0x03 }; Assert.IsTrue(m_DataBuffer.SequenceEqual(validBuffer), "Command Data Sequence is wrong"); }
public void DisposeNoHardwareTest() { using var result = new Epd7In5Bc(); result.Initialize(m_EPaperDisplayHardwareMock.Object); }
public void ConstructorTest() { using var result = new Epd7In5Bc(); result.Initialize(m_EPaperDisplayHardwareMock.Object); }