Esempio n. 1
0
        private async Task InitDisplayAsync()
        {
            // Allocate buffers
            var bytesPerPixel = GraphicsTools.GetBitsPerPixel(pixelFormat) / 8;

            displayBuffer = new byte[Width * Height * bytesPerPixel];
            // displayBuffer = new byte[Width * Height * 3];

            // Hardware Reset
            resetPin.Write(GpioPinValue.High);
            await Task.Delay(500);

            resetPin.Write(GpioPinValue.Low);
            await Task.Delay(500);

            resetPin.Write(GpioPinValue.High);
            await Task.Delay(500);

            // Which display type?
            switch (displayType)
            {
            case ST7735DisplayType.B:
                await InitDisplayBAsync();

                break;

            case ST7735DisplayType.R:
            case ST7735DisplayType.RBlack:
            case ST7735DisplayType.RGreen:
            case ST7735DisplayType.RGreen144:
            case ST7735DisplayType.RRed:
                await InitDisplayRAsync();

                break;

            default:
                throw new InvalidOperationException(string.Format(Strings.UnknownDisplayType, displayType));
            }

            // Breathe
            await Task.Delay(10);

            // If the orientation is not portrait we need to update orientation
            if (orientation != DisplayOrientations.Portrait)
            {
                // Set orientation, do not flip
                // Note, this also reverts to RAM mode when done
                SetOrientation(false);
            }

            // Set address window to full size of the display
            // Note, this also reverts to RAM mode when done
            SetAddressWindow(0, 0, (byte)(width - 1), (byte)(height - 1));
        }