コード例 #1
0
        //########################################################################################

        #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);
        }
コード例 #2
0
        public void DoubleDisposeTest()
        {
            var result = new Epd7In5b_V2();

            result.Initialize(m_EPaperDisplayHardwareMock.Object);
            result.Dispose();
            result.Dispose();
        }
コード例 #3
0
        public void DisplayImageSmallTest()
        {
            using var result = new Epd7In5b_V2();
            result.Initialize(m_EPaperDisplayHardwareMock.Object);

            var image = CommonTestData.CreateSampleBitmap(result.Width / 2, result.Height / 2);

            var validBuffer = new List <byte>
            {
                (byte)Epd7In5b_V2Commands.DataStartTransmission1
            };

            SeparateColors(image, out var imageBw, out var imageRed);

            using (imageBw)
            {
                validBuffer.AddRange(SendBitmapToDevice(imageBw, result.Width, result.Height, byte.MaxValue));
            }

            validBuffer.Add((byte)Epd7In5b_V2Commands.DataStartTransmission2);

            using (imageRed)
            {
                validBuffer.AddRange(SendBitmapToDevice(imageRed, result.Width, result.Height, 0));
            }

            validBuffer.Add((byte)Epd7In5b_V2Commands.DisplayRefresh);
            validBuffer.Add((byte)Epd7In5b_V2Commands.GetStatus);

            m_DataBuffer.Clear();

            var bitmapEPaperDisplay = new SKBitmapLoader(result);

            bitmapEPaperDisplay.DisplayImage(image);

            for (int i = 0; i < m_DataBuffer.Count; i++)
            {
                if (i < validBuffer.Count)
                {
                    if (m_DataBuffer[i] != validBuffer[i])
                    {
                        Debug.WriteLine($"{i} - {m_DataBuffer[i]} - {validBuffer[i]}");
                    }
                }
                else
                {
                    Debug.WriteLine($"{i} - {m_DataBuffer[i]} - X");
                }
            }

            Assert.AreEqual(validBuffer.Count, m_DataBuffer.Count, "Data Length is wrong");
            Assert.IsTrue(m_DataBuffer.SequenceEqual(validBuffer), "Command Data Sequence is wrong");
        }
コード例 #4
0
        public void FinalizerNoHardwareTest()
        {
            var result = new Epd7In5b_V2();

            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();
        }
コード例 #5
0
        public void PowerOnTest()
        {
            using var result = new Epd7In5b_V2();
            result.Initialize(m_EPaperDisplayHardwareMock.Object);

            m_DataBuffer.Clear();

            result.PowerOn();

            var validBuffer = new List <byte>
            {
                (byte)Epd7In5b_V2Commands.PowerOn,
                (byte)Epd7In5b_V2Commands.GetStatus
            };

            Assert.IsTrue(m_DataBuffer.SequenceEqual(validBuffer), "Command Data Sequence is wrong");
        }
コード例 #6
0
        public void WakeUpTest()
        {
            using var result = new Epd7In5b_V2();
            result.Initialize(m_EPaperDisplayHardwareMock.Object);

            m_DataBuffer.Clear();

            result.WakeUp();

            var validBuffer = new List <byte>
            {
                (byte)Epd7In5b_V2Commands.BoosterSoftStart,
                0x17,
                0x17,
                0x27,
                0x17,
                (byte)Epd7In5b_V2Commands.PowerSetting,
                0x07,
                0x07,
                0x3f,
                0x3f,
                (byte)Epd7In5b_V2Commands.PowerOn,
                (byte)Epd7In5b_V2Commands.GetStatus,
                (byte)Epd7In5b_V2Commands.PanelSetting,
                0x0f,
                (byte)Epd7In5b_V2Commands.TconResolution,
                0x03,
                0x20,
                0x01,
                0xe0,
                (byte)Epd7In5b_V2Commands.DualSpi,
                0x00,
                (byte)Epd7In5b_V2Commands.VcomAndDataIntervalSetting,
                0x11,
                0x07,
                (byte)Epd7In5b_V2Commands.TconSetting,
                0x22,
                (byte)Epd7In5b_V2Commands.GateSourceStartSetting,
                0x00,
                0x00,
                0x00,
                0x00
            };

            Assert.IsTrue(m_DataBuffer.SequenceEqual(validBuffer), "Command Data Sequence is wrong");
        }
コード例 #7
0
        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");
        }
コード例 #8
0
        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}");
            }
        }
コード例 #9
0
 public void DisposeNoHardwareTest()
 {
     using var result = new Epd7In5b_V2();
     result.Initialize(m_EPaperDisplayHardwareMock.Object);
 }