public void ClearTest() { using var result = new Epd7In5b_V2(); result.Initialize(m_EPaperDisplayHardwareMock.Object); m_DataBuffer.Clear(); result.Clear(); const int pixelPerByte = 8; var displayBytes = result.Width / pixelPerByte * result.Height; const byte white = 0x01; const byte black = 0x00; var eightWhitePixel = result.MergePixelDataInByte(white, white, white, white, white, white, white, white); var eightBlackPixel = result.MergePixelDataInByte(black, black, black, black, black, black, black, black); var validBuffer = new List <byte> { (byte)Epd7In5b_V2Commands.DataStartTransmission1 }; for (int i = 0; i < displayBytes; i++) { validBuffer.Add(eightWhitePixel); } validBuffer.Add((byte)Epd7In5b_V2Commands.DataStartTransmission2); for (int i = 0; i < displayBytes; i++) { validBuffer.Add(eightBlackPixel); } validBuffer.Add((byte)Epd7In5b_V2Commands.DisplayRefresh); validBuffer.Add((byte)Epd7In5b_V2Commands.GetStatus); Assert.IsTrue(m_DataBuffer.SequenceEqual(validBuffer), "Command Data Sequence is wrong"); }
public void TestMergePixelDataInByte() { using var result = new Epd7In5b_V2(); var random = new Random(); for (int i = 0; i < 200; i++) { var value = random.Next(0, byte.MaxValue); var b1 = (value & 128) > 0 ? byte.MaxValue : byte.MinValue; var b2 = (value & 64) > 0 ? byte.MaxValue : byte.MinValue; var b3 = (value & 32) > 0 ? byte.MaxValue : byte.MinValue; var b4 = (value & 16) > 0 ? byte.MaxValue : byte.MinValue; var b5 = (value & 8) > 0 ? byte.MaxValue : byte.MinValue; var b6 = (value & 4) > 0 ? byte.MaxValue : byte.MinValue; var b7 = (value & 2) > 0 ? byte.MaxValue : byte.MinValue; var b8 = (value & 1) > 0 ? byte.MaxValue : byte.MinValue; var newResult = result.MergePixelDataInByte(b1, b2, b3, b4, b5, b6, b7, b8); Assert.AreEqual(value, newResult, $"Merged Byte Run {i} is wrong. Expected {value}, Returned {newResult}"); } }