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);
        }
Exemple #2
0
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Tunes(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('P', this);

            tunePWM = new GTI.PWMOutput(socket, Socket.Pin.Nine, false, this);

            playList = new Melody();
        }
        /// <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);
        }
 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);
     }
 }
        // Initialises the tunes module to be on the given socket.
        public TunesModule(int socketNumber, DomainModel.Model model)
        {
            socket = GT.Socket.GetSocket(socketNumber, true, null, null);

            pwm = new GTI.PWMOutput(socket, GT.Socket.Pin.Nine, false, null);
        }