예제 #1
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public DisplayN18(int socketNumber)
            : base(WpfMode.Separate)
        {
            this.byteArray  = new byte[1];
            this.shortArray = new ushort[2];
            this.isBgr      = true;

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

            this.resetPin     = GTI.DigitalOutputFactory.Create(this.socket, Socket.Pin.Three, false, this);
            this.backlightPin = GTI.DigitalOutputFactory.Create(this.socket, Socket.Pin.Four, true, this);
            this.rsPin        = GTI.DigitalOutputFactory.Create(this.socket, Socket.Pin.Five, false, this);

            this.spiConfig      = new GTI.SpiConfiguration(false, 0, 0, false, true, 12000);
            this.netMFSpiConfig = new SPI.Configuration(this.socket.CpuPins[6], this.spiConfig.IsChipSelectActiveHigh, this.spiConfig.ChipSelectSetupTime, this.spiConfig.ChipSelectHoldTime, this.spiConfig.IsClockIdleHigh, this.spiConfig.IsClockSamplingEdgeRising, this.spiConfig.ClockRateKHz, this.socket.SPIModule);
            this.spi            = GTI.SpiFactory.Create(this.socket, this.spiConfig, GTI.SpiSharing.Shared, this.socket, Socket.Pin.Six, this);

            this.Reset();

            this.ConfigureDisplay();

            base.OnDisplayConnected("Display N18", 128, 160, DisplayOrientation.Normal, null);

            this.Clear();
        }
예제 #2
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 = GTI.SpiFactory.Create(spiSocket, new GTI.SpiConfiguration(false, 0, 0, false, true, 2000), GTI.SpiSharing.Shared, spiSocket, GT.Socket.Pin.Six, null);
            this.leftIRLED   = GTI.DigitalOutputFactory.Create(spiSocket, GT.Socket.Pin.Three, true, null);
            this.rightIRLED  = GTI.DigitalOutputFactory.Create(spiSocket, GT.Socket.Pin.Four, true, null);

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

            this.buzzer         = GTI.PwmOutputFactory.Create(analogSocket, GT.Socket.Pin.Seven, false, null);
            this.enableFaderPin = GTI.PwmOutputFactory.Create(analogSocket, GT.Socket.Pin.Eight, true, null);
            this.leftSensor     = GTI.AnalogInputFactory.Create(analogSocket, GT.Socket.Pin.Three, null);
            this.rightSensor    = GTI.AnalogInputFactory.Create(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);
        }
예제 #3
0
        /// <summary>Constructs a new instance.</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);

            this.statusLED = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, false, this);
            this.spi       = GTI.SpiFactory.Create(socket, new GTI.SpiConfiguration(false, 0, 0, false, true, 4000), GTI.SpiSharing.Shared, socket, Socket.Pin.Six, this);
        }
예제 #4
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public FEZtive(int socketNumber)
        {
            var socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            this.spi    = GTI.SpiFactory.Create(socket, new GTI.SpiConfiguration(true, 0, 0, false, true, 1000), GTI.SpiSharing.Shared, socket, Socket.Pin.Six, this);
            this.leds   = null;
            this.zeroes = null;
        }
예제 #5
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public MaxO(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            this.spi    = GTI.SpiFactory.Create(socket, new GTI.SpiConfiguration(false, 0, 0, false, true, 1000), GTI.SpiSharing.Shared, socket, Socket.Pin.Five, this);
            this.enable = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, false, this);
            this.clr    = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, true, this);
            this.boards = 0;
            this.data   = null;
        }
예제 #6
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public WiFiRS21(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

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

            this.spi = GTI.SpiFactory.Create(socket, null, GTI.SpiSharing.Exclusive, socket, Socket.Pin.Six, this);
            this.networkInterface = new WiFiRS9110(socket.SPIModule, socket.CpuPins[6], socket.CpuPins[3], socket.CpuPins[4], 4000);

            this.NetworkSettings = this.networkInterface.NetworkInterface;
        }
예제 #7
0
        /// <summary>Constructs a new instance.</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);

            this.spi       = GTI.SpiFactory.Create(socket, new GTI.SpiConfiguration(false, 1000, 1000, true, true, 5000), GTI.SpiSharing.Shared, socket, Socket.Pin.Six, this);
            this.busyPin   = GTI.DigitalInputFactory.Create(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, this);
            this.resetPin  = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, true, this);
            this.stepClock = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, false, this);

            this.send    = new byte[1];
            this.receive = new byte[1];

            this.InitializeChip();

            this.Reset();
        }
예제 #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>
        /// <param name="socketNumberTwo">The second socket that this module is plugged in to.</param>
        public CerbotController()
        {
            this.buzzer = new PWM(Cpu.PWMChannel.PWM_0, 1000, 0, false);

            this.leftSensor  = new AnalogInput((Cpu.AnalogChannel) 8);
            this.rightSensor = new AnalogInput(Cpu.AnalogChannel.ANALOG_6);
            this.leftIRLED   = new OutputPort(Generic.GetPin('B', 13), true);
            this.rightIRLED  = new OutputPort(Generic.GetPin('B', 14), true);

            this.leftInverted        = false;
            this.rightInverted       = false;
            this.leftMotor           = new PWM(Cpu.PWMChannel.PWM_4, CerbotController.MOTOR_BASE_FREQUENCY, 0, false);
            this.rightMotor          = new PWM(Cpu.PWMChannel.PWM_5, CerbotController.MOTOR_BASE_FREQUENCY, 0, false);
            this.leftMotorDirection  = new OutputPort(Generic.GetPin('A', 6), false);
            this.rightMotorDirection = new OutputPort(Generic.GetPin('C', 4), false);

            this.servo = new PWM(Cpu.PWMChannel.PWM_1, 20000, this.servoMinPulse, PWM.ScaleFactor.Microseconds, false);

            this.servoConfigured = false;

            var spiSocket  = GT.Socket.GetSocket(3, true, null, null);
            var tempSocket = GT.Socket.SocketInterfaces.CreateNumberedSocket(10);

            tempSocket.SupportedTypes = new char[] { 'S' };
            tempSocket.CpuPins[3]     = Generic.GetPin('B', 2);
            tempSocket.CpuPins[4]     = Generic.GetPin('B', 2);
            tempSocket.CpuPins[5]     = Generic.GetPin('B', 2);
            tempSocket.CpuPins[6]     = Generic.GetPin('B', 2);
            tempSocket.CpuPins[7]     = spiSocket.CpuPins[7];
            tempSocket.CpuPins[8]     = spiSocket.CpuPins[8];
            tempSocket.CpuPins[9]     = spiSocket.CpuPins[9];
            tempSocket.SPIModule      = spiSocket.SPIModule;
            GT.Socket.SocketInterfaces.RegisterSocket(tempSocket);

            this.spiConfig   = new GTI.SpiConfiguration(false, 0, 0, false, true, 2000);
            this.forwardLEDs = GTI.SpiFactory.Create(tempSocket, this.spiConfig, GTI.SpiSharing.Shared, tempSocket, Socket.Pin.Six, null);

            this.enableFaderPin = new PWM((Cpu.PWMChannel) 13, 500, 500, PWM.ScaleFactor.Microseconds, true);
            this.enableFaderPin.Start();
            this.SetLEDBitmask(0x0);
        }
예제 #9
0
        /// <summary>
        ///   Initializes SPI connection and control pins
        ///   <param name="irqPin"> IRQ pin as a Socket.Pin
        ///   <param name="cePin"> Chip Enable(CE) pin as a Socket.Pin
        ///   <param name="irqPin"> Chip Select Not(CSN or CS\) pin as a Socket.Pin
        ///   <param name="spiClockRateKHZ"> Clock rate in KHz (i.e. 1000 = 1MHz)
        /// </summary>
        public void Initialize(Socket.Pin irqPin, Socket.Pin csPin, byte config, uint spiClockRateKHZ = 1000)
        {
            _spiConfig = new GTI.SpiConfiguration(false, 0, 0, false, false, spiClockRateKHZ);

            // Chip Select : Active Low
            // Clock : Active High, Data clocked in on rising edge
            //_socket = GTS.GetSocket(6, false, this, null);
            _spi = GTI.SpiFactory.Create(_socket, _spiConfig, GTI.SpiSharing.Shared, _socket, csPin, this);

            // Initialize Chip Enable Port
            _csPin = GTI.DigitalOutputFactory.Create(_socket, Socket.Pin.Four, true, this);

//            _irqPin = GTI.InterruptInputFactory.Create(_socket, irqPin, GTI.GlitchFilterMode.On, GTI.ResistorMode.PullUp, GTI.InterruptMode.FallingEdge, this);
            _irqPin            = GTI.InterruptInputFactory.Create(_socket, irqPin, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, GTI.InterruptMode.FallingEdge, this);
            _irqPin.Interrupt += _irqPin_Interrupt;
            _initialized       = true;

            _config = config;

            ResetConfig();
        }
예제 #10
0
파일: DisplayS22_43.cs 프로젝트: radtek/MFE
        // 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(DisplayModule.WpfMode.Separate)
        {
            // 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     = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, false, this); // pin 3
            pinBacklight = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, false, this);  // pin 4
            pinDC        = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, false, this);  // pin 5

            spiConfig      = new GTI.SpiConfiguration(false, 0, 0, false, true, spiSpeed);
            netMFSpiConfig = new SPI.Configuration(socket.CpuPins[6], spiConfig.IsChipSelectActiveHigh, spiConfig.ChipSelectSetupTime, spiConfig.ChipSelectHoldTime, spiConfig.IsClockIdleHigh, spiConfig.IsClockSamplingEdgeRising, spiConfig.ClockRateKHz, socket.SPIModule);
            spi            = GTI.SpiFactory.Create(socket, spiConfig, GTI.SpiSharing.Shared, socket, Socket.Pin.Six, this);

            Reset();
            ConfigureDisplay();
            Clear();
            SetBacklight(true);
        }
예제 #11
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(DisplayModule.WpfMode.Separate)
        {
            // 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 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, false, this); // pin 3
            pinBacklight = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, false, this); // pin 4
            pinDC = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, false, this); // pin 5

            spiConfig = new GTI.SpiConfiguration(false, 0, 0, false, true, spiSpeed);
            netMFSpiConfig = new SPI.Configuration(socket.CpuPins[6], spiConfig.IsChipSelectActiveHigh, spiConfig.ChipSelectSetupTime, spiConfig.ChipSelectHoldTime, spiConfig.IsClockIdleHigh, spiConfig.IsClockSamplingEdgeRising, spiConfig.ClockRateKHz, socket.SPIModule);
            spi = GTI.SpiFactory.Create(socket, spiConfig, GTI.SpiSharing.Shared, socket, Socket.Pin.Six, this);

            Reset();
            ConfigureDisplay();
            Clear();
            SetBacklight(true);
        }
        // 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 LightningDetectorSPI(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)
            var socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            _socket = socket;

            socket.ReservePin(Socket.Pin.Three, this);
            socket.ReservePin(Socket.Pin.Six, this);
            socket.ReservePin(Socket.Pin.Seven, this);
            socket.ReservePin(Socket.Pin.Eight, this);
            socket.ReservePin(Socket.Pin.Nine, this);

            // from as3935 datasheet Chip Select (active low)
            // data are sampled on the falling edge of SCLK (CPHA=1)

            spiConfig = new GTI.SpiConfiguration(false, 0, 0, false, false, 2000);

            spi = GTI.SpiFactory.Create(socket, spiConfig, GTI.SpiSharing.Exclusive, socket, Socket.Pin.Six, this);

            Initialize();
        }
예제 #13
0
        /// <summary>
        ///   Initializes SPI connection and control pins
        ///   <param name="irqPin"> IRQ pin as a Socket.Pin
        ///   <param name="cePin"> Chip Enable(CE) pin as a Socket.Pin
        ///   <param name="irqPin"> Chip Select Not(CSN or CS\) pin as a Socket.Pin
        ///   <param name="spiClockRateKHZ"> Clock rate in KHz (i.e. 1000 = 1MHz)
        /// </summary>
        public void Initialize(Socket.Pin irqPin, Socket.Pin csPin, byte config, uint spiClockRateKHZ = 1000)
        {
            _spiConfig = new GTI.SpiConfiguration(false, 0, 0, false, false, spiClockRateKHZ);

            // Chip Select : Active Low
            // Clock : Active High, Data clocked in on rising edge
            //_socket = GTS.GetSocket(6, false, this, null);
            _spi = GTI.SpiFactory.Create(_socket, _spiConfig, GTI.SpiSharing.Shared, _socket, csPin, this);

            // Initialize Chip Enable Port
            _csPin = GTI.DigitalOutputFactory.Create(_socket, Socket.Pin.Four, true, this);

            //            _irqPin = GTI.InterruptInputFactory.Create(_socket, irqPin, GTI.GlitchFilterMode.On, GTI.ResistorMode.PullUp, GTI.InterruptMode.FallingEdge, this);
            _irqPin = GTI.InterruptInputFactory.Create(_socket, irqPin, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, GTI.InterruptMode.FallingEdge, this);
            _irqPin.Interrupt += _irqPin_Interrupt;
            _initialized = true;

            _config = config;

            ResetConfig();
        }