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 LightSense(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported('A', this); this.input = GTI.AnalogInputFactory.Create(socket, Socket.Pin.Three, this); }
/// <summary>Constructs a new instance.</summary> /// <param name="socketNumber">The socket that this module is plugged in to.</param> public CurrentACS712(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported('A', this); this.input = GTI.AnalogInputFactory.Create(socket, Socket.Pin.Five, this); }
/// <summary>Constructs a new instance.</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); this.input = GTI.AnalogInputFactory.Create(socket, Socket.Pin.Three, this); this.enable = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, false, this); }
/// <summary>Constructs a new instance.</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 = GTI.AnalogInputFactory.Create(socket, Socket.Pin.Three, this); this.center = GTI.AnalogInputFactory.Create(socket, Socket.Pin.Four, this); this.right = GTI.AnalogInputFactory.Create(socket, Socket.Pin.Five, this); this.centerSwitch = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Six, true, this); }
private double Read(GTI.AnalogInput input) { double total = 0; for (int i = 0; i < this.samples; i++) { total += input.ReadProportion(); } return(total / this.samples); }
// 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 AD8495Thermocouple(int socketNumber) { Offset = 0; // 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('A', this); _input = GTI.AnalogInputFactory.Create(socket, Socket.Pin.Four, this); }
/// <summary>Constructs a new instance.</summary> /// <param name="socketNumber">The mainboard socket that has the module plugged into it.</param> public Joystick(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported('A', this); this.inputX = GTI.AnalogInputFactory.Create(socket, Socket.Pin.Four, this); this.inputY = GTI.AnalogInputFactory.Create(socket, Socket.Pin.Five, this); this.input = GTI.InterruptInputFactory.Create(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.On, GTI.ResistorMode.PullUp, GTI.InterruptMode.RisingAndFallingEdge, this); this.input.Interrupt += (a, b) => this.OnJoystickEvent(this, b ? ButtonState.Released : ButtonState.Pressed); this.offsetX = 0; this.offsetY = 0; this.samples = 5; }