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); }
/// <summary>Constructs a new instance.</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); this.pwm = GTI.PwmOutputFactory.Create(socket, Socket.Pin.Nine, false, this); this.playlist = new Queue(); this.syncRoot = new object(); }
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); } }