Esempio n. 1
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);
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs a new TouchC8 sensor.
        /// </summary>
        /// <param name="socketNumber">The socket number the sensor is plugged into.</param>
        public TouchC8(int socketNumber)
        {
            this.readBuffer    = new byte[1];
            this.writeBuffer   = new byte[2];
            this.addressBuffer = new byte[1];

            this.socket = GT.Socket.GetSocket(socketNumber, false, this, "I");

            this.reset = new GTI.DigitalOutput(this.socket, GT.Socket.Pin.Six, true, this);


            this.Reset();

            this.device = new GTI.I2CBus(this.socket, TouchC8.I2C_ADDRESS, TouchC8.I2C_CLOCK_RATE, this);

            this.interrupt            = new GTI.InterruptInput(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, GTI.InterruptMode.FallingEdge, this);
            this.interrupt.Interrupt += new GTI.InterruptInput.InterruptEventHandler(OnInterrupt);

            this.previousWheelDirection = (Direction)(-1);
            this.previousWheelPosition  = 0;
            this.previousWheelTouched   = false;
            this.previousButton1Touched = false;
            this.previousButton2Touched = false;
            this.previousButton3Touched = false;

            Thread.Sleep(250);

            this.ConfigureSPM();
        }
Esempio n. 3
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="baud">The baud rate to communicate with the module with.</param>
        public Bluetooth(int socketNumber, long baud)
        {
            // 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);

            this.reset      = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, this);
            this.statusInt  = new GTI.InterruptInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingAndFallingEdge, this);
            this.serialPort = new GTI.Serial(socket, 38400, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.One, 8, GTI.Serial.HardwareFlowControl.NotRequired, this);

            //this.statusInt.Interrupt += new GTI.InterruptInput.InterruptEventHandler(statusInt_Interrupt);
            this.serialPort.ReadTimeout = Timeout.Infinite;
            this.serialPort.Open();

            Thread.Sleep(5);
            this.reset.Write(true);

            // Poundy added:
            Thread.Sleep(5);
            this.SetDeviceBaud(baud);
            this.serialPort.Flush();
            this.serialPort.Close();
            this.serialPort.BaudRate = (int)baud;
            this.serialPort.Open();
            // Poundy

            readerThread = new Thread(new ThreadStart(runReaderThread));
            readerThread.Start();
            Thread.Sleep(500);
        }
Esempio n. 4
0
        /// <summary>Constructs a new RelayX1 instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public RelayX1(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this);

            this.enable = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);
        }
Esempio n. 5
0
        /// <summary>Constructor</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public DistanceUS3(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this);

            Echo    = new GTI.DigitalInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, this);
            Trigger = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);
        }
Esempio n. 6
0
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public ReflectorR3(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            this.left         = new GTI.AnalogInput(socket, Socket.Pin.Three, this);
            this.center       = new GTI.AnalogInput(socket, Socket.Pin.Four, this);
            this.right        = new GTI.AnalogInput(socket, Socket.Pin.Five, this);
            this.centerSwitch = new GTI.DigitalOutput(socket, Socket.Pin.Six, true, this);
        }
Esempio n. 7
0
 public Sim900Modem(int port, GTM.Display_HD44780 display)
 {
     this.display = display;
     socket = GT.Socket.GetSocket(port, true, null, null);
     powerPin = new GTI.DigitalOutput(socket, GT.Socket.Pin.Three, false, null);
     serial = new System.IO.Ports.SerialPort("COM2", 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
     serial.ReadTimeout = 1000;
     serial.Open();
     bufferd = new byte[32];
 }
Esempio n. 8
0
        /// <summary>Constructor</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public FLASH(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            statusLED = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);

            Initialize(socket);
        }
Esempio n. 9
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 LED7C(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this);

            m_RedPin   = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);
            m_BluePin  = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this);
            m_GreenPin = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);
        }
Esempio n. 10
0
        /// <summary>Constructor</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public GasSense(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('A', this);

            ain = new GTI.AnalogInput(socket, Socket.Pin.Three, this);

            heatingElementEnable = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);
        }
Esempio 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 Thermocouple(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this);

            _miso = new GTI.DigitalInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, this);
            _clk  = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);
            _cs   = new GTI.DigitalOutput(socket, Socket.Pin.Five, true, this);
        }
Esempio n. 12
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public KeypadKP16(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('Y', this);

            this.out1 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Three, true, null);
            this.out2 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Four, true, null);
            this.in1  = new GT.Interfaces.DigitalInput(socket, GT.Socket.Pin.Five, GT.Interfaces.GlitchFilterMode.Off, GT.Interfaces.ResistorMode.PullUp, null);
            this.in2  = new GT.Interfaces.DigitalInput(socket, GT.Socket.Pin.Six, GT.Interfaces.GlitchFilterMode.Off, GT.Interfaces.ResistorMode.PullUp, null);
            this.in3  = new GT.Interfaces.DigitalInput(socket, GT.Socket.Pin.Seven, GT.Interfaces.GlitchFilterMode.Off, GT.Interfaces.ResistorMode.PullUp, null);
            this.in4  = new GT.Interfaces.DigitalInput(socket, GT.Socket.Pin.Eight, GT.Interfaces.GlitchFilterMode.Off, GT.Interfaces.ResistorMode.PullUp, null);
        }
Esempio n. 13
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            _relay = extender.SetupDigitalOutput(Socket.Pin.Three, _relayState);

            var timer = new GT.Timer(1000);
            timer.Tick += timer1 =>
                              {
                                  _relayState = !_relayState;
                                  _relay.Write(_relayState);
                              };
            timer.Start();
        }
        // 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 ADC_Mux(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);

            addr0 = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, null);
            addr1 = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, null);

            this.analogA = new GTI.AnalogInput(socket, Socket.Pin.Four, this);
            this.analogB = new GTI.AnalogInput(socket, Socket.Pin.Five, this);
        }
Esempio n. 15
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 ColorSense(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this);

            LEDControl = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this);

            softwareI2C = new GTI.SoftwareI2C(socket, Socket.Pin.Five, Socket.Pin.Four, this);

            // Send COMMAND to access control register for chip power-up
            // Send to power-up chip
            softwareI2C.Write(colorAddress, new byte[] { 0x80, 0x03 });
        }
Esempio n. 16
0
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public LED7R(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('Y', this);

            for (int i = 0; i < leds.Length; i++)
            {
                leds[i] = new GTI.DigitalOutput(socket, Socket.Pin.Three + i, false, this);
            }
        }
Esempio n. 17
0
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public MotorDriverL298(int socketNumber)
        {
            this.Frequency = 25000;

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

            socket.EnsureTypeIsSupported(new char[] { 'P' }, this);

            m_Pwm1 = new GTI.PWMOutput(socket, Socket.Pin.Seven, false, this);
            m_Pwm2 = new GTI.PWMOutput(socket, Socket.Pin.Eight, false, this);

            m_Direction1 = new GTI.DigitalOutput(socket, Socket.Pin.Nine, false, this);
            m_Direction2 = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, this);

            m_Pwm1.Set(Frequency, 0);
            m_Pwm2.Set(Frequency, 0);
        }
Esempio n. 18
0
        ///// <summary>
        ///// Sets the backlight to the passed in value.
        ///// </summary>
        ///// <param name="bOn">Backlight state.</param>
        //public void SetEnable(bool bOn)
        //{
        //    if (blueSocket != null)
        //    {
        //        if (bOn)
        //        {
        //            enablePin.Write(true);
        //        }
        //        else
        //        {
        //            enablePin.Write(false);
        //        }
        //    }
        //    else
        //    {
        //        ErrorPrint("Cannot set enable pin yet. RGB sockets not yet initialized");
        //    }
        //}

        private void ReserveLCDPins(int rgbSocketNumber1, int rgbSocketNumber2, int rgbSocketNumber3)
        {
            bool gotR = false, gotG = false, gotB = false;

            Socket[] rgbSockets = new Socket[3] {
                Socket.GetSocket(rgbSocketNumber1, true, this, "rgbSocket1"), Socket.GetSocket(rgbSocketNumber2, true, this, "rgbSocket2"), Socket.GetSocket(rgbSocketNumber3, true, this, "rgbSocket3")
            };

            foreach (var rgbSocket in rgbSockets)
            {
                if (!gotR && rgbSocket.SupportsType('R'))
                {
                    gotR = true;
                }
                else if (!gotG && rgbSocket.SupportsType('G'))
                {
                    gotG = true;

                    greenSocket  = rgbSocket;
                    backlightPin = new GTI.DigitalOutput(greenSocket, Socket.Pin.Nine, true, this);
                }
                else if (!gotB && rgbSocket.SupportsType('B'))
                {
                    gotB = true;

                    //blueSocket = rgbSocket;
                    //enablePin = new OutputPort(blueSocket.CpuPins[8], true);
                }
                else
                {
                    throw new GT.Socket.InvalidSocketException("Socket " + rgbSocket + " is not an R, G or B socket, as required for the LCD module.");
                }

                rgbSocket.ReservePin(Socket.Pin.Three, this);
                rgbSocket.ReservePin(Socket.Pin.Four, this);
                rgbSocket.ReservePin(Socket.Pin.Five, this);
                rgbSocket.ReservePin(Socket.Pin.Six, this);
                rgbSocket.ReservePin(Socket.Pin.Seven, this);
                //rgbSocket.ReservePin(Socket.Pin.Eight, this);

                if (!rgbSocket.SupportsType('G'))
                {
                    rgbSocket.ReservePin(Socket.Pin.Nine, this);
                }
            }
        }
Esempio n. 19
0
        public RelayX1Plus(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this);

            this.enable = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);


            // Plus part
            this.input            = new GTI.InterruptInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.On, GTI.ResistorMode.PullUp, GTI.InterruptMode.RisingAndFallingEdge, null);
            this.input.Interrupt +=
                (i, v) =>
            {
                sensorState = this.input.Read();
            };
            sensorState = this.input.Read();
        }
Esempio n. 20
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 Load(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('Y', this);

            P1 = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this);
            P2 = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);
            P3 = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);
            P4 = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, this);
            P5 = new GTI.DigitalOutput(socket, Socket.Pin.Seven, false, this);
            P6 = new GTI.DigitalOutput(socket, Socket.Pin.Eight, false, this);
            P7 = new GTI.DigitalOutput(socket, Socket.Pin.Nine, false, this);
        }
Esempio n. 21
0
 private void SetSpeed(GTI.PWMOutput motor, GTI.DigitalOutput direction, int speed, bool isLeft)
 {
     if (speed == 0)
     {
         direction.Write(false);
         motor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, 0.01);
     }
     else if (speed < 0)
     {
         direction.Write(isLeft ? true : false);
         motor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, speed / -100.0);
     }
     else
     {
         direction.Write(isLeft ? false : true);
         motor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, speed / 100.0);
     }
 }
Esempio n. 22
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;
        }
Esempio n. 23
0
        /// <summary>
        /// Determines whether or not a given key is pressed.
        /// </summary>
        /// <param name="key">The key whose state we want to check.</param>
        /// <returns>Whether or not the key is pressed.</returns>
        public bool IsKeyPressed(Key key)
        {
            bool out1 = false;
            bool out2 = false;

            if (key == Key.One || key == Key.Four || key == Key.Seven || key == Key.Star)
            {
                out1 = false; out2 = false;
            }
            else if (key == Key.Two || key == Key.Five || key == Key.Eight || key == Key.Zero)
            {
                out1 = true; out2 = false;
            }
            else if (key == Key.Three || key == Key.Six || key == Key.Nine || key == Key.Pound)
            {
                out1 = false; out2 = true;
            }
            else if (key == Key.A || key == Key.B || key == Key.C || key == Key.D)
            {
                out1 = true; out2 = true;
            }

            this.out1.Write(out1);
            this.out2.Write(out2);

            if (key == Key.One || key == Key.Two || key == Key.Three || key == Key.A)
            {
                return(!this.in1.Read());
            }
            else if (key == Key.Four || key == Key.Five || key == Key.Six || key == Key.B)
            {
                return(!this.in2.Read());
            }
            else if (key == Key.Seven || key == Key.Eight || key == Key.Nine || key == Key.C)
            {
                return(!this.in3.Read());
            }
            else if (key == Key.Star || key == Key.Zero || key == Key.Pound || key == Key.D)
            {
                return(!this.in4.Read());
            }

            return(false);
        }
Esempio n. 24
0
        /// <summary>An FM radio module for Microsoft .NET Gadgeteer</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public RadioFM1(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported(new char[] { 'Y' }, this);

            this.resetPin = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);
            this.i2cBus   = new GTI.SoftwareI2C(socket, Socket.Pin.Eight, Socket.Pin.Nine, this);

            this.InitializeDevice();

            this.SetChannelConfiguration(Spacing.USAAustrailia, Band.USAEurope);

            this.Channel = this.MinChannel;
            this.Volume  = RadioFM1.MIN_VOLUME;

            this.radioTextWorkerThread = new Thread(this.RadioTextWorker);
            this.radioTextWorkerThread.Start();
        }
Esempio n. 25
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary>Constructor</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public RelayISOx16(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('Y', this);

            //Default on-state fix submitted by community member 'Lubos'
            data   = new GTI.DigitalOutput(socket, Socket.Pin.Seven, false, this);
            clock  = new GTI.DigitalOutput(socket, Socket.Pin.Nine, false, this);
            enable = new GTI.DigitalOutput(socket, Socket.Pin.Three, true, this); //Switching lines for enable and latch prevents default on state
            latch  = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);
            clear  = new GTI.DigitalOutput(socket, Socket.Pin.Four, true, this);

            DisableAllRelays();

            EnableRelay(0);

            EnableOutputs();
        }
Esempio n. 26
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();
        }
Esempio n. 27
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();
        }
        /// <summary>
        /// Creates a ControlRelays object connected to the specified socket number.
        /// </summary>
        /// <param name="socketNumber"></param>
        public ControlRelays(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)
            try
            {
                socket = Socket.GetSocket(socketNumber, true, this, "XY");
                relay1 = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this);
                relay2 = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);

                Relay1 = false;
                Relay2 = false;
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Creates a ControlRelays object connected to the specified socket number.
        /// </summary>
        /// <param name="socketNumber"></param>
        public ControlRelays(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)
            try
            {
                socket = Socket.GetSocket(socketNumber, true, this, "XY");
                relay1 = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, this);
                relay2 = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);

                Relay1 = false;
                Relay2 = false;
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 30
0
        void ProgramStarted()
        {
            /**
             * Iniciliza los modulos conectados con Gadgeteer
             */

            Socket10 = GT.Socket.GetSocket(10, true, null, null);

            vibrationControl = new GT.Interfaces.DigitalOutput(Socket10, GT.Socket.Pin.Four, false, null);

            analogPressureMeter = new GT.Interfaces.AnalogInput(Socket10, GT.Socket.Pin.Three, null);
            analogFlexorMeter   = new GT.Interfaces.AnalogInput(Socket10, GT.Socket.Pin.Five, null);


            matrix = new Adafruit_BicolorMatrix(Socket10);

            graphics = new Graphics(matrix);

            data_manager = new DataManager(sdCard, graphics);

            peripheral_manager = new PeripheralManager(graphics, vibrationControl, analogPressureMeter, analogFlexorMeter);

            /**
             * Determina un timer y una funcion que se ejecuta cada 100 millis
             */
            intervalTimer       = new GT.Timer(100);
            intervalTimer.Tick += new GT.Timer.TickEventHandler(TimerTick);
            intervalTimer.Start();

            /*
             * Se inicializan las variables
             **/

            is_being_pressed = false;
            pressed_times    = 0;

            cycles          = 0;
            vibrationCycles = 0;

            Debug.Print("Program Started!!");
        }
Esempio n. 31
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 Bluetooth(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);

            this.reset = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, this);
            this.statusInt = new GTI.InterruptInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingAndFallingEdge, this);
            this.serialPort = new Serial(socket, 38400, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.One, 8, GTI.Serial.HardwareFlowControl.NotRequired, this);

            //this.statusInt.Interrupt += new GTI.InterruptInput.InterruptEventHandler(statusInt_Interrupt);
            this.serialPort.ReadTimeout = Timeout.Infinite;
            this.serialPort.Open();

            Thread.Sleep(5);
            this.reset.Write(true);

            readerThread = new Thread(new ThreadStart(runReaderThread));
            readerThread.Start();
            Thread.Sleep(500);
        }
Esempio n. 32
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);
        }
Esempio n. 33
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);
        }
Esempio n. 34
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);
        }
Esempio n. 35
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();
        }
Esempio n. 36
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);
        }
Esempio n. 37
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);
        }