Exemplo n.º 1
0
        private void Initialize(GT.Socket socket)
        {
            spiConfig = new GTI.SPI.Configuration(false, 0, 0, false, true, 4000);
            spi       = new GTI.SPI(socket, spiConfig, GTI.SPI.Sharing.Shared, socket, Socket.Pin.Six, this);

            ClearBuffers();
        }
Exemplo n.º 2
0
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public EthernetENC28(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            _spi = new GTI.SPI(socket, null, GTI.SPI.Sharing.Exclusive, this);

            socket.ReservePin(Socket.Pin.Three, this);
            socket.ReservePin(Socket.Pin.Four, this);
            socket.ReservePin(Socket.Pin.Six, this);

            Interface = new GHINet.EthernetENC28J60(socket.SPIModule, socket.CpuPins[6], socket.CpuPins[3], socket.CpuPins[4], 1000);

            //if (!Interface.IsOpen)
            //{
            //    Interface.Open();
            //}

            //GHINet.NetworkInterfaceExtension.AssignNetworkingStackTo(Interface);

            //Thread.Sleep(500);

            //NetworkSettings = Interface.NetworkInterface;
        }
Exemplo n.º 3
0
        private void Initialize()
        {
            var spiSocket    = GT.Socket.GetSocket(10, true, null, null);
            var pwmSocket    = GT.Socket.GetSocket(11, true, null, null);
            var analogSocket = GT.Socket.GetSocket(12, true, null, null);

            this.forwardLEDs = new GTI.SPI(spiSocket, new GTI.SPI.Configuration(false, 0, 0, false, true, 2000), GTI.SPI.Sharing.Shared, spiSocket, GT.Socket.Pin.Six, null);
            this.leftIRLED   = new GTI.DigitalOutput(spiSocket, GT.Socket.Pin.Three, true, null);
            this.rightIRLED  = new GTI.DigitalOutput(spiSocket, GT.Socket.Pin.Four, true, null);

            this.leftMotorDirection  = new GTI.DigitalOutput(pwmSocket, GT.Socket.Pin.Three, false, null);
            this.rightMotorDirection = new GTI.DigitalOutput(pwmSocket, GT.Socket.Pin.Four, false, null);
            this.leftMotor           = new GTI.PWMOutput(pwmSocket, GT.Socket.Pin.Seven, false, null);
            this.rightMotor          = new GTI.PWMOutput(pwmSocket, GT.Socket.Pin.Eight, false, null);
            this.servo = new GTI.PWMOutput(pwmSocket, GT.Socket.Pin.Nine, false, null);

            this.buzzer         = new GTI.PWMOutput(analogSocket, GT.Socket.Pin.Seven, false, null);
            this.enableFaderPin = new GTI.PWMOutput(analogSocket, GT.Socket.Pin.Eight, true, null);
            this.leftSensor     = new GTI.AnalogInput(analogSocket, GT.Socket.Pin.Three, null);
            this.rightSensor    = new GTI.AnalogInput(analogSocket, GT.Socket.Pin.Four, null);

            this.leftMotor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, 0);
            this.rightMotor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, 0);

            this.enableFaderPin.Set(2000, 1.0);

            this.leftMotorInverted  = false;
            this.rightMotorInverted = false;
            this.servoConfigured    = false;

            this.SetLedBitmask(0x00);
        }
Exemplo n.º 4
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The mainboard socket that has the module plugged into it.</param>
        public WiFiRS21(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            // Since the Configuration parameter is null, this just reserves the pins and sets _spi.SPIModule but doesnt set up SPI (which the WiFi driver does itself)
            _spi = new GTI.SPI(socket, null, GTI.SPI.Sharing.Exclusive, this);

            // Make sure that the INT pin gets reserved. This is used internally by WiFi driver
            socket.ReservePin(Socket.Pin.Three, this);
            socket.ReservePin(Socket.Pin.Four, this);
            socket.ReservePin(Socket.Pin.Six, this);

            Interface = new GHINet.WiFiRS9110(socket.SPIModule, socket.CpuPins[6], socket.CpuPins[3], socket.CpuPins[4], 4000);
            //Interface = new GHINet.WiFiRS9110(Microsoft.SPOT.Hardware.SPI.SPI_module.SPI2, (Microsoft.SPOT.Hardware.Cpu.Pin)16, (Microsoft.SPOT.Hardware.Cpu.Pin)18, (Microsoft.SPOT.Hardware.Cpu.Pin)6, 4000);

            if (!Interface.IsOpen)
            {
                Interface.Open();
            }

            GHINet.NetworkInterfaceExtension.AssignNetworkingStackTo(Interface);

            Thread.Sleep(500);

            NetworkSettings = Interface.NetworkInterface;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes the module for the passed in clock rate and the length of the LED strip
        /// </summary>
        /// <param name="numLEDS">Number of LEDs to control. Default as provided with the module is 80 per strip.</param>
        /// <param name="spiClockRateKHZ">The SPI clock rate in KHz.</param>
        public void Initialize(int numLEDS = 80, uint spiClockRateKHZ = 1000)
        {
            _spiConfig = new GTI.SPI.Configuration(true, 0, 0, false, true, spiClockRateKHZ);

            _spi = new GTI.SPI(_socket, _spiConfig, GTI.SPI.Sharing.Shared, this);

            LEDs = new Color[numLEDS];

            for (int i = 0; i < LEDs.Length; i++)
            {
                LEDs[i] = new Color(0, 0, 0);
            }

            _zeros = new byte[3 * ((numLEDS + 63) / 64)];
        }
Exemplo n.º 6
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public MaxO(int socketNumber)
        {
            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            config = new GTI.SPI.Configuration(false, 0, 0, false, true, 1000);
            spi    = new GTI.SPI(socket, config, GTI.SPI.Sharing.Shared, socket, Socket.Pin.Five, this);

            Enable = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this);
            CLR    = new GTI.DigitalOutput(socket, Socket.Pin.Four, true, this);

            numBoards = 0;
        }
Exemplo n.º 7
0
        /// <summary>Constructs a new PulseCount instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public PulseCount(int socketNumber)
        {
            this.socket = Socket.GetSocket(socketNumber, true, this, null);

#if USE_SOFTWARE_SPI
            this.socket.EnsureTypeIsSupported('Y', this);

            this.CS    = new GTI.DigitalOutput(this.socket, Socket.Pin.Six, true, this);
            this.MISO  = new GTI.DigitalInput(this.socket, Socket.Pin.Eight, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, this);
            this.MOSI  = new GTI.DigitalOutput(this.socket, Socket.Pin.Seven, false, this);
            this.CLOCK = new GTI.DigitalOutput(this.socket, Socket.Pin.Nine, false, this);
#else
            socket.EnsureTypeIsSupported('S', this);

            this.config = new GTI.SPI.Configuration(false, 0, 0, false, true, 1000);
            this.spi    = new GTI.SPI(socket, this.config, GTI.SPI.Sharing.Shared, socket, GT.Socket.Pin.Six, this);
#endif

            this.Initialize();
        }
Exemplo n.º 8
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public StepperL6470(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            // Initialize SPI
            spiConfig = new GTI.SPI.Configuration(false, 1000, 1000, true, true, 5000);
            spi       = new GTI.SPI(socket, spiConfig, GTI.SPI.Sharing.Shared, socket, Socket.Pin.Six, this);

            // Initialize pins
            busyPin   = new GTI.DigitalInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, this);
            resetPin  = new GTI.DigitalOutput(socket, Socket.Pin.Four, true, this);
            stepClock = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);

            // Initialize chip registers
            InitializeChip();

            Reset();
        }
Exemplo n.º 9
0
        private uint spiSpeed = 8000; // kHz

        #endregion Fields

        #region Constructors

        //, int socketNumberTwo)
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        /// <param name="socketNumberTwo">The second socket that this module is plugged in to.</param>
        public DisplayS22(int socketNumber)
            : base(WPFRenderOptions.Intercept)
        {
            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            socket = Socket.GetSocket(socketNumber, true, this, null);
            socket.EnsureTypeIsSupported('S', this);

            socket.ReservePin(Socket.Pin.Three, this); // reset
            socket.ReservePin(Socket.Pin.Four, this); // back light
            socket.ReservePin(Socket.Pin.Five, this); // D/C
            socket.ReservePin(Socket.Pin.Six, this); // CS
            socket.ReservePin(Socket.Pin.Seven, this); // MOSI
            socket.ReservePin(Socket.Pin.Eight, this); // MISO
            socket.ReservePin(Socket.Pin.Nine, this); // SCK

            /*
             * Serial peripheral interface (SPI).
             * Pin 7 is MOSI line, pin 8 is MISO line, pin 9 is SCK line.
             * In addition, pins 3, 4 and 5 are general-purpose input/outputs, with pin 3 supporting interrupt capabilities.
            */

            pinReset = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this); // pin 3
            pinBacklight = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this); // pin 4
            pinDC = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this); // pin 5

            spiConfig = new GTI.SPI.Configuration(false, 0, 0, false, true, spiSpeed);
            //netMFSpiConfig = new SPI.Configuration(socket.CpuPins[6], spiConfig.ChipSelectActiveState, spiConfig.ChipSelectSetupTime, spiConfig.ChipSelectHoldTime, spiConfig.ClockIdleState, spiConfig.ClockEdge, spiConfig.ClockRateKHz, socket.SPIModule);
            spi = new GTI.SPI(socket, spiConfig, GTI.SPI.Sharing.Shared, socket, Socket.Pin.Six, this);

            Reset();
            ConfigureDisplay();
            Clear();
            SetBacklight(true);
        }
Exemplo n.º 10
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        /// <param name="socketNumberTwo">The second socket that this module is plugged in to.</param>
        public DisplayS22(int socketNumber)//, int socketNumberTwo)
            : base(WPFRenderOptions.Intercept)
        {
            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            socket = Socket.GetSocket(socketNumber, true, this, null);
            socket.EnsureTypeIsSupported('S', this);

            socket.ReservePin(Socket.Pin.Three, this); // reset
            socket.ReservePin(Socket.Pin.Four, this);  // back light
            socket.ReservePin(Socket.Pin.Five, this);  // D/C
            socket.ReservePin(Socket.Pin.Six, this);   // CS
            socket.ReservePin(Socket.Pin.Seven, this); // MOSI
            socket.ReservePin(Socket.Pin.Eight, this); // MISO
            socket.ReservePin(Socket.Pin.Nine, this);  // SCK

            /*
             * Serial peripheral interface (SPI).
             * Pin 7 is MOSI line, pin 8 is MISO line, pin 9 is SCK line.
             * In addition, pins 3, 4 and 5 are general-purpose input/outputs, with pin 3 supporting interrupt capabilities.
             */

            pinReset     = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this); // pin 3
            pinBacklight = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);  // pin 4
            pinDC        = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);  // pin 5

            spiConfig      = new GTI.SPI.Configuration(false, 0, 0, false, true, spiSpeed);
            netMFSpiConfig = new SPI.Configuration(socket.CpuPins[6], spiConfig.ChipSelectActiveState, spiConfig.ChipSelectSetupTime, spiConfig.ChipSelectHoldTime, spiConfig.ClockIdleState, spiConfig.ClockEdge, spiConfig.ClockRateKHz, socket.SPIModule);
            spi            = new GTI.SPI(socket, spiConfig, GTI.SPI.Sharing.Shared, socket, Socket.Pin.Six, this);

            Reset();
            ConfigureDisplay();
            Clear();
            SetBacklight(true);
        }
Exemplo n.º 11
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public NRF24(int socketNumber)
        {
            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            socket = Socket.GetSocket(socketNumber, true, this, null);
            socket.EnsureTypeIsSupported('S', this);

            socket.ReservePin(Socket.Pin.Three, this); // IRQ
            socket.ReservePin(Socket.Pin.Five, this); // CSN
            socket.ReservePin(Socket.Pin.Six, this); // CE
            socket.ReservePin(Socket.Pin.Seven, this); // MOSI
            socket.ReservePin(Socket.Pin.Eight, this); // MISO
            socket.ReservePin(Socket.Pin.Nine, this); // SCK

            GTI.SPI.Configuration spiConfig = new GTI.SPI.Configuration(false, 0, 0, false, true, spiSpeed);
            spi = new GTI.SPI(socket, spiConfig, GTI.SPI.Sharing.Shared, socket, pinCSN, this);

            pinCE = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, this); // pin 6
            pinIRQ = new GTI.InterruptInput(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, GTI.InterruptMode.FallingEdge, this);
            pinIRQ.Interrupt += new GTI.InterruptInput.InterruptEventHandler(pinIRQ_Interrupt);

            // Must allow the radio time to settle else configuration bits will not necessarily stick.
            // This is actually only required following power up but some settling time also appears to
            // be required after resets too. For full coverage, we'll always assume the worst.
            // Enabling 16b CRC is by far the most obvious case if the wrong timing is used - or skipped.
            // Technically we require 4.5ms + 14us as a worst case. We'll just call it 5ms for good measure.
            // WARNING: Delay is based on P-variant whereby non-P *may* require different timing.
            //Thread.Sleep(5);
            Thread.Sleep(100);

            IsEnabled = false;

            Initialize();
        }
Exemplo n.º 12
0
        /// <summary>Constructor</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public DisplayN18(int socketNumber) : base(WPFRenderOptions.Intercept)
        {
            this.byteArray  = new byte[1];
            this.shortArray = new ushort[2];

            this.socket = Socket.GetSocket(socketNumber, true, this, null);
            this.socket.EnsureTypeIsSupported('S', this);

            this.resetPin     = new GTI.DigitalOutput(this.socket, Socket.Pin.Three, false, this);
            this.backlightPin = new GTI.DigitalOutput(this.socket, Socket.Pin.Four, false, this);
            this.rs           = new GTI.DigitalOutput(this.socket, Socket.Pin.Five, false, this);

            this.spiConfig      = new GTI.SPI.Configuration(false, 0, 0, false, true, 12000);
            this.netMFSpiConfig = new SPI.Configuration(this.socket.CpuPins[6], this.spiConfig.ChipSelectActiveState, this.spiConfig.ChipSelectSetupTime, this.spiConfig.ChipSelectHoldTime, this.spiConfig.ClockIdleState, this.spiConfig.ClockEdge, this.spiConfig.ClockRateKHz, this.socket.SPIModule);
            this.spi            = new GTI.SPI(this.socket, this.spiConfig, GTI.SPI.Sharing.Shared, this.socket, Socket.Pin.Six, this);

            this.Reset();

            this.ConfigureDisplay();

            this.Clear();

            this.SetBacklight(true);
        }
Exemplo n.º 13
0
        /// <summary>Constructor</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Display(ModelType model, int socketNumber)
            : base(WPFRenderOptions.Intercept)
        {
            #region UTFT
            ushort[] dsx = {239, 239, 239, 239, 239, 239, 175, 175, 239, 127, 127, 239, 271, 479, 239, 239, 239, 239, 239, 239, 479, 319, 239, 175, 127, 239, 239, 319, 319};
            ushort[] dsy = {319, 399, 319, 319, 319, 319, 219, 219, 399, 159, 127, 319, 479, 799, 319, 319, 319, 319, 319, 319, 799, 479, 319, 219, 159, 319, 319, 479, 479};
            byte[] dtm = { 16, 16, 16, 8, 8, 16, 8, (byte)DisplayTransferMode.SERIAL_4PIN, 16, (byte)DisplayTransferMode.SERIAL_5PIN, (byte)DisplayTransferMode.SERIAL_5PIN, 16, 16, 16, 8, 16, (byte)DisplayTransferMode.LATCHED_16, 8, 16, 8, 16, 16, 16, 8, (byte)DisplayTransferMode.SERIAL_5PIN, (byte)DisplayTransferMode.SERIAL_5PIN, (byte)DisplayTransferMode.SERIAL_4PIN, 16, 16 };

            disp_x_size = dsx[(byte)model];
            disp_y_size = dsy[(byte)model];
            display_transfer_mode = dtm[(byte)model];
            display_model = (byte)model;

            if (display_transfer_mode == (byte)DisplayTransferMode.SERIAL_4PIN)
            {
                display_transfer_mode = 1;
                display_serial_mode = (byte)DisplayTransferMode.SERIAL_4PIN;
            }
            if (display_transfer_mode == (byte)DisplayTransferMode.SERIAL_5PIN)
            {
                display_transfer_mode = 1;
                display_serial_mode = (byte)DisplayTransferMode.SERIAL_5PIN;
            }

            if (display_transfer_mode != 1)
            {
                //_set_direction_registers(display_transfer_mode);
                //P_RS = portOutputRegister(digitalPinToPort(RS));
                //B_RS = digitalPinToBitMask(RS);
                //P_WR = portOutputRegister(digitalPinToPort(WR));
                //B_WR = digitalPinToBitMask(WR);
                //P_CS = portOutputRegister(digitalPinToPort(CS));
                //B_CS = digitalPinToBitMask(CS);
                //P_RST = portOutputRegister(digitalPinToPort(RST));
                //B_RST = digitalPinToBitMask(RST);
                //if (display_transfer_mode == LATCHED_16)
                //{
                //    P_ALE = portOutputRegister(digitalPinToPort(SER));
                //    B_ALE = digitalPinToBitMask(SER);
                //    pinMode(SER, OUTPUT);
                //    cbi(P_ALE, B_ALE);
                //    pinMode(8, OUTPUT);
                //    digitalWrite(8, LOW);
                //}
                //pinMode(RS, OUTPUT);
                //pinMode(WR, OUTPUT);
                //pinMode(CS, OUTPUT);
                //pinMode(RST, OUTPUT);
            }
            else
            {
                //P_SDA = portOutputRegister(digitalPinToPort(RS));
                //B_SDA = digitalPinToBitMask(RS);
                //P_SCL = portOutputRegister(digitalPinToPort(WR));
                //B_SCL = digitalPinToBitMask(WR);
                //P_CS = portOutputRegister(digitalPinToPort(CS));
                //B_CS = digitalPinToBitMask(CS);
                //P_RST = portOutputRegister(digitalPinToPort(RST));
                //B_RST = digitalPinToBitMask(RST);
                //if (display_serial_mode != SERIAL_4PIN)
                //{
                //    P_RS = portOutputRegister(digitalPinToPort(SER));
                //    B_RS = digitalPinToBitMask(SER);
                //    pinMode(SER, OUTPUT);
                //}
                //pinMode(RS, OUTPUT);
                //pinMode(WR, OUTPUT);
                //pinMode(CS, OUTPUT);
                //pinMode(RST, OUTPUT);
            }
            #endregion

            socket = Socket.GetSocket(socketNumber, true, this, null);
            socket.EnsureTypeIsSupported('S', this);
            /*
             * Serial peripheral interface (SPI).
             * Pin 7 is MOSI line, pin 8 is MISO line, pin 9 is SCK line.
             * In addition, pins 3, 4 and 5 are general-purpose input/outputs, with pin 3 supporting interrupt capabilities.
            */

            pinReset = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this); // pin 3
            pinBacklight = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this); // pin 4
            pinDc = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this); // pin 5

            spiConfig = new GTI.SPI.Configuration(false, 0, 0, false, true, 12000);
            netMFSpiConfig = new SPI.Configuration(socket.CpuPins[6], spiConfig.ChipSelectActiveState, spiConfig.ChipSelectSetupTime, spiConfig.ChipSelectHoldTime, spiConfig.ClockIdleState, spiConfig.ClockEdge, spiConfig.ClockRateKHz, socket.SPIModule);
            spi = new GTI.SPI(socket, spiConfig, GTI.SPI.Sharing.Shared, socket, Socket.Pin.Six, this);

            Reset();
            ConfigureDisplay();
            Clear();
            SetBacklight(true);
        }
Exemplo n.º 14
0
        /// <summary>Constructor</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Display(ModelType model, int socketNumber)
            : base(WPFRenderOptions.Intercept)
        {
            #region UTFT
            ushort[] dsx = { 239, 239, 239, 239, 239, 239, 175, 175, 239, 127, 127, 239, 271, 479, 239, 239, 239, 239, 239, 239, 479, 319, 239, 175, 127, 239, 239, 319, 319 };
            ushort[] dsy = { 319, 399, 319, 319, 319, 319, 219, 219, 399, 159, 127, 319, 479, 799, 319, 319, 319, 319, 319, 319, 799, 479, 319, 219, 159, 319, 319, 479, 479 };
            byte[]   dtm = { 16, 16, 16, 8, 8, 16, 8, (byte)DisplayTransferMode.SERIAL_4PIN, 16, (byte)DisplayTransferMode.SERIAL_5PIN, (byte)DisplayTransferMode.SERIAL_5PIN, 16, 16, 16, 8, 16, (byte)DisplayTransferMode.LATCHED_16, 8, 16, 8, 16, 16, 16, 8, (byte)DisplayTransferMode.SERIAL_5PIN, (byte)DisplayTransferMode.SERIAL_5PIN, (byte)DisplayTransferMode.SERIAL_4PIN, 16, 16 };

            disp_x_size           = dsx[(byte)model];
            disp_y_size           = dsy[(byte)model];
            display_transfer_mode = dtm[(byte)model];
            display_model         = (byte)model;

            if (display_transfer_mode == (byte)DisplayTransferMode.SERIAL_4PIN)
            {
                display_transfer_mode = 1;
                display_serial_mode   = (byte)DisplayTransferMode.SERIAL_4PIN;
            }
            if (display_transfer_mode == (byte)DisplayTransferMode.SERIAL_5PIN)
            {
                display_transfer_mode = 1;
                display_serial_mode   = (byte)DisplayTransferMode.SERIAL_5PIN;
            }

            if (display_transfer_mode != 1)
            {
                //_set_direction_registers(display_transfer_mode);
                //P_RS = portOutputRegister(digitalPinToPort(RS));
                //B_RS = digitalPinToBitMask(RS);
                //P_WR = portOutputRegister(digitalPinToPort(WR));
                //B_WR = digitalPinToBitMask(WR);
                //P_CS = portOutputRegister(digitalPinToPort(CS));
                //B_CS = digitalPinToBitMask(CS);
                //P_RST = portOutputRegister(digitalPinToPort(RST));
                //B_RST = digitalPinToBitMask(RST);
                //if (display_transfer_mode == LATCHED_16)
                //{
                //    P_ALE = portOutputRegister(digitalPinToPort(SER));
                //    B_ALE = digitalPinToBitMask(SER);
                //    pinMode(SER, OUTPUT);
                //    cbi(P_ALE, B_ALE);
                //    pinMode(8, OUTPUT);
                //    digitalWrite(8, LOW);
                //}
                //pinMode(RS, OUTPUT);
                //pinMode(WR, OUTPUT);
                //pinMode(CS, OUTPUT);
                //pinMode(RST, OUTPUT);
            }
            else
            {
                //P_SDA = portOutputRegister(digitalPinToPort(RS));
                //B_SDA = digitalPinToBitMask(RS);
                //P_SCL = portOutputRegister(digitalPinToPort(WR));
                //B_SCL = digitalPinToBitMask(WR);
                //P_CS = portOutputRegister(digitalPinToPort(CS));
                //B_CS = digitalPinToBitMask(CS);
                //P_RST = portOutputRegister(digitalPinToPort(RST));
                //B_RST = digitalPinToBitMask(RST);
                //if (display_serial_mode != SERIAL_4PIN)
                //{
                //    P_RS = portOutputRegister(digitalPinToPort(SER));
                //    B_RS = digitalPinToBitMask(SER);
                //    pinMode(SER, OUTPUT);
                //}
                //pinMode(RS, OUTPUT);
                //pinMode(WR, OUTPUT);
                //pinMode(CS, OUTPUT);
                //pinMode(RST, OUTPUT);
            }
            #endregion

            socket = Socket.GetSocket(socketNumber, true, this, null);
            socket.EnsureTypeIsSupported('S', this);

            /*
             * Serial peripheral interface (SPI).
             * Pin 7 is MOSI line, pin 8 is MISO line, pin 9 is SCK line.
             * In addition, pins 3, 4 and 5 are general-purpose input/outputs, with pin 3 supporting interrupt capabilities.
             */

            pinReset     = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this); // pin 3
            pinBacklight = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);  // pin 4
            pinDc        = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);  // pin 5

            spiConfig      = new GTI.SPI.Configuration(false, 0, 0, false, true, 12000);
            netMFSpiConfig = new SPI.Configuration(socket.CpuPins[6], spiConfig.ChipSelectActiveState, spiConfig.ChipSelectSetupTime, spiConfig.ChipSelectHoldTime, spiConfig.ClockIdleState, spiConfig.ClockEdge, spiConfig.ClockRateKHz, socket.SPIModule);
            spi            = new GTI.SPI(socket, spiConfig, GTI.SPI.Sharing.Shared, socket, Socket.Pin.Six, this);

            Reset();
            ConfigureDisplay();
            Clear();
            SetBacklight(true);
        }