// 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 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Six, false, this); this.statusInt = GTI.InterruptInputFactory.Create(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingAndFallingEdge, this); this.serialPort = GTI.SerialFactory.Create(socket, 38400, GTI.SerialParity.None, GTI.SerialStopBits.One, 8, GTI.HardwareFlowControl.NotRequired, this); //this.statusInt.Interrupt += GTI.InterruptInputFactory.Create.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); }
/// <summary>Constructs a new instance.</summary> /// <param name="socketNumber">The socket that this module is plugged in to.</param> public RadioFM1(int socketNumber) { this.radioTextWorkerRunning = true; this.currentRadioText = "N/A"; this.spacingDivisor = 2; this.baseChannel = 875; this.registers = new ushort[16]; Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported(new char[] { 'Y' }, this); this.resetPin = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, false, this); this.i2cBus = new GTI.SoftwareI2CBus(socket, Socket.Pin.Eight, Socket.Pin.Nine, RadioFM1.I2C_ADDRESS, 100, this); this.i2cBus.LengthErrorBehavior = GTI.ErrorBehavior.ThrowException; 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(); }
/// <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(); }
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 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 = GTI.DigitalOutputFactory.Create(this.socket, GT.Socket.Pin.Six, true, this); this.Reset(); this.device = GTI.I2CBusFactory.Create(this.socket, TouchC8.I2C_ADDRESS, TouchC8.I2C_CLOCK_RATE, this); this.interrupt = GTI.InterruptInputFactory.Create(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, GTI.InterruptMode.FallingEdge, this); this.interrupt.Interrupt += this.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(); }
/// <summary>Constructs a new 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 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, 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); }
/// <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); }
/// <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>Constructor</summary> /// <param name="socketNumber">The socket that this module is plugged in to.</param> public Distance_US3(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this); Echo = GTI.DigitalInputFactory.Create(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, this); Trigger = 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 LED7C(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this); this.red = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, false, this); this.blue = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, false, this); this.green = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, false, this); }
/// <summary>Constructs a new instance.</summary> /// <param name="socketNumber">The socket that this module is plugged in to.</param> public TempHumidity(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this); this.sck = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, false, this); this.data = GTI.DigitalIOFactory.Create(socket, Socket.Pin.Three, true, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, this); this.running = false; }
// 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 = GTI.DigitalInputFactory.Create(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, this); _clk = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, false, this); _cs = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, true, this); }
/// <summary>Constructs a new instance.</summary> /// <param name="rSocketNumber">The mainboard socket that has the display's R socket connected to it.</param> /// <param name="gSocketNumber">The mainboard socket that has the display's G socket connected to it.</param> /// <param name="bSocketNumber">The mainboard socket that has the display's B socket connected to it.</param> public DisplayN7(int rSocketNumber, int gSocketNumber, int bSocketNumber) : base(WpfMode.PassThrough) { var config = new DisplayModule.TimingRequirements() { UsesCommonSyncPin = true, //not the proper property, but we needed it for OutputEnableIsFixed CommonSyncPinIsActiveHigh = true, //not the proper property, but we needed it for OutputEnablePolarity HorizontalSyncPulseIsActiveHigh = true, VerticalSyncPulseIsActiveHigh = true, PixelDataIsValidOnClockRisingEdge = false, HorizontalSyncPulseWidth = 1, HorizontalBackPorch = 46, HorizontalFrontPorch = 16, VerticalSyncPulseWidth = 1, VerticalBackPorch = 23, VerticalFrontPorch = 7, MaximumClockSpeed = 24000, }; base.OnDisplayConnected("Display N7", 800, 480, DisplayOrientation.Normal, config); var rSocket = Socket.GetSocket(rSocketNumber, true, this, null); var gSocket = Socket.GetSocket(gSocketNumber, true, this, null); var bSocket = Socket.GetSocket(bSocketNumber, true, this, null); rSocket.EnsureTypeIsSupported('R', this); gSocket.EnsureTypeIsSupported('G', this); bSocket.EnsureTypeIsSupported('B', this); this.backlightPin = GTI.DigitalOutputFactory.Create(gSocket, Socket.Pin.Nine, true, this); rSocket.ReservePin(Socket.Pin.Three, this); rSocket.ReservePin(Socket.Pin.Four, this); rSocket.ReservePin(Socket.Pin.Five, this); rSocket.ReservePin(Socket.Pin.Six, this); rSocket.ReservePin(Socket.Pin.Seven, this); rSocket.ReservePin(Socket.Pin.Eight, this); rSocket.ReservePin(Socket.Pin.Nine, this); gSocket.ReservePin(Socket.Pin.Three, this); gSocket.ReservePin(Socket.Pin.Four, this); gSocket.ReservePin(Socket.Pin.Five, this); gSocket.ReservePin(Socket.Pin.Six, this); gSocket.ReservePin(Socket.Pin.Seven, this); gSocket.ReservePin(Socket.Pin.Eight, this); bSocket.ReservePin(Socket.Pin.Three, this); bSocket.ReservePin(Socket.Pin.Four, this); bSocket.ReservePin(Socket.Pin.Five, this); bSocket.ReservePin(Socket.Pin.Six, this); bSocket.ReservePin(Socket.Pin.Seven, this); bSocket.ReservePin(Socket.Pin.Eight, this); bSocket.ReservePin(Socket.Pin.Nine, this); }
/// <summary>Constructs a new instance.</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); this.echo = GTI.DigitalInputFactory.Create(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, this); this.trigger = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, false, this); this.AcceptableErrors = 10; }
/// <summary>Constructs a new instance.</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); this.writeBuffer = new byte[1]; this.readBuffer = new byte[2]; this.led = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, false, this); this.i2c = new GTI.SoftwareI2CBus(socket, Socket.Pin.Five, Socket.Pin.Four, 0x39, 100, this); this.i2c.Write(new byte[] { 0x80, 0x03 }); }
/// <summary>Constructs a new instance.</summary> /// <param name="socketNumber">The mainboard socket that has the module plugged into it.</param> public Button(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this); this.currentMode = LedMode.Off; this.led = GTI.DigitalOutputFactory.Create(socket, GT.Socket.Pin.Four, false, this); this.input = GTI.InterruptInputFactory.Create(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.On, GTI.ResistorMode.PullUp, GTI.InterruptMode.RisingAndFallingEdge, this); this.input.Interrupt += this.OnInterrupt; }
/// <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; }
/// <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 = GT.SocketInterfaces.DigitalOutputFactory.Create(socket, GT.Socket.Pin.Three, true, null); this.out2 = GT.SocketInterfaces.DigitalOutputFactory.Create(socket, GT.Socket.Pin.Four, true, null); this.in1 = GT.SocketInterfaces.DigitalInputFactory.Create(socket, GT.Socket.Pin.Five, GT.SocketInterfaces.GlitchFilterMode.Off, GT.SocketInterfaces.ResistorMode.PullUp, null); this.in2 = GT.SocketInterfaces.DigitalInputFactory.Create(socket, GT.Socket.Pin.Six, GT.SocketInterfaces.GlitchFilterMode.Off, GT.SocketInterfaces.ResistorMode.PullUp, null); this.in3 = GT.SocketInterfaces.DigitalInputFactory.Create(socket, GT.Socket.Pin.Seven, GT.SocketInterfaces.GlitchFilterMode.Off, GT.SocketInterfaces.ResistorMode.PullUp, null); this.in4 = GT.SocketInterfaces.DigitalInputFactory.Create(socket, GT.Socket.Pin.Eight, GT.SocketInterfaces.GlitchFilterMode.Off, GT.SocketInterfaces.ResistorMode.PullUp, null); }
// 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 TemperatureSensor(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); _sck = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, false, this); _data = GTI.DigitalIOFactory.Create(socket, Socket.Pin.Three, true, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, this); new Thread(TakeMeasurements).Start(); }
/// <summary>Constructs a new instance.</summary> /// <param name="socketNumber">The socket that this module is plugged in to.</param> public Load(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported('Y', this); this.P1 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, false, this); this.P2 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, false, this); this.P3 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, false, this); this.P4 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Six, false, this); this.P5 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Seven, false, this); this.P6 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Eight, false, this); this.P7 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Nine, false, this); }
/// <summary> /// Use this constructor if you are connecting XBee using Gadgteteer socket. /// </summary> /// <param name="socketNumber">The socket that this module is plugged in to.</param> /// <remarks> /// The function <see cref="Configure"/> can be called to configure the <see cref="SerialLine"/> before it is used. /// If it is not called before first use, then the following defaults will be used and cannot be changed afterwards: /// <list type="bullet"> /// <item>Baud Rate - 9600</item> /// <item>Parity - <see cref="System.IO.Ports.Parity">Parity.None</see></item> /// <item>Stop Bits - <see cref="System.IO.Ports.StopBits">StopBits.One</see></item> /// <item>Data Bits - 8</item> /// </list> /// </remarks> public XBee(int socketNumber) { _connectedToGadgeteerSocket = true; // 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(new[] { 'K', 'U' }, this); _serialPortName = socket.SerialPortName; _gadgeteerResetPin = DigitalOutputFactory.Create(socket, Socket.Pin.Three, ResetState.NotRunning, this); _gadgeteerSleepPin = DigitalOutputFactory.Create(socket, Socket.Pin.Eight, SleepState.Awaken, this); }
/// <summary>Constructs a new instance.</summary> /// <param name="socketNumber">The socket that this module is plugged in to.</param> public GPS(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported('U', this); this.lastPositionReceived = TimeSpan.MinValue; this.LastPosition = null; this.powerControl = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, true, this); this.gpsExtInt = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Six, true, this); this.serial = GTI.SerialFactory.Create(socket, 9600, GTI.SerialParity.None, GTI.SerialStopBits.One, 8, GTI.HardwareFlowControl.NotRequired, this); this.serial.NewLine = "\r\n"; this.serial.LineReceived += this.OnLineReceived; }
/// <summary>Constructs a new 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); this.socket.EnsureTypeIsSupported('Y', this); this.write1 = new byte[1]; this.write2 = new byte[2]; this.read5 = new byte[5]; this.cs = GTI.DigitalOutputFactory.Create(this.socket, Socket.Pin.Six, true, this); this.miso = GTI.DigitalInputFactory.Create(this.socket, Socket.Pin.Eight, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, this); this.mosi = GTI.DigitalOutputFactory.Create(this.socket, Socket.Pin.Seven, false, this); this.clock = GTI.DigitalOutputFactory.Create(this.socket, Socket.Pin.Nine, false, this); this.enable = GTI.DigitalOutputFactory.Create(this.socket, Socket.Pin.Five, true, this); this.Initialize(); }
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); } }
/// <summary>Constructs a new instance.</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); this.data = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Seven, false, this); this.clock = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Nine, false, this); this.enable = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, true, this); this.latch = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, false, this); this.clear = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, true, this); this.DisableAllRelays(); this.EnableRelay(0); this.EnableOutputs(); }
/// <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(); }
/// <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 IsPressed(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); }
// 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 = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Seven, false, this); clock = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Nine, false, this); enable = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, true, this); //Switching lines for enable and latch prevents default on state latch = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Five, false, this); clear = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Four, true, this); DisableAllRelays(); EnableRelay(0); EnableOutputs(); }
/// <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(); }
/// <summary>Constructs a new instance.</summary> /// <param name="socketNumber">The socket that this module is plugged in to.</param> public Barometer(int socketNumber) { Socket socket = Socket.GetSocket(socketNumber, true, this, null); socket.EnsureTypeIsSupported('I', this); this.writeBuffer1 = new byte[1]; this.readBuffer1 = new byte[1]; this.readBuffer2 = new byte[2]; this.readBuffer18 = new byte[18]; this.coefficients = new Coefficients(); this.xclr = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, false, this); this.i2c = GTI.I2CBusFactory.Create(socket, Barometer.EEPROM_ADDR, 100, this); this.ReadFactoryCalibrationData(); this.i2c.Address = Barometer.ADC_ADDRESS; this.timer = new GT.Timer(200); this.timer.Tick += (a) => this.TakeMeasurement(); }
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> /// <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); }
public LedDigital(DigitalOutput outputPort) { _outputPort = outputPort; }